Celebrations

Some days you celebrate the little victories, other days, you celebrate the big ones.

Today, I get to celebrate a pretty significant victory, in my humble opinion: I managed to get the ensembl java API to compile and generate a fully operational battle station jar file that works with my Java code.

I know, it doesn’t sound like such a big deal, but that means I worked out all of it’s dependencies, managed to get all of it to compile without errors and THEN managed to fix a bug.  Not bad for a project I thought would take months.  In fact, I’ve even made some significant upgrades, for instance, it now creates a java 1.6 jar file, which should run a bit faster than the original java 1.4.  I’ve also gone through and upgraded some of the code – making it a bit more readable and in the java 1.6 format with “enhanced loops”.  All in all, I’m pretty pleased with this particular piece of work.  Considering I started on friday, and I’ve managed to make headway on my thesis project in the meantime, I’d say I’m doing pretty well.

So, as I said, I get to celebrate a nice little victory…. and then I’ll have to immediately get back to some more thesis writing.

—–

For posterity’s sake, here are the steps required to complete this project:

  1. Get the full package from the Ensembl people. (They have a version that includes the build file and the licence for the software.  The one I downloaded from the web was incomplete.)
  2. Get all of the dependencies.  They are available on the web, but most of them are out of date and new ones can be used.
  3. Figure out that java2html.jar needs to be in ~/.ant/lib/, not in the usual ./lib path
  4. Fix the problem of new data types in AssemblyMapperAdaptorImpl.java. (It’s a 2 line fix, btw.)
  5. Modify the build.properties file to use the latest version of the mysql API, and then copy that to the appropriate ./lib path.
  6. Modify the build.properties file to reflect that you’re generating a custom jar file.
  7. Modify the build.xml to use java 1.6 instead of 1.4
  8. Figure out how to use the ant code.  Turns out both “ant build” and “ant jar” both work.
  9. Note, the project uses a bootstrap manifest file which isn’t available in the source package on the web. If you use that code, you have to modify the build.xml file to generate a custom manifest file, which is actually pretty easy to do.  This isn’t required, however, if you have the full source code.

When you write it out that way, it doesn’t sound like such a big project does it?  I’m debating putting the modified version somewhere like sourceforge, if there’s any interest from the java/bioinformatics community.  Let me know if you think it might be useful.

Fixing the screen/LCD brightness keys on a macbook pro, Ubuntu 10.10.

If you’ve been following my posts, you’ll know I have a macbook pro running Ubuntu Linux, and you’ll also know I love tweaking things. I’m not obsessive about tweaking, but if something could work better, I’d like it to work better. So after a month of having 4 dead keys on my laptop, I figured I had to do something about it.

They keys are:

  • keyboard back light brightness up
  • keyboard back light brightness down
  • monitor brightness up
  • monitor brightness down

They’re hardly the most important buttons on a keyboard, but I figured I’d let them sit idle long enough.

Getting them to work turns out to be a relatively simple.  Initially, I’d just followed the instructions here to get the keyboard LED brightness working, and that did a decent job…. but not perfect.  It didn’t actually let you get the brightness all the way to zero or to 255, the max brightness.   Thus, I modified the script:

(You can download it here)

#!/bin/bash
# Francisco Diéguez Souto (frandieguez@ubuntu.com)
# This script is licensed under MIT License.
# Modified by Anthony Fejes (apfejes@gmail.com)
#
# This program just modifies the value of backlight keyboard for Apple Laptops
# You must run it as root user or via sudo.
# As a shortcut you could allow to admin users to run via sudo without password
# prompt. To do this you must add sudoers file the next contents:
#
#   ALL = (ALL) NOPASSWD: /usr/sbin/keyboard-backlight
#
# You must then install the script in the path given above, eg, /usr/sbin/
# If you chose another path, then the location in the sudoers file must reflect 
# that path.
#
# After this you can use this script as follows:
#
#     Increase backlight keyboard:
#           $ sudo keyboard-backlight up
#     Decrease backlight keyboard:
#           $ sudo keyboard-backlight down
#
# You can customize the amount of backlight by step by changing the INCREMENT
# variable as you want it.

BACKLIGHT=$(cat /sys/class/leds/smc::kbd_backlight/brightness)
INCREMENT=10

if [ $UID -ne 0 ]; then
    echo "Please run this program as superuser"
    exit 1
fi                                                                                                     
                                                                                                       
SET_VALUE=0                                                                                            
                                                                                                       
case $1 in                                                                                             
                                                                                                       
    up)                                                                                                
        TOTAL=`expr $BACKLIGHT + $INCREMENT`
        if [ $BACKLIGHT -eq "255" ]; then
                exit 1
        fi
        if [ $TOTAL -gt "255" ]; then
            TOTAL="255"
        fi
        echo $TOTAL > /sys/class/leds/smc::kbd_backlight/brightness
        ;;
    down)
        TOTAL=`expr $BACKLIGHT - $INCREMENT`
        if [ $BACKLIGHT -eq "0" ]; then
                exit 1
        fi
        if [ $TOTAL -lt "0" ]; then
            TOTAL="0"
        fi
        echo $TOTAL > /sys/class/leds/smc::kbd_backlight/brightness
        ;;
    *)
        echo "Use: keyboard-light up|down"
        ;;
esac

Following the instructions in the header to add this into the sudoers file, you can then go to your windowing environment and associate the keys with the command. In my case, I went to the Settings menu in the KDE launcher, clicked on the System Settings toolbox and went into the Gestures and Shortcuts menu. I created a new group brightness controls in the custom input action settings, then used the menu to create new global shortcuts and picked the “command/URL” type. At this point, all you need to do is move to the “Trigger” tab, click on the key you want to associate with each command, then enter the commands into the action tab. (The commands are:

sudo /usr/sbin/keyboard-backlight up

and

sudo /usr/sbin/keyboard-backlight down

Getting the screen brightness to work wasn’t that much harder. The script looks like:

(You can download it here)

#!/bin/bash                                                                                            
                                                                                                       
# Anthony Fejes (apfejes@gmail.com)                                                                    
# Template taken from post by Fran Diéguez at                                                          
# http://www.mabishu.com/blog/2010/06/24/macbook-pro-keyboard-backlight-keys-on-ubuntu-gnulinux/       
#                                                                                                      
# This program just modifies the value of video brightness for Apple Laptops                           
# You must run it as root user or via sudo.
# As a shortcut you could allow to admin users to run via sudo without password
# prompt. To do this you must add sudoers file the next contents:
#
#   ALL = NOPASSWD: /usr/sbin/mbp_backlight

# After this you can use this script as follows:
#
#     Increase backlight keyboard:
#           $ sudo mbp_backlight up
#     Decrease backlight keyboard:
#           $ sudo mbp_backlight down
#

BACKLIGHT=$(cat /sys/devices/virtual/backlight/mbp_backlight/brightness)
MAX=$(cat /sys/devices/virtual/backlight/mbp_backlight/max_brightness)
MIN=4
INCREMENT=1

if [ $UID -ne 0 ]; then
    echo "Please run this program as superuser"
    exit 1
fi

case $1 in

    up)
        TOTAL=`expr $BACKLIGHT + $INCREMENT`
        if [ $BACKLIGHT -eq $MAX ]; then
                exit 1
        fi
        if [ $TOTAL -gt $MAX ]; then
            let TOTAL=MAX
        fi
        echo $TOTAL > /sys/devices/virtual/backlight/mbp_backlight/brightness
        ;;
    down)
        TOTAL=`expr $BACKLIGHT - $INCREMENT`
        if [ $BACKLIGHT -eq $MIN ]; then
                exit 1
        fi
        if [ $TOTAL -lt $MIN ]; then
            let TOTAL=MIN
        fi
        echo $TOTAL > /sys/devices/virtual/backlight/mbp_backlight/brightness
        ;;
    *)
        echo "Use: mbp_backlight up|down"
        ;;
esac

And method is identical to that above, associating the appropriate keys to the command:

sudo /usr/sbin/mbp_brightness up

and

sudo /usr/sbin/mbp_brightness down

And I’m now happily able to use all of the keys on my keyboard!

Kubuntu 10.04 on a Macbook pro

After spending a few hours setting up a macbook pro with kubuntu 10.10 (Maverick), I figured there were a few things that would be useful to jot down.

First of all, I found this page very helpful: https://help.ubuntu.com/community/MacBookPro6-2/Maverick – instructions on setting up a macbook pro 6,2 with Kubunu Maverick provided by the community.

Unfortunately, not all of their advice was spot on, so there are a few things I figured I’d need to point out:

  1. run sudo apt-get update; sudo apt-get dist-upgrade once you’ve got things set up – that will upgrade and solve a few problems right off the bat
  2. you will need to install mbp-nvidia-bl to get the screen brightness controls working (more on that later) and you’ll want macfanctld to control the fans. I’m not sure what btusb-dkms does, but it wasn’t a problem down the road, so you can install all three at once with: sudo apt-get install mbp-nvidia-bl-dkms macfanctld btusb-dkms
  3. Mac Keys:The equivalent instruction on the community page suggests installing pommed – Do not install pommed! It’s unnecessary, it constantly takes up about 4% cpu and doesn’t work well. You can configure all of the buttons elsewhere. (eg, I used compiz to set up the desktop widget and scale applications)
  4. You’ll want to have mbp-nvidia-dkms running at boot, so you’ll add the word “mbp-nvidia-bl” to the end of the /etc/modules file. (I also have coretemp in the file, having followed the instructions for sensors on the community page.)
  5. At some point, I installed “nvidia-bl-dkms”, which was causing the mbp-nvidia-bl-dkms to not be loaded (aka, blacklisted), so I had to remove it – if you haven’t added it, you won’t have that problem.)
  6. I used the command “alsamixer” to unmute the speakers, as suggested on the community page, but then also had to make a few changes to the sound control widget. First, I had to change the master control from the High Def sound controller to the onboard sound controller, and then un-mute that. That enabled sound on my system AND made the sound buttons on the keyboard work.
  7. I found (and still find) the touchpad to be extremely annoying – so I tried touchfreeze. Unfortunately, touchfreeze takes a constant 4% of cpu as well, so I killed that. The next best solution I had was to use the command “syndaemon -d -i 1” on the command line. This runs syndaemon in the background, and prevents the touchpad from doing anything one second after you’ve typed anything. It’s not perfect, but WAY better than nothing. You can put it into systems -> Startup and Shutdown -> Autostart, so that it will turn on every time you log in.
  8. Screen brightness is somewhat of a pain. Once you have mbp-nvidia-bl running as a module, you can use the screen brightness slider on the power control (battery) applet to control the screen brightness. Unfortunately, I haven’t gotten the buttons working yet – though, I’ve read that you can add “acpi_backlight=vendor” to your /etc/default/grub file to the end of the GRUB_CMDLINE_LINUX_DEFAULT parameter. I haven’t tried this yet. EDIT: Tried it – didn’t work. EDIT 2: There appears to be a KDE bug report for this problem, which is fixed in a patch in Nov 2010 – which means it’s unlikely that there’s a trivial fix for it – and furthermore, that it will be fixed in Kubuntu 11.04. (see this)

Everything else seems to have worked as advertised on the community page.

Credit for everything here should go to the people who posted them in forums – I didn’t invent any of this myself, and, unfortunately, I didn’t write down the sources for what I did use – I’ve googled using too many other computers on the way to getting things set up.

Further Notes by means of EDIT:

  • To enable the speakers on the macbook pro, you do need to install the gnome-alsamixer package, which will then give you the option of un-muting the speakers. I couldn’t track down this option using any of the other interfaces (sound applet, control panel or the alsamixer for the command line.)
  • The best way to set up the touch pad is to use the control panel to disable the single tap (set it to none), but allow tapping to be on otherwise. That fixes most (if not all) of the weird track pad behaviors.

Happy Kubuntu-ing.

A salute to IDEs.

Not that this will mean much to anyone but coders, but it was a startling revelation to me. After mainly doing code development in Java using the eclipse IDE (Integrated development environment, for the non-coders) for a couple of years, I’ve become pretty “soft” as a programmer.. When your IDE prompts you for function names, does imports and stuff, you can code pretty quickly, and the quality of your code is going to be relatively high. After all, you can focus on the algorithms and not worry about leaving silly typos in your code. (Bugs yes, typos not so much.)

However, since this weekend, I’ve been hacking around with data visualization using javascript/HTML5 – which, as far as I know, doesn’t have a Linux IDE for development. Hence, I’m writing code in the nano editor. (If you used email in the early nineties, nano looks just like the pine email client.) Unlike my “cushy” java IDE where function names come up automatically, working in nano means I need to memorize the name of every function I want to use.

Even worse, nano doesn’t display the code with proper formatting – it just assumes the whole thing is html and thus messes around with colours (making everything a dark, unreadable blue) every time I use a less-than (“<") symbol. Anyhow, even with the total lack of a decent IDE, I've still managed to write a couple hundred lines of code and have some neat but pre-mature animations. But... Unfortunately, I'm spending equal amounts of time looking up functions, testing code, and trying to debug typos. Coding this way is just like developing in pascal in 1992, except back then I had only a help file with no search function, whereas google is now my best friend. At any rate, I would like to take this opportunity to say thank you to the people who write IDEs. Like human rights and basic freedoms, you never appreciate your tools fully until you have to live without them.

Microsoft Fanboi Thread

Ok, I know you’ve been waiting for this.  Here’s a place for the Microsoft Fanboys to rant about how stupid I am.

When I left Nature Blogs, I spent time outlining why I hate Microsoft. Yes, that’s right, I do not like Microsoft or want to have anything to do with them.  They’re a monopoly, repeatedly convicted of abusing that monopoly to the detriment of the consumers around them.

It’s not a speculation, it’s a fact, held up in courts around the world.

In response to “Joe Hammock” – a coward who signed up with a “fastmail.fm” account just to write  a terribly rude comment on my Nature Blog post –  let me reply to get things started:

“You are quitely [sic] frankly the biggest fricken [sic] idiot I’ve ever seen in my entire life”

You lead a sheltered life.

“If you had a clue, you’d know that Microsoft is more altruistic than all the other tech companies combine. Hell, Bill Gates has pleged [sic] half of his wealth to charity. Jesus Christ, do some research before you run off a bunch of lies.”

Oh, I’m well aware that Bill Gates gives up a lot of his wealth to good causes.  I still consider much of it ill-gotten.   Microsoft made most of it’s money on its flag ship products of Windows and Office, both of which have been the focal points of lawsuits for the way that Microsoft has harmed their competitors. (The OS/2 Fiasco as well as WordPerfect come to mind as great examples of how Microsoft lied and cheated on their contracts to gain dominance.)  That Gates now feels he needs to give away 1/2 of his money to make him feel better about how he got it, after retiring from Microsoft, doesn’t make me feel any better about Microsoft as a corporation.

“As for the list of awful things Microsoft has done, would you like for me to reel off the massive list of things that Apple and Google have done?”

Actually, Yes!  I would.  I have never heard of Google abusing it’s monopoly, destroying competitors because it felt like it or engaging in otherwise unethical practices.  I know the standard lines about Google getting in Microsoft’s way, but that’s hardly a crime.  As for Apple, I don’t like their business decisions, but I’m not aware of any that were illegal.

So yes, please do list them! But hold the insults – they’re unnecessary.

“You are clueless and beyond idiotic.”

Thanks!  From you, that’s actually a compliment.

“It’s quite evident that you are nothing more than another pathetic Apple sycophant whose decided to hate Microsoft because of your love of Apple’s overrated products.”

Frankly, your shot is wide of the mark.  I rarely use Apple products, and I find them, for the most part, to be just as poor as Microsoft’s.  I don’t like the lack of interoperability or transparency.  If I’m a fan of anything, it’s GNU/Linux.   So, would you like to tell me why Linux is unethical?

“Did you know that hackers proved at a hacker’s convention that OS X is even less secure than Windows? No, because you’re an idiot.”

Wow.. that’s the best you can do for propaganda?  Common Microsoft Fanboys… man up and at least tell me which convention.  Anyhow, did I mention that I’m not emotionally attached to Apple?  Even if you had evidence, proving that Microsoft is no worse than Apple is hardly going to upset me.  Now, if you can show me how many critical flaws are found in the Microsoft Kernel versus the Linux Kernel, you might be on the right track.  Unfortunately, if you’re following the FUD trail left by Microsoft, their stats compare the Microsoft Windows kernel with the whole Linux ecosystem – hardly a fair comparison.

“God you are pathetic.”‘

I’m an atheist – suck on that.

Ok, have at it, Fanboy, this thread is all yours.

Slow ssh on Ubuntu.

Ok, really, no one is going to be interested in this, but I wanted to put it somewhere I won’t forget.

I’ve been having trouble with ssh sessions taking 2 or 3 minutes to connect and ask for the password – which is intolerable when the computer on the other end has a 2-3 minute time out.  Turns out there’s a very simple solution:

sudo nano /etc/ssh/ssh_config

find the following two lines:

GSSAPIAuthentication yes
GSSAPIDelegateCredentials no

Comment those two lines out, which should look like this:

# GSSAPIAuthentication yes
# GSSAPIDelegateCredentials no

Tada – no more slow ssh!

>Dates and misleading messages.

>Here’s an entertaining debugging challenge for people.

I was trying to get the history of code changes between April and June, so that I could write up a quick report for a working group at the GSC. I used the following command:

svn log -r {2009-06-31}:{2009-04-01}

and got the following error:

svn: Syntax error in revision argument '{2009-06-31}:{2009-04-01}'

After scratching my head for a while to figure out what the correct syntax was, and going through a ton of different threads on-line to figure out what the correct format should be, I finally figured out the error…

Are you ready for it?

June doesn’t have 31 days. Replacing it with the correct date range solved the error. Oops!

>sshfs: another useful Linux tool

>Ok, I just had to share this tool – I’m sure anyone who’s familiar with Linux already knows it, but just in case there are people out there who are behind me on the Linux learning curve, this one is worth knowing: sshfs

If you’ve never heard of it before, the full name is the ssh file system. What it does is quite simple: it allows you to mount any ssh accessible directory as a local file system. It’s not any faster than ssh access would be, and apparently (from various sources on the web) it doesn’t do well under huge stress, but for my purposes, it’s been brilliant.

Normally, if I want to do anything with my work account, I have to ssh into the work machines, then download/scp files all over the place, leaving several copies on each of the computers I work on. This inevitably leads to version-ing nightmares.

This is where sshfs steps in. Instead of copying files, I now just mount each of the ssh accessible computers are mount points, and operate directly over the ssh share. It’s pure genius.

To use it, you need to install the sshfs package, which is trivially easy on Ubuntu or another debian based system:

sudo apt-get install sshfs

Then you need to create the mount point (which I usually do in /media, just for ease of use), and assign yourself permissions to use that mount point. This is done with your own username on the local machine, and doesn’t change the permissions on the server.:

cd /media
sudo mkdir servername
sudo chown username.username servername/

This sets up a point for you to attach the server. All that’s left is then to attach the directory on the server to your local mountpoint, using a command eerily similar to scp’s:

sshfs username@servername.example.com:/home/username /media/servername/

Tada. All that’s left is to open your file manager of choice and open up the directory.

If only I’d discovered this tool sooner!

>Nifty little trick for debugging frozen applications

>This trick is just too cool not to mention.  I was trying to debug an application that was getting stuck in an endless loop, the other day. It was a rather complicated set of changes that was required and I had no idea where the program was getting stuck.’

In the past, I would have just ended the program with a control-c, and then started dropping in print statements until I could isolate exactly where the program was getting stuck.  Instead, I stumbled upon a very nifty little trick: using the kill function to halt the program and dump the thread’s core to screen with the command:

kill -3 [pid]

For a java code running from the class files, the core dump shows you exactly which line is being executed in each thread, allowing you to find out precisely where the problem is – making debugging go much more quickly.

Anyhow, I haven’t yet tried if this works on a .jar file, or what else you can do with a quick “kill -3”, but this certainly broadens my toolkit of debugging utilities, and gives me a whole new respect for the kill signals.  I may have to test out a few of the other ones….

>TomTom has no Linux support?

>I’m still procrastinating – A plumber is supposed to show up to cut a hole in my ceiling in a few minutes, basically as exploratory surgery on my new house, in order to find a leak that’s developed in the pipes leading away from the washer and dryer. So, I thought I’d spend the intervening moments doing something utterly useless. I looked up TomTom’s web site and took a look at what they have to offer.

If you don’t know TomTom, they’re a company that produces GPS units for personal and car use. They’ve recently shot to fame because Microsoft decided to sue them for a bunch of really pointless patents. The most interesting ones of the bunch are the ones that Microsoft seems to think are being infringed just because TomTom is using Linux.

Anyhow, this post wasn’t going to be about the patents, since I already gave my opinion of that. Instead, since I’d been thinking about buying a GPS unit for a while, I thought it might be worth buying one from someone who uses embedded Linux – and I’d like to support TomTom in their fight against the Redmond Monopoly. Unfortunately – and this is the part that boggles my mind – TomTom offers absolutely zero support for people who run Linux as their computer operating system. Like many other companies, they’re a Windows/Mac support only shop.

This strikes me as rather silly – all of the open source users out there would probably be interested in buying an open source GPS, and would probably be happy to support TomTom in their fight… but they’ve completely neglected that market. They’ve generated a great swelling of goodwill in many communities by standing up to Microsoft’s bullying, but then completely shut that same market segment out of purchasing their products.

Well, that’s some brilliant strategy right there. I only hope TomTom changes their mind at some point – since otherwise all that goodwill is just going right down the toilet…

And thinking of plumbing, again, it’s time to go see about a hole in my ceiling.