Ubuntu on an HP Compaq dx2300 Microtower

March 19th, 2009

My new desktop at varsity is, as described in the title, an HP Compaq dx2300 Microtower. First thing I did when I got access to it was, of course, to install Linux – Ubuntu 8.10 in this case. It’s a pretty nice machine (although not particularly high-spec) and pretty much everything worked straight away from install. The graphics card is Intel, so I’m not going to be doing any serious gameplaying (this is a work computer, anyway) but it runs Compiz pretty well. Being a desktop, suspend and hibernate aren’t terribly important, but as it happens they work fine.

The only problem – and this is the main point of this post – was with the soundcard (an Intel HDA). The box has three audio outputs: headphone plugs front and back, and a tinny built-in speaker. Under Ubuntu all three outputs were switched on all the time, and it wasn’t possible to adjust them separately. The purpose of headphones in a shared lab environment is entirely defeated if the built-in speaker is always on! I tried fiddling with all of the multitude of ALSA settings, but nothing worked. It couldn’t have been a hardware problem, because it did the right thing under Windows.

So, the problem was narrowed down to the audio driver, snd-hda-intel to be specific. Some googling established that changing the model parameter to the module might have some effect on the output selection behaviour. Further searching established that the possible values are listed in Documentation/sound/alsa/HD-Audio-Models.txt in the kernel source.

To find out what the possible values are, you have to know which codec your card uses. This you can do by running

cat /proc/asound/card0/codec#0 | grep Codec

For the dx2300 the result was Realtek ALC888. Indeed, under the list of models for the ALC888, there is one called “3stack-hp” for “HP machines with 3stack”. Guessing that this was the correct one, I added to /etc/modprobe.d/alsa-base the line

options snd-hda-intel model=3stack-hp

and rebooted. Hey presto, suddenly the internal speaker switches off when headphones are plugged in.

tl;dr summary: If you have a dx2300 and you’re having problems with the audio under Linux, then add the line options snd-hda-intel model=3stack-hp to the file /etc/modprobe.d/alsa-base (at least in Ubuntu; your distro might put module options in a different file).

Not quite how one expects to find out…

January 14th, 2009

This afternoon I discovered that I’ve officially been accepted to the MSc programme in Maths at UCT. But how did I discover this? I received an automated email from ICTS (UCT’s IT administration) that said “Dear Post-Honors Student, A new email address has been created for you in the Name.Surname format…” So I figured, “OK, they’ve given me a new email address, I guess that means I’ve been accepted.” And indeed, when I checked Peoplesoft (the student admin system) there was a green tick in the Admissions section that hadn’t been there before.

Now, it doesn’t really bother me to find out this way, since in my case the official acceptance is just a technicality. But in general it seems like the best way to inform prospective students that they’ve been accepted is not through an automated notice about an email alias creation. Of course a proper signed letter is in the post as I write, but, y’know, it might be nice to send an email saying “Congratulations, you’re in” before sending one saying “Here’s your email account”.

Oh yes, and they could try to spell “Honours” properly, too.

Whois-related irritation

January 13th, 2009

Responsibility for the African IP ranges was transferred to AfriNIC what, four years ago, right? So why is it that some services that use the whois data still ignore the AfricNIC whois data? The result of this is that they believe that all African IP addresses are in Mauritius. If you’re on a South African IP, you can see this with, for example, the WhatsMyIP.org service by going to http://www.whatsmyip.org/more/ and looking at the “Whois Lookup” information.

Also, Netcraft should really know better. Check out the Netcraft information for the UCT website. It’s not like this information hasn’t been around for a while; all the open-source whois tools started using the AfriNIC server long ago. (I myself submitted the bug and patch for FreeBSD.) So really, they need to get with the program.

Update: I may have maligned Netcraft unfairly. Although they get the UCT information wrong, most SA sites do show up correctly. SAIX, for example. I’ve sent them a bug report.

HSDPA modem and custom routing

January 13th, 2009

So, for my Christmas present to myself I got a Huawei E220 HSDPA modem – it’s one of the Vodafone-branded ones, but I reflashed it with the generic firmware. Anyway, it’s an awesome thing to have for a geek like me – I can be connected to the Internet at broadband speeds almost anywhere in the city. It’s particularly useful when i’m on campus, so I can avoid the dog-slow UCT internet connection.

Problem is, I’d like to stay connected to the UCT network as well so that I don’t use up my precious* data bundle for UCT services, and this requires a bit of custom routing magic. So I have a script:

#!/bin/sh
GATEWAY=137.158.32.97
route add -net 137.158.0.0/16 gw $GATEWAY
route add -net 192.48.253.0/24 gw $GATEWAY
route del default
route add default ppp0

137.158.0.0/16 and 192.48.253.0/24 are the UCT netblocks, and 137.158.32.97 is the router on the subnet that I’m mostly using at the moment. ppp0 is, of course, the name of the interface associated with the HSDPA connection.

The problems with this script currently are that I have to edit it to change the gateway for each subnet that I’m on, that I have to run it manually each time I connect, and that it doesn’t restore the original routing when I disconnect. The first and third problems should be reasonably easy to solve, but the second will probably require that I dig into the mysterious world of NetworkManager. (Cue dramatic music.)

*It’s ourssss, my preciousss… they wants to take it from us, the nasssty Vodacom…

Graduation redux

December 11th, 2008

On Monday I was admitted by the University of Cape Town to the degree of Bachelor of Science (Honours) in Mathematics of Computer Science, in the first class. While I am, of course, very pleased to have graduated (and incredibly pleased that the Year From Hell is over), the whole “graduation experience” wasn’t nearly as exciting as last time, I guess because this time I knew what to expect.

Anyone who has mentioned graduation to me will have heard my description of it as “three hours of boredom punctuated by a moment of excitement”. (I didn’t make that up; it’s a paraphrase of the quote about war: “long periods of boredom punctuated by moments of sheer terror”.) I guess I attend it anyway because it serves as a useful psychological “marker” that the degree is over. If I didn’t go, I think I’d have a huge sense of anticlimax.

(The fact that I go may also have something to do with my parents being on staff and thus able to sit on the stage and put the hood over my head; also something to do with my grandmother’s demand for photographs.)

Blog resurrection

December 9th, 2008

OK, so I’ve rather neglected this blog for the last few months. In my defense, I can offer that I was finishing my Honours degree, including the notoriously timeconsuming major project. But that is now over (thank heavens) and I am free at last. (Shout it from the rooftops!) So hopefully I will have a little more time to spend on leisure activities like blogging.

I’ve also found the time to finally upgrade the Wordpress install that runs this blog. (It was still at 2.3.3, and the current is 2.6.5!) As you will notice, I’ve also returned to the default Wordpress theme. I know it’s boring, but it actually looks fine and it works well enough.

Only in Cape Town…

September 1st, 2008

…are trains cancelled due to rough seas.

Rough Seas
(Click to view; taken from the Cape Metrorail Traffic Report.)

For those of you not familiar with the Simon’s Town line, this is actually entirely reasonable. In places, the railway line runs right next to the beach; with a spring tide and a heavy storm surge, the sea can wash right over the tracks.

Impressed with Telkom

July 8th, 2008

We South Africans complain frequently about Telkom and the level of service it provides; and mostly the complaints are justified. But it is only fair that, when Telkom provides good service, we should also take note of it.

My phone and DSL line started having issues about a week ago, and it was becoming progressively worse: there was heavy crackle on the voice circuit, and the DSL line was showing about 20% packet loss. On Thursday evening I reported the problem through the fault reporting website.

Early this morning they phoned me and informed me that the technician would be able to visit later today, and he did indeed arrive at about 11. Because of the nature of the problem – an issue with the lines between my building and the distribution box – he had to travel back and forth a few times between my flat and the box on Main Road, so the process did take a while. Nonetheless, throughout the experience he was friendly, efficient, and competent.

I should mention in particular that at no point did I have to deal with the notorious callcenters and the interminable on-hold music. I didn’t have to spend any of my cell-phone minutes waiting for someone to take note of my problem. All I had to do was fill out the form on the website, and wait for them to get back to me – which only took two working days.

This is a marked contrast from my experience two years ago with my parents’ broken phone line, where it took five days and many hours on the phone to get the DSL and line repairs departments to agree on who was responsible for fixing the problem.

Load shedding bot FAQs

April 17th, 2008

Since posting about my Jabber load shedding warnings bot I’ve had a couple of questions asked about it. So here are the answers:

Where does the data come from?
The City of Cape Town has posted on the web the load shedding timetable as an Excel spreadsheet. I do a bit of manual manipulation on the spreadsheet before dumping it to a CSV file. Then I have a script which parses the CSV file and generates a SQLite database.

What’s the bot coded in?
Python. (Of course.) It uses the xmpppy module to do the Jabber communication, and SQLObject for the database.

How does it work?
The bot is actually made up of two separate components. There is a control daemon that is always available on Jabber, which accepts subscriptions and responds to your commands. Then there is a queuerunner fired by cron at the appropriate times, which sends the warning messages; it uses a negative Jabber priority, so your messages to the control daemon will never go to the queuerunner by accident.

How many users do you have?
As of 18 April, there are 20 users. The average user subscribes to warnings for two different locations.

Get load shedding warnings via Jabber

April 12th, 2008

Tired of having the power go out without warning? Now you can get warnings about predictable load-shedding sent to the Jabber account of your choice – including Google Talk accounts. Unfortunately, at the moment the warnings are for the City of Cape Town supply area only.

To set it up, ask your Jabber client to subscribe to loadshed@frith.co.za – in Pidgin that’s the “Add Buddy” command, in GMail it’s “Invite to chat”. The loadshed bot will accept your subscription, and reciprocate with a subscription request to you. When you accept it, the bot will send you instructions about how to proceed.

You can search the list of suburbs by sending the message “search [text]“, which will give you a list of suburbs in the City Council’s list with a name matching “[text]“. Then you can subscribe to warnings for a suburb with “subscribe [number]“, where [number] is the number that was listed next to the suburb in the search results. There’s also a “list” command which shows what susburbs you’re subscribed to; and “unsubscribe [number]” which works in the same way as “subscribe”.

The bot will send you warnings 15, 10, 5, and 2 minutes before the load shedding period is scheduled to start. A planned future development is to make the warning times configurable.