Musings on turning American
Two groups are forming on my contact list, as I settle into a social life here in California: My old prominently-Canadian comrades, and my new American friends. Today, I find myself having to think twice every time I write “colour” or “favourite”, cut back, and rewrite it without our endearing u depending on the recipient.
All of this is expected, but what occured to me is that I’ve been writing “color” since I first cracked open a terminal. In fact, I just wrote grep --color=auto a moment ago and didn’t skip a beat.
So, when it comes to my brain, the default spelling in English language: colour; default spelling in programming language: color. What gives? Feels like the two are independent parts of the brain. Anyone have similar experiences?
4 commentsCalifornia Dreaming

In 29 days, I’m going to board a plane with three hefty suitcases and fly off to San Francisco, CA where I’ll settle into Silicon Valley for my short-sighted foreseeable future.
I’m worrixcitified.
Things that excite me:
- Weather. I’ve lived in cold continental climates (Canada, Russia) and I’ve lived in hot mediterranean climate (Israel), but the valley offers a utopian climate of t-shirt afternoons and jacket evenings.
- Culture. From all the places I’ve visited, Toronto and the valley are the two places where I’d want to spend my life… until I buy a cabin at an undisclosed location with a phat pipe into the tubes and secretly control the world from the comfort of an Aeron chair.
- Work. But I don’t discuss personal details on the blog.
Things that keep me up at night:
- Finances. I’m not starving on the streets (despite what my raggy wardrobe might suggest). Between leaving my previous job a few months ago, moving to a new country, and eventually buying a car, I think concerns and obsessive preparation is understandable. Right?
- Migration. I have to sell all my belongings — anyone looking for a swanky black leather sofa or a huge Ikea glass desk? I have to ship my belongings which I don’t want to sell — FedEx, please don’t murder my monitor and desktop. I have to start from scratch on the other side — maybe another checklist blog post in the making?
- Relationships. Friends, family, significant other. But I don’t discuss personal details on the blog.
This move represents a 24pt list item in my metaphorical “Things to accomplish before expiry” Google Doc, the first of many I intend to strikeout in the next year!
1 commentConsidering offers? A checklist in alphabetical order

Every offer you get will include some details and omit others. To perform a proper comparison between multiple offers and reach a good decision, you’ll need all the details for all offers. After numerous back-and-forths with several companies, I composed a checklist ideal for anyone on the verge of deciding the next stage of their career.
- Benefits
Medical, dental, vision. Yes, you’re young and healthy, but root canals are much more painful when you’re paying for them out of your pocket. - Bonuses
Sign-on bonus, moving bonus, refresher bonus, performance bonus, yearly bonus. Some companies have them, others don’t. This affects your “total compensation” per year. - Career opportunities
What positions are available in the event that you earn a promotion? What is the procedure for promotions and raises? Some companies require a strict number of years of experience or qualification before you can reach specific positions. - Equity
Stock options and restricted stock units are two that I’ve encountered. Find out the vesting conditions (when the stock actually becomes yours), and more importantly find out its value. For publically traded companies you can look up the value of each share, but for private companies 100,000 shares means nothing if you don’t know how many shares there are in total. Ultimately, you want to find out what portion of the company value you are getting in the event that there is a buyout. Large and VC-funded companies will usually have less stock floating around for new hires, while smaller privately-funded companies will usually offer more stock for a lower salary. It’s up to you to determine how much you think that company (and thus, your stock) is worth.
I highly recommend reading Venture Hacks’ writeup on considering offers from startups if you find yourself in that boat. - Hours
What is the company culture regarding the number of hours they’re expecting you put in? Is it a 60hr/wk sweatshop, or do they not care how late you stumble in and how early you bust out as long as your work is getting done? - Leaving
You never know when your life might change and you have to jump ship. Keep an eye out on leaving conditions and consequences, such as having to pay back your bonuses. You don’t want to find yourself in unexpected debt. - Perks
Free lunches, gym access and trainers, public transit pass, housing assistance, commute shuttles, relocation assistance, company events, corporate discounts. They don’t pay the bills, but they don’t get taxed and make you a little bit happier even if you refuse to admit it. - Salary
This is heavily proportional to the location and its cost of living. Your salary is worth a lot less in California than it is in Seattle where the cost of living is half, and there is no state income tax. - Starting date
How flexible is your starting date? - Telecommuting
What is the policy for working from home? What about workign abroad during an extended trip? - Title
You might not think it matters right now, but it matters to your career. That, and salaries are often proportional to your title. Find out what positions are available in your branch of specialty and figure out what bracket they’re offering you. Big tech companies often have things like Software Engineer Level 1 (new graduate), Level 2, etc. - Vacation
How many days of vacation per year? Personal days? Sick days?
What did I miss?
5 commentsCircadian Somersault
(Crop from an xkcd comic.)
Last week I decided to experiment with a 28 hour day cycle. Instead of scheduling my sleep around a 24 hour day, I would schedule it around a 28 hour day with 9 hours of sleep. I would do this until I complete a full loop around the clock and return to normal sleeping times.
Everyone asks “Why? What are the benefits?”
I didn’t do it for any particular benefits; I did it because it’s something I’ve always wanted to do since my sleeping patterns naturally drift forward if left unattended, and because they already started veering forward and I figured it’d be more fun to do a full somersault forward than to slowly revert my sleep times into civilized hours.
It went something like this:
Day Sleep
------------------------
Friday 12 am - 9 am
Saturday 4 am - 1 pm
Sunday 8 am - 5 pm
Monday 12 pm - 9 pm
Tuesday 4 pm - 1 am
Wednesday 8 pm - 5 am
Thursday 12 am - 9 am
Like normal sleep patterns, I veered in one direction or another by under an hour, but overall I completed the trip. My notes on the experience follow:
- Saturday, officially decided to start the process today. I am very well rested well rested, I even had trouble getting the full 9 hours of sleep tonight and had to settle with 8.5.
- Sunday, the first day being awake on opposite hours from the rest of local civilization. Everything is quiet and exciting.
- Monday, easily getting the full 9 hours of sleep, and no trouble waking up. I feel rested throughout the day.
- Wednesday, no trouble sleeping or waking up, but towards the second half of the day I was feeling tired and unable to focus, so I settled into a 45 minute nap.
- Thursday, again became tired towards the second half of the day and took a 45 minute nap.
Waking up at unusual hours was an interesting experience, although I would probably need more than 9 hours of sleep to maintain this pattern for longer periods. Or just adapt to 9 hours + short naps.
To me, sleep is very important. Getting enough sleep noticeably affects my memory, focus, and stuttering. Also, I enjoy sleep and look forward to it, and I usually get 9 hours of sleep even with a regular 24 hour sleep pattern.
If I had to push myself to spend more time awake then I would definitely prefer a 28 hour sleep pattern over polyphasic sleep or pulling all-nighters and crashing. It’s a bonus that it lasts a predictable 6 days, and I am not experiencing any problems while integrating back into a normal 24 hour sleep cycle.
In a few hours, I’m getting on a plane to the west coast for some interviews and sun. Be back in nine days!
No commentsEmployment status: differently abled

Today: My final day of work at Idée Inc. I wrapped up documenting and handing off my projects, returned my key and notebook, cleansed my hard drive of incriminating evidence, and headed off with my co-workers to celebrate my departure by consuming unhealthy quantities of delicious sushi at New Generation Sushi on Bloor. Tea, rolls, teriyaki, and dirty jokes were had by all, suffixed by ice cream and a heartwarming going away card.
Two weeks ago: I declared my intent of resignation. I learned freighter-loads of knowledge-units at Idée, especially in the first several months, but I realized that my growth has plateaued and it’s time to move on to a new environment which will yield novel challenges and new experiences. It was hard saying good bye to everyone, especially knowing that I will be back on Wednesdays and Fridays to mooch Idée’s free food and beer. I met great people and formed important friendships, and I’m not abandoning that!
What now: Take some time and indulge in my interests which were not discarded but merely supressed by my dive into adulthood. I will focus more on contributing to open source projects, such as those I’ve started in my free time while being employed (workerpool, s3funnel, urllib3) and those I use on a daily basis which hold a special place in my heart (PIDA, Pylons, Gentoo, and KDE). Maybe I’ll also dabble in some game development.
Alas, sooner or later, bills will start piling up and I’ll have to seek new employment, or at the very least some freelance/contract work. So tell your friends and neighbours that a Python ninja (and Javascript slayer by night) with wicked webapp and database experience is available for hire.
4 commentsGoogle’s Lucky is fickle, too
One of Google’s most used underacknowledged features is the I’m Feeling Lucky query. On the surface, it seems silly and beside the point, but many people have grown to depend on it. What is it good for? Link resolving. You could go to Youtube.com and type “Rickroll” into the search box, or you could type “rickroll video” into your Firefox address bar (effectively doing an I’m Feeling Lucky search) and jump straight to where you want to go.
I no longer type “wikipedia.org” when I can type “wikipedia“. Why type “mail.google.com” when I can just type “gmail“? To me, Google has become a kind of DNS — resolving keywords into a complete URL. At that point, it’s hardly even search — it’s just a convenient side effect.
Providing a transparent link resolving service seems like a great selfless gesture by our unevil Google overlords. Rescuing the lazy with transparency and anonymity… Well, not quite. It turns out that the I’m Feeling Lucky feature only really works if you run it from the Google homepage, and approximately half-works from anywhere else.

Getting technical…
Anyone can turn a normal Google query into an I’m Feeling Lucky query, just append btnI=1 to the end of the URL (contrary to popular belief, btnI can take on any value, even empty string).
Let’s examine the problem. Consider this query:
workerpool site:shazow.net
Try opening that link, and then to compare, try the same query from google.com by hitting I’m Feeling Lucky.
Notice how clicking the link brings you to the Google results page, but the same query from the Google homepage does what it’s supposed to — takes you to the first result. It’s starting to become evident what’s going on here, but let’s beat this dead horse into the ground by hand crafting some HTTP requests, for great justice.
$ nc google.com 80 GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1 User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?) HTTP/1.1 200 OK Cache-Control: private, max-age=0 Date: Thu, 09 Oct 2008 01:07:47 GMT Expires: -1 Content-Type: text/html; charset=UTF-8 ... $ nc google.com 80 GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1 User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?) Referer: http://www.google.com/webhp?hl=en HTTP/1.1 302 Found Location: http://shazow.net/blog/2008/04/02/gentoo-rockband-code-and-music/ ...
I used netcat to send a raw socket request (the first two lines) to google.com on port 80, and then Google responded (lines 4 and onwards). There are two requests, one is a vanilla request and the second includes a fake Referer header claiming that I was coming from the Google homepage, which yielded the 302 redirect we want.
Sometimes external I’m Feeling Lucky links work, other times they don’t. It appears that Google has some secret threshold to decide when to get in the way of your destination like an angry ceiling cat catapulting itself onto your face. It seems to happen when there’s a small number of results, or the magic search juice score of the top score is relatively low.
Sadface, but what can we do?
Google may not be completely selfless, but they’re still pretty good compared to some jerkwads. Thankfully, Google provides a no-strings-attached search API to their wonderful magic search juice. It’s not very well advertised (or clearly documented), but once you hunt it down, it’s simpler than sketching a wrinkly gourd. Observe: Same fail query as above in JSON.
Writing your own I’m Feeling Lucky redirector is a piece of cake. I took the liberty of making one on the Google App Engine with a few bonus features:
http://302found.appspot.com/ (source code @ github)
Pass-through multi-car elevators
I had a dream last week about elevators that go through each other. After a bit of research, I found a few multi-car elevator shaft schematics and patents but they all seem to use a cyclic method of elevators cycling from one shaft and into another, instead of passing through each other.
Here’s my idea:
At least two shafts are required. One shaft is dedicated for people going up, the other is dedicated for people going down. Each shaft will contain many elevator cars, proportional to the number of floors. For an average residential building, 3 cars per shaft should be sufficient. Huge office buildings can have 5-10 cars per shaft.
Considering a single shaft (for people going up), it will work as follows:
People enter an “active” elevator car, the car goes up. Once the last person leaves the car, the elevator car transforms into “inactive” mode: The doors close and the floor collapses outwards to be on the same plane as each side wall. Then, each wall extends outwards one level, effectively allowing “active” elevators below it to pass through it. Once an elevator is in the “inactive” mode, it will make its way down to the bottom floor and wait until the last active elevator departed the bottom floor, at which point the walls will contract, the floor hatch will close, and the door will open waiting for new passengers.
Considerations
- Advantage: Elevator shafts are expensive. Consider a large office building with six to ten elevator shafts, imagine how much money would be saved if there were only two shafts with the same (or better) efficiency.
- Rush hour: This scheme is great for repetitive bursts of people. There should always be a steady stream of elevators, unlike current elevator systems where the shafts tend to accidentally get in sync and you end up waiting while all 4 elevators make their way down from the 40th floor.
- Danger: Collapsing floor instantly screams danger, yes. But with some thorough planning, it should be alright. The elevators cars can use sensitive weight sensors to insure that nothing remains in the elevator when the floor opens. If something refuses to leave the elevator, then the car will proceed to a special extra floor at the top (or bottom) of the building where further effort can be taken without interrupting the rest of the cars.
- Movement mechanism: The classic pulley setup wouldn’t work here. The columns on each corner of the shaft will need some kind of rails which each car can use to traverse and power itself.
In all practicality, it wont happen. But it’s still a cool idea. Who wants to write a simulator?
3 commentsDon’t put all your Python eggs in one basket

One of my favourite things about Python is how I can package up my module into an egg and easy_install it from a tarball, source export, or even an http link. All you need is setuptools and you’re off to the races, but there’s a few things to watch out for:
- There’s no easy_uninstall. To remove an egg, you would need to go into
/usr/lib/python2.5/site-packages/easy-install.pth, manually prune out the offending line, and finallyrm -rfthe directory container of that egg. Oh, and carefully pick out the various binary scripts the egg installed into/usr/bin. Good luck. - What if you’re working on two projects that require different versions of a specific egg? Having to re-easy_install a different version of an egg every time you switch contexts is no fun.
- Didn’t your mother teach you that it’s always better to not do things as root?
The solution is virtualenv.
Virtualenv creates a local copy of everything you need for maintaining your eggs. The prescribed way to use it is to virtualenv ~/python1 and then execute ~/python1/bin/activate to enter into the environment of that local installation. From then on, anything you easy_install will go into your local installation instead of your root install. If zombies attack and you need to purge your site-packages of any disease, you can scrap the whole thing and start a-new — try to do that with your root install without losing hair.
The shazow method
The default use of virtualenv is great, but I like to take things a little further. I setup a permanent local install as soon as I log into a fresh Linux user. This way, I never have to install any eggs as root.
sudo easy_install virtualenv virtualenv ~/local
And add these two lines to your ~/.bashrc or equivalent:
export PYTHONPATH=~/local/lib/python2.5:$PYTHONPATH export PATH=~/local/bin:$PATH
Now I never have to activate anything, I just happily use my local install without worrying about making a mess in my root. If I need to have different versions of things, I create a separate virtualenv install and activate that whenever I need it as mentioned before.
It’s nice to have your very own contained egg basket. This is especially useful for deploying production code on servers. Production environments often require very specific versions of packages, so deploying multiple Python apps on the same server is made much easier with virtualenv.
Update: Another good idea is to use --no-site-packages with virtualenv, this way the root PYTHONPATH can be omitted and all of your package dependencies will live entirely in the virtual environment. (Thanks, Chris! Check out his Virtualenv and PasteScript screencast for more on the topic.)
IPython caveat!
For those of you who have discovered the incredible life-changing tool of never-ending code-gasms that is IPython, there’s one extra step you’ll need to perform: It turns out that IPython saves some hard-coded paths when it’s installed, so you’ll need to re-install it with your new virtualenv active before it will work properly.
5 commentsBack to real life, from Cuba
Went to Cuba a few weeks ago and I brought back this timelapse video for you.
Highlights from the trip:
- A female Cuban customs agent with a distinguished Stalin-like bushy mustache.
- Bottomless quantities of mediocre food where buffet leftovers aren’t discarded but re-served the next morning.
- Perfect ocean beaches with silky-smooth sand.
- Snorkeling with picturesque waterlife and enormous sea sponges slowly strafing their way across the waterbed.
- Sleeping.
There was a lot of sleeping.
Great experience. Recommended to anyone with a dire need of a real vacation or Cuban cigars. 3 comments
Do your tubes have deep coverage?
One of the perks of being sick and working from home is getting to answer all those fun telemarketer calls.
Telemarketer: Would you like a free Toronto Sun newspaper subscription for six weeks?
Me: No.
T: How about just a weekend?
M: No.
T: Do you read any other papers?
M: No…
T: Well then, how do you get your news, sir?
M: Online.
T: Do you realize you’re not getting the in-depth coverage?
M: Yes I am.
T: Have a good day sir. *Hangs up*
“News: If you’re not getting the in-depth coverage from the Toronto Sun, you’re doing it wrong.”
1 comment
