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.
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?
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.
** !!! 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:
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:
<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
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.