Stefan Goodchild

Rails, Clearance, Subdomains and Remember Me?

Been building a side project in Rails 2.3.8 recently and found that whilst getting the session cookie to work across subdomains is pretty trivial the Remember Me? cookie used by Clearance isn’t, especially for someone new to it like I am. Some fiddling around and some StackOverflow browsing led me to a pattern that solved my problems which I’ve published below for reference.

Just put the following into your environments (the period before the domain name is the key here)

COOKIE_DOMAIN = '.yourdomain'

if ActionController::Base.session
  ActionController::Base.session[:domain] = COOKIE_DOMAIN
else
  ActionController::Base.session = { :domain => COOKIE_DOMAIN }
end

And put the following into config/initializers/clearance_override.rb and restart and you should be golden.

Clearance::Authentication::InstanceMethods.module_eval do
  def remember(user)
    user.remember_me!
    cookies[:remember_token] = { :value   => user.token,
                                 :expires => user.token_expires_at,
                                 :domain => COOKIE_DOMAIN }
  end

  def forget(user)
    user.forget_me! if user
    cookies.delete(:remember_token, :domain => COOKIE_DOMAIN)
    reset_session
  end
end

Infocow

Infocow connects young people with useful stuff to help take control of life - sites, stories, information and inspiration.

Worked on the front end code and UI design with Nicolas Alpi and Ed Davey developing the back end on this project for Futurelab. Was a great experience with lots of brilliant feedback and user testing done by Futurelab feeding into the Agile development methodology we use here at Jiva.

Survive or Thrive 2010

A simple WordPress website to support the Survive or Thrive digital conference put on by JISC. The work included creating a custom WordPress plug in to allow easy updating and display of the shifting agenda on a day to day basis.

Was pleased to be able to do a design based on Conway’s Game of Life. The pixel shapes in the logo are two examples of patterns that are either static (survive) or create exponential growth (thrive) using the standard rules of the game.

Tutorhub

The project I have been product managing and designing for nearly 9 months now has entered private beta. Tutorhub is a website built to connect tutors and students. Built on a number of cutting edge technologies detailed over at the Jiva website this is something new in the market place and allows secure one to one tutoring sessions to take place using a familiar instant messaging interface.

The private beta is now live and we are looking for students and tutors to start testing.

Peter Gabriel – New Blood Tour Visuals

Spent 6 days on a soundstage at Shepperton Studios preparing tour visuals with a great team of talented people for the Peter Gabriel New Blood Tour and I was coding the sound reactive visuals using Processing and the hugely useful Toxiclibs) building on my earlier work.

The visor screen from “Boy In The Bubble” (Fan shot video)

The visor screen from “Mirrorball” (Fan shot video)

The rear vertical screens on “Apres Moi” (Fan shot video).

The rear vertical screens on “My Body Is A Cage” (Fan shot video).

And some stills from the original renders..

Peter Gabriel – New Blood Tour Visuals

Recently spent a fantastic 6 days on a soundstage at Shepperton Studios preparing sound reactive tour visuals (with Processing) for the Peter Gabriel New Blood Tour with a great team of talented people. I had a great time and produced some work I’m very proud of. Some videos of the concerts have started to appear on YouTube including the work I did for the rear vertical screens on “My Body Is A Cage”.

And the visor screen from “Mirrorball”

Novation Launchpad – Note number to XY Coordinates and back again.

First thing I did with my new Launchpad? Nope, I didn’t hook it up to Live and jam. I hooked it up, fired up Processing and worked out how to light up the pads and recieve the notes so I could hack it to do anything I wanted to.

One thing I noticed straight off the bat is the note numbers are not incremental. Each row starts 16 higher than the last - I assume to allow for the same firmware to work in a 16 x 16 layout model - and there is a very simple way that reminds me of the technique of bitshifting I used back in the bad old days of DVD authoring to convert from one to the other.

// To go from XY to the note number
noteNumber = y * 16 + x;

// To go from the note number to the XY
x = noteNumber % 16;
y = (noteNumber - x) / 16;

Hopefully that will save someone ten minutes of head scratching.

Jiva Technology

The new Jiva Technology website template for WordPress with custom Twitter feed and Project carousel.

Disco Maths

I started messing around with sin/cosin based grid manipulation a few days ago and posted the results on Flickr along with an abstract of the code and equation I used to generate the images.

This prompted Andy Best to amend the code to create two animations. Inspired by his efforts I decided to do my own animation in response.

The music is a quick edit I did of a Sir Drew bootleg 12” I’ve had for years and always loved.