Sunday, October 10, 2010

Suspend shortcut on Ubuntu Gnome panel

Admittedly, the default Gnome panel setup on Ubuntu Lucid is rather sleek and utilitarian, alas there are some who would like to suspend to RAM in one click not two. The screen will be locked upon resuming, better safe than sorry right?

1. Create a file named suspend.sh with the following content:

#!/bin/bash
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

2. You may need to

chmod 755 suspend.sh

3. Right-click Gnome top panel and 'Add to panel...'

4. Create a new launcher.

5. Select the following launcher properties:

Type: Application in Terminal
Name: Suspend
Command: /point/to/suspend.sh

6. Choose an appropriate icon like e.g. /usr/share/icons/hicolor/48x48/apps/gdu-hba.png , yeah I know that's not what an off-button looks like. It's close, give me that.

Friday, July 2, 2010

Making Python2.6 the default over Python2.5

On Kubuntu Lucid I only find Exaile to be sufficient for handling my 15k tracks, but after installing Python2.5 (for Google AppEngine) then this fine large collection player gives the unfortunate errors:

ImportError: No module named gobject
AttributeError: 'Exaile' object has no attribute 'dbus'

Somehow Python2.5 overrides Python2.6 as the default, so to upgrade your snake-script you have to:

sudo rm /usr/local/bin/python
sudo ln -s /usr/bin/python2.6 /usr/local/bin/python

For KDE I calmly recommend making a custom Input Actions group (System Settings) for Exaile with the following commands (you'll figure it out):

Stop: exaile -s
ToggleUI: exaile --toggle-visible
Play/Pause: exaile -t
NextSong: exaile -n

Enjoy your 50,000 hours of music, I know I'll do.

Sunday, January 24, 2010

SDPA 7.3.1 installation problem in Cygwin

So you've managed to construct a 40000x40000 linear programming constraint matrix, hoping to solve it with a revised simplex function you coded in c++. Then after a week of research and programming, you find out that the usefulness of your lp solver depends wholly on its numerical stability.

Fortunately, the folks at sdpa.indsys.chuo-u.ac.jp did all the hard work for you, so that you can enjoy the favourable numerical properties of an optimised interior point algorithm.

For some reason however, you still just love working and coding in Windows. So you opt for a Cygwin installation to further that amazing piece of software you have tapped your blood for the past couple of weeks.

After following the reasonable SDPA 7.3.1 installation instructions you are greeted with one of those wonderful compile fail messages:

/usr/lib/gcc/i686-pc-cygwin/4.3.4/libgcc_s.dll.a(_chkstk.o):/gnu/gcc/releases/packaging/4.3.4-3/gcc4-4.3.4-3/src/gcc-4.3.4/libgcc/../gcc/config/i386/cygwin.asm:48: multiple definition of `__alloca'
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../libcygwin.a(t-d000121.o):(.text+0x0): first defined here

/usr/local/gfortran/lib/gcc/i686-pc-cygwin/4.5.0/libgcc.a(unwind-sjlj.o): In function `_Unwind_SetGR':
/home/jerry/gcc/objdir/i686-pc-cygwin/libgcc/../../../trunk/libgcc/../gcc/unwind-sjlj.c:204: multiple definition of `__Unwind_SetGR'

sdpa-sdpa_exe.o:sdpa_exe.cpp:(.eh_frame+0x12): undefined reference to `___gxx_personality_v0'
./libsdpa.a(libsdpa_a-sdpa_call.o):sdpa_call.cpp:(.eh_frame+0x12): undefined reference to `___gxx_personality_v0'

Don't stress, be calm. First extract libgfortran.a with

ln -s /usr/local/gfortran/lib/gcc/i686-pc-cygwin/4.5.0/libgfortran.a /usr/local/gfortran/lib/libgfortran.a

Then simply edit $HOME/sdpa/sdpa/sdpa.7.3.1.src/Makefile by changing

FLIBS = -L/usr/local/gfortran/lib/gcc/i686-pc-cygwin/4.5.0 -L/usr/local/gfortran/lib/gcc/i686-pc-cygwin/4.5.0/../../.. -lgfortran -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32

to

FLIBS = -L/usr/local/gfortran/lib -lgfortran -luser32 -lkernel32 -ladvapi32 -lshell32

and make again. All should be well in winux land.