Categories
Looking glass
Navigate/Search

Ack!

_   /|
\'o.O'
=(___)=
   U    ack!

find . -name “*.some_ext” | xargs grep ’some_pattern’

Man does this not age very well when you do it al lot. Yeah yeah, you’re a smart-ass and you can write a shell script and make that easier. But what if there was a tool you could use to do it smartly? With highlighting and a slew of other features? Enter ack.

I’ve been ignoring my homies on #pso with a stupid kind of ‘i got fingers and i can type’ smugness. So wrong was I. His name is Bill, he’s my new friend.

The culture of failure




I love failure and I want to fail more. While looking at videos over at Stanford’s Entrepreneur’s corner, I stumbled upon one video from Randy Komisar of Kleiner Perkins, the VC firm. What he says is true of the valley, and of entrepreneurship in general; one must embrace failure. ‘Fail often, fail fast‘ is a mantra typically enunciated by startup types.

This goes hand-in-hand with the idea that execution is king and rapid iteration comes to mind. There is no point to wait on the perfect idea, the perfect plan. Does that imply that we should throw away the adage ‘Measure twice, cut once‘?  But does that mean that we have a free  license to push out a lot of crappy code? I think not.

Another rule of thumb I came across was ‘Be pessimistic in the short term, optimistic in the long term‘ which I think ties both ideas together.

The time to act is NOW. The best plan to execute is the one right NOW. Innovation is driven by failure. Success is a by-product of failure… or is it?

Rails: to_prepare executing code before each request

I have found little or no documentation on this on the net, so here I’m trying to give back a little from what I learnt. Hopefully that will be the beginning of a solution for others.

Rails version: 2.1.0

The problem:

I have certain ActiveRecord models that I want to monkeypatch (i.e. inject functionality to an existing class on runtime). That’s the beauty of dynamic languages, poor Java sods, no need for an AbstractFactoryFactory for j00!

My first approach was to write a script in ./config/initializers that would be invoked on initialization. However, as it turns out, while this works fine for an immediate use of the said monkeypatched object, this wouldn’t work for later instances of this class. In my case, an ActionController method, when calling one of the monkeypatched functionality would raise a NoMethodException.

It took me a bit to realize what was going on and how rails was actually running through its initialization process.

The solution:

Rail’s initialization code has a method called to_prepare which can be invoked in the initialization block. Now looking at the rails source code for initialization, the method requires dispatcher which loads ActionController::Dispatcher and invokes the method to_prepare. Bingo!

What to do next is simple. In my script found in ./config/initializers, the only change i needed to do is to require 'dispatcher' and to monkeypatch as follows:

Done. Profit.

Computer “Science”

I am rectum’al about some things though probably not when I reek of alcohol (sometimes) or almost falling asleep, like now. One of those things is spelling. The people that I chat with often have to endure my misspellings : ‘ey man’, ‘transcenadnce’ and ‘eligjtment’ are samples from my chat logs the other day.

No matter that when I read chats/blogs from people, I expect none other than perfection. Another anality of mine, which I gratuitously violate(d), is grammar. The denizens of the interwebs have got their tubes connected to their rears when it comes to grammar and spelling; stool samples are easily collected: ‘rediculous’, ‘there’ instead of ‘their’, ’should of’, ‘could of’ and incorrect use of the semi-colon.

GOD! Grammar isn’t rocket surgery*! That’s how we get stupid expressions that don’t make any sense anymore! The old expressions are pardoned because they help gave birth to hotforwords.

This is a long-winded post to mention the awesomely rad Computer Science Unplugged,  about computer science and how it has little to do with computers**.

* Thanks DHH for this new (to me, and stupid) internet meme probably automagically rendered a gazillion times more popular after startupschool. DHH is actually a very nice guy, no ill feeling.

** Notice how real sciences don’t have “science” affixed? Thanks, Richard for the observation the other day.

Just do it

I attended startupschool about a week ago and that was quite a blast. The folks at justin.tv and omnisio have got the video transcripts up, definitely worth a watch.

I missed the major parts of two talks, and by Murphy’s law, they just had to be two of the top 3 talks I wanted to hear; Paul Buchheit and Paul GrahamWe had a production server outage, so I was furiously competing for wireless access point time with 400 other geeks (and PG during his talk… XD).

I did, however, manage to catch this quote from one of PG’s slides:

A good plan, violently executed now, is better than a perfect plan next week.
George S. Patton
US general (1885 - 1945)

I wonder why this wasn’t even a discussion topic for the HN crowd, but this struck a chord in me. It is now my motto.

Wonderful hacker gathering and awesome pre- and post- parties. Much love for SUS. See you next year.

P.S.: We got that production issue fixed BTW