Fork me on GitHub

Kernow Soul

Ruby, Rails and JavaScript Consultant

Running JSLint Through TextMate

| Comments

UPDATE: I now use jsHint which is more configurable, there’s an excellent TextMate bundle available

I’ve been developing with JavaScript a lot recently and found JSLint to be a rather useful tool for picking up syntax errors. Being primarily a ruby developer I have a nasty habit of omitting semicolons from the end of lines.

I found an article on running JSLint through a TextMate command but found Ryan’s script didn’t quite work with the output from the version of JSLint I’m using so I thought I’d share my modifications.

#!/usr/bin/env ruby
require 'cgi'

lint = `/usr/bin/java -jar ~/Library/JSLint/js.jar ~/Library/JSLint/jslint.js "$TM_FILEPATH"`

lint.gsub!(/(line \d+ character \d+:) ([^\n]+)\n([^\n]+)/m) do
  "<p><strong>#{CGI.escapeHTML($1)}</strong> #{CGI.escapeHTML($2)}</p>" <<
    ($3 ? "<pre>#{CGI.escapeHTML($3)}</pre>" : '')

lint.gsub!(/^(jslint:.*at )/, '')

print <<HTML
  <style type="text/css">
    p { margin-bottom: 0; }
    pre {
      background: #f5f5f5;
      border: 1px solid #cfcfcf;
      font-size: 12px;
      margin-top: 2px;
      padding: 2px 4px;

New Bars and Rubber for the Steed

| Comments

Lemond Fillmore with bull horn bars and orange rubber

A couple of weeks ago I had to replace the old tires on my Fillmore as I’d worn through the green ones that came with the bike. Took a bit of getting used to the orange but it’s definitely growing on me.

This last weekend I managed a puncture the inner tube while pulling the pump off which required a trip to Strada Cycles. I ended up replacing the bars and break callipers so it turned out to be a much more expensive trip than I was expecting. Just shy of £100 got me a new inner tube and I was back on the road again.

Running Merb on a Shared Host Without Compiler Permissions

| Comments

I ran into a problem earlier today when testing a Merb application in a shared hosting environment running Phusion Passenger. Like most shared hosts access to compilers is not allowed for obvious security reasons, this causes a problem when trying to run a Merb app. Merb makes use of RubyInline which needs to compile a C application in your home folder before it can run so when the user you’re running Merb under doesn’t have permission to run C compilers you’ll get an error similar to:

sh: /usr/bin/gcc: Permission denied

The way to get around this is to have a privileged user compile the C application for you, then copy it to your users home folder. The easiest way to do this is to generate and run a Merb app as the root user:

merb-gen app tmp-merb

Then copy the RubyInline C application to the users home folder:

cp -R /root/.ruby_inline /home/<username>

Make sure the file ownership is set correctly:

chown -R <username>:<username> /home/<username>/.ruby_inline

After this you should be able to run Merb as expected. If you’re still getting errors relating to file permissions after following the instructions above you’ll need to combine the fix from Vignet and put the .ruby_inline folder in a place accessible to both the apache user and the user running the Merb app, I’ve not tested this but it should work.

Updating RubyGems on OSX

| Comments

UPDATE: This article is now rather old, Ruby Gems 1.8.15 is the latest version and should be grabbed from here

Slightly late to the show I updated to RubyGems 1.3.0 today, the upgrade isn’t as straight forward as usual on OSX 10.5 and requires a little extra work. posted up some instructions on how to upgrade to RubyGems 1.3.0 which are useful for anyone having issues.

UPDATE: It looks like this issue is not specific to OSX, I was updating a couple of Linux servers and had to follow the same procedure.

Colour Profiles in Photoshop for Web Design

| Comments

While getting the photo of my new business card ready for the web I fired up Photoshop on the laptop. I soon realised I’d not used Photoshop on the laptop before, when I hit the save for web button my lovely photo changed into something hideously washed out. As someone who rarely uses Photoshop these days I always forget how to set-up colour profiles and spent quite some time doing this on the desktop machine.

To my relief a quick google search and a couple of minutes later I was all set-up and had exported my photo exactly how it should be. Thanks Usability Post for your amazingly simple and accurate guide to setting up colour profiles for web design.

My New Business Cards Have Arrived

| Comments

I’ve been making do with some terrible old business cards for the last few years and thought it was about time for some nice new ones. I wanted to go for something clean and simple so designed them with just a little type, a bit of custom kerning then shot them off to the nice little moo bot for printing. I have to say I do quite like the playful tone and little touches moo uses in their communications, it makes you feel happy.

Jamie Dyer business card

Is Anyone Else Excited About Merb 1.0?

| Comments

I certainly am, Merb 1.0 is due to be announced at MerbCamp on the 11th October 2008. Right now the guys are hard at work polishing the knobs and working on documentation.

I’ve been following Merb with interest ever since I first heard about it. One of the things I found hard to keep up with – just dipping into it now and then – was the speed of development and change. Every time I had a few minutes to play with it everything had changed. Its a bit like having the rug pulled out from under you every time you manage to get to your knees.

The 1.0 release Merb should be far more stable, and with some decent documentation I hope it will start taking off quickly, the barrier to entry will be greatly reduced. Even though I won’t be at MerbCamp I’ll certainly be following it closely.

I wonder if the 1.0 release will be promptly followed by a 1.0.1 release, as is tradition.

UK Does It Better… I Agree

| Comments

So the rain has backed off for the first sustained period since I moved back to the UK, I’ve taken the opportunity to lay on the grass in the sun and read a book I picked up the other day, Punk Marketing. Not that far in and I’m all ready enjoying it, who would have thought a book on marketing could be entertaining!

I came across a quote I thought I would share…

“Go to a multiplex, sit through the ads, and see how abused you feel by the start of the movie. Then to to a cinema in the UK and motive that most people turn up to view those commercials. Because they are actually fun-sensible and intriguing and full of messages that make people applaud.Yes, shout out with glee! These are entertaining, funny, well-produced, and cool. Four terms you’d never use to describe an ad at movies in the US of A today.”

I couldn’t agree more, those poor Canadians are force fed the majority the USA’s crappy ads. What’s probably worse is that often the product or service isn’t even available to them! I digress, having suffered with the Canadians for the last three years I can say I would gladly watch several hours of English commercials than a single US ad break.

In closing… Well done Britain, we produce some of the best ads in the world.