Archive for May, 2008

Setting up Nginx with Rails

Posted by rich on May 22nd, 2008 categorised as How-to | 5 Comments »

So the other day I decided to switch from using Apache to Nginx not because apache isn’t any good, far from it. Nginx just uses much less ram and when you’re on a fairly small slice, using up more ram just isn’t good. I was going to benchmark speed and things between apache and nginx but I forgot to take some readings before stopping the apache service and installing nginx so we’ll skip over that idea like the thought never came into my head.

I’ll mention a few things I like about nginx first:

  1. It’s Russian -Being Russian it makes me feel like a communist, which is fun. It also reminds me of being build to take all things thrown at it.
  2. It uses a lot less memory - As I said before, not really done much benchmarks so these were some quick figures from ‘top’ but I had apache running with about 5 instances each using 2-3% of ram even at 2% each that’s still 10% of ram being used just for apache… with nginx I appear to have 2 instances running both using 0.2% of ram, so 0.4% in total - which is a nice difference.
  3. Faster page serving - Now this is meant to be a server fast at serving static content so its not just be me but I find the site much quicker compared to when it used to be on apache (all the sites in fact). I’m not to sure if I just think it’s quicker, the slice has more ram free so never going into swap or…. it is just a lot quicker at serving pages.

Read the rest of this entry »

Come back in focus again

Posted by rich on May 15th, 2008 categorised as General | No Comments »

Off to see Kerry at aber this weekend so thought I’d pump out a quick youtube Friday before I head off.

First off I thought I’d start with the Floyd, this is from division bell, which is one of my favourite Pink Floyd album.

Next up a bit of Thom, not to sure if I’ve posted this before - I have yet to import posts from the old blog. I’m sure you can survive having to watch it again…..after all it is Thom :)

Finally I thought I’d post this video I found, I was orginally going to find Bob’s version, and then the one thats playing at the end of the last season of Battlestar Galactica but instead I found this insane child playing it like a pro. Enjoy (All along the watch tower btw).

I love web frameworks, why don’t you?

Posted by rich on May 11th, 2008 categorised as Grind My Gears | No Comments »

Lately I’ve become fanatical over web frameworks, mainly Django, Rails and CakePHP. Something about them just clicks, maybe its because I can go back to a rails app months after I’ve written it, even with no comments, and just know where each file is likely to be and where to find a certain method. Also I can create CRUD (Create, Read, Update and Delete) functionality in seconds as most frameworks provide some form of scaffold, something that would take time to produce without a framework in something like PHP.

If there is one thing that pisses me off about frameworks - it’s the people who don’t like them. If like me you’ve read a lot of people talking about how crap frameworks are? How they don’t see the point: “What’s the point in a framework? I can just find all the different library’s I need such as templating, databases and include them in my app”. Why? Why would you want to waste your time including a database class, setting it up and then going to find a template engine to include and then setting that up too! When the framework will just give you that from the word go. It just confuses me. Then there is the fact that with most frameworks you get nice clean URL’s, free without having to do anything. try doing that in your simple PHP app without doing some form of mod_rewrite YOURSELF.

Most frameworks will log errors, show debug information (in development mode), give you the option of simply editing a file (not having to set it up too) to get nice 404/500 type errors. Something that would require you to make your own form of exceptions, your own error logging if you were not using a framework, which would do it all for you.

Another thing that pisses me off about not having a framework - is validating form inputs. Argh, it annoys me so much having to do lots of if statements to check if a field is empty, having to do a query to check a field isn’t already taken. In a framework, for example rails I just have to do:

validates_presence_of :title

Tell me again why people prefer to spend ages writing if statements and queries to check form data?

People will always try to say “I don’t like being told how I should code” - Fuck me, yes maybe…maybe there are some standards you have to stick to in frameworks and if you’re totally mentally retarded you might think this is horrible idea to have to agree on a naming convention for the benefit of others. It’s like these people have never worked with other people? At work we’ve had entire meetings just agreeing on a standard form of code to use, have you ever tried submitting a PEAR class?! talk about anal. I’ve found apart with some naming conventions you can pretty much code however the hell you like in a framework - much like you can if you were not using a framework!

From my experience so far I’ve never had a website that has not fitted the framework type model… now I’m sure there are loads of sites that would not work at all in a framework and the anti-framework people will be the first to tell you but that’s fair enough if it doesn’t fit the model then you don’t have much choice. But these people do it out of choice?! Are they better than us mortals? Do they know something we don’t? No! from my experience the people who shoot down using a framework to speed up development, to help bring out creativity, to help with debuging, these people are generally scared to learn something new, scared to well…learn. They refuse to even look becuase they know it’ll be something else that’s not what they know, even if the current method they use is rubbish.

All this technology, all the advances in medicine we have, space travel, you name it. It all comes from people wanting to discover, people wanting to learn. So I beg you, don’t just push the framework out the window as though it’s all ‘hype’ and doesn’t have any real world use.. please please please just give it a try. There’s a reason it’s popular, even among the big names, because frameworks are damn good.

Where the hell have you been?

Posted by rich on May 8th, 2008 categorised as Youtube Friday | No Comments »

Man have I been busy the last two weeks what with travelling and doing projects for other people, feels like I never get time to write a blog post - which of course will be my excuse. You see I get home from work have some dinner, do a bit of a project and before you know it the night has gone, gone like the acting skills of Keanu Reeves in, well anything?

I’ve missed youtube Friday twice now and quite frankly that just needs to be sorted out right now. So bring on youtube Friday. Before I post some videos I’d like to bore you, come on entertain me for a second or too - I’m of course talking about what I’m up to and stuff.

Lately I have been busy doing a website for someone which I initially started in cakePHP and switched to rails - don’t ask me why!? Maybe it’s because I’m a fan boy (GO RAILS, GO APPLE!) and like a good fanboy I do as I’m told. Not to say I don’t like cake, I love cake! Frameworks in general are just a really neat idea.

I did manage to finish the project from scratch in a weekend though - which was handy and I even tried JRails to replace prototype with jquery, much much better and all the helpers and RJS I normally use still work.

While we’re in that framework sort of area - I’m going to relearn the limited python I know and do readinfra.com in django and here’s the twist I might just record screencasts of what I learn and how I learned it right from the beginning so if anyone else wants to pickup python and/or django feel free to watch along.

For the project I did at the weekend I decided to switch to using GIT to revision control it, and I has to say I do really like it. Yes! More fanboyisum but I just love how quick it is, how easy it is to do branches. I actually use branches now with SVN I’d always create a branches folder but did I ever use it? Nope. For readinfra I’m going to try Mercurial (HG) though see if I perfer that to git, has better windows support and while I personally don’t care about that as I don’t ever see myself trying to run rails/python apps on windows and pretty much always developing on my Mac, others however may differ so easier for team projects.

Enter youtube fun

The first video I’m posting is of good ol’ Thom. Thought I’d start off with a quite video but doesn’t Thom just look the perfect picture of strange folk at the start, when he takes a nice glare at the crowd. Anyhow enjoy - oh and shutup Jools.

The second video is from someone accross the pond, so to speak from Thom. Stephen Malkmus, singing in a lift, while clapping.

I’m a new soul, I came to this strange world, Hoping I could learn a bit bout how to give and take, But since I came here, felt the joy and the fear, Finding myself making every possible mistake…..macdell air.

Ah, Tony and Bush - at the gay bar?