Sometimes I write very small web applications. I like to have the power and flexibility of ruby and my libraries, but I don’t want to drag around a huge web stack like Rails or even Merb. For this there is the great interface of Rack.
From the rack project:
Rack provides an minimal interface between webservers supporting Ruby and Ruby frameworks.
So here are the basics of using rack in a [semi]useful project:
First, we install the gem:
gem install rack
Then we implement a very basic app. Save this as “app.ru”.
Magic, right? Now if you also need this application of yours to be screaming fast and not need to lean on [crappy] ruby threading, we need to add EventMachine, which is one of the greatest additions to Ruby network programming ever. The easiest way to do this is to use Thin.
Luke and I were having an in-depth conversation about the UI for our Zeep Media product. We’re doing some really cool work with geographic targeting and report visualization on top of Google Maps. I’m sure that there will be subsequent blog posts about the technical challenges here.
I was trying to explain the NANP (North American Numbering Plan) and exactly what the NXX in NPA-NXX meant. NPA is a set of three numbers ([2-9][0-8][0-9]) that you will probably know as “Area Code” and NXX is just the next three digits.
So if we pick apart my number:
+1 (778) 227-3859
+ means we’re using E164
1 means we’re dialing in NANP
778 is the NPA or area code
227 is the NXX or exchange
3859 is the station code
Unimportant as they may seem, the NXX digits used to prominently have a real, practical use.
Before cell phones, before digital-electronic switching, in fact before digital-mechanical switching there was the operator. The operator’s job was to manually connect wires running to people’s phones.
A telephone operator manually connecting calls with patch cables at a telephone switchboard.
As everyone knows, the best of systems can be ruined when you introduce human error, greed or incompetence. That brings us to an undertaker, Almon Brown Strowger. Almon was convinced that the local manual telephone exchange operators were sending calls to a competing undertaker business and thus set out to invent the automatic telephone exchange.
The exchange existed of a collection of Strowger Switches that would allow a phone connected to a wire pair on one side to dial using a set of pulses to connect a wire pair at the end, making another phone ring. Each switch would move the the corresponding index based on the number of pulses it received.
Dialing 3-8-5-9 a switch would take the first three pulses and place the initiating pair on the “3” circuit, the switch connected on that circuit there would then select the “8” circuit. As you can imagine, when you add a lot of numbers, say 10,000 of them, you need a lot of these switches. A lot of these switches would take up a lot of space. So, for every 10,000 numbers (0000-9999) there would be one building that housed all of these switches, the exchange. This is why old phones pulsed, they were actually moving a mechanical piece every time a pulse went over the wire.
For some reason, this simple example has eluded me for some time. “EventMachine is a library for Ruby, C++, and Java programs. It provides event-driven I/O using the Reactor pattern.” When using Eventmachine, as I often do, asynchronous network calls are key. And often in the word of web services, crawling and scraping most useful clients I write these days deal with HTTP. So here is the most basic example of an HTTP client written using eventmachine:
Simon Wex
12:29
hehe
bettter than playing smart
You know…
Mr. Anonymous
12:31
...
Simon Wex
12:31
I can’t get over it, I think people to speak to themselves are stupid.
Maybe an unfair bias…
but if you actually have to vocalize something to understand it, what sorts of limitations does that put on your understandings?
Mr. Anonymous
12:32
probably none
fuck you
Simon Wex
12:32
hehe
You you talk to yourself?
Mr. Anonymous
12:32
I’ve caught myself doing it
Simon Wex
12:32
is that part of your “playing dumb”?
Mr. Anonymous
12:32
and yes, I have trouble with certain levels of abstraction
I was trying to sleep last night just outside of Portland Oregon and, to be honest, I wasn’t doing a great job of it. So instead of shutting my eyes and ignoring the strange sounds coming from the woods, I watched Chop Shop [IMDB]
It was real to the point of feeling voyeuristic. It didn’t have a rocketing trajectory to a massive climax, but instead depressingly trudged on like the main characters’ lives. – Though my description doesn’t sell it, it was a very enjoyable watch and I highly recommend it.
So here’s something sort of funny that I just noticed. When on my mac clicking on “Get Info” for my friend’s desktop (‘doze), you get this appropriate little preview…
Good old windows blue screen. It has been a while and I don’t miss you.
I’m a happy kinda guy. I think a lot of this comes from generally being happy with what I have, not lusting after what I don’t. I think this explains my stance on things like plastic surgery and suicide bombings.
Around a month ago I blew out my back. I was well on my way to recovery – something you measure differently when you’re unable to put on your own socks – when I tweaked it and I’m now pretty much back to square one. So there I was, teetering on my rickety legs reaching down to the second shelf for a yogurt in one of those big multipacks. I was hoping for a strawberry as my hand touched a pack. I realized it didn’t matter. I was going to get what I got and the pain was not worth going back for a replacement. Mmnnn tasty yogurt.
I suppose today I'm playing the optimist. I was playing with Google Trends this morning and noticed something I found promising. There are no brilliant insights I have to contribute, I'll let this graph representing the popularity of search terms related to "oil prices" and "electric car" speak for itself:
Scale is based on the average traffic of electric car from United States in the last 12 months.
Learn more