Stop top posting, bitches

March 31st, 2010

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A Collection of Inexcusable Governmental Failings

March 30th, 2010

New Zealand

* ECan dissolved, dictators appointed.
* Proposal to mine conservation land.
* Implementation of Voluntary Student Membership nationally in NZ.
* Cutting funding to Radio New Zealand.
* Internet filtering.
* To be amended, no doubt.

Australia

* Even worse internet filtering.

PHP is teh coolzor

March 16th, 2010

(14:51:35) Jasper: php considers that 0 == “eggs”
(14:51:40) Jasper: and also that 0 == “spam”
(14:51:46) Jasper: but “spam” != “eggs”
(14:52:04) Michael: that’s pretty wtf
(14:52:07) Jasper: yep
(14:52:10) Jasper: a good reason never to use PHP
(14:52:15) Michael: as if you needed another one.

Clever Cass

March 15th, 2010

(11:09:01) Cass: what I love about homeopathy
(11:09:05) Cass: is it should be self defeating
(11:09:16) Cass: if people who believed in it needed a rememedy
(11:09:19) Cass: they need buy it once
(11:09:30) Cass: then dump it in a large container of water

Geminids Success!

December 14th, 2009

I’m really supremely pleased that I have so many friends (such as Jasón James Auger, Storm Geldenhuis, André Geldenhuis, Cass Jones, Frank Ansell, Erin Morgan, Mathew Falloon, Acacia Voorkamp, Giles Reid, Daniel Neville, Roisin Ward, Hamish Winn, Vincent E. Konrad, Nicholas Lloyd, Raphael Nolden, Phil Anderson, Hannah and others!) willing to drive to the wops on a Sunday night just to watch sand ablate in the atmosphere. You guys rock so hard it’s not funny.

Thanks mostly to Jasón for getting the ball rolling. Hope to see some or all of you again at future amateur astronomy occasions (which we may just have to hold.)

Handy Linux Tip #4: Resolving Iceweasel / Firefox Flash Player plugin crashes in Debian Lenny on x86_64

November 11th, 2009

Recently Adobe released a long-anticipated x86_64 build of their ubiquitous Flash Player. After several months many distro-makers began to bundle this as standard, including, Debian in the Lenny release.

Unfortunately for some this plugin makes use of the “LAHF” instruction, an instruction that is not always present on otherwise capable x86_64 CPUs. What this means is that on these CPUs (including early AMD64s, Pentium 4s and others) the Flash Player plugin will cause Firefox or Iceweasel to exit suddenly with an “Illegal instruction” message (or no message at all, depending on how it was launched).

If you are the owner of one of the affected CPUs though, all is not lost. This issue was raised on the Gentoo bug tracker and a clever solution was developed by Maks Verver. The solution comes in the form of a wrapper plugin. This wrapper is compiled from a short section of C code which intercepts the SIGILL signal and emulates the behaviour of the missing LAHF instruction.

Here is the code in its entirety:

/* Simple work-around for running the 64-bit Adobe Flash plug-in version 10
on Athlon64 processors without support for the lahf instruction.


Compile with:
cc -fPIC -shared -nostdlib -lc -oflashplugin-lahf-fix.so flashplugin-lahf-fix.c
Then place the .so file in the plug-in directory (e.g. $HOME/.mozilla/plugins)
or use LD_PRELOAD to force Firefox to load the library.

- Maks Verver <maksverver@geocities.com> July 2009 */

#define _GNU_SOURCE
#include <stdlib.h>
#include <signal.h>
#include <ucontext.h>

static void sig_handler(int signal, siginfo_t *info, void *context) {
if (signal != SIGILL) return;
if (*(char*)info->si_addr != (char)0x9f) abort();
greg_t *regs = ((ucontext_t*)context)->uc_mcontext.gregs;
((char*)&regs[REG_RAX])[1] = ((char*)&regs[REG_EFL])[0];
regs[REG_RIP]++;
}

static struct sigaction old_sa, new_sa = {
.sa_flags = SA_SIGINFO,
.sa_sigaction = &sig_handler };

int _init() { sigaction(SIGILL, &new_sa, &old_sa); return 0; }
int _fini() { sigaction(SIGILL, &old_sa, &new_sa); return 0; }

In order to make use of this on Debian Lenny, copy and paste the code to a text file called flashplugin-lahf-fix.c and compile from the same directory like so:


cc -fPIC -shared -nostdlib -lc -oflashplugin-lahf-fix.so flashplugin-lahf-fix.c

If you find this doesn’t work, first install the package build-essential with aptitude. See the Debian documentation for more on how to do this.

Once the wrapper has been built you can either copy it to the system-wide plugins directory by executing this command as root:


cp flashplugin-lahf-fix.so /usr/lib/mozilla/plugins/

Or drop the file in to ~/.mozilla/plugins (creating the directory as necessary). Then restart Firefox / Iceweasel and ensure that Flash is running by visiting a site like YouTube and playing a video.

24 Hour Movie Marathon

November 2nd, 2009

Incredibly Strange
Alright, so this weekend I attended the 10th annual Incredibly Strange Vendetta Films 24 Hour Movie Marathon at the gritty Hollywood Cinema in Avondale. To give you perhaps some brief understanding of how it all went down, here is a chronlogical list of all the films that played, linked to the relevant IMDB page:

  1. The Secret Four
  2. Zombieland
  3. Road House
  4. Forbidden World
  5. Vice Squad
  6. Paranormal Activity
  7. Maidens of Fetish Street
  8. Mill of the Stone Women
  9. Night Train to Terror
  10. The Visitor
  11. The Informant
  12. Creature From Black Lake
  13. Howling II
  14. Commando

I’ll be writing a bit more about how awesome this was later.

Handy Linux Tip #3: Summing a column of numbers with awk

September 24th, 2009

Supposing we look at the output of ls -l:

michael@armstrong ~ $ ls -l
total 861648
-rw-r–r– 1 michael michael 145605 2008-10-15 23:14 1224064858283.gif
-rw-r–r– 1 michael michael 104323 2008-12-15 20:36 1229312381830.png

This is a synthetic example, supposing we now want to know the sum of the filesizes in the output of ls -l? You might think that bc is a good fit here, but I found it to be needlessly verbose for the purpose (needs a longish script to sum a column of numbers on stdin).

So? awk to the rescue! And it’s a recipe that you can probably remember despite not needing it too often:

michael@armstrong ~ $ ls -l | awk ‘{ sum+= $5 } END { print sum }’
881289090

Easy as that, substituting $5 to select which space-separated field to sum.

Handy Linux Tip #2: Xnest

September 3rd, 2009

Xnest is a handy X server with a slightly unusual design characteristic: It draws its output in to the window of an existing X server.

The practical upshot of this is that you can launch a new X session inside a window of your existing one. This is useful for, among other things:

  • Testing applications on different display resolutions
  • Running X applications as a different user
  • Testing new desktop environments, window managers, etc

For those of you running Debian, you may have spotted the “Applications -> System Tools -> New Login in a Window” menu option. It would appear that while this is intended to launch a new Xnest instance with GDM, Xnest isn’t actually included in the GNOME desktop task installed by tasksel.

On a stock Debian install selecting this option is more likely to display the following amusing error:
lol

The solution to this is pretty simple though, aptitude install xnest and you should be up and running. Here’s a screenshot of running Xnest on my machine, running a GNOME session for root (note that you probably shouldn’t do this):
GNOME screenshot

Handy Linux Tip #1: Calling ioctl to reload the partition table

August 11th, 2009

If you do low-level manipulation of a block device with a partition table such that the partition table should be reloaded by the kernel (for instance, dd’ing an image file to a USB mass storage device) you need to make a call to ioctl to tell the kernel to reload the partition table from the device (and re-populate /proc/partitions, etc).

Various partition tools do this for you when you manipulate the table (e.g, fdisk from util-linux-ng) but sometimes you just want to hex edit / dd / cat changes to your partition table.

In this instance, I discovered a handy bit of code that just makes the ioctl call. It’s called “partprobe” and it’s included in the GNU parted package for Debian.

aptitude install parted or check out the package http://packages.debian.org/lenny/parted.

If anyone knows a smaller package with the same functionality, drop me a line.

Update: jbg has correctly pointed out that the util-linux package (that you almost certainly already have) contains a tool to do this as well:

blockdev –rereadpt /dev/foo

Easy as that :)