Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

Upgrading Ubuntu Gutsy to Hardy

Posted by Jim Morris on Sun Jul 13 04:32:03 -0700 2008

I did my duty and upgraded from Gutsy to Hardy, after letting Hardy settle for a while. For the most part it was painless (unlike the last upgrade to Gutsy!).

Unfortunately the sound was now broken I have a HDA-Intel AD198x Analog chip set.

... Show more ...

Posted in Linux  |  Tags ubuntu,hardy,cups  |  4 comments

OpenMoko Freerunner first impressions

Posted by Jim Morris on Fri Jul 11 13:53:11 -0700 2008

OK so I just got my shiny new OpenMoko Freerunner GTA02.

This is an Open source GSM cell phone, running Linux and OpenMoko S/W stack.

... Show more ...

Posted in Openmoko,Linux  |  Tags openmoko,freerunner  |  19 comments

XPath matchers for rspec

Posted by Jim Morris on Wed Jan 02 13:32:50 -0800 2008

I've been working on a project that is mostly Java for the last many months, so haven't had much Ruby or Rails stuff to share.

However one thing I found when working on my tests in Java was an xpath matcher for JUnit 4.0 using the Hamcrest libraries.

... Show more ...

Posted in Rails,RSpec  |  Tags rspec,xpath,matcher  |  5 comments

Bit Vector Preferences

Posted by Jim Morris on Tue Aug 07 23:53:09 -0700 2007

In my latest web project I potentially have a lot of boolean preferences, which I use for enabling or disabling various email notifications to users.

Rather than having to add a migration everytime I want to add a new preference, I thought I would use the composed_of feature in my model and compose the boolean preferences from a bitvector. That way I can simply modify my model to add new preferences rather than add new columns to the database.

... Show more ...

Posted in Rails  |  Tags rails,preferences,composed_of,bitvector  |  2 comments

Paginating acts_as_taggable with will_paginate

Posted by Jim Morris on Mon Jul 30 15:04:50 -0700 2007

A question I see asked a lot is how do I paginate acts_as_taggable (on steroids)?

I haven't seen any answers I liked, so I created my own, which I'm sure a few people won't like either ;) But it works for me (tm).

... Show more ...

Posted in Rails  |  Tags acts_as_taggable,will_paginate  |  20 comments

RSpec testing all actions of a controller

Posted by Jim Morris on Sat Jul 28 14:23:07 -0700 2007

A pattern I find very helpful is to find all the actions in a controller and apply a test to all those actions.

For instance this is useful for automatically testing all actions are protected from unauthorized access when using a login system.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,controllers  |  14 comments

Using RSpec to test HAML helpers

Posted by Jim Morris on Sat Jul 14 16:44:33 -0700 2007

UPDATED for HAML 2.0 and RSpec 1.1.5 - Changed open to haml_tag, prefix helper. to all rspec calls...

The most recent release of HAML introduced a neat feature that allows you to use HAML-like syntax in your helpers to generate HTML HAML#haml_tag.

... Show more ...

Posted in HAML,Rails,RSpec  |  Tags test,haml,rspec,helpers  |  8 comments

RSpec testing views for escaped HTML

Posted by Jim Morris on Fri Jul 06 18:22:57 -0700 2007

For my social networking site snowdogsr.us I decided to escape all user input that gets displayed. I know people like to trick out their profiles with HTML but I want to avoid the various hacks that it allows.

So thinking I had done a good job of using h everywhere I output user input fields, I decided to see if I could actually test this with RSpec view tests.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,escapinghtml  |  4 comments

REST scaffold_resource security warning

Posted by Jim Morris on Tue Jun 26 15:14:04 -0700 2007

This one is so blatantly obvious it bit me in the Butt at 4am this morning when I had to get up and fix it! I am so embarrassed, luckily no private data got out, as no-one has entered any private data yet.

I used the script/generate scaffold_resource to get started, and I left in those nice format.xml things in, thinking I may use them in the future. For the most part this is not a problem, but one of my controllers is a profile table. Much of the data in there is public anyway so no big deal, but a few columns are private data like email, date of birth, phone numbers etc. These are specifically private and not viewable publicly. This is enforced but not having a view that shows any of that stuff to the general public.

... Show more ...

Posted in Rails  |  Tags rails,scaffold_resource  |  4 comments

Developing a social networking site part 3 - tag cloud

Posted by Jim Morris on Sat Jun 23 14:02:49 -0700 2007

This is a simple one.

I use the excellent acts_as_taggable plugin, and I wanted to have a tag cloud like everyone does.

... Show more ...

Posted in Rails  |  Tags rails,tagcloud,acts_as_taggable  |  no comments