Archive for the 'Programming' Category

Flushing memcached servers the easy way

Tuesday, June 10th, 2008

This is easy right?  Can’t you just restart the memcached server? Well yes, but you may cause errors in applications that are already connected to it. You can follow your memcached restart with an application restart, eg for a Ruby on Rails app:

# /etc/init.d/memcached restart && mongrel_rails cluster::restart

Of course if you have more than one application server you have to restart your app on every single one. This would work on an engineyard slice assuming you have the eycap gem installed:

$ cap production memcached:restart
$ cap production mongrel:restart

Restarting your application is not ideal however, you will lose anything cached in memory, cause delays to users trying to access your site, that sort of thing.

So what can be done? The answer is really simple. Assuming a memcached running on the local machine on the default port:

$ echo ”flush_all” | nc localhost 11211

Easy!

Arse-peck

Wednesday, April 2nd, 2008

I was entertaining my wife yesterday evening with some witty banter on the subject of RSpec and was most annoyed that she wouldn’t stop laughing. As we all know RSpec is deadly serious so I couldn’t understand what could cause her such paroxysms, perhaps she had become ill of the mind; a raving loon? I made a mental note to check her dosage.

It turns out that she was only half-listening to me and having no idea what I was talking about (she is not a software developer) thought I was talking about something called ‘Arse-peck’. Last time something I said caused her to laugh this much was when I told her there was a UNIX utility called ‘ping’.

I really should get out more. At least that’s what my wife says.

LOSE

Wednesday, March 26th, 2008

After ‘winning‘ revision 1000 and 2000 carl attempted a new tactic in the race for 3000, the last-minute sprint. However he fell at the last hurdle, his basic grasp of basic maths. Here is the IRC log of the incident (botz0r reports subversion commits in IRC). Botz0r outputs each commit on two lines, the first being stats of the commit and the second is the log message:

 

[14:29] botz0r: the_project carl r2983 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: i
[14:29] botz0r: the_project carl r2984 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: am
[14:29] botz0r: the_project carl r2985 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: the
[14:29] botz0r: the_project carl r2986 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: mother
[14:29] botz0r: the_project carl r2987 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: fucking
[14:29] botz0r: the_project carl r2988 [trunk] (0 lines added, 0 removed in 1 file)
[14:29] botz0r: winnah
[14:30] botz0r: the_project carl r2989 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: for
[14:30] botz0r: the_project carl r2990 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: the
[14:30] botz0r: the_project carl r2991 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: third
[14:30] botz0r: the_project carl r2992 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: time
[14:30] botz0r: the_project carl r2993 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: you
[14:30] botz0r: the_project carl r2994 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: cannot
[14:30] botz0r: the_project carl r2995 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: defeat
[14:30] botz0r: the_project carl r2996 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: me
[14:30] botz0r: the_project carl r2997 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: muhahahaha
[14:30] botz0r: the_project carl r2998 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: hahaha
[14:30] botz0r: the_project carl r2999 [trunk] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: WINNAH
[14:30] botz0r: the_project ciaran r3000 [trunk/] (0 lines added, 0 removed in 1 file)
[14:30] botz0r: asdsa
[14:30] carl: FAIL
[14:30] Wlll: MATHS FAIL!
[14:31] ciaran29d: fail of the century

Announcing finder.overcycle.com

Wednesday, January 23rd, 2008

It is my pleasure to announce the Recycling group finder, Something I have been working on for the past couple of weeks with my wonderful employer 29degrees. For those of you who don’t know, Freecycle is a worldwide recycling network, in their own words:

The Freecycle Network™ is made up of 4,205 groups with 4,211,000 members across the globe. It’s a grassroots and entirely nonprofit movement of people who are giving (& getting) stuff for free in their own towns. It’s all about reuse and keeping good stuff out of landfills. Each local group is moderated by a local volunteer (them’s good people).

As the name suggests, Freecycle Group Finder is a new way to find Freecycle groups.

Finding a group - the old way

To find a group you enter a location to search for in the box on the Freecycle homepage. I live in Romiley, so I enter that and click search. But it can’t find any groups! Failed freecycle search

In order for it to find my local group I would have to guess it was called ‘Stockport‘ and search for that. I could have used the Freecycle group browser but who browses anymore? People demand search! I wanted to make this better so I wrote the Recycling Group Finder.

Finding a group - the finder.overcycle.com way

Just enter any location into the search box on the homepage and it will find all your local groups: Successful  freecyclegroupfinder.com search

The Freecycle search gets it right sometimes. Take a search for Alameda, CA. It lists all the groups nearby, but Freecycle Group Finder does better. Freecycle Group Finder shows you a map of where all the local groups are! It lets you scroll around and visually determine the closest group (Try it for yourself!). An improvement we feel, and one that will help more people join up and start recycling.

What keeps it rolling?

At 29degrees we’re big fans of Ruby on Rails. It helps us make web applications faster, and with more fun, and it was no exception for the Freecycle Group finder. We are using Postgres for the database and serving it all with mongrel and of course Apache. Of course if wouldn’t be anwhere near as good if it wasn’t for Tony, 29degrees co-founder and designer extroadinaire!

GolfScript

Thursday, December 20th, 2007

flagitious (sometimes to be found in #codegolf on irc.freende.net) has released GolfScript, in his words:

GolfScript is a stack oriented esoteric programming language aimed at solving problems (holes) in as few keystrokes as possible. It also aims to be simple and easy to write.

This is pretty impressive. According to Carl it can solve the codegolf grid-computing challenge in 21 bytes. The next best effort would ba a Perl solution in 43 bytes. It hasn’t been implemented as an allowed language yet though, maybe in codegolf V2.

Bourne Shell Server Pages

Friday, November 23rd, 2007

Utterly wrong, but amusing.

Bourne Shell Server Pages are ordinary ASCII text files, with the special extension .shit, which denotes “Shell-Interpreted Template.” The result of invoking the page compiler on a .shit file, is, naturally, a shell script. (It occurred to me that this file extension might seem objectionable to some, but since it quite accurately—if unintentionally—conveyed my sentiments toward Web technology in general, I decided that it should be left unchanged.)

How to ‘win’ at subversion

Friday, September 28th, 2007

Carl bagged the 1000th commit on a big project by cheating with this script:

while :; do svn up | ruby -e 'gets; if $_ =~ /999/; `svn commit -m 'Winnah.' ../trunk`; end'; sleep 30; done

The contents of the commit? A single file containing the word ‘Winnah’.

PHP is stupid

Wednesday, September 19th, 2007

cheetara:~ will$ php -r 'pg_escape_string();'

Warning: pg_escape_string() expects exactly 2 parameters, 0 given in Command line code on line 1
cheetara:~ will$ php -r 'pg_escape_string( "" );'
cheetara:~ will$

Why?! Thanks to Carl for spotting this particular inadequacy in PHP.

Lazy lazy methods

Monday, August 6th, 2007
Golfr saves you all the hassle of having to type out full method names

Lazy! But quite cool.

Rails sucks

Thursday, June 21st, 2007
Logger debug message consisted entirely of “cocksucker.” Took it out. Seemed minimally informative, and impolite.

Excellent.