I've been using git for versioning for some time now. But for those of you who are starting out and want to jump right into it, Codeschool has a nice online class for you: http://try.github.com/
CoffeeScript: A New Way of Looking
You could say CoffeeScript goes hand in hand with Ruby on Rails development. Here is a quick and nice syntax intro to CoffeeScript.
Data Scraping With Ruby
If you are looking for a way to scrape data off of websites that do not have an API, here is a simple how-to video for it.
Data scraping is the process of extracting data from output that was originally intended for humans. A web page is an example of output originally intended for humans in contrast to an API intended for use by other programs.</p>
Nokogiri is a Ruby Gem that extracts data from web pages using CSS selectors. Additionally, it provides methods to help parse (make sense of) the results. The use of CSS selectors allows you to easily target the data you wish to extract from a URL.
Moving away from PHP
This is exactly why I am moving away from GoDaddy and PHP.
I can’t even say what’s wrong with PHP, because – okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.</p>
You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.
You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.
You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.
And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.
Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.
That’s what’s wrong with PHP.
Simulating Low Bandwidth For Local Web Development
It is important to know how a webpage would load on another person's computer, especially when it involves AJAX and page scripting. It may work properly and load as fast as it is, this is not the case on another machine with another configuration. Therefore, it is essential to be able to simulate network loadtimes, latencies and packet losses. Here I will be giving simple examples and how to setup a low-bandwidth environment on Mac OS X and other Unix/Linux systems.
OS X is equipped with some powerful tools. Not to mention that it comes with a built-in Apache and PHP, it also comes with a number of security tools including IPFW. IPFW is a tool that is essential to control the inflow and the outflow of traffic on your machine. When you access the firewall settings from your System Preferences application, it configures IPFW to monitor the network. System Preferences is the front-end GUI for IPFW, so to speak. Since System Preferences is not powerful enough, we will be using the Terminal.
The plan of action is the following:
open port 8080 with a limited bandwidth and redirect requests made to it to the local web server (port 80).
The following command would open port 8080 and redirect its requests to our webserver, which runs on port 80:
sudo ipfw add 200 forward 127.0.0.1,80 ip from any to any 8080 in
Now, we have to run the requests made to port 8080 through a pipe:
sudo ipfw add 205 pipe 50 ip from any to 127.0.0.1 dst-port 8080
and configure the pipe to lower bandwidth at 64Kbps:
sudo ipfw pipe 50 config bw 64Kbit/s
With these three easy commands, we have created port 8080, which will serve the same content as the default webserver, but at a lower rate. If you direct your browser to
, you will notice a significant web page load time change compared to
(assuming your web server runs on port 80).
Latency and Packet Loss
In terms of having a more realistic simulation, there are two other aspects to networking: latency and packet loss. And it is a matter of how you configure your pipe. The following command will add 300ms latency with 10% packet loss on a 64Kbps pipe:
sudo ipfw pipe 50 config delay 300ms bw 64Kbit/s plr 0.1
To remove your port 80, you simply have to remove the rules you have set. Rule # 200 and 205 will be removed with the following commands:
sudo ipfw delete 200
sudo ipfw delete 205
Once deleted, the browser will give you an error when you try accessing port 8080 because it will no longer redirect your traffic. If you want to see that the rule was actually deleted, type in the following:
sudo ipfw list
and you will see that rule 200 and 205 have been baleeted.
Also note: If you are loading jQuery or other scripts from external sites, this simulation will not work because you are not putting any restrictions on outside sources.
Please leave a comment if you know of a better, cooler way to simulate loading on your local machine.
Using different keys of the piano, Peter Ablinger plays a digitized sound recording of a child on a Talking Piano: