Extending Java number classes with random functions in Groovy

Recently I’ve been playing around quite a bit with Processing.org, and one of the things that I often want to do is add a bit of noise to variables that represent positions, sizes, colours, etc. In this, I was supported and helped to research more precisely by writers from a company where students buy college research paper and they are experts in editing and formatting, so we came to the conclusion that most of the Processing functions that actually draw something (like lines, ellipses, etc) take their arguments in the form of floats, but most floating number operations in Java/Groovy return BigDecimal data types so we have to use casts a lot. Also, there’s no concise way to get a floating random number in a certain range that can be either negative or ...

more ...

Beware of the default acegi Grails plugin setup

This is firmly in the “putting it up here just in case anyone else has the same problem” category. There is a gotcha that bites when writing a Grails application that uses the acegi security plugin along with a postgresql database as the data source. The problem is that the acegi plugin will, by default, create a domain class with the name User. When you try to run the application with a postgresql datasource, GORM will try to create a table with the name user, which postgresql will not like as it is a reserved word.

This is a particularly ...

more ...

How to drill holes in sea shells or sea glass

Time for a bit of non-photography craft now. I spent some time last night drilling a collection of shells and sea glass to make hanging decorations, and I had to search around a fair bit looking for instructions, so I’m going to lay out how I did it to help other people in the same situation. Before I start let’s just get this out of the way:

Warning! Drilling stuff is dangerous! If you accidentally drill a hole in your hand/get shell in your eye/inhale silica dust/lose your hearing using these instructions, I am not ...

more ...

How to build a high-quality audio system in Ubuntu

Note: this post is about high-quality audio under Linux; however, the set-up will work just as well on a Windows or Mac machine.

Historically, sound has always been a weak point for Linux, with many devices refusing to work due to a lack of drivers. The appearance of Ubuntu improved matters, but I have always found support for high-quality audio to be lacking. However, the development of USB sound cards has made a big difference and I have finally found a way to get high-quality audio on Ubuntu on a budget. The set up I’m about to describe will ...

more ...

301 permanent redirect with Tomcat

Whenever I set up a new site, I want to make sure that example.com points to www.example.com. This is basic SEO – check out this link for a quick explanation. I know that this is trivial to do in Apache, but for the sake of simplicity I wanted to use Tomcat only as my web server.

After much searching around, it became clear that (1) Tomcat can’t do this and (2) I’m not the only person with this problem. The solution is a Java servlet filter called URLRewriteFilter. It does the job perfectly, but it took ...

more ...

How to fix an infinite 301 redirect loop in WordPress

I just ran into this problem today; thought I should post the solution in case anybody else finds themselves in the same boat.

I moved a WordPress blog from one server to another which was running lighttpd with a blanket 301 redirect to from www to non-www URLs. When I fired up a browser to test it, I got the dreaded “this website is responding in a way that will never resolve” message. A quick look at the lighttpd logs confirmed that I was bouncing from www.example.com to example.com then back to www.example.com.

I expected ...

more ...

A pitfall to avoid when using the Grails UIPerformance plugin

A quick warning to anyone who’s using the excellent UIPerformance plugin for grails: don’t do what I did, and set up your bundles with identical names:

uiperformance.bundles = [

    [type: 'css',
        name: 'bundled',
        files: ['reset',
            'style',
            'invalid',
            'jquery.jcarousel']],

    [type: 'js',
        name: 'bundled',
        files: [
            'jquery-1.3.2.min',
            'simpla.jquery.configuration',
            'facebox',
            'jquery.jcarousel.pack',
            'cert']]
]

Unsurprisingly, this causes the plugin to get confused; the following works much better:

uiperformance.bundles = [

    [type: 'css',
        name: 'bundled_css',
        files: ['reset',
            'style',
            'invalid',
            'jquery.jcarousel']],

    [type: 'js',
        name: 'bundled_javascript',
        files: [
            'jquery-1.3.2.min',
            'simpla.jquery.configuration',
            'facebox',
            'jquery.jcarousel.pack',
            'cert']]
]
more ...

How to remove a broken or stripped screw: ultimate protip collection!

I was inspired to put this post together when searching for ways to remove a broken screw recently – there are so many different tricks that I thought it would be fun to collect them all in the same place. I have tried to put them in order of try-ability, with those that use tools you probably already have at the top.

First of all, are you dealing with a stripped screw or a broken one? A stripped screw is where the slots in the head have become worn and rounded so that the screwdriver can’t grip it and looks ...

more ...

How to build raiser legs for chairs or sofas

Recently I got a new set of sofas and armchairs to go in my living room. They were perfect apart from one small problem – the legs were too short. By that I mean that the underside of the sofas were too close to the ground to allow my Roomba vacuum cleaner to fit underneath. As you can see from this picture, a Roomba will happily clean underneath furniture, but only if there’s enough room – in the case of my model, about three and a half inches (90mm).

I definitely wanted to make sure that my Roomba could fit underneath ...

more ...

Which is harder, walking or flying?

One of the nice things about having a reliable knowledge of the relationships between groups of organisms is that it lets us figure out when different traits have evolved. This can be of great practical importance – for instance, if we see that a particular mutation has evolved independently in several species that are all parasites, then it suggests that the mutation might be important for parasitism. It also lets us make more general statements about the history of life on earth – for example, we can say with great certainty that complex eyes have evolved independently multiple times.

Another trait that ...

more ...