A heavy bass line is my kind of silence

January 1st, 2010

Turns out I still have a working WordPress install!

Merry new year etc. It’s a bit odd looking back over a blog I haven’t posted to for over a year. I never really got the hang of blogging but I always liked the idea. In the last yearish I’ve discovered a use for the Twitter account I’d forgotten about: blogging without the giant empty textarea to fill.

I’m not going to put a to do list of things I intend to do this year, it’s not something I’ve found helpful (turns out it doesn’t make me any more likely to do stuff). Instead I’m going to go with a vague concept for the future as I like the upward trajectory kind of change rather than some temporary change which doesn’t stick. Oddly, despite me being an engineering techie type and liking black and white solutions, on a personal level I’m quite vague which I’ve never really figured out.

A while (maybe a year or two) ago I decided to make a conscious effort to close the gap between what I say I’ll do and what I’ll actually do. It’s really hard for me to do but I think it’s kinda partially working. I think I’m over-promising and under-delivering less. Still not as much as I’d like, it’s working more for work stuff rather than personal things but it’s a start.

I had a minor epiphany earlier which leads to my next self improvement concept: consume less, create more. I don’t mean this in the eco-stop-using-carrier-bags-pish, but in a more general way. I figure I spend (I’m loathed to say “waste”) a lot of time consuming blogs but no time blogging myself. I read about cool projects and come up with great ideas but never quite get around to doing any projects of my own.

So that’s the plan, I’ll see how it goes. Man, that turned out to be a serious post! Here’s something I heard tonight that is awesome:

I should now grow a beard

November 28th, 2008

Because I’ve finally found a use for sed!

sed (a stream editor), along with awk, is one of those Unix command line tools that only beardy types ever seem to know how to use well. Further, the beardies can pretty much teleport to the moon using only a combination of sed, awk, grep and magic (I know someone who wrote a webserver using only dd and shell scripting, although he is bonkers and Italian in addition to beardy).

So anyway, the practical use of sed? Say you have a hypothetical large SQL file which you’re theoretically trying to import into MySQL using the command line. Let’s say, there’s a slight chance that there might be an error in that file, possibly on line 17,633. Opening the file in a text editor and searching for that line is pretty tedious and even simple text editors get pretty slow when you ask them to open a 24Meg file…

Enter sed. Assuming there’s a bug on line 17,633, you’d probably want to display a few lines either side, and this will do it:
sed -n "17630,17640 p" file.sql



September 12th, 2008

So, I’ve been playing with symfony while developing a new site. This site has a contact form, so I added a reCAPTCHA to the feedback form. During testing my favourite ever CAPTCHA turned up:

Awesome reCAPTCHA

It knows me!

Making Ubuntu Hardy Heron work with a Radeon 9600

May 9th, 2008

This is one of those “blog it so I can find it again” posts (much like that entirely unfascinating post on disabling Magic Quotes which I still search for when I have that irritation. See, blogging is useful after all!). This might also be useful for someone else so I’ll list the steps I took.

This post is about making an ATI Mobility Radeon 9600 in my old Toshiba M30X laptop work with Ubuntu 8.04. I just freshly installed Hardy Heron on the Tosh and found that the graphics driver is many times more screwy than it ever used to be. It worked fine with Gutsy Gibbon (which loaded a reasonable driver and correctly autodetected the panel resolution) but with Hardy I was instantly boned.

When booting the Hardy live CD to the live desktop the picture became a scrambled mess as soon as it hit GDM, which makes it fairly safe to assume the graphics driver is wonky. It installed fine using the “Safe Graphics Mode” option (hit F4 from the boot prompt for more options) and xorg defaulted to the vesa driver (which worked but at the wrong resolution).

After much faffing I’ve discovered that the open source Radeon driver doesn’t seem to work particularly well at the moment (launchpad has a few bug reports about it). The solution: go closed source (hmm, yes, that sucks).

I installed the ATI binary driver using the following steps (adapted from here):

  • Make sure the ATI driver package is installed (it was already for me): At a terminal run sudo apt-get install xorg-driver-fglrx
  • If the package wasn’t already installed, run this to load the module: sudo depmod -a
  • Edit /etc/X11/xorg.conf and replace Driver “vesa” with Driver “fglrx”
  • Run sudo aticonfig --inital -f to set up xorg.conf
  • Restart xorg (log out then kill X with [Ctrl]-[Alt]-[Backspace] (brutal but effective))
  • Hope everything works out nicely

It seems to have worked here but we’ll see just how stable it is…

Chuckle of the day

April 6th, 2008

Ahh, blogging. I never really got the hang of it. Anyway, here’s my chuckle of the day taken from the Freecycle Edinburgh mailing list, here’s an excerpt from an offer advert for a Samsung CRT monitor:

I have a really good quality Samsung 19″ CRT monitor going spare – I just don’t have room for it in my new flat.

The monitor works perfectly and has excellent colour reproduction, so really good for anyone that does digital photghraphy or design work etc.

The only problem with it is that a couple of years ago, during a fit of angst when installing Windows on a new PC, I wrote ‘F### Bill Gates in the ass” on the front of the monitor. In permanent marker. Oops. I’ve tried to get it off, but it won’t budge (it’s faded a bit, but still clearly visible).


A complete tosser’s guide to pancakes

February 5th, 2008

It’s very simple:

  1. Print this recipe out
  2. Stick it to somewhere handy in your kitchen
  3. Follow it to the letter
  4. Enjoy fabulous pancakes and excuse to use that new Jamie Oliver frying pan you got in the sales

Thanks Delia!

Note: Be careful using non-milk type spreads instead of butter, oil based ones float on the top of the batter. It doesn’t taste bad but it does make the pancakes a bit slippy to hold.

Tomorrow night: How to enjoy pancakes the year round and on days other than Tuesday.

(Man, this is so seamless nobody will notice I haven’t blogged for about seven years!)

Tasty Links

August 14th, 2007

eggfriedrice, now with!

My three (count em!) links should be appearing over in the sidebar on the right. I tried using a caching plugin for WordPress but that needs CURL support compiled into Apache, which means recompiling Apacahe. Which I can’t be arsed to do right this minute so the caching will have to wait a bit and you’ll have to put up with the javascript.

Never let it be said I’m not right on the ball with new internet fads!

“Power is wasted and danger is made”

August 12th, 2007

According to Sarah this is what happens when you leave the iron switched on. She’s right, and it points out a common failing with many appliances: they stay on when you don’t need them to be on.

In the case of an iron there’s a very simple fix for this, insert a little widget that detects movement (you picking up the iron) and if there isn’t any movement for five minutes switch the iron off. It would be simple to implement, an accelerometer, a microcontroller and a relay. Couldn’t really be simpler, could it? So why don’t irons have a “not in use” timeout? Probably because it makes the device slightly more complicated (not by much though), it adds another point of failure (though modern irons last about six months anyway) and, most importantly, it would add about 25 pence to the retail price.

I guess the only way to get this sort of iron safety device built into new irons would be for the Government to mandate it. Maybe I should start an e-petition for this… I might get three signees, that’s sure to get an act through Parliament!

PHP Number Validation

August 10th, 2007

I have nothing of any use or consequence to blog about today, I did some work, we went to Sainsbury’s, that’s about it really. Instead I’ll post a little PHP trick I’ve discovered.

It’s a very simple one-liner to test if a number is actually a number, it validates this without needing a special class, it just uses built in PHP functions. This is kind of validation is very important if you’re about to poke that number into a database query to, for example, pull out a page based on it’s ID.

This is it:
if($id != strval(intval($id))){
echo("Invalid ID");

Variables in PHP are loosely typed so they can hold anything without the programmer specifying what they should be allowed to hold. This means that $id could hold an integer number or a floating point number or a string or an object or any number of other things. What we do here is use intval() and strval() to firstly get the integer value of $id and then turn it back into a string then compare it to itself. The net effect is that if $id holds a 2 intval() will return 2, strval() will then return the string “2” and that’s the original value (the value in $id was actually a string to start with).

If you put in, say “cheese” then intval() would return a 0. It won’t work without strval() as it is needed to handle the weird values intval() returns (that I don’t fully understand).

All the code does is check that the number is an integer and if not print a message and exit. It won’t catch non-existent database records for example but as a simple, first pass, test it’s quite handy.

Ecogeek: Al’s Very Small Solar Experiment

August 8th, 2007

I’ve always been fascinated by solar power. It’s leccy from the sun! That’s cool! I’ve also always been fascinated by LEDs. Stuff that lights up is ALWAYS cool to at least some minor degree. With this in mind you can see why a £2.99 solar powered garden light in Poundstretcher was purchased fairly quickly.

Here’s my plan: glorious sunshine in, cool LED light out. I could hack it to suck light from outside and put it indoors. The problem is that this gizmo is just too small, I need to scale up a bit (but not to ‘big’, more from ‘pico’ to ‘nano’).

With a bit of prodding from Sarah, and after some eBay searching I settled on a 12 Volt, 5 Watt solar panel which wasn’t too expensive. It looks a bit (well, a lot) like this:
Solar Panel

That’s it sat on one of the front window sills. The solar panel will get hooked up to a big arse battery (arriving soon) to charge up during the day and power (initially) some lights at night.

There are are a couple of minor issues here:

  • I live in Edinburgh, and Scotland isn’t famed for it’s glorious sunshine. But it has been very sunny for at least two days this year and until rain power is cracked it’s probably the most reliable environmentally friendly power source around.
  • I’m on the second floor so this is going to have to sit on a window sill and only get sunlight for half of the day.

Neither of these issues are going to stop me, I’ve done stupider things that have worked!

And, just to prove you can get something out of a solar panel in Edinburgh…
Let there be light!
That’s an RGB LED lit by solar power, bask in it’s brightness! There were resistors involved, I’m actually quite hopeful about getting some useful juice out of the panel, I measured 23 V open circuit and the short circuit current was 130 mA.

We’ll see what happens when the battery arrives. I’ve got a book out of the library that might help a touch: Solar Electricity: A Practical Guide to Designing and Installing Small Photovoltaic Systems. It’s actually got some handy stuff in it, it’s a book aimed at the practicalities of installing a low cost system using simple parts and tools. This appeals to me.

I’ll let you know how it goes when more bits arrive!