MathJax

SyntaxHighlighter

Highlight

Custom CSS

Thursday, October 25, 2007

DbUnit gotchas on inserting data

If you have an XML dataset that looks something like this:

<orders id="1" date_paid="2000-07-01"/>
<orders id="2" date_paid="2000-04-01" date_voided="2000-04-02"/>
<orders id="3" date_paid="2000-03-01" date_voided="2000-03-02"/>
<orders id="4" date_paid="2000-02-01" date_voided="2000-02-02"/>
<orders id="5" date_paid="2000-01-02" email="test@test.com"/>

You might be stumped when you run your test and DbUnit won't insert data into the date_voided and email columns (I know I was). Apparently, DbUnit will use the first <orders> element as a template (eg insert into orders(id, date_created, date_paid) values(...)), thus ignoring the other columns. The solution is to change your first element to make all the relevant columns null or some default value:

<orders id="1" date_paid="2000-07-01" date_voided="[null]" email="[null]"/>

Ambiguous MySQL error messages

I got this error message from MySQL the other day:

ERROR 1025 (HY000): Error on rename of './mydatabase/#sql-13c8_8' 
to './mydatabase/mytable' (errno: 150)

It have been nice if MySQL told me I couldn't drop a FK without dropping both the FK constraint and the index (and in that order), but such is life. If you are running a SQL statement like this:

alter table `mytable` drop `mycolumn`;

..then you want to write this instead:

alter table `mytable` drop foreign key `myconstraint`;
alter table `mytable` drop index `myindex`;
alter table `mytable` drop `mycolumn`;

Sunday, October 21, 2007

Getting the Thinkpad T60 media buttons to work

I had originally used XFCE's keyboard preferences applet to configure this, but I found that the tpb package offers volume up/down/mute support (natively, without your needing to write your own scripts), plus it provides a neat little OSD that shows you the volume level. To do this, follow these steps:

  1. Install the tpb package via: sudo apt-get install tpb. You will be prompted to remove hotkey-setup, type y.
  2. Copy the /etc/tpbrc file to ~/.tpbrc.
  3. Edit ~/.tpbrc and look for the THINKPAD line, then change the command on the right to whatever command you want executed when the ThinkVantage button is pressed.
  4. If you have created a .Xmodmap to remap capslock to ctrl, uncomment the line that says XEVENTS OFF.
  5. Finally, make sure that the MIXER settings are all commented out and save the file.
  6. Add yourself to the nvram group via the Users and Groups applet.
  7. Edit /etc/default/tpb and change the line START_TPB="true" to START_TPB="false"; I've found if tpb starts automatically as root and you assign, say, xfce-setting-show to the ThinkVantage button, it won't be managed by your window manager.
  8. Add the following command in your Autostarted Applications applet: tpd -d
  9. Restart and try pressing the volume up/down keys

Troubleshooting: If it doesn't work, you can run tpd -v in the terminal to give you verbose output and help troubleshoot the problem. Type groups and double check that you are in the nvram group.

Update

Don't run tpb -d as root!

Wicd, for great wireless justice

I hate network-manager, wifi-radar, or anything else in the official Ubuntu repositories. All of them have their own share of annoyances and you need to enter your password to connect to a wireless network (yes I realize there are ways around it), but for an easy hassle free interface, I and 4 out of 5 other IT professionals recommend: wicd.

Enabling the framebuffer

To enable the framebuffer for high resolution text consoles (eg when your system is booting up), edit your /boot/grub/menu.lst file, and find a section that looks like this:

title   Ubuntu 7.10, kernel 2.6.22-14-generic
root    (hd0,0)
kernel    /boot/vmlinuz-2.6.22-14-generic root=UUID=fa696915-5ca5-4629-a3ee-296c7e382e2d ro quiet splash
initrd    /boot/initrd.img-2.6.22-14-generic
quiet

Add vga=791 to the end of the line that begins with kernel, so it looks like this:

kernel    /boot/vmlinuz-2.6.22-14-generic root=UUID=fa696915-5ca5-4629-a3ee-296c7e382e2d ro quiet vga=791

I usually take out the splash directive so I can actually see all the pretty high resolution text (and figure out what went wrong if something did).

Upgrading to Gutsy Gibbon

If you learn but one thing from this post, learn this: turn off your screensaver before upgrading from Feisty. You don't want what happened to me to happen to you. I left the upgrade process unintended after it started downloading all the files for the install, and when I came back, my screensaver was activated but I could not login. Logins had been disabled for some unknown reason; even trying to make a new login would not work. Hard drive activity had ceased, so I knew the update manager was just waiting on some input from me. Beautiful.

After doing a soft reset, I was halfway between a Gutsy install and a Feisty install. I knew the process probably crapped out as it was configuring installed packages, so after running dpkg --configure -a, I was looking good. Also, I ran the update-manager one more time, and it told me I had an unfinished partial installation, and finished it up for me. Despite running Gutsy smoothly, that nagging feeling in the back of my mind that tells me to use Gentoo is getting stronger.

Update

I also noticed I had to add thinkpad_acpi to my /etc/modules after upgrading, otherwise my fan would not work.

Update

You'll also want to update your 3rd party sources. I use Medibuntu and Wine, and their sources can be updated adding the following lines in /etc/apt/sources.list:

# Medibuntu multimedia packages
# GPG key: 0C5A2783
deb http://packages.medibuntu.org/ gutsy free non-free
#deb-src http://packages.medibuntu.org/ gutsy free non-free

# Upstream Wine
# GPG key: 387EE263
deb http://wine.budgetdedicated.com/apt/ gutsy main
deb-src http://wine.budgetdedicated.com/apt/ gutsy main

Update

VMware doesn't work anymore :( You can download the Gutsy version of VMware here.

Friday, October 12, 2007

Viewing source in Firefox with any editor

You can use any editor you want to view source code in Firefox. Just type about:config in the location bar, and change these values:

view_source.editor.external = true
view_source.editor.path = /usr/bin/gvim

Change /usr/bin/gvim to whatever you like.

Tuesday, October 9, 2007

Module r818x causes Ubuntu Feisty to freeze

If you have an SMP kernel (likely, as the linux-image-generic package is installed by default), the r818x is likely to freeze Feisty when using your wireless card. I found this out through trial and error with my DLink card, and there are only two possible fixes.

One is to download the WinXP driver and use ndiswrapper to install it. This isn't the route I chose, but to do it, just download the WinXP driver, and run:

ndiswrapper -i 
ndiswrapper -l

If the driver and hardware show up after the last command, you're in business. Just edit /etc/modules and add ndiswrapper to that list of modules.

The second way to do it is simply to use a non-SMP kernel, like linux-image-386, which is what I did, because I only have one processor on that machine.

Saturday, October 6, 2007

How to fix double click for Java applications in Xubuntu

No matter how I tweak the mouse sensitivity settings in Xubuntu, the changes aren't reflected in Java applictions I run. This creates ugly problems in IDEA and Netbeans because I can't open files. The fix is to edit the ~/.Xresources and add:

*multiClickTime: 400