March 28, 2013

Udacity CS253 Web Development

I've never been really interested in "web development" even though I set up the first website in Thailand years and years ago as a joke that got me into heaps of trouble. But I was browing Udacity's course offerings, and the chipmunk looked just friendly enough for me to click in to take a look. The course is taught by Steve Huffman of Reddit fame, so I decided to check it out.

Lesson 1: HTML stands for Hypertext Markup Language! Here's how HTTP works! ...
Problem Set 1: Install Google App Engine and make a basic Hello, Udacity! web app.

?!?!?!?!?!?!?!?!?!?!

Okay, installing Google App Engine wasn't hard for me, but I'm sure there would be thousands of others who would be completely stumped by this. But Python? There's nothing in the course description about using Python and GAE (I had assumed JavaScript), but since I'm learning Python, so I was glad this was another chance to learn Python.

Lesson 2: Here's how to do basic HTML web forms!
Problem Set 2: Make a user signup form using App Engine.

?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!

Okay, this involved some reading of the fantastic manuals, but I was able to figure it out without too much trouble.

Lesson 3: SQL stands for Structured Query Language. Here's how to do some basic SELECT statements.
Problem Set 3: Make a blog.

Wow. I was hooked by Lesson 3 since the lessons have nearly nothing to do with the problem sets and the problem sets really needs a lot of documentation reading and web searching which I'm really good at. No hand holding here and nothing about breaking the problem down into little pieces. I read the outdated forum posts and people seem to be divided into those who were completely lost and those who were saying the course is too simple.

Lesson 4: Cookies.
Problem Set 4: Make the signup form work, including logins and logouts.

Lesson 5: RSS.
Problem Set 5: Make the blog output JSON.

Lesson 6: Caching.
Problem Set 6: Implement caching for the blog.

Final Project: Make a working wiki, including signups / logins / logouts, signed-in users are able to create new wiki entries, as well as edit existing wiki entries.
Bonus Final: Make the wiki display editing history.

Since Udacity's courses are all self-paced, I was able to complete the entire course in about a week. I watched all the videos and did the in-video quizzes, and completed all the problem sets, the final project, and the bonus final, and was able to download my Certificate with Highest Distinction.


I'm now ready to take over the Internet.

March 15, 2013

Self-changing Wi-Fi password


I'm totally addicted to coffee, and whenever I see a new coffee shop, I would stop and try their coffee. These days, most coffee shops have free Wi-Fi, and sometimes, it's easy to drink one cup of coffee, and then steal their Wi-Fi permanently since most places don't have the knowledge to change their Wi-Fi password frequently. (Might as well not set a password if you never change the password!)

Presenting... automatic WPA2-PSK password changer for Tomato firmware. Put this little script into the Init script area (Administration -> Scripts -> Init). Now whenever the router reboots, a new password will be generated. You should also put this script either into a schedule so the password can change daily, or preferably, make a schedule to reboot the router daily.

As written the password is based on the current date. If you read the script below, you can see the password is based on a very simple formula: Year x Year x Month x Date, then use only the last eight digits. So if today is March 15, 2013, the password would be 82347605. You can vary the formula, for example, by using %U (week number) instead of %d to change the password weekly, or take out %d to change the password monthly. Just make sure the password is at least eight digits. I prepend the password with 00 in case the generated password is shorter than eight digits. It would be simple to make a spreadsheet with all possible future passwords, or even manually calculate the password.

The delay at the beginning of the scripts waits for the date to be retrieved by NTP. Note that if NTP time can not be retrieved, the Wi-Fi password will be the initial password, which is whatever you saved using the Basic -> Network configuration screen. My configuration is WPA2-PSK, other security types are untested. This script is tested on the ASUS WL500gP (v1 and v2) and the ASUS RT-N16.

You may have to change the nvram line depending on your Wi-Fi chipset if you have another Tomato supported router. The reason I set both wl and wl0 is that I needed both lines to support my notebook and my Android tablet. The wl line for my ThinkPad notebook, and the wl0 line for my Android tablet. If I don't have both lines, then only one device could connect.

Oh yeah, this is not a captive portal since there's no login screen for different users, but rather for changing the Wi-Fi password. As usual, no warranties.

#!/bin/sh
#www.ivoidwarranties.com
cat > /tmp/wifi.sh << EOL
#!/bin/sh
while [ \`date +%Y\` -lt 2010 ]
do
    sleep 10
done
YY=\`date +%Y\`
MM=\`date +%m\`
DD=\`date +%d\`
SUMD=\$((YY*YY*MM*DD))
WIFIPW=\$(echo "00"\$SUMD | tail -c 9)
nvram set wl_wpa_psk=\$WIFIPW
nvram set wl0_wpa_psk=\$WIFIPW
service net restart
EOL
chmod a+x /tmp/wifi.sh
/tmp/wifi.sh &

Will update this page again when I have time to test if this script also works on the DD-WRT firmware.

March 10, 2013

Massive open online course


So, I was looking for some online Python tutorials when I came across edX and 6.00x Introduction to Computer Science and Programming. I've heard about massive open online courses ("free university") before, and I've certainly visited MIT's OpenCourseWare site frequentyly, but edX (what is it with adding X to everything these days?) seemed far more interesting than a self-study site, and 6.00x course just happened to be starting, so I registered for it to learn the Python language.

One thing lead to another, now I'm addicted to watching online lectures, and I've tried out courses in all three of the big MOOC players: Coursera, edX, and Udacity.

The difference between MOOC and other free learning resources is that they're operated like a real school. The courses run on a schedule and there are graded assignments. If you join the course too late you can't catch up, so it's best to wait until the next offering. At the end of the course you receive a PDF certificate if you reach the passing grade.

Even though they're free right now, but I imagine in the future it would cost some money to get a certificate, or perhaps a small monthly fee. In fact, as I type this I suddenly remember paying a $4.95 monthly fee for ZDnet University years ago. It was such a great idea back then, but eventually everything fell apart because the courses rarely got updated and they weren't structured like a real school, there was no wide support outside of ZD themselves, and the Internet was way too slow back then. I actually found a link that talks about ZDU. Good old days...

Anyway, Coursera is probably the most famous and with lots of partipating universities and hundreds of courses ranging from programming to biology to music appreciation. edX is owned by Harvard, MIT, and UC Berkeley and seems to be more technical and scientific. Udacity came out of Stanford and seems to have most "industry support" from technical leaders like Google or Intel and generally focuses on technical courses.

I really like Coursera's course offerings. I'm a technical person, but because IT is so much business now, I've been reading about the business aspects of IT, and I've been trying to hire someone into my team who didn't get started as a programmer. Coursera has everything I need. Unfortunately, Coursera's video player simply sucks. If I get any network hiccups and the video lecture pauses, attempting to resume the video just causes it to restart from the beginning. The video also plays in a pop-up window. If I accidentally click outside the pop-up window, the window closes, and if I click on the video again, it restarts too. This is quite unfortunate because all the videos I watched in Coursera appear to be really professionally made. They do offer a link to download the videos, but there are embedded quizzes inside the videos, and I believe I have to skip to the embedded quizzes to answer them even if I watch the videos offline. The web interface is really nicely made too, but apprently each course is free to do what they want with the organization, making things a bit confusing if you're taking more than one course.

(Edit: Also, because Coursera's courses are from so many different universities, each has its own stance on issuing certificates or credentials. I looked a bit and most don't seem to offer any credentials and seem to look at Coursera as an experiment to draw perspective students into their own paid online courses.)

I just wrote above that MOOC's are operated like a real school, but strangely enough, Udacity changed their policy recently to do-it-at-your-own-pace instead of scheduled classes. The reason being many people who are registered in these free classes are not full-time students, and often have trouble keeping up with the rigorous schedules more suitable for part-time or even full-time students. The problem with being at-your-own-pace though is that the forum discussions are totally messed up. I registered for a course and found many of the forum posts are from months ago, and it will get worse as time passes by. It also makes for people who just joins a course, does the final exam, and leaves with a certificate. Which is exactly what I did.


I guess this proves the certificate isn't worth much, and they should stick to scheduled courses and not open registration. But I've always had the same opinion about those MCSE and CCNA certificates. But hey, it might fool my boss. Other than that, all the videos I saw are amateurish, which isn't a problem to me since it actually feels like I'm in a meeting or a training session and not a classroom. But they could've made the slides just a bit more professional looking and not use handwritten papers for the presentations. (It does get hard to read at some points.) However, all these issues may be moot, since Udacity's courses are not based on actual courses, but they're all newly created specifically for the Udacity platform, and are often sponsored by IT industry giants, and all of Udacity's courses are computer or technology related at this point.

As for edX that I started with in the first place, it turns out that I prefer it the most. I'm enjoying the 6.00x Python course tremendously. I joined to learn the Python language and to refresh some computer science concepts, so the programming problems are really simple for me, and so I ended up spending most of the time in the forum trying to help others with their programming issues after I'm done submitting my homework. The video lectures are released on a schedule and programming homework have to be submitted on time. (The server crashed on the due time the first few times due to the sheer number of submissions.) Because everything is on a schedule, the forum discussions are current and viable. I have no trouble with the video player and if I do, I can click on a link and the video opens up in YouTube. The only drawback with edX is that they seem to have designed the site for people with huge monitors, I keep having to scroll up and down to view the course materials.

I tried a few different courses in edX and all the offerings have similar layouts, but it's still up to each course's designer how to organize their course material. 6.00x has really poor lecture notes, with each lecture's note separated into its own PDF file. But the CS188.1x AI course's lecture notes are organized into one large PDF file ready for printing out.

Speaking of printing out, one more cool thing about the 6.00x class is that the textbook (Introduction to Computation and Programming Using Python) used in the course is readable online inside the course material area. (And yeah, some of the Coursera courses I looked at seem more like disguised ads in order to sell the teachers' books.) When I first saw the textbook I noticed it looked pixelated instead of smooth like a PDF file. Sure enough, right clicking the page allowed saving the page as a 1700x2200 png file. The significance of that size is that it's a letter sized page at 200 dpi, perfectly suitable for printing out!