Precompiling non-default assets with Rails 3

I've just been playing with an interesting problem whereby Rails 3 wasn't precompiling assets as I would expect.

I have an application which contains two main javascript 'bundles'.  One for the common man, and one for the administrators only.  Now there's no point in serving a whole load of admin stuff to regular users hence the seperation.

However, when precompiling my assets I noticed that Rails was only doing the default application.js, and ignoring my admin.js.

Well, it turns out you need to manually tell Rails that you've added that additional resource.  Luckily this is nice and easy:

Job jobbed.


How to do wildcard selectors with Sass


RIP Steve Jobs


Making Postgres STFU in Rails

If you're using Heroku to host your Ruby Rack apps, then you're probably also using Postgres, which is the default choice for the database stack.

However, one downside to this is that in development Postgres is a noisy bastard telling you about everything that you never wanted to know, plus the odd query of interest.

Well, luckily there is a couple of things you're able to do to reduce the noise.  Firstly you can tell Postgres directly that you don't want to hear it's warnings about table creation and the like:

If this isn't enough for you - you can also tell Postgres to only give you the queries that your app generates rather than everything that postgres sends over the wire.  This is all handled by the silent-postgres gem.

To add, simply whack this in your gemfile.

Bundle install, and you're good to go, and in peace.


Social Media Burnout

This might turn into a long ranty post, so bear with me, it's been in the pipeline for a while.

These days, it appears that you cannot move for another social network popping up. We've got Facebook, Twitter, Google+, Foursquare, Gowalla, LinkedIn, and that's only to name the few that have been reasonably successful, but outside of this very small circle, there's hundreds more.

The problem we have these days is that social isn't a new thing, it's a very well established market online and the main players have already made themselves very well known.  However, every day, there's some other network popping up, and it's normally a clone or vague twist on one of the established players.  Sites like About.me for instance, which fulfill a small niche job, but basically do the same thing as all the other networks out there.

So why?  Well, I would hazard a guess that it's to do with money.  There's a billion and one startups out there who've got the next shit idea that will make them their VC billions - eBay for dentists, Facebook for pets, the list goes on, but the thing is, they're all flawed in so many ways (cats can't type).  But social equals money. We've all seen how much money companies like Facebook and Twitter are allegedly worth* these days, and everyone wants a slice of that pie.

For instance, new network Zerply, a site where you can add your CV online and 'Find like minded people by tags, skills, location and more'.  For starters, other than the fact that it's a bit simpler, and more colourful than LinkedIn - it's LinkedIn, just in a frock.

But what problem does this solve?  It's another place to dump your information and create an online profile / CV.  But would you ever rock up to an interview with a potential employer with your LinkedIn or Zerply profile, or would you spend the time to make a proper resume that you have full control over?

OK, so maybe it's the networking effect that is the key.  Well, again, to this day I've never been introduced to anyone through LinkedIn for work.  I've never got a job through LinkedIn, and I don't know anyone who has.  As far as I am aware, every single person I know has only 'connected' with people they already know, and received a shit load of crap from recruiters.

Ah, yes.  Recruiters.  The underbelly of the IT industry that stalk us at our every turn, and one of the primary reasons I have a LinkedIn account no more.  These buggers keyword search you and send you email for jobs that'll never interest you, and then harass you until you take some action to stop them.  These are the people who like the idea of the online CV, but only because they're generally quite lazy **.

So, let's assume our new social network idea is a good one, where's the next problem?  Well, the fact that everyone is using something else for starters.  Take Google+, the new network from Google.  Functionally it's superior to Facebook in almost every way, and looks nicer to boot, however, even though millions of people have Google accounts it's still relatively quiet.  Why?  Well everyone's using Facebook aren't they...

Your average Joe isn't going to migrate over to Google+ until his buddies do, otherwise he's out there on his own.  It takes a mass migration to get people to change their core network site of choice, and isn't something the web has seen before.  When Facebook popped up there wasn't much else in the way of alternatives.  Whether Facebook maintains it's position for the years to come remains to be seen.

For now though, any social network that is created has an exceptionally massive hill to climb.  Not only has it got to provide something that is relatively feature complete, but it also needs to do something unique (and useful), and woo people away from the tool they know and love already - which is going to be hard.

* If you believe the valuations at all and realise that they aren't just made up money.
** Note, I know plenty of GOOD recruiters, just none in IT.

Update to heroku_san_sanity

Warning

 

Today, I pushed an update to my heroku_san sibling gem heroku_san_sanity.  

In short, the gem now provides a platform health check against Heroku prior to any deployments and lets you know if there's an issue asking you if you if you want to continue or not.  

This change was brought about after I found myself in a deploy limbo where deploy itself has occurred, but the DB migration rake tasks weren't functioning, causing my deployment to be hung halfway until Heroku fixed the issue (which luckily was only a staging deploy)

To install, simply add heroku_san_sanity to your gemfile, and you're cooking.

I've got a new job... and it's at Kyan.

Over the past three years and three months I've been working at Monochrome, a digital agency in Epsom, Surrey.  However, at the end of this month I'll be moving over to Kyan, another agency based in Guildford to join the team doing web development with my weapon of choice, Ruby on Rails.

Whilst the companies are essentially the same, Kyan represents a new opportunity and one where I hope I'll be up to some new and interesting things with the bunch that work there.

Looking back, Monochrome was a great company to work for, but times move on, and so must I.  However, if you fancy following in my footsteps, Monochrome are recruiting at the moment.  If you're looking for a Rails job in Surrey, check it out.

 

Kyan


Introducing Heroku_san_sanity

Over the past few months, I've been using heroku_san for all my Heroku deployments.  In short, this gem wraps up the heroku git tasks into a neat little format that supports multiple environments (.e.g production, staging etc).

However, there's not much difference between a staging deploy and production one, so the risk of muscle memory kicks in.

Which is why I've created the heroku_san_sanity gem.  Adding this gem to your Gemfile, will ensure that you're sure you want to do a production deployment.  Before deploys to any production deployment the following will be presented to you:

!    WARNING: Potentially Destructive Action
!    This command will affect the environment: production
!    To proceed, type "production"

Only by typing in 'production' will the deploy continue, forcing you to mentally double check before stomping over your live application. If you don't, nothing happens. 

The code's on Github, so feel free to fork and improve!

What to do if your HTC Desire won't power on

If you've got an HTC Desire that won't start up (no lights, no nothing) there's a few simple steps that you can do to try and get things back on track.

1) Remove the battery
2) Plug it into the USB cable as if you were charging the phone (leave the back cover off)
3) Replace the battery without plugging in the phone
4) Things should now start working (if not, give the power button a press)

If that doesn't work, try some percussive maintenance and lob it in the bin.

Avoiding zombie dynos with Heroku

I've been looking at some long running processes on Heroku of recent and found there is a behaviour in place which is not quite what I expected.

The heroku docs state:

The Heroku routing mesh will also detect a different kind of performance problem: long-running requests. If your dyno takes more than 30 seconds to respond to a request, the mesh will serve a “Request Timeout” page to the user.

Now, initially, you'd think that this means that your dyno process is killed off after 30 seconds.  What is actually happening, is literally as the docs say, the routing mesh is returning a page timeout to the user. The dyno is actually still spinning away, working it's merry little heart out even though nobody's listening any more.  The primary problem with this is that dyno is still busy and can't accept any more requests until it's finished - which leads you to having a zombie'd dyno.

So, what can we do?  Well, the support guys at Heroku pointed me at rack-timeout, a gem which can be used to timeout all your application requests within a set time limit (for instance, the 30 seconds that Heroku set).  Gem is a dead simple install and configuration, and solves this problem neatly and elegantly.

Next