Devlog December 2011

With me back to a place where I can be completely open about what code I am writing (yay!), I think it’s time I restart my devlog :)

Last time, I was using my old blogging engine, and hand-wrote them in a markdown file on my netbook. Things have changed a lot since then, and this time I’ll be directly writing/publishing them daily from WordPress

Dec 4

I finally grokked Indexes in databases. It all makes perfect sense now. Yay! (And this was thanks to being able to read on the Kindle, so yay for that too). Nothing productive done though.

Dec 3

Serious push to get livetrains project out within a few days. GeoJSON output done properly. Moved from OpenLayers to Leaflet.js on geohacker’s suggestion. Don’t regret that a bit. Also, coffeescript is fun!

I got to a point where I’ve got GeoJSON rendering routes. No live animation yet. Spent some time trying to find a easy screenshot saving app, found none. All the ones I found suck. Sigh.

Dec 1 – 2

Kindle arrived. Loading it up with books to read. SICP is good enough on it. Loading up as much as I can find about Hacker Culture/History.  Moved my entire vim setup to vundle. Not bad.

 

 

What I learnt from reading “Javascript – The Good Parts”

Just finished reading ‘Javascript – The Good Parts’. Here is what I learnt:

  • I knew jack shit about JavaScript. I was able to get along so far simply because I knew jQuery and understood how closures work.
  • Holy shit that’s one fucked up language. Quite schizophrenic, saved by almost limitless extensibility/monkey-patchability/watcha-gonna-do-write-a-java-applet-hahaha .
  • If you’re going to write Javascript, you’ll have to subset. Subsetting/augmenting has its own share of problems – primarily that map in your code might not be the same as map in someone else’s code, even if they seem to be working on the same ‘type’
  • jQuery is incredible. I guess it is sort of like a ‘Standard Library’ of sorts, atleast on the client side. I’m sure there exists something similar on the server side as well (underscore.js, perhaps?)
  • I haven’t written any sufficiently large Javascript program yet. Need to fix that.

Defensive Programming

When you’re writing PHP, you program defensively. The language is out to get you. Make one wrong step and it’ll fuck you over. Never assume anything, make sure you always check the documentation. You can’t trust the language. It’s not stupid, it’s schizophrenic.

I think I should start treating JavaScript also that way.

3 reasons why people join ‘IT companies’

Source: Friend of mine who is sadly ‘training’ at a big ‘IT company’ now (He wishes to remain anonymous, and I could see why)

  1. Because everyone else did
  2. Because parents told
  3. Because it will be very sophisticated and relaxing there, with lots of recreational facilities

I’m just going to leave this here, and hope that when this boom does bust, it doesn’t leave too many dead bodies in its wake.

Our Greatest Fear – ‘Flash and Fade’

HP:MOR is an awesome fanfic that anyone intent on improving themselves should read. It’s a bit like HHG2G – you don’t read for the storyline (which is jumbled) but for the characters, wit, rationality and humor. Quite a few of those things hit very close to home – if you are a geek, they would perhaps to you too. Highly reccomended.

Of the many quotable parts of that book, here’s one little nugget I found:

_[…] the simplest explanation for this unverbalizable fear of yours is just the fear of losing your fantasy of greatness, of disappointing the people who believe in you, of turning out to be pretty much ordinary, of flashing and fading like so many other child prodigies..

_ – The Sorting Hat, Ch 10, HP:MOR

A few friends were discussing this a while ago, and I think this phrase succinctly explains our greatest fear.

Here is to hoping that I don’t just ‘flash and fade’ :)

My Vim setup

I moved from emacs to vim a while ago, and have been steadily accumulating a series of plugins in my .vim. They’re all up in my rather messy dotfiles repo. Here’s a slightly more neatly organized list of the plugins I currently use:

  1. command-t – File opener and buffer switcher. In-fuckin-credibly useful.
  2. vimpress – What I use to blog since moving to wordpress.
  3. matchit – Lets % work with html tags
  4. commentary – Generic commenting and uncommenting script NERDCommenter has replaced commentary due to being more flexible and having more options.
  5. fugitive – Incredibly awesome git wrapper for vim. I rarely go to the commandline for git these days
  6. tagbar – Useful code-exploratory plugin when I’m looking around a codebase trying to familiarize myself.
  7. supertab – Buffer completion in insert mode only when I need it.
  8. gist – Put stuff up in gist to pass it around
  9. BufClose – So I can close a buffer without messing up my splits
  10. extradite:Glog replacement that builds on top of fugitive. I don’t understand why this isn’t bundled with fugitive
  11. TwitVim – Yes, so I don’t have to go to the browser (and be consumed by chat/reddit/hn) just to post a tweet.
  12. ack.vim – Ack integration for vim. Do yourself a favor and use ack instead of grep.
  13. Syntastic – Automatic syntax checking so that I don’t miss a semicolon and not know about it
  14. php-doc – Insert boilerplate PHP doc compatible strings in my PHP files whenever I want to. Very PHP specific, need to find something that works across languages. (Note: This plugin has quite some identity crisis. It’s named PDV but it’s filename is php-doc. Since php-doc is more descriptive, I’m using that)
  15. delimitMate – Automatically closes quotes, parens, braces, etc for you. I initially thought this would be super annoying, but in fact it is rather very pleasant.

I’m also on the default desert color theme – haven’t found anything better. Suggestions welcome – both for the color scheme and for new/replacement plugins. After trying out wombat and jellybeans color schemes, I have settled on wombat for now.

Suggestions for more plugins still welcome :)

This is the list as of 24 Aug 2011. Updated as of September 2 2011 (added 10, 11, 12 since last update). Updated as of September 5 2011 (changed 4, added colorscheme change). Updated as of September 12 2011 (added 13, 14, 15). I am moving quite fast, am I not? Will keep this post updated as and when things change.

The fridge at InterviewStreet office

We bought a fridge two days ago, and spent a day stocking it up. Perhaps it needs a bit more non-liquid content in it, but I think the choco fills and Dark Fantasy biscuits (not to mention the litres of Ice Cream we’ve stocked up on) would do just fine for now :)

And before you start harping on about ‘health’ – the bottom tray has a mysterious cover full of apples shipped from Chennai by mom.

Non-ASCII Characters in HTTP Headers

I was debugging an issue at work today where a (generated) file refused to download in Chrome, but the same URL worked just fine with wget. I remember reading in the HTTP Spec that HTTP headers can only be lower ASCII, so when wget mangled the output file’s name, the problem was obvious – the file name contained a character that wasn’t in lower ASCII (an accented A). Chrome had borked on encountering it, while wget soldiered on. Using iconv to strip non-ASCII characters in the file name on the server side fixed the issue.

Moral of the story? Read the RFCs! The HTTP one, in particular, is remarkably readable and you should read it if you’re doing non-trivial Web Development.

P.S: If I had had time, I’d have went around testing this behavior in several user agents and documenting their behavior (and possibly submitting bug reports) – but .

 

You are a programmer if you can run code in your head

From HN:

From my experience, the largest hurdle first time programmers have is being able to execute programs in their head. It takes a cognitive leap to go from the source code in front of them, and what happens at runtime.

(emphasis mine)

I believe that if you have made that cognitive leap, you can call yourself a programmer. It means you’ve entered into the second hump – you are a programmer. One of us. Welcome :)

This is also the reason why solving programming challenges at places like InterviewStreet Challenges, CodeChef, TopCoder, SPOJ, etc also increase your general programming skills – they require that you continuously run code in the interpreter in your head. Helps you train your procedural memory. Same reason why learning different language paradigms (OOP, Purely Functional, Procedural, etc) makes you a better programmer.

Reminds me that I have four more chapters in SICP to finish and Clojure to learn :)

 

Temptations

Just came across this beautiful piece of conversation that had me doubled up for quite while:

Him: The Nexus S tempts me. Only 20k.

Her: The Galaxy SII tempts me.

Him: Hehe, that’s way out of my range though.

Him: You tempt me!

Her: Hehe, that’s way out of your range too!

:)

“What is the best way to stop your child becoming an athiest?”

From the usually boring Yahoo answers, we have this gem of a question:

What is the best way to stop your child becoming an athiest?

I don’t want any of my children to be punished by God.

However, it also had this gem of an answer:

Do not educate them, or expose them to critical thinking, logic or science.

Lie to them constantly about how the world works. Feed them a steady diet of mumbo jumbo dressed up like real knowledge – the jumbo jet in the whirlwind for example – and pretend that it is deep wisdom.

Make them loathe their own natural bodies and functions. Convince them they are small and weak and worthless and need redemption. Tell them everything enjoyable is grievously wrong to even think about, and that their only fun should be in grovelling to an invisible friend.

Ensure that they resent anyone who is not like them in every way – skin color, nationality, political opinion but especially creed. Make such people out to be evil and vile and give them – impotent minorities all – the fictional power to somehow oppress and persecute the vast majority who do think like you.

Teach them to laugh at and dismiss out of hand any faith but their own. Early – early mind you – make sure they are taught the difference between superstitious deadly error – that one raving lunatic in the desert told the truth about a vicious god who killed people, and divine eternal truth – that another raving lunatic in the desert told the truth about a vicious god who killed people.

Instruct them with all severity and import to never question for themselves – to never think for themselves – to never live for themselves – but to seek answers only in one – just one – particular set of semi-literate bronze age folk tales.

Above all – and this cannot be overemphasized – make sure they cannot spell, use correct grammar, or understand basic English words.

That should do the trick.

It is, however, two years old. Maybe if Yahoo had not been the place where products go to die…