Monday, March 19, 2012

Disable "browser back" and "browser forward" keys in gnome

My lenovo thinkpad has keys above the left and right arrow keys, that by default are wired to my browser's "forward" and "back" buttons.  This is a horrible idea, because it means that frequently I'll accidently hit them while entering text in a textbox, and lose all my edits when the browser leaves the page.

This fixed it for Ubuntu Lucid (running gnome):

System ... Keyboard Shortcuts ... Add ... Name: Do nothing ... Command: /bin/true ... Apply ... click in the "Shortcut" column for the newly created shortcut ... press the browser back button.

It should display as "XF86Back".  Now repeat, creating another shortcut for XF86Forward.  Problem solved!

Monday, March 05, 2012

mbw MCBLOCK test results (used to be) bogus

Update: Andras updated mbw to fix this.

I was testing a machine's memory performance, and ran across the "mbw" package in Ubuntu lucid.

$ mbw -a -n 1 1024
...
0 Method: MEMCPY Elapsed: 0.23493 MiB: 1024.00000 Copy: 4358.801 MiB/s
0 Method: DUMB Elapsed: 0.16298 MiB: 1024.00000 Copy: 6282.864 MiB/s
0 Method: MCBLOCK Elapsed: 0.08543 MiB: 1024.00000 Copy: 11986.562 MiB/s

I was curious why the MCBLOCK numbers were so much higher than the others, and this led me to the relevant piece of code:


                for(t=0; t < array_bytes; t+=block_size) {
                        c=mempcpy(b,a,block_size);    
                }
                if(t > array_bytes){
                        c=mempcpy(b,a,t-array_bytes);
                }

Which appears to be completely broken.  The mempcpy(b, a, block_size) call does exactly same thing every time.  All I can figure is that the author either was trying to demonstrate cache performance, or fumbled an attempt to do the memcpy() calls on blocks of block_size each.

Anyway, it's a good reminder of Caveat Emptor when using random benchmarks.

Wednesday, February 29, 2012

Rip audio CDs in ubuntu Lucid

Sound Juicer couldn't seem to find the track info for my CDs, but https://help.ubuntu.com/community/CDRipping also mentions asunder, which works great.  It also will encode to both flac and ogg at the same time.

Thursday, February 23, 2012

Copying files to Galaxy Nexus from Ubuntu

Wow, what a pain.  MTP support in lucid is broken, or at least incredibly slow for galaxy nexus.  PTP works okay with nautilus / gphoto2, but is also painfully slow.  The various ssh servers all seem to be broken (I just get connection timed out errors when I try to ssh in).

Ultimately I ended up installing the "SwiFTP" ftp server app (ugh! plain ftp with no security!), but it worked great over wifi.  I even managed to mount it using curlftpfs as root:

curlftpfs -o allow_other,user=username:password ftp://username@192.168.1.70:2121 /mnt/GalaxyNexus

With that done, I could use rsync to copy some music over:

rsync -T /tmp -rv --progress --exclude='*.wav' --exclude='*.flac' . /mnt/GalaxyNexus/sdcard/Pictures/music/

(The -T /tmp was necessary since curlftpfs doesn't seem to allow creating temp files)

Wednesday, February 01, 2012

RobotShop sucks

robotshop.com's customer service sucks.  I paid extra for 2-day shipping, and 4 days later they emailed me back asking for my social security number.  I had to work out on my own that it (probably) wasn't an identity theft scam, but something to do with import duties (they ship from Canada), because they didn't give any reason why they wanted it.

So I sent them my company's taxpayer ID, and the next day I get a voicemail asking me for it once again.  So we're almost a week on, it still hasn't shipped, and they're apparently not even reading their email.  Ugh.

Friday, January 27, 2012

Repeated strings in bash

I just whipped up a little bar graph in bash using this trick: printf '=%.0s' $(seq 10)

A more complete example, using some file with lines containing a date string:

for d in {17..27} ; do
  N=$(grep 2012_01_$d /tmp/somefile | wc -l)
  echo -n "Jan $d: $N "
  printf "=%.0s" $(seq $N)
  echo
done
Jan 17: 28 ============================
Jan 18: 22 ======================
Jan 19: 43 ===========================================
Jan 20: 32 ================================
Jan 21: 0 =
Jan 22: 0 =
Jan 23: 46 ==============================================
Jan 24: 50 ==================================================
Jan 25: 50 ==================================================
Jan 26: 51 ===================================================
Jan 27: 41 =========================================

(Breaks for 0, as you can see)

If you're doing it for constant numbers, you can use {1..10} instead of $(seq 10), but {1..$N} doesn't seem to work.

Friday, January 06, 2012

Creating spectrograms in Linux using a ColorMunki


The software that comes with the ColorMunki Photo is windows-only and is only about calibrating displays and printers.  I wanted to get spectrograms out of it so that we can measure lighting and transmissive materials -- a chart of wavelength vs. intensity.  BTW, check the argyll docs before you buy a ColorMunki -- apparently several of the models are the same hardware priced differently.

Install the argyll ubuntu package, then use the spotread command to take readings.  The -S flag will display a graph after each reading.  Other flags let you set which mode to use -- it has its own light for lighting a surface and measuring the reflected color, or you can have it read ambient light through a diffuser, or do spot readings without the light.  I used -e to take spot readings.

It also prints out a list of intensities at regular wavelength intervals, so that should be easy to import into a spreadsheet for making your own charts.

Here's an example of a chart that spotread produced: