Custom Bash completions for lazy bastards

At $work, we have a log server, where the current day’s logs from a given machine are stored in, e.g. /logs/machinename/year/month/day/. In a moment of yak shaving, I added a function to my .profile, named cdmachinelogs to allow me to type e.g. cdmachinelogs somemachine, and end up in the appropriate directory.

Now, Bash will automatically tab-complete e.g. “cdm” into cdmachinelogs, but I wanted to be extra-lazy and tab-complete the machine name, too.

Enter the following snippet:


complete -W "$(find /log/path -maxdepth 1 -mindepth 1 -type d -printf '%f ')" cdmachinelogs

So, it sets up tab-completion for the cdmachinelogs command, using a list of words obtained by finding each directory name under the path to the logs.

Posted mostly for my own later reference, but also for anyone who might find it useful.

Newsflash: America not centre of world

KFC advertisement in Australia sparks race row

The Australian arm of the fast food chain Kentucky Fried Chicken has had to withdraw an advertisement after accusations of racial insensitivity.

[…]

When the advertisement reached America via the internet there were complaints.
It was accused of reinforcing a derogatory racial stereotype linking black people in the American deep south with a love of fried food.

Picked up by the American media, the advertisement immediately stirred controversy, because it was alleged to have perpetuated the racial stereotype that black people eat a lot of fried chicken.

[…]

It is the second time in three months that something broadcast in Australia has caused a racial stir in America.

Dear America: the world does not revolve around you; please pipe down and shut the fuck up about things that don’t concern you. Kthx.

Blackberry Bold Christmas wallpapers (480×320)

I recently upgraded from a Blackberrry Curve to a Blackberry Bold 9000, which has a higher screen resolution (480×320), so I decided to re-do the wallpapers I resized & cropped and shared last year, and figured I may as well share the results.

Below are a selection of wallpapers I chose; some my own photos, the others are taken from various places around the web. I believe them to all be in the public domain but unfortunately I’m not certain, as I didn’t think to note where each one was downloaded from.

Each thumbnail links directly to the full-size 480×320 image, so you can just right-click & “Save Target As” or similar.

Enjoy!

OpenDNS vs Google – speed comparison

I read a Twitter post earlier mentioning Google’s public DNS service, and suggesting that it could displace the popular OpenDNS

I thought it would be interesting to do a performance comparison between Google and OpenDNS, to see how they compare. I also decided to include the nameservers of my ISP, Virgin Media, to illustrate whether there are performance gains to be had by changing to OpenDNS (which I primarily use, along with others) or Google, or whether staying with defaults works. Continue reading OpenDNS vs Google – speed comparison

SSH and rsync on Lacie Ethernet Disk Mini v2

Lacie Ethernet Disk Mini v2

A couple of months back, I acquired a Lacie Ethernet Disk Mini v2 for backups – I’m planning to give it to a friend to plug in, so I’ll have a little self-contained box to back up to.

The drive is a pretty stylish-looking and very solid-feeling device.

However, it comes with rather limited software – a rather poor and ugly web interface (even worse when you see the code behind it), and it supports Samba (SMB/CIFS) shares, FTP, some kind of Apple file sharing protocol, and uPnP media streaming.

Ignoring all that though, what I want is the ability to back up to it by rsync – something it doesn’t support, out of the box. However, it’s an ARM-powered unit running Linux underneath, so with a little trickery, you can make it much more functional.

There are several guides on uncrippling it to get SSH access to make proper use of it – I followed this one.

Basically, the process consists of opening up the device, and temporarily hooking up the hard drive directly to your computer in order to add a telnet binary and a backdoor to the web interface. I used a little USB to SATA/IDE adaptor I bought from eBuyer, meaning I could hook it up happily to my laptop, and didn’t have to remove the drive from the Lacie unit, simply removing the outer case and unplugging the cables from the drive and plugging in the ones from the USB unit.

See the guide linked to above for the full process, but you basically drop in a shell script which you can call via its web interface once it’s back up to execute whatever you want. The webserver on it runs at root (ugh) so it can start whatever you want it to. Typically, you’ll start utelnetd so that you can then telnet to it, download some ARM packages to install OpenSSH, rsync and other bits, get SSH working, then disable telnet, the horrible web interface, and anything else you don’t plan to use (I disabled proftpd, Samba, and the uPnP media sharing software).

Once it’s all done, you have a small but usable Linux system you can SSH to:

lacienas1

Naturally it’s not super-fast, but it does the job well enough!

A few tech specs, for anyone interested:

davidp@EDmini davidp $ cat /proc/cpuinfo 
Processor	: ARM926EJ-Sid(wb) rev 0 (v5l)
BogoMIPS	: 266.24
Features	: swp half thumb fastmult 
CPU implementer	: 0x41
CPU architecture: 5TEJ
CPU variant	: 0x0
CPU part	: 0x926
CPU revision	: 0
Cache type	: write-back
Cache clean	: cp15 c7 ops
Cache lockdown	: format C
Cache format	: Harvard
I size		: 32768
I assoc		: 1
I line length	: 32
I sets		: 1024
D size		: 32768
D assoc		: 1
D line length	: 32
D sets		: 1024

Hardware	: MV-88fxx81
Revision	: 0000
Serial		: 0000000000000000
davidp@EDmini davidp $ cat /proc/meminfo 
MemTotal:        61632 kB
MemFree:          1380 kB
Buffers:           188 kB
Cached:          28924 kB
SwapCached:          0 kB
Active:          17336 kB
Inactive:        23328 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        61632 kB
LowFree:          1380 kB
SwapTotal:      128448 kB
SwapFree:       128448 kB
Dirty:            3472 kB
Writeback:           0 kB
Mapped:          14548 kB
Slab:            16688 kB
CommitLimit:    159264 kB
Committed_AS:    56104 kB
PageTables:        508 kB
VmallocTotal:   450560 kB
VmallocUsed:       716 kB
VmallocChunk:   449844 kB

“White-label” Nominet tag? Not quite…

I still receive occasional newsletters from Heart Internet, after trying out their free web hosting a long time ago (actually, I seem to recall it being a plan to mirror some content there, and never actually getting round to it).

Anyway, their latest newsletter sings the praises of their new “generic Nominet TAG”:

Previously, because of Nominet’s rules surrounding the registration of .uk domain names, we have had to register our reseller’s domain names through our Nominet tag, HEARTINTERNET, thus potentially exposing ourselves to reseller’s clients. Not any longer! We have now added an additional Nominet tag to our control panel for our resellers to use called EXTEND. This allows all our resellers to register domain names or transfer domain names through a generic tag, helping maintain their brand’s integrity.

I’m not exactly sure how this is helpful – instead of your clients seeing HEARTINTERNET they see EXTEND; it’s still not your brand, and Nominet’s tag list page still clearly identifies the tag as belonging to “Heart Internet Ltd t/a eXtend”.

(I was however amused by the wording of “potentially exposing ourselves to reseller’s clients” – that’s probably something best avoided! :) )

David Precious – professional Perl developer, motorcyclist and beer drinker