eggfriedrice.com

Tasty Links

August 14th, 2007

eggfriedrice, now with del.icio.us!

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");
die();
}

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!

Putting the Hop into Hopen Source

August 7th, 2007

If you’ll excuse the quite appalling title to this post (though you really shouldn’t, it’s an offence to any person’s sensibilities), beer makes the code go round. Open source software is driven by it, to the point where free software conferences are timed to line up with beer festivals.

This intro is really just a poor excuse to set the scene for the rest of this post, a review of Black Isle Brewery’s Red Kite Ale. It’s not so much a review as telling you that I’ve just drunk a bottle of this and it’s nice. You might have got a more in depth review if I’d done the wine tasting gargle and spit type sampling but that would have been wasteful.

Instead I’ll tell you that Red Kite is a very pleasant real ale made with organic hops, giving the catchy strap line “Save The Planet – Drink Organic”. Save the planet, drink beer! Who knew it would be that easy! Plus I’ve just written some PHP code that works, thus vindicating my appalling introduction to this post.

I bought my Red Kite from Real Foods but I bought my first Black Isle beers from their stall at the Edinburgh Farmer’s Market (which we haven’t been to for ages) up at Castle Terrace.

I think that counts as a review. Night!

Browsing like it’s 1999

August 6th, 2007

Finally! I’ve got Internet Explorer to run nicely under Puppy Linux under QEMU!

I call it Al’s Antique Browsing Appliance (virtual machine appliances are all the rage you know). And here’s my abbreviated howto in case anyone should want to replicate what I’ve done (though I’m sure there are easier ways, like not running 64 bit Debian in the first place).

  1. Install QEMU on the host box. The QEMU packages in the Debian repositories work fine.
  2. Download QEMU Launcher (not essential but it does make QEMU nice and easy to use).
  3. Download a Puppy Linux ISO image (I used 2.17).
  4. Using QEMU Launcher (or the relevant command line voodoo if you’re really bored) create a new configuration, put the Puppy ISO in the CD-ROM box, add a new image as Hard Disk 0 (I made my a gig and that’s plenty of room)
  5. Select CD-ROM as the boot device. Boot the new virtual machine and follow the locale choosing stuff
  6. Say hello to Puppy (and let your girlfriend give it a name, like ‘Pinkerton’)
  7. (I needed this step to make the install work properly, you might not) Use fdisk from a shell to create a partition table and one big partition of type 83 on /dev/hda. I didn’t do this at first and the Puppy installer did a “superfloppy” install which then didn’t have a bootloader
  8. Run the Puppy universal installer (from Menu -> Setup).
  9. Follow the installer prompts (I think I just used the default all the way through)
  10. Marvel when nothing gets confused as a virtual CD is installed to a virtual hard disk in a virtual computer
  11. When it’s done, shutdown the virtual computer, change the boot device to the first disk and boot again
  12. Now we’ve got an OS it’s time to install the stuff needed for IE, start with the Puppy Wine packages (download the files and click on them from the file manager)
  13. Next, download Cabextract (used to, well, extract CAB files). I used the Slackware package and it worked fine.
  14. Lastly, download IEs4Linux and extract and run (as per the instructions). This cool thing downloads various versions of IE straight from Microsoft and installs them.
  15. Run IE! Running /root/bin/ie6 from a terminal should give you IE6 in all it’s wonderful crappiness.

And there you go, you have a virtual machine that can run IE5, 5.5 and 6 (and 7 with a beta of IEs4Linux) at the same time! Now go and test your websites!

Here’s the proof:
puppyie.png
IE on Puppy Linux on Debian Etch

In other news, I got my Highers results today, I got an A for Computing and a B for Maths. I’m quite chuffed with Maths, it’s not my strong point and the last year has been a bit of a struggle but it worked out in the end. I’ve got what I needed to get into university and it’s nice to have actually completed this and done it fairly well. It’s a nice sense of accomplishment to have worked for something and got it. Oddly the B means more than the A just because it took much more work to get (honestly, if you’re bored next year sign yourself up for Higher Computing and turn up for the exam. If you managed to use a web browser to get to this blog then you should get a C, minimum!).

So now I’ve got four years of uni. Four years! Well, at least I don’t have to sit on a bus for 45 minutes to get there…

Feel the groove

August 5th, 2007

Today we went to see the Edinburgh Cavalcade which pretty much is the start of the festival(s). It’s not every day you see the Lady Boys of Bangkok rubbing shoulders with the Scouts, and the Tay Valley Twirlers following Dr Who (and the Tardis, a Dalek and K9)! We also collected a metric butt load of leaflets and whistles and crap which I think will get a photo for prosperity.

The fine Scottish drizzle was out in force, as you’d expect, so much of the fun was spotting the split in the paraders between those feeling the groove and the ones that were just wet and pissed off. I particularly liked the guy holding the sign for The Edinburgh Samba School and friends who clearly was an ex-raver and was just itching for a glow stick.

In other news I’m still faffing about with emulated Linux. I’m getting somewhere with Puppy Linux now but I ran out of (virtual) disk space because I made the disk image too small. So I’m now growing that with Gparted. In case you hadn’t figured, I’m still not taking the easy way out!

You take the high road, I’ll take the one with potholes and speedbumps

August 4th, 2007

The new site that Sarah and I are working on is going to be developed primarily with Firefox because that’s what we use. We also decided that we should actually test it in that nasty Redmond browser. As most of the browsing population uses IE6 (if this is you then watch your back, or at least watch your PC, if you ever see me in person) we need to find a way to run both IE6 and IE7 to test in both. Of course, being a Microsoft product, two versions of the same browser aren’t designed to be run at the same time.

Faced with this problem we attacked it from two different mindsets:

  • Sarah: Find a tool for Windows that allows you to run IE 6 and 7 at the same time, download it and run it in under ten minutes.
  • Al: Spend most of the night trying to install IEs4Linux (a cool looking bit of software) into DamnSmallLinux (also cool) in Qemu (mit das cool) but get stuck in dependency hell.

Whoever is the smart one here, it’s not me. I’m now abandoning DSL as it seems to die when I try to install the GCC package (yes, it’s getting so bad I’m compiling dependencies) and I’m going to try Puppy Linux.

All this desperation is because I’m using 64 bit Debian and there still aren’t 64 bit packages for Wine which is a PITA. So I’m emulating 32 bit Linux instead. Which is probably a sign from a higher being that I should just pull my finger out and downgrade to 32 bit and be done with it. But where would the fun be in that?! There’s compiling to be done!

More icons, less insight

August 3rd, 2007

OK, so I’m not doing very well at the blogging challenge. I’ve missed two days now and I’m pretty sure someone’s keeping note…

I need to blog earlier in the day when I’m still awake. Mind you, last night was EdLUG and I never really woke up today.

I’ve done a bit more work on the big giant database and it’s starting to come together a bit. It’s funny how even though the todo list keeps growing I feel like it might actually get there soonish. In related news, HSBC are being tossers over getting an internet merchant account for the online booking side of this site, even though the organisation has had a MOTO merchant account with HSBC for >15 years (pretty much the feeling I get as a long term personal HSBC customer where it seems like they’d be quite happy if I died as then they wouldn’t have the chore of posting my bank statements).

Also, my probable choice of payment processor for the new site, Protx, made a spectacular cock up of an upgrade to their system a couple of days ago. I might be looking around for alternatives…

I’ve finally got an excuse to use a couple of icons from FAMFAMFAM’s Silk icon set. Nice little icons and under a Creative Commons licence.

And that’s today’s exciting news, the time now is a bit past 11 and it’s time for news where you are.

Ecogeek: Tetrapaks

August 1st, 2007

Tetrapaks. They’re excellent at keeping the orange juice on the shelf in the fridge (and not in a puddle at the bottom of the fruit drawer). All well and good. But, after I have full enjoyed my orange juice, can I recycle them? After half an hour’s serious internet browsing the answer is… maybe, possibly and I don’t know.

See, on Sarah’s carton of milk that I was flattening to recycle/bin there was this URL: tetrapakrecycling.co.uk which leads to some excellent hyperbolic propaganda that told me just how wonderful Tetrapaks are and that if my drink isn’t provided in a Tetrapak then I should be suspicious and prepared for death should the drink not have been shielded from the deadly sunlight. It’s quite dark in my fridge when the door’s closed but I’ll put that aside for now.

The website did tell me that Tetrapaks are formed of a seven layer laminate (this makes them nigh on impossible to recycle into anything meaningful). The recycling process apparently goes like this:

1) Baled cartons are dropped into a pulper, similar to a giant domestic food mixer,
2) filled with water, and
3) pulped for around 20 minutes.
4) This breaks down the packaging to produce a grey-brown mixture.
5) The aluminium foil and polyethylene are separated from the fibre,
which is recovered to make new paper products.
6) The remaining mix of plastic and aluminium can then be used in furniture, to generate energy or even separated out into pure aluminium and paraffin.

So basically you dump them in water and beat the crap out of them and at the end you get two types of sludge, papery sludge and plasticy sludge. You can then make paper out of the paper sludge and pretty much bugger all with the plastic sludge. Oh, but you can always set fire to it! Sorted!

OK, so can I recycle it? Well that depends on your local authority having the right (wet and beat crap out of) facilities. And does my local authority? Maybe. Hop on to www.edinburgh.gov.uk and have a look. I found this PDF which helpfully tells me the stuff I can put in the tenement recycling bins. The closest thing to a Tetrapak in the list is “Cardboard Drinks Cartons”, but there is a photo of Tetrapaks (to the right, the central photo is of beer cans, welcome to Scotland!). But I’m not supposed to put in the lids which the Tetrapak Recycling site said I could.

So my final answer to “can I recycle a Tetrapak” is a tentative “mostly”.

If you’re not lucky enough to have a council that will recycle Tetrapaks (and according to the Tetrapak Recycling site the entire UK is “coming soon”) then they have a cunning plan. And it really is cunning. Take all your Tetrapaks, put them in a big cardboard box, print out and affix this label, take the box to your local post office and pay a small fortune to have the box shipped to Somerset! Baldrick would have been proud.