On being tired

April 16th, 2008

And deploying code which let anyone using any login and password (and by any I mean really any combination, even asdf/asdf worked) authenticate. And have access to the administration panel. No fun. At least at first, when I shook my head with disbelief over the deployed code. How could I not check it… How could I not write even the simplest unit test… Quick fix and few minutes later the site was fixed. After that I’ve simply burst in laughter over my stupidity.

Thankfully hardly anyone ever tries to login to this particular site (login page has both no-index and no-follow so it does not attract google scripters) so despite the fact that this bug has been live for a little over 12 hours no one broke in.

Movies I've watched recently:

  • Vantage Point (2008) 3.5/5

    2008-07-08 23:34
    * * * +

    Watchable action flick, although there were way too many tiring flashbacks.

    0.3
  • Bill (2007) 3.5/5

    2008-07-07 01:15
    * * * +

    Predictable, schematic, much too naive, yet somehow funny, very funny at that.

    0.3
  • Omaret yakobean (2006) 3/5

    2008-07-06 00:51
    * * *

    Just good. Too long, too boring, too poor acting, too many unsolved plots and to top it off - storyline has too many weak points.

    0.3
  • The Children of Huang Shi (2008) 2.5/5

    2008-07-05 00:50
    * * +

    Big ambitions, poor resolution. Great story ruined by weak script and poor acting. Could've been so much better...

    0.3
  • There Will Be Blood (2007) 4.5/5

    2008-07-04 01:03
    * * * * +

    And blood there was. Oil, power, religion, atheism, hatred, money and lots of other things too. Dark, very dark movie.

    0.3
  • The Spiderwick Chronicles (2008) 1/5

    2008-07-02 00:23
    *

    Another fantasy movie for little kids. Schematic, predictable and full of holes in the loop. In other words: crap.

    0.3

Movie ratings archive »

On being dead

April 16th, 2008

Mark Twain:

I do not fear death. I had been dead for billions and billions of years before I was born, and had not suffered the slightest inconvenience from it.

Got me thinking.

via Ry Dahl.

Lawrence Lessig on the “Age of prohibitions”

April 9th, 2008

Great talk. Short, only 25 minutes. Don’t know who Larry Lessig is? Shame on you…

From TEDTalks.

Rails helpers. Rediscovered

April 5th, 2008

Normally, you’d use partials to manage some common functionality in a single file. For example like this:

Somewhere in your view:

<%= render :partial => 'ads/ad', :locals => {:placement => 'frontpage-banner1'} %>

It’s quite concise, but how about making it even less verbose? Helpers to the rescue:

module AdsHelper
  def ad(placement)
    render :partial => 'ads/ad', :locals => {:placement => placement}
  end
end

And now you can write this in your view:

<%= ad 'frontpage-banner1' %>

Nice! I believe it’s as short as it gets. Sure, if you render this partial only a few times it might not be worth it, but what if you render it 20 or 30 times?

content_tag FTW!

April 3rd, 2008

About those one-liners… How about turning this:

<% if logged_in? then %>
<p><%= link_to 'Edit', document_edit_path(@document) %></p>
<% end %>

into this:

<%= content_tag 'p', link_to('Edit', document_edit_path(@document)) if logged_in? %>

I don’t know about you, but to say that I’m impressed would be not enough. Available from Rails 2.0 upwards.

Steve Yegge. Again

April 2nd, 2008

Steve Yegge (emphasis added):

So how do you make yourself a superstar? Never stop learning. I’ve heard people say they think this position is a crock, that it’s ludicrous, that you couldn’t possibly spend your whole career learning new things.

But I think differently. I think every program you write should be the hardest you’ve ever written. And that’s what I blog about, mostly. Improving yourself.

It got me thinking today and the more I think about it the more sense it makes. I would go even further with this and say that writing not just hard programs but simply more complicated code is good for you. Not obfuscated nor unreadable but code which is just a bit harder to understand. What I mean is using new constructs, new methodologies, shorter one-liners (but not those super-obfuscated Perl ones), etc.

There are lots of people who will tell you that you should write the simplest code possible (even despite the obvious bloat) because this results in a more maintainable application. This is of course true, but should the maintainability be the ultimate goal? I think that self-improvement should be a higher placed goal. And I think that you self-improve by writing code you need more time to comprehend because the harder code you write now and the more time you spend understanding it in the future the less complicated it becomes. Over time. And that is progress. That is self-improvement. Plus, as a side effect of this, your code is usually more concise.

Now going back to refactoring one of my projects

Mongrel_cluster not starting after hard reboot

March 29th, 2008

Does the following error sound familiar?

** !!! PID file log/mongrel.pid already exists.  Mongrel could be running already.  Check your log/mongrel.log for errors.
** !!! Exiting with error.  You must stop mongrel and clear the .pid before I'll attempt a start.

It usually happens when the server crashes. After that you need to ssh into it, remove the mongrel pid files and start the cluster manually. No more.

I assume you have mongrel_cluster setup properly, ie: project’s config file is in /etc/mongrel_cluster and the mongrel_cluster script has been copied from:
/usr/lib/ruby/gems/1.8/gems/mongrel_cluster-*/resources/
to the /etc/init.d directory. You need to edit the /etc/init.d/mongrel_cluster file:

Change this two bits:

start)
  # Create pid directory
  mkdir -p $PID_DIR
  chown $USER:$USER $PID_DIR

  mongrel_cluster_ctl start -c $CONF_DIR
  RETVAL=$?
;;

and

restart)
  mongrel_cluster_ctl restart -c $CONF_DIR
  RETVAL=$?
;;

to

start)
  # Create pid directory
  mkdir -p $PID_DIR
  chown $USER:$USER $PID_DIR

  mongrel_cluster_ctl start --clean -c $CONF_DIR
  RETVAL=$?
;;

and

restart)
  mongrel_cluster_ctl restart --clean -c $CONF_DIR
  RETVAL=$?
;;

respectively.

Adding the --clean option makes the mongrel_cluster_ctl script first check whether mongrel_rails processes are running and if not, checks for existing pid files and deletes them before proceeding.

You must be using the mongrel_cluster version 1.0.5+ for it to work as advertised (previous versions were buggy). To upgrade do:

gem install mongrel_cluster
gem cleanup mongrel_cluster

Here’s the related mongrel_cluster changeset.

Old, but oh so good!

March 11th, 2008
<Khassaki> HI EVERYBODY!!!!!!!!!!
<Judge-Mental> try pressing the the Caps Lock key
<Khassaki> O THANKS!!! ITS SO MUCH EASIER TO WRITE NOW!!!!!!!
<Judge-Mental> fuck me

(via bash.org)

Today’s haiku

March 8th, 2008

High traffic
You wish to see
High traffic
You wish were gone

Steve Yegge live

February 12th, 2008

After yesterday’s best read of the month here comes the best show of the day. Which is Steve Yegge, live, talking about branding during 2007 OSCON. Without any slides. 25 minutes.

He also reveals that in his opinion Javascript2 will be the Next Big Language (NBL). I was kind of suspecting this would be it. Coincidently, lately I’ve discovered (what a big word) jQuery. And let me tell you, I’ve never seen any other piece of code, which is so concise and does so many things with so much style. Prototype, dojoToolkit and all other js libraries simply look pale in comparison. I’m hooked on jQuery and use it for every new project, while trying to implement it in my old ones too.