LyX 2.0 beta3 on Ubuntu Maverick

In my first attempt to package something that wasn’t a Gentoo ebuild I have made a first attempt at making Lyx 2.0 beta 3 available in my PPA on Launchpad. The Ubuntu Packaging Guide provides some very detailed instructions on how to create source packages, and with the help of the existing stable lyx ubuntu package the process seems all too easy.

I am certain however that there are numerous packaging recommendations that haven’t been followed so if anyone can enlighten me I’d be delighted to update the package.

Feel free to add the PPA using Synaptic as ppa:vladsharp/personal and install the updated lyx-2.0.0beta3-0ubuntu1ppa1 package.


Apple keyboard function key mapping in Ubuntu 10.10

I am a big fan of the Apple Keyboard with numeric keypad. It is flat like a laptop keyboard, has 2 USB ports and you can physically remap the keys to any layout you want (like Colemak). One other very nice feature is that keyboard has 19 function keys. Since programs generally don’t have shortcuts that are mapped to function keys higher than F12, this leaves 7 keys that can be used for global shortcuts. This is quite convenient on OS X, for example if you run Visor which gives you at the press of a single key.

I recently switched to Ubuntu 10.10 (Maverick Meerkat) and was very pleased to discover that the media function keys (forward, play/pause, …) work by default as long as you select the Apple Keyboard upon installation. Of course, this behavior can be changed – you can see some details here for example. Unfortunately, the F13-F19 keys are not mapped to F13-F19 but to something else. (I haven’t really looked at a PC keyboard in years, but I suppose it must be stuff like PrtScrn et. al.)

To get the F13-F19 keys back so that they can be used for global shortcuts, I’ve put the following script to run on Gnome startup:

xmodmap -e 'keycode 191 = F13'
xmodmap -e 'keycode 192 = F14'
xmodmap -e 'keycode 193 = F15'
xmodmap -e 'keycode 194 = F16'
xmodmap -e 'keycode 195 = F17'
xmodmap -e 'keycode 196 = F18'
xmodmap -e 'keycode 197 = F19'

xkbset exp m

As an alternative to Visor, I’m using Yakuake – it’s built on top of konsole and so is fairly customisable and solid.

Promoting structure reuse – does OOP really help?

I have become involved in some commercial Java development in the past month; consequently, my perception of Java as a counterproductive language has been changing to mediocre rather than anything else. I have been feeling uneasy about developing in Java mostly due to constant self-repetition in the code that I write. Forget the trivial lack of automatic getters/setters (as seen in C#) – this uneasiness comes from the style of the language.

When programming in the Object-Oriented Style, your primary concern is to model your domain as closely as possible – creating objects for concepts like Account or Position. However the model of the real world is never so simple so as to be modeled by an acyclic graph of classes that inherit from superclasses (if you have that kind of domain, consider yourself lucky). Generally there are some cross-cutting concerns that can be found across your subclasses – and however minor, they are difficult to separate from the rest of the code. Nor would you want to – having logic sprinkled across a myriad of superclasses is not exactly the epitome of good design or maintainability. (Maybe this has something to do with the fact that when we model the domain, for different subclasses it is generally the case that the Liskov substitution principle is violated – as the behaviour of different subclasses is intended to be different! A solution to this would be to spill abstract methods into interfaces and keep the concrete methods the same – but this again comes at the cost of naming complexity, amongst other detrimental effects).

Sometimes it is necessary to bite the bullet, and use copy-and-paste, then change a line in a method or two. This isn’t exactly DRY, and any errors in code that has been copied (verbatim or not) will propagate across different parts of your program.

Perhaps the most relevant question is whether any programming language could do better – whether copy-and-pasting could be avoided without the nice, clean design you originally started with. I believe to know of a language that could help in this respect – Factor. Below I will give an intuitive reasoning as to why this kind of programming language helps.

In Factor, arguments to “functions” are passed implicitly on the stack. Much of the benefit from using a functional concatenative language is derived from the fact that functions do not need any context, just their arguments in the correct order on top of the stack. This in turn means that a word (the term for “function” used in concatenative languages) could do just the kind of small data-fiddling that we need to have in our Java program in order to follow DRY. But of course, unlike Java – the word does not need to know any extraneous information – it takes the minimum structures it needs to perform its work. Sounds like reuse, does anybody disagree?

If anybody would like an example – I could post one on here.

Configuring the Linksys WUSB54GR on OS X 10.5 Leopard

I spent some time today coaxing my USB wireless adapter to work in OS X 10.5.6 Leopard, and I would like to share my experience (which wasn’t a particularly painless one). I have a WUSB54GR-UK – this is a basic 802.11g adapter which I bought because of (a) Vista compatibility, and (b) cost-effectiveness. Although admittedly, there was an ulterior motive – this adapter contains a Ralink chipset, and in my experience, Ralink provide very good drivers for OS X and Linux. (Maybe it’s just impressive that drivers for anything other than Windows are provided at all!)

After plugging it in the USB adapter shows up in System Profiler under the ‘USB’ category as:

Wireless-G USB Network Adapter
Product ID:    0x0023
Vendor ID:    0x13b1
Version:    0.01
Speed:    Up to 480 Mb/sec
Manufacturer:    Cisco-Linksys
Location ID:    0xfa300000
Current Available (mA):    500
Current Required (mA):    300

A quick google doesn’t return much information about the WUSB54GR and OS X, but if you remove the R there are plenty of hits.

I visit the Ralink support page for Macintosh and find the recommended drivers: USB(RT257x/RT2671). An install, root password confirmation dialog and a reboot later, the UsbWirelessUtility doesn’t see a device. Great.

Beginning to wonder whether I’m out of luck with this adapter, and it’s not a Ralink at all (which could be, because versions of the WUSB54G prior to v4 were Broadcom devices), I find the Kismac-ng Trac page which confirms the adapter as RT73. Sigh of relief, but no closer to the goal. After checking kextstat, the equivalent of lsmod in OS X, I find the RT2500 kext absent from the loaded list, and begin to suspect that the USB device/vendor ID matching mechanism is not linking this device to the right driver. A quick check of ioreg supports that theory – the Wireless-G adapter is given a generic USB driver, and nothing else.

Google gives some posts on InsanelyMac from 2006 which recommend changing Info.plist for the kext, but after some tinkering I noticed the USB product code recommended for the WUSB54G v4 is different from what System Profiler shows. A couple of reboots later, and still no show – even though ioreg has the adapter’s driver status as matched. Close, but not close enough – I decide to take a look at similar adapters, in particular, the WUSB54GS. This has a product code of 0x20, admittedly closer than 0xd – and the plist example given in Google’s cache indicates that I’m probably using the wrong portion of the driver for my adapter. I change it, and a reboot later wireless works. Question: why does this have to more painful than needed – is it too hard for Ralink to add the relevant section to their drivers?

Here then are the instructions to get this adapter to work. I am assuming you have already installed the correct drivers. Open up Terminal and switch to root user by typing in sudo su - and your password when prompted. Edit the kext’s plist file nano /System/Library/Extensions/RT2500USBWirelessDriver.kext/Contents/Info.plist. The beginning of the file should look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>Lens Wang</string>

Press Enter, then add the following lines:


The next line ought to read <key>ALPHA</key>. Press Ctrl-X, press Y to confirm saving, and nano will exit. Before rebooting, the kext cache needs to be flushed, so run the following lines in the Terminal you have open:

chown -R root:wheel /System/Library/Extensions
chmod -R 755 /System/Library/Extensions
kextcache -k /System/Library/Extensions
diskutil repairPermissions /

Reboot, and enjoy!

P.S. If you don’t yet know about AppleJack, now is the time to find out about this useful little utility. A somewhat interesting point is that when I installed Windows 7 RC1 recently, the drivers for this adapter were automatically installed and it “just worked”. That, Apple, is perhaps something to think about, even as Mac market share is relatively steady through the recession. Operating Systems are for allowing hardware to function, not for restricting arbitrarily what hardware can function.

First post, a humble hello

I will be writing today on behalf of the Open Slate Project. Now is as good a time as ever to open up a little discussion on the experiences that come from developing an operating system, and besides, I need to work on my voice.

The template was chosen from the stock list of templates, I hope you like it!