eggfriedrice.com

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

Sorted!

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…

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…

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!

TuxScreen

July 13th, 2007

I got a new phone today. It’s got a touchscreen, an ARM processor and runs a full Unix like operating system. No, it doesn’t have an Apple logo on it… I got it for free, and there’s no contract. iPhone shmiphone! What you want is a TuxScreen!

It’s maybe not quite as portable as an iPhone though…
Tuxscreen
(Mine looks like that underneath the dust.)

Way cool eh? Well yes, except that it’s American. And American’s have wimpy 110volt leccy and so I can’t plug it in to proper mains. So at the moment I’ll have to just sit and look at it. And when I do get it powered up it won’t do anything useful because our phone network is incompatible too… So I’ll have to flash it with a more useful Linux install and then find something to do with it. But still, Linux, touchscreen, cool! Thank you to Hamish on Freecycle if you’re reading!

Fruit illumination

April 28th, 2007

Making strawberries light up is surprisingly difficult. (All will become clear soon)

Aside from lighting up fruit I’ve been colleging, pottering around a bit and doing some work. It’s all feeling very close to the end of Maths now, in some ways I’ll miss it but generally I can’t wait to be shot of it. Exam is two weeks on Tuesday. TWO WEEKS in order to cram all this crap about vectors and the wave function in. Joy! y-b=m(x-a), b2 – 4ac, kcos(x-α) etc.

Last night I went to Edlug’s extraordinary meeting (extraordinary in the “additional to the usual monthly meeting” sense, not where we all just agreed to “bugger it and use Vista instead” sense) to see Howard Chu’s presentation on OpenLDAP. It was interesting to see something like that, it’s the first time I’ve met and chatted with an open source big gun. Nice chap, good fiddler. I did sit through most of the presentation wondering what OpenLDAP (it stands for Open Lychee Digestion and Polishing(*)) really did but it was very interesting to see how aggressive they are in development, especially removing large bits of old code from the source that people are still using (and if you don’t use the new features Howard will come around to your house and punch you in the face(**)).

And then there was the traditional consumption of large volumes of beer, which is always nice.

Other things that have happened recently in no particular order:

  • I went to Bits and Bobs Scrapstore with Sarah to buy more perspex and stuff. Got some nice shop fitting (we think) letters. My name is cheaper to spell than Sarah’s.
  • I’ve upgraded Wordpress to the latest, less likely to get hacked, version. But I don’t like the new Write Post page.
  • Finally read enough of the Make Magazine blog to get under 100 unread posts, go me!
  • Went to see the Cabaret Mechanical Theatre exhibition at Kinetica, which is royally awesome.
  • I very, very nearly fell alseep in a Computing lecture about internet protocols.
  • I discovered I have lost ever single pair of pliers that I own

Other stuff has happened but it’s not been overly interesting(***) so I’ll leave you there.

* I make mit der joking
** Still der joking
*** Nicht fur der joking

Widget of the Week: athcool

February 6th, 2007

Your computer isn’t a high tech super clever thinking machine, it’s a box for turning electricity into heat and occasionally adding some numbers together.  What you have on the floor under your desk, or on your lap, is an expensive bar heater with a calculator glued on the side.

Basically modern computer processors are very inefficent, much like incandescent light bulbs. A bog standard 100 Watt incandescent light bulb turns 95 of the watts you put in into heat, only 5% of the electricity it uses gets turned into what you’re after, light.  Modern computer processors are pretty much the same, they produce massive amounts of heat and only work because of the big lump of metal that is the heatsink attached to the top of the processor.  Your computer is a piece of crap, and so is mine!

The annoying thing is that heatsinks get hot, it’s their job, they are sinking heat after all.  So to get around this fans are attached to the heatsinks to help dissipate the heat.  So far so good, it works.  Processor gets hot, fan blows air.  The problem is that the heat pumped out costs money (as electricity going in) and fans are noisy.  The best thing to do is cut the amount of heat generated by the processor in the first place, then the fan can slow down and still properly cool the processor.

Less heat = less wasted money and less noise, excellent!

But how to put out less heat?  Most modern processors have some throttling system built in, my Intel based laptop, for example, is currently running at 600Mhz instead of the 1.4Ghz it’s rated for because I’m typing slowly (relative to a processor… and, well, my Mum who touch types) and there’s not much going on in the background.  (This is turning out quite rambly, bear with me!)

This whole thing of heatsinks and fans being noisy hasn’t really bothered me until this week while I’ve been building the MythTV box which I’d like to make less noise than Harrier jump jet.  The first attempt at construction booted but hung after a few minutes of trying to install Ubuntu.  I thought this was weird as the Ubuntu installer never bothered me before and seemed quite stable.  Oddly it wasn’t happy running Knoppix either.  I found out that the processor was overheating because the heatsink I was using was too cheap and nasty for my second hand Athlon XP 2100.  I upgraded to a nice heavy Akasa one and it’s been working fine ever since.

End of the story?  No, amazingly I haven’t even got to the point yet!

Now this box runs and is nice and stable I thought I’d see what temperature the processor is idling at, I grabbed GKrellM which while being quite ugly does give me a readout of the temperature with zero configuration.  The processor was idling around 54° C.  This, I thought, was a bit on the high side, so I wondered if there were any throttling things I could enable or tweak to cool it down a bit.  Long story short, I didn’t find anything tweakable, I think the kernel generally does a pretty good job of enabling the right stuff to cool processors by default.  As I’m using an Athlon for this I was interested when I came across this though…  (drumroll as I finally get to the point)

athcool!

This seems to be written by some Japanese guy and really looks very fishy.  The page mentions STPGNT and ACPI C2 state and other stuff I only vaguely understand.  It also has some nice red bits in the supported chipsets section where people have reported that their computer hangs or the hard disk writes garbage or the monitor starts flickering and other really nice sounding side effects.

I figured as I’d only just installed Ubuntu on this box I wouldn’t mind if I corrupted the filesystem at this point, I can always reinstall.  I had a look in Synaptic and athcool was already in the Ubuntu repository (admittedly in Universe where any stuff can end up), so, bugger it, I downloaded it.  Once I got past the nice warning “!!!WARNING!!! … may cause… massive filesystem corruption”.  Not just corruption, no, MASSIVE corruption.  This must be good.  And surprisingly, it is!  The processor now idles at about 45° C, a nine degree drop.

I haven’t noticed anything weird with the box, it still seems to be stable but it is running cooler and
the fan has been slowed down by the motherboard as it’s happy with the temperature.  All in all, I’m quite amazed this actually works!  Whether you’ll want to try it or not is something else altogether.  It’s quite happy with my (antiquated) Athlon XP2100+ on an MSI KM3M-V with a VIA KM400(A) chipset.  YMMV!

A warning though, don’t stick your thumb in your Akasa heatsink’s fan by accident (or deliberately), it turns out the blades are sharp considering they’re made of plastic.  I guess “blades” should give it away really.  I nearly lost a chunk of my thumb!  That’s number 4156 on the “Stupid Things I have Done” list.

Possession is ten tenths of the law

January 14th, 2007

(Thank Sarah for the title, apparently Linguists are allowed to remake well known phrases)

Yesterday I started assembling my mythical MythTV box.

MythTV? That’s a cool bit of software which takes a Linux install and does the job of a Tivo/Sky+ but better. It can do all the usual stuff like timer recording programmes (or whole series) to hard disk, playing DVDs and other nice things, like running the MAME emulator to play old console games.

Mythical? Because I’ve been talking about building it for about three years and haven’t got around to it. Yesterday I thought “screw it, just put bits together” (or words to that effect). So I now have a motherboard with processor and RAM which locks solid about a minute after booting. I’m working on the theory that I need more thermal compound under the heatsink.

But at least it’s a start. And the remaining bits that I need (tuner card, graphics card with a TV-out, wifi card) have been bought from eBay so hopefully I’ll have all the hardware together soon.

I like that it’s getting easier to choose hardware for Linux now, but it’s still not easy.  I’ve bought cheap stuff because I’m not sure if it’ll all work or if I’ll have some doorstops.  It’s really nice to Google a chipset and find “this has been supported since kernel 2.6.8″ but there’s also a lot of vagueness.  It’s this very vagueness that’s been putting me off completing the set and buying the things I need to make this work.  Trying to figure out if a DVB tuner card will work is tricky to say the least.  I’m resolving to blog the stuff I have and the process I go through so maybe it’ll help someone else.  If it all works…

At this point I’d like to thank the kind donor of a temporary case to build this in.  I say donor, I mean Greek person who left it by the bins on West Newington Place.  I say Greek because there was also a keyboard which seems to be in Greek.  Anyway, thanks!

I’ll let you know how it goes.  In other news, I still don’t like Higher Maths.  Compound Angle Formulae??  You’re kidding, right?

Widget of the Week: SoundConverter

January 10th, 2007

Welcome to the first in an occasional series of my reviews of a program, tool, widget, fish or whatever I think is cool.

First up SoundConverter. This little Gnome app converts audio files from one format to another. I’ve been using it to transcode my ripped Flac files to MP3s for my new Archos ipodtypething (it can’t handle Ogg). It’s neat and easy to use and it’s available in the package repositories for Ubuntu and Debian. It seems to be able to handle pretty much any common audio format, it uses Gnome’s Gstreamer so it can take Flac, WAV, Ogg, MP3, AAC etc as input and can write out WAV, FLAC, MP3, and Ogg files.

Some caveats I discovered trying to get it to work:

  • You need to install an additional (non-default) package under Ubuntu and Debian for Lame encoding (to produce MP3s). Under Ubuntu you need the excellently named “gstreamer0.10-plugins-ugly” package and under Debian the “gstreamer0.10-lame” package sorts it (there are probably similar packages for other distros)
  • SoundConverter silently fails when the output path contains a space. I’m trying to file a bug report about that but the Berlios site seems to be down at the moment

Other than the path bug SoundConverter seems to work perfectly, it converted 1242 Flacs (29.5GB) to 256 variable bit rate MP3s (6.9GB) in about seven and a half hours.

Not something I’ll use every day but very good at it’s job when it is needed.