Posts tagged coding
Posts tagged coding
More than 170,000 people have signed up for Codecademy’s challenge to learn how to code in 2012, and New York Mayor Michael Bloomberg is one of them. The challenge, Code Year, was launched by New York-based startup Codecademy on Sunday and quickly took off as Twitter and Facebook users adopte…
When I tutored Computer Science back in college, I came to one conclusion: There are just some people who are unable to code. You need a certain switch to be flipped in your brain to be able to do it, and there are some people just don’t have it.
That is why I have never suggest coding to someone who isn’t a coder. If you are really good with computers and have that coding switch on in your brain, then you have probably already dabbled in a little HTML work or backend modifications. But if you never had the urge to find out how computers tick, then I doubt that you will be able to pick up a language just like that, Mr. Bloomberg.
This is my company’s brand new salesforce blog. I will be writing articles in it every few weeks on coding apex and visualforce in Force.com platform. I’m actually really excited to be blogging again.
I apologize now if my upcoming links to my articles appear spammy and self-promotional, but this is the kind of stuff that pays my bills, so it’s kinda important for me. ;-)

Got an assignment today to create an application using Salesforce.com.
Seems a little bit much for spec work, but I’ve been seeing this Salesforce thing come up a lot in job classifieds. Might be a good skill to acquire and put on my resume.
Another coder was looking over the HTML source code to Litter today and he asked me, “Why are you using single quotes here?” Well, the answer was because in PHP, my code looked something like this:
echo(“<div id=’foo’ class=’bar’></div>”);
Because I was using double quotes for the string in PHP, I used single quotes for strings in the HTML. The result was sloppy looking HTML output that randomly switched between single and double quotes.
So this got me to thinking if there really is a difference between using single or double quotes in web development and if so, just which one should I be using? After some Googling, this is what I came up with:
HTML - No difference. Both are acceptable by W3C standards.
JavaScript - No difference. Both will work exactly the same.
PHP - Yup, there is a difference! And it turns out to be quite a big one.
What’s the difference in PHP? Well, in this code sample, the program will output the same two strings:
$i = ‘World’;
echo(“Hello $i!”);
echo(‘Hello ‘.$i.’!’);
When you use double quotes, you can embed variables right in the string. When you use single quotes, you have to use concatenation. I’ve been using the embedding method as a shortcut in PHP coding, but it turns out that concatenation is the more memory efficient of the two.
I modified the JQuery version of Litter so that only double quotes appear in the HTML code. From now on when I develop websites, I’m going to discipline myself to only use double quotes in HTML tags and to use single quotes for PHP and JavaScript.
In the To-do List app I posted this morning, I require the user to create a username and password. That information has to be saved onto a database which I have complete access to. But I shouldn’t be able to see their password. That’s personal information that only the user should know.
So to solve this problem, we use MD5 one-way encryption. With MD5, if you pass in a string, you get back a 32-character hexadecimal string of gibberish. For example, the password “password” will come back as 5f4dcc3b5aa765d61d8327deb882cf99. However, if your password was “Password” with a capitol P, the encryption would be dc647eb65e6711e155375218212b3964. That one letter change made the gibberish totally different.
The thing is that MD5 is one-way, so while I can turn “password” into gibberish, I can’t turn the gibberish back to “password”. That is why I only save the encrypted password on my database, because there’s nothing I can do with it, it’s gibberish. Then later on when the user logs in again with “password”, the program turns it into gibberish and compares it with the gibberish on my database. If the two strings of gibberish match, the user entered the right password and they log on.
(The above photo is a snapshot of my actual database with actual password encryptions, and while it is totally safe for me to post them, I decided to censor a couple of digits just to prevent reverse lookups.)
This was an old programming assignment I had to pull together one afternoon some time ago. I decided to go back and make the site W3C compliant and adhere to progressive enhancement standards.
It’s done.
Go ahead. Turn off cookies. Turn off JavaScript. Turn off CSS.
The application still works. It might not look pretty, but it still works.
I’ll go in for some debugging tomorrow. Then I’m going to go back into versions 1 and 2 and making sure they’re W3C compliant.
All the source code to my programming projects posted in one central repo.