Lee Packham’s Corner
The rants of a software busy body
  • Home
  • Gallery
  • About
  • dtrace Stuff

The blog - It’s moved! Again!

Random Rants No Comments »

I decided to come back to a Wordpress based blog - hosted at Joyent. The reasons were pretty simple. I wasn’t overly happy with the way that Typepad’s pricing model worked. It’s ok for people wanting a pretty basic blog, but if you actually used it and want to customise it, I think Wordpress is better.

I could have done the whole free hosting on Wordpress.com thing - but I prefer hosting myself.

Hope the few readers I do have like the theme!


October 19th, 2008 |

Tags: Random Rants




Mus domesticus (Rodent Mice)

Random Rants 1 Comment »

We get mice up in our flat a reasonable amount. A block of 50 or so flats tends to mean there'll always be some. Plus, this is London - so you're never too far from them I guess. Being on the 5th floor helps a bit, as they have quite a way to come to get here.

So we put down traps and poison. Recently however, we've noticed an increase in the number that brave beyond underneath the kitchen. Annoying? Yes. Obvious as to why? No. 

They're eating the poison. We have a number of open bait trays with a nice 'bleed them to death' type affair. The trays under the kitchen were empty! I mean, completely. Couple of droppings and that's it! We've caught a couple in traps too. 

So now I have relocated the bait under the kitchen. I guess we'll also have to get more poison! Blocking their entrance and exit is hard. Basically they're coming in from around the waste pipes and there isn't really any way to properly block it (without removing the entire kitchen). More elaborate methods of blocking required.

I'm also a little concerned that the poison isn't actually killing them! 

However, those few that do read the blog… any clever tricks on dealing with these pesky buggers? Do these "Ultra Sonic Repellents" work?

October 8th, 2008 |



Big table and changing indexes

MySQL No Comments »

MySQL sucks at large tables. Sorry if you’ve come here thinking that I, in any way, like MySQL. That said, I have to look after some sizeable databases which are on MySQL for various reasons - so needs must.

I recently needed to sort out an issue with indexes on a table. I needed to drop one, and add a couple more. Snag? The table has 3.6 million rows and as such I would call it a large table.

Normally, I guess, you would do something like:

ALTER TABLE foo ADD INDEX (my_column);
ALTER TABLE foo DROP INDEX old_index;

This doesn’t work when you have a lot of rows. Well, it does… if you have a few hours to spare. Let’s look at why.

When you add an index to a pre-existing table, MySQL has to go look through the entire table to populate the new index. When you drop an index on a pre-existing table, it loops through every row depopulating the index before finally dropping it.

So, here’s what I did to speed things up:

  1. SELECT * FROM foo INTO OUTFILE 'foo_outfile.dmp';
  2. CREATE TABLE foo_a LIKE foo;
  3. ALTER TABLE foo_a ADD INDEX (my_column);
  4. ALTER TABLE foo_a DROP INDEX old_index;
  5. LOAD DATA INFILE 'foo_outfile.dmp' INTO TABLE foo_a;
  6. TRUNCATE TABLE foo; DROP TABLE foo;
  7. ALTER TABLE foo_a RENAME foo;

Why TRUNCATE before DROP? That’s easy, DROP tries to delete each row. To delete each row the index has to be updated… 3.6M times! TRUNCATE trashes everything, then you’re dropping an empty table!


September 29th, 2008 |



The importance of tabs

Programming No Comments »

This sort of thing drives me barmy - why can’t people set a standard on tabs?

The above snippet is taken from eJabberd (a Jabber Server written in Erlang). Notice how some lines are soft tabs, others are hard. The causes havoc when dealing with merging in source control (I don’t care if you use a new fangled Git approach). Whitespace (both tabs and line endings) must be consistent on programming projects. Much pain ensues if they are not!

Personally I set rules in SVN commit hooks. This means that if a developer has anything ‘bad’ like Windows Line Endings on a Python project, then it is dealt with accordingly.

Saves a lot of merge pain!


September 27th, 2008 |



pkgsrc and OpenSolaris 2008.05 - made easy

Open Solaris 1 Comment »

This is something that’s been bugging me for ages. I could not easily make pkgsrc bootstrap and compile packages under OpenSolaris. Today I cracked it:

  1. Grab the latest stable tarball and gtar xzf it somewhere sensible (under /usr is good).
  2. pfexec pkg install SUNWgcc sunstudioexpress SUNWgmake
  3. pfexec pkg install SUNWxwinc
  4. pfexec pkg install SUNWcvs SUNWgnome-common-devel
  5. su
  6. cd /usr/pkgsrc/bootstrap
  7. export PATH=/usr/ccs/bin:$PATH
  8. ./bootstrap
  9. <patience>
  10. Edit your .bash_profile to make sure /usr/pkg is in your path

And you’re done! Working a charm for me here.


September 12th, 2008 |



OpenSolaris 2008.05 finally works properly on HP Proliant ML115 G5

Solaris No Comments »

Finally, OpenSolaris 2008.05 snv_97 is out! This includes the network driver for the network card on the HP Proliant ML115 G5 (the Broadcom BCM 5722). By surprise, it also includes the GFX driver for the onboard graphics card (some MGA 200 thing). This makes installation a lot easier than trying to do it via Text.

This is great news. I can finally drop running Solaris under ESXi 3.5u2 and get onto using the OpenxVM (which is really XEN, but packaged by Sun). Why is that good news? I prefer native ZFS. Speed being the main thing.

You can get the DVD directly from Genunix in both primary languages and all languages formats.


September 12th, 2008 |



Not so Genius iTunes

Mac / OSX No Comments »

The new iTunes 8 came out yesterday! Excellent. Loving the new features - especially the Genius playlist thingie. Apart from… It’s not ACTUALLY that good. Sorry. If you’re listening to a popular artist (Say Coldplay, Michael Jackson or similar), it’s great. If you’re listening to one of the reams of Christian music albums, forget it.

Genius just pops up a message saying “Tough” (see the image for the proper text) when I click the little Genius button while Tim Hughes is playing. Tim Hughes is one of the most popular worship leaders in the UK (and a top guy to boot). I was hoping it would find other inspirational songs when I hit the button. Alas, just the error.

The iTunes store had no trouble finding other Christian tracks for me to buy in the Genius sidebar! Figures. Pandora (although that’s no longer available) and last.fm don’t ever have this trouble. So why does iTunes. I put to you that Genius is truly not Genius.

EDIT: It can’t even handle the Mark Ronson - Version album. That’s far less obscure than some big religion thing!


September 10th, 2008 |



Debugging SMTP

Python 2 Comments »

I saw this today on djangosnippets and figured it’s useful enough for me to post! Sometimes when writing a webapp you need to debug the output of your e-mail sending. This can be quite hard as things have to, usually, go via an SMTP server. What you really want is a quick way to grab the output with all the headers that YOUR code is setting - you can, easily, with Python.

OSX/Unix/Linux

sudo /usr/lib/python2.5/smtpd.py \
    -n -c DebuggingServer localhost:25

(obviously on Solaris/OpenSolaris you want to use pfexec instead of sudo!)

Windows

c:\python25\python.exe c:\python25\lib\smtpd.py \
    -n -c DebuggingServer localhost:25

You then get an output in the terminal window you ran it in every time a message hits the server. Handy.


September 9th, 2008 |



Be* Mixes Toolbar

Web/Tech No Comments »

When we made Mixes at work, we made sure that we built it in a RESTful way. This has a few cool advantages. Not least because one of the guys I work with, Lloyd Pick, made a quick toolbar up for Firefox to view the status of current matches.

It’s a very simple affair. The grey men change to green men as the server fills up and you can click to go to the page and get yourself on that server.

I’m loving it during the beta. It means I don’t have to sit on the page waiting for a game to get going, I can see instantly as I browse round the web that something’s going on.

Good job Limi, let’s hope Mozilla Addons get it out of the Experimental bin.

Mixes Toolbar @ addons.mozilla.org


September 1st, 2008 |



Postgres Replication with Slony on Solaris

PostgreSQL No Comments »

Slony doesn’t compile out of the box on a Solaris 10/OpenSolaris 2008.5 box. Quite frustrating! Even with everything installed, it can’t find libpgport.a. I tried hunting through Google, but had no joy - but I did fix it!

Assuming you’re using Postgres 8.2.9 (that’s the latest shipping version in Solaris 10/OpenSolaris):

  1. Grab the source code for Postgres
  2. Make sure Coolstack 1.3 is installed (or some other copy of readline)
  3. Make sure /opt/coolstack/lib is in your crle path
  4. Make sure you have sunstudio or sunstudioexpress installed and in the path
  5. gtar xjf postgresql-8.2.9.tar.bz2
  6. cd postgresql-8.2.9
  7. CC=cc CXX=CC ./configure --prefix=/opt/postgres \
    --with-libs=/opt/coolstack/lib \
    --with-include=/opt/coolstack/include
  8. cd src/port
  9. gmake
  10. cp *.a /usr/postgres/8.2/lib

Now you’ll be able to make Slony. I’m not saying this is the right way, but it certainly worked for me and I now have it up and running just fine.


August 28th, 2008 |



Previous Entries
  • Recent Posts

    • The blog - It’s moved! Again!
    • Mus domesticus (Rodent Mice)
    • Big table and changing indexes
    • The importance of tabs
    • pkgsrc and OpenSolaris 2008.05 - made easy
  • Archives

    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • November 2007
    • October 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • January 2007
    • December 2006
    • October 2006
    • September 2006
  • Recent Tracks (last.fm)

    • Guns N' Roses – Riad N' The Bedouins 4 hours ago
    • Guns N' Roses – Scraped 5 hours ago
    • Guns N' Roses – Catcher In The Rye 5 hours ago
    • Guns N' Roses – There Was A Time 5 hours ago
    • Guns N' Roses – If The World 5 hours ago
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
Copyright © 2008 Lee Packham’s Corner All Rights Reserved
RSS XHTML CSS Log in
Wp Theme by n Graphic Design
Powered by Wordpress