CompSci 101 - Big-O notation

I recently had a couple of Google interviews in Tokyo, and while preparing for them I ended up with a huge list of things I wanted to brush up on before the interview. It turns out I didn’t get the job (next time!), but I thought I might be able to learn something anyway by working through the list and blogging about the main areas that companies like Google expect you to know. Without further ado, first on the list is Big-O notation: ...

December 7, 2010 · 8 min · Dave Perrett

jQuery SimpleColor plugin hits version 1.0

A couple of weeks ago someone commented on the SimpleColor plugin with a nice suggestion - adding the selected color as text inside the color selection button. I finally got around to implementing this last night, and added a couple of extra options to support this : ...

December 7, 2010 · 1 min · Dave Perrett

A weekend project - fromthecache.com

I was playing around on the weekend screen-scraping and analyzing word-frequencies for various sites (don’t ask), and was getting some slow responses (and accidentally got my IP blocked from one site when I hit them a few too many times). Eventually I hit upon the idea of hitting Google Cache for each URL (the pages I was scraping had sequential ?id=xxx URLs so it was easy to automate), with the aim of speeding things up a bit and taking some load off the target sites. With this in mind, I spent a few hours Saturday and Sunday developing fromthecache.com - it’s built on rails, and designed to provide transparent access to the Google cache, while fetching the original page as a fallback if necessary. ...

November 3, 2010 · 2 min · Dave Perrett

Introducing Rails Kitchen Sink

2013-03-28 Update : This project is very dated, and I don’t recommend it’s use. It’s now hosted on GitHub. I’m happy to announce the release of Rails Kitchen Sink a rails-project-starter, which I’ll be building all future Rails apps off of. ...

October 21, 2010 · 1 min · Dave Perrett

Static blogging the Jekyll way

In building the new site, I decided to take the opportunity to try out something new. I’ve been using WordPress to power my blog for about 5 years, and while it has served me well, I wanted to try out something different. The main criteria for choosing a new blogging platform were : It should serve true static pages, with no need for server-side processing. It should be easy to store the entire site in Git. It should support the concept of layouts - I wanted to have a single ‘template’ file that blog posts could easily inherit from. It should support MarkDown or Textile for formatting posts, since I want to keep away from posting raw HTML as much as possible. It should support comments. I should be able to deploy updates to the site with a single command. By patching together a few different open-source technologies, I’ve been able to achieve the above and more. ...

October 12, 2010 · 9 min · Dave Perrett

Excluding fields from rails json and xml output

Rails has a very handy ‘respond_to’ feature to render your pages in different formats : respond_to do |format| format.json { render :json => @user } format.xml { render :xml => @user } format.html end However, by default it outputs every field in the model, which exposes some data (encrypted-password and password-salt) that I’d rather keep to myself : ...

October 3, 2010 · 1 min · Dave Perrett

HABTM before_filter in rails models

I’ve been playing about with Devise and CanCan for rails authentication and authorization recently - this great pair of posts from Tony Amoyal have helped a great deal. I have a User model and a Role model, and wanted to automatically add the :user role to each user whenever roles are assigned. The roles were set in the controller as follows: ...

October 3, 2010 · 2 min · Dave Perrett

How to create a TextMate bundle

If you find yourself repeating the same commands over and over in TextMate, it’s relatively straightforward to create your own bundle. Recently I’ve been migrating a bunch of blog posts from WordPress to Jekyll, and found myself repeating the same tasks again and again : ...

September 30, 2010 · 3 min · Dave Perrett

New 'projects' section launched

2013-03-28 Update : All projects are now hosted on GitHub I’m pleased to announce my new projects section, where I’ll be consolidating the various open-source projects I’ve released. Until now these projects have usually only been released via blog posts, but from now on each project will have a dedicated project page, with git repository information, issue tracking, and a link to a downloadable zip bundle of the latest release. ...

September 29, 2010 · 1 min · Dave Perrett

Security testing with Google's ratproxy

Ratproxy is a passive web application security assessment tool released by Google. Basically you set it up as a proxy server between yourself and the target site, and then click around in the target site doing whatever it is you normally do, while ratproxy analyzes your activity in the background and looks for security holes. ...

September 24, 2010 · 6 min · Dave Perrett