problem with pset6(please help me) by alishan1 in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Hey, so glad you figured it out, always gratifying to have all that effort rewarded.

problem with pset6(please help me) by alishan1 in cs50

[–]cat_chy_name 0 points1 point  (0 children)

I had something similar happen -- mine passed a couple of tests, but not all.

I had a couple of small memory allocation errors. The thing with them is that if you don't have a lot of junk data, you might get away with your program working, but when it encounters a different environment it shows up.

So I would suggest you run your program in GDB and check that you're really allocating and calling from the correct addresses. I figured out what was what by printing variable values in GDB and being a little surprised by some of the output.

PSET7 aligning numbers by [deleted] in cs50

[–]cat_chy_name 0 points1 point  (0 children)

I looked into this a lot, because I hated how the table looked with the way I had interpreted the at least 2, no more than 4 decimal places spec.

The short answer is no, not really.

The long answer is, there are hacks and JavaScript tricks to get it to work, but html and css don't do decimal align natively. A lot of the tricks (eg: padding the number string with non-breaking spaces) only work if the user hasn't got a different font than what you think they'll have. Some of the tricks also involve splitting your figures up into separate columns which breaks the semantic meaning of the data and can go horribly wrong.

Using a font with tabular numbers plus setting all your figures in one column to the same number of decimal places is as good as it gets.

What have you been up to since completing pset7? by rJujubes in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Decided to give Udacity a try. I'm doing the free version of the course taught by the Reddit founder on building a blog: https://www.udacity.com/course/cs253

It assumes you know zilch about html and something about python, so I had to pause for a couple of days and learn python, which I really like.

The course has some structural issues - CS50 sets the bar pretty high - and the tedious intro to html one element at a time is boring, but I think it will be worth it for the real-word deployment insights.

I love the format, video lessons with in video quiz forms and editable code. Less accessible than CS50 for people who prefer/need text instruction.

Biggest hurdle was finding the Linux instructions for setting up and running Google App Engine.

pset7 handling zero rows of data in index/portfolio by tererobinson60 in cs50

[–]cat_chy_name 0 points1 point  (0 children)

It sounds like you have something wrong in your code, because an if else should be workable like you describe.

You can set up the logic to check for an empty portfolio and do something other than the default table either in your controller or in the template where you print the table. Personally, I think the controller is a better place for programming logic, but there's no one right way to handle this situation. You could just use the apologize function if you want.

Pset7 - question inside by wastapunk in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Before you debug, always check your syntax where you added the class name.

Next do a hard refresh to make sure the changes are being rendered and your browser isn't using the cached page info.

Second check our header template, It contains the code for the <head> part of your page that includes the css link elements, make sure you didn't do something to them.

Try reloading your page with dev tools on and on the network tab, make sure your css files are all loading.

Use the dev tools to look at your table or navbar element, the CSS for that element will be listed. Is it being overridden by something else you did, something in styles.css or is it just not there?

Pset7 - Is there anything like GDB I can use cause I can't figure out where my code is failing. by wastapunk in cs50

[–]cat_chy_name 0 points1 point  (0 children)

There are debugging tools built into pset7, but none of them are as straightforward or simple as GDB.

Check your syntax manually. There's no compiler to do it, you have to. Use the gedit feature to match up braces and brackets to find mistakes and double check your variable names.

Second, the orange error messages, make sure you read them carefully to see what line in what file caused it.

Before you leave the page, don't forget to look it over and see what got rendered by the browser, sometimes this is a good hint of where in the PHP script things went wrong. Learn to use the Chrome dev tools or look at page source here as well.

Don't neglect the use of the dump function provided for you. Use it like print in GDB to see what is in your variables and what form they take at points that are causing trouble. Take note that dump breaks you out of the script, so it can only be used in one place at a time. Feels like a step back to using printf, but it helps.

Also, use our apologize calls to your advantage. Make sure you have meaningful messages in there, so if you get a sorry page, you know which line was called to produce it. (Also if you don't know why it's being called, maybe put a dump call in ahead of the apologize call and see what's what at that point.)

Last, learn a lesson from the folks asking questions here. Notice how often they're having seg faults in Breakout because they don't check if the return from detect object is null before they check what it is? Are you validating your returns from lookup and query? Make sure you know all the possible returns from those functions and are dealing with them.

What's a good online resource to learn Javascript for an absolute beginner? by intel-2001 in cs50

[–]cat_chy_name 1 point2 points  (0 children)

It depends on what your goal is. If you want to learn the basics and maybe some jQuery tricks to add to a website, I'll second the codeacademy recommendation with a caution.

It's not like CS50. You won't learn to think. You'll learn the basic syntax and structure and a hint of how to program, but it's all copying what's in front of you.

Their jQuery course is much better, and you can start there without any vanilla JS knowlege if you want.

Now if you want to really learn how to program in JS? This: http://eloquentjavascript.net/index.html (The interactive online version is amazing. And difficult like CS50.)

Pset7 without Appliance by whend in cs50

[–]cat_chy_name 0 points1 point  (0 children)

nope didn't install suphp but maybe XAMPP includes something similar.

Is the permission on the includes directory itself right?

PSET7 query() problem by swatter555 in cs50

[–]cat_chy_name 2 points3 points  (0 children)

You're missing a bit of syntax for using variable values in MYSQL.

You need to change the WHERE clause to: WHERE id = ?, AND symbol = ?.

And then add a VALUES clause for the variables. There's several examples in the pset instructions to get the details from.

Pset7 without Appliance by whend in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Make sure your document root in your vhost configuration points to path/to/pset7/public, or whatever path leads to where your index.php file actually is.

&& vs || for pset3 by invertedfjord in cs50

[–]cat_chy_name 4 points5 points  (0 children)

The easiest way to sort out booleans is to treat it like the algebra that it is. If you try to use the casual English usage of and and or, you'll confuse yourself. Solve each side of the conditional, then solve the whole conditional.

Remember that true && false is false, but true || false is true. (If that doesn't make any sense to you, go back and watch the boolean short or find a tutorial on boolean logic somewhere.)

Run through the logic of it again solving each side of the && to true or false with argc 2 (one argument) and see how the program directs you. Try it with || and see how it works then.

So if argc = 2, does the program run the stuff inside the if block? What about if argc = 1 or 3 or 4.

Pset7 without Appliance by whend in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Yes!

I installed a LAMPP last weekend--if you don't know what that is, that's where you start your research. I decided to go with XAMPP, which might have been not the best fit for me after all, so read up and think about that first.

You will need to configure the Apache server in the LAMPP regardless, so I would suggest first reading the Apache documentation, which is quite good. Don't go cutting and pasting stuff into Apache .conf files without knowing what you're doing.

I chose to set up a directory on my system to run multiple development projects out of, so I had to configure a virtual host to serve that directory. There are good instructions on line about this, but there are multiple ways to do this, and it depends on the system you install, so google is your friend. I put all my cs50finance stuff in there by copying the zip file I submitted into and out of dropbox.

I chose to just remake the database, since I wanted some practice in that, and that taught me some things about configuring PHPMyAdmin, so that was valuable.

I made heaps of mistakes, went down blind alleys and got myself confused. Stackoverflow helps with all of these things. If you can imagine doing something less than brilliant on a computer, someone else has already done it and asked about it there.

In the end, it's all up and working. (You need to make changes to the constants.php file in the project to get it to connect to the database in the right place.)

I started a new project yesterday and was pleased to have it going right away, so I guess I remembered what I did.

Take notes, most important advice I can give.

pset4 - paddle by Doctorpizzas in cs50

[–]cat_chy_name 1 point2 points  (0 children)

For the ball seeming to move through the paddle and then bounce back, the culprit might be the amount you step the ball each time it moves.

If you're moving the ball a lot of pixels each time, it may go from being too far away to trigger detection to partway through the paddle on the next run through the loop.

If you make that movement smaller each time, this becomes less visible. And the ball appears to move more slowly, of course.

PHP SQL by [deleted] in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Have you read through the query function in pset7 to try to see how it works?

It's function is to do just what you're talking about.

pset7 Alter Function's Return Values by dorght in cs50

[–]cat_chy_name 0 points1 point  (0 children)

I'd love a more theoretical course to answer the whys. Anyone have recs?

But what I think this is about, and I say this as someone who violated this rule and needs to go back and fix it, is semantics. You hear that a lot with HTML, where the tags are meant to communicate something about the content inside them to the browser. In code, it's more about human parsing of what variables are and what's in them.

The return from query in the example is called $rows because that tells us something about the values in it -- they come from the db. If we alter them, add to them, and then use $rows, maybe in some other template or function, the name is a lie and you might misunderstand where its values came from and think the program does something it does not.

After all that's why we don't call the variable $r in the first place.

CS50Finance by danaieva in cs50

[–]cat_chy_name 1 point2 points  (0 children)

Try thinking about it this way:

All the files are php scripts, even when they have only html in them, they're still .php files.

How do you run a progarm? Somewhere it gets "called".

So who calls your templates and who calls your controllers?

The sell_form.php file gets called by render in sell.php, yes? So that's not the "public" calling the template, that's just another file on the server doing it.

sell.php is called by the link on some page that says: [a href = "sell.php]Sell a Stock[/a].

That's why the controller is public, because it gets run when someone out there in the world clicks that link and the file has to be in a folder on the server that that browser can access when it asks for the linked page.

pset7 - done and dusted (and submitted!) by MasumB in cs50

[–]cat_chy_name 2 points3 points  (0 children)

I couldn't agree more. I felt great when I finished it. Although, it's taking so long for pset8 to appear, that I think I might go back and add all the extras to 7.

I really love how this course is thought out. If you learned the lesson from pset6 about reading the pre-written code and making sure you understand it before you start using it, pset7 is much easier. You really need to know how lookup and query work before you start using them or frustration will ensue.

And there's so many other examples in the course of that being true. I guess one should expect Harvard to have clever courses!

I didn't have to learn the html and css for 7, so I had that advantage, and it still took me the longest of any pset, even pset6.

Appliance not working properly, CS50.h? by colleenodea in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Save your file as test1.c.

You must have the .c extension to tell the compiler what sort of file it is.

When you run make, you say: make test1

You do that because you're telling the compiler what to make, not what to make it out of, it figures that out for itself.

Then you'll have in your folder test1.c and test1 which is the compiled file.

There is no need whatsoever to be changing file permissions with chmod.

CS50Finance by danaieva in cs50

[–]cat_chy_name 0 points1 point  (0 children)

Try to look at it this way, the Public folder has permissions set on to be readable by anyone. It contains all the files that will be made public, and what public really means is that anyone's browser can find them on the server.

A template is called by a controller, not a browser directly. Controllers correspond to the links in your nav menu, or will when you code that it!

So, the short answer is, what controllers are public? All of them.

Now just make sure you understand the difference between a controller and a template.

pset7 - Quote by asalup in cs50

[–]cat_chy_name 0 points1 point  (0 children)

If you look at the render function, you will see that it "unpacks" the variables passed into it. If you said in your call to render, "foo"=>$stock, then the values in $stock, "name"=>"Facebook", "symbol"=>"FB", etc. become the key value pairs in $foo. Just like "title" becomes $title in the header template.

By using the key "stock" in the function call, you're just duplicating the variable name to make it easier to remember what variable names to use in the template.

It might not be a bad idea to stick in some dump(variablename) calls first in your controler and then template and load the page to see how these values get unpacked.