Archive for

March, 2011

...

Have You Ever Tried to Sell a Diamond?

no comments

After reading it several years ago, I finally managed to find back Edward Jay Epstein’s fascinating story about De Beers, Oppenheimer, and the diamond trade over the last 150 years. His book “The Rise and Fall of Diamonds“, is unfortunately out of print, though. “New” editions starts at $200 at Amazon, but maybe I’ll pick up a used one.

Also worth reading is his article “Have You Ever Tried to Sell a Diamond?“.

Limewire Being Sued For 75 Trillion

no comments

It’s slightly old news by now, but still worth laughing about: “13 record companies are trying to sue Limewire for $75 Trillion“. According to Google, the sum of all GDPs in the world was $58 trillion in 2009. The lower end of their claim is $400 Billion, or a bit more than the GDP of Norway. Even the judge calls the numbers absurd.

Interacting with the Button Pad Controller SPI

4 comments

By popular request, here’s an update to the first code for the Button Pad Controller SPI. This sketch now includes interactive feedback, in the form of changing colours based on key-presses.

Click view full size image.

Click to view full size image.

Click to play video.

Click to play video.

Download the sketch here.

// The wires
#define CS 10
#define MISO 11
#define MOSI 12
#define SCK  13

// Frame buffer for lights
int lights = 16;
int depth = 3;
byte buf[16][3];

boolean wait = false;
boolean ready = true;

void setup() {
  pinMode(CS, OUTPUT);
  pinMode(MISO, OUTPUT);
  pinMode(MOSI, INPUT);
  pinMode(SCK, OUTPUT);

  digitalWrite(CS, LOW);
  delay(100);

  blank();

  Serial.begin(9600);
  Serial.println("Starting");
}

void blank() {
  // init frame buffer
  for(int l = 0; l < lights; l++) {
    for(int d = 0; d < depth; d++) {
      buf[l][d] = 0;
    }
  }
}

void loop() {
  digitalWrite(SCK, HIGH);
  digitalWrite(CS, HIGH);
  delayMicroseconds(15);

  // Set lights: 3 x 16 bytes
  for(int d = 0; d < depth; d++) {
      for(int l = 0; l < lights; l++) {
        writeByte(buf[l][d]);
      }
  }

  if(!ready) {
    wait = true;
    ready = true;
  }

  // Read the buttons: 16 bytes.
  for(int l = 0; l < lights; l++) {
    // readByte returns a non-zero value when a button is pressed.
    byte b = readByte();

    // If a button is pressed, change the colour.
    if (b > 0 && ready && !wait) {
      if      (buf[l][2] > 0) { buf[l][2] = 0; }
      else if (buf[l][1] > 0) { buf[l][1] = 0; buf[l][2] = 255; }
      else if (buf[l][0] > 0) { buf[l][0] = 0; buf[l][1] = 255; }
      else {                                   buf[l][0] = 255; }

      Serial.print("Button ");
      Serial.print(l);
      Serial.print(": ");
      Serial.print((int)b);
      Serial.println();

      // Change colours slowly.
      ready = false;
    }
  }

  digitalWrite(CS, LOW);

  // After the second cycle, get ready to read new button clicks.
  if(wait) {
    delay(500);
    wait = false;
    ready = true;
  }

  delayMicroseconds(400);
}

// Write out a byte.
// This is for a single colour channel, for a single button.
void writeByte(byte data) {
  for(int i = 0; i < 8; i++) {
    digitalWrite(SCK, LOW);
    delayMicroseconds(5);

    digitalWrite(MISO, (data & (1 << i)) >> i);
    delayMicroseconds(5);

    digitalWrite(SCK, HIGH);
    delayMicroseconds(10);
  }
}

// Read a byte.
// Returns the value for a single button.
// Non-zero if it is pressed, or 0 otherwise.
byte readByte() {
  byte result = 0;
  for(int i = 0; i < 8; i++) {
    digitalWrite(SCK, LOW);
    delayMicroseconds(5);

    result += (!digitalRead(MOSI)) * i;
    delayMicroseconds(5);

    digitalWrite(SCK, HIGH);
    delayMicroseconds(10);
  }

  return result;
}

Arduino for Fedora

no comments

It’s old news, but I missed that the Arduino IDE now is available in the Fedora repository, since Fedora 13.

sudo yum install arduino

You might also have to include your user in some additional groups:

sudo usermod -a -G uucp,dialout,lock $USER

Should you still have problems with messages like “How can I use Lock Files with rxtx? in INSTALL”, setting the permission on /var/lock might help:


sudo chgrp uucp /var/lock
sudo chmod 775 /var/lock

Firefox, Fedora & Ubuntu: Disabling notifictaions

1 comment

Notifications (a.k.a. OSD) is one of those UI features which seems fancy at first, but quickly gets in your face. Possibly originated on the Mac, the annoyance has now spread to Firefox, Fedora and Ubuntu as well. Here’s how to quickly switch them off:

Firefox

Enter about:config in the location bar. Search for this preference, and double click.
browser.download.manager.showAlertOnComplete

Fedora and Ubuntu

sudo mv /usr/share/dbus-1/services/org.freedesktop.Notifications.service /usr/share/dbus-1/services/org.freedesktop.Notifications.service.disabled

IBM patent on inteligent Teddy Bears

no comments

IBM has filled a patent application for Teddy Bear AI which will help in the upbringing up a child. There are of course a number of issues with this, and you’d think there was enough prior art? Anyway, what will all the bears and other cuddly toys on Facebook say?

ATI Graphics Driver on Fedora 14

3 comments

I finally got around to installing the video card driver for my onboard ATI Radeon HD 3200 (on an Asus M3A78 PRO). Earlier, this involved manual download and even compilation. However, now, the driver is in the RPMFusion non-free repository (see Fedora 14 installation post for details on getting that).

All I had to do, was to install the package, and run the proprietary Catalyst Control Center to configure the screen.


sudo yum install xorg-x11-drv-catalyst
sudo amdcccle

Note that for a single desktop over dual displays, you’ll have to enable Xinerama under Display Options. Before you do that, confirm that the driver and card works with dual display over multi-desktop.

While you’re working with this, you might have to restart X a few times. Instead of rebooting the whole machine, you’ll save a lot of time by booting into runlevel 3 instead. Edit /etc/inittab, and swap 5 for 3. Remember to set it back once you’re done.


sudo emacs /etc/inittab


#id:5:initdefault:
id:3:initdefault:

glxgears now gives a FPS count around 1550, which is significantly better than the 60 FPS without the driver. It was a bit embarrassing when the my mobile (MeeGo on Nexus S) had a higher count than my desktop.

Moo Cards and QR Codes

5 comments

I’m definitely not the first to think of adding a QR code, to my Moo business cards. There are some neat examples out there, including stickers, and mini cards. But how to generate the code, and make sure it works with your phone. I’ll briefly go through both steps here.

Background and History: QR Code
From the patent on barcodes in 1948, it was a long road to the first Universal Product Code in 1974. The first matrix (2D) based code appeared in 1992, called Code 1. The QR Code was created by Toyota subsidiary Denso-Wave in 1994. While in 1995, another 2D code, the Aztec code was invented, and published in public domain in 1995. Another popular format is the Data Matrix.

All these standards only define the physical layout of the code (or modules), though. NTT Docomo has established a de-facto encoding standard, and MSKYNET (that name might worry some) has formalized that in the SPARQCode. This standard includes the MECARD from NTT Docomo, and the older vCard business card format.

As the vCard pre-dates the MECARD format, this might be the only supported by older phones. In particular, Nokia has used vCard to exchange phone book information over SMS, IR and Bluetooth for many years. Thus, it might be a safer bet to encode in that. The Android ZXing reader can read both.

Generating the QR Code

There are several QR code generators out there. ZXings own worked well for my purpose. However, by default, it encodes using the MECARD format. That means, you’ll first have to generate your information on vCard. There are several of those generators out there was well, but the easiest might just be to look at the documentation on Wikipedia.

The point is, you can cut some of the cruft the generators add. The essential properties include: N, FN, TEL, EMAIL, and URL. In the end, you might end up with something like this. Notice how the name is duplicate in the FN and N attribute. That is to allow different phones to pick up the name regardless of which format they expect.

BEGIN:VCARD
N:Doe;John Michael
FN: John Michael Doe
TEL:+123456789
EMAIL:john@example.com
URL:http://example.com
END:VCARD

Once you have the vCard encoding, select “Text” contents in the ZXing generator, and paste in the vCard text. Generate a large image. You’ll get something like this.

Designing your QR Business Card
The size of the generated image will depend on the amount of information you put in, and the size you choose to generate in. Note that you can manually tweak the URL to Google’s Chart API above. The first attribute, chs defines the size pixels (it’s always square).

You want your business card to work flawlessly, so it’s important to make sure the QR Code is clear. It is done by making it as large as possible, and pay attention to the physical size of each square (module) of the code. At Denso-Wave, they recommend at least 4 dots per module. At 300 dpi, that is 0.33 mm per module.

The size of the business card at Moo is 84mm x 55mm, and the recommended resolution for uploaded images is 1039 x 697 pixels. Taking the trim into account, that corresponds to 300 dpi. Make sure your code does not exceed the trim area, though. It is about 5% on either side, which means you have 939 x 597 pixels left to play with. At four pixels / module, that gives you a maximum size of the code of 149 modules. That is a lot. Increase the size to six, and you’re limited to 99 modules. The example above used only 41 modules, and at 350 pixels it had seven pixels / module. That should be picked up relatively easy by all readers.

Reading the code

On the Android phone, you’ll find the ZXing app in the Market. Or you can download directly from the source. For other phones, including Nokia, there’s the Kaywa Reader. It can be downloaded both directly from your phone, and from their web site.

Personal Fedora 14 Installation Guide

1 comment

Although a bit delayed, here’s the Fedora 14 installation tips. Based on Mauriat Miranda’s guide. Assuming you’ve gotten the DVD, and installed a fresh system, here’s the initial steps to make you feel comfortable. (This is all based on a 64 bit machine).

Initial update
Assuming you’ve installed from a pre-built DVD, you’re initial install will be somewhat out of date. Always do an update before trying to fix or add other stuff.


yum -y update

Third Party Repositories
You’ll need them for various patent encumbered libraries and apps, for playing MP3, DVD, etc.

sudo rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
sudo rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Main packages
Here’s my personal selection of packages for work and leisure.


yum -y install ant arj audacity autopano-sift-C bash-completion digikam dosbox dvdauthor dvgrab easymock easytag emacs enblend flash-plugin geeqie gimp git gitk gnome-mplayer gnome-volume-manager gnucash gstreamer-ffmpeg gstreamer-plugins-ugly gthumb gtkpod htop hugin ImageMagick java-1.6.0-openjdk java-1.6.0-openjdk-javadoc java-1.6.0-openjdk-plugin java-1.6.0-openjdk-src k3b-extras-freeworld kdebase kdegraphics kdiff3 kino kover ktorrent lame-mp3x libcddb libdvdcss liberation-fonts-common liberation-mono-fonts liberation-narrow-fonts liberation-sans-fonts liberation-serif-fonts mencoder mjpegtools mozplugger mp3gain ncftp obexfs OpenEXR OpenEXR_Viewers openoffice.org-calc openoffice.org-writer parcellite pidgin-otr qemu-launcher qtpfsgui quicksynergy rdesktop samba subversion thunderbird thunderbird-lightning transcode ufraw ufraw-gimp unrar vcdimager vdr-mp3 vlc w3m wine wireshark-gnome xine xine-lib-extras xine-lib-extras-freeworld xmms xmms-faad2 xmms-mp3 xmms-pulse

Extras
MPlayer Codecs

wget -O /tmp/all-20110131.tar.bz2 http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20110131.tar.bz2
mkdir -p /usr/lib/codecs
tar -jxvf /tmp/all-20110131.tar.bz2 --strip-components 1 -C /usr/lib/codecs/

DVD Playback

wget -O /tmp/libdvdcss-1.2.10-5.fc14.x86_64.rpm http://dl.atrpms.net/all/libdvdcss-1.2.10-5.fc14.x86_64.rpm
wget -O /tmp/libdvdcss2-1.2.10-5.fc14.x86_64.rpm http://dl.atrpms.net/all/libdvdcss2-1.2.10-5.fc14.x86_64.rpm
yum --nogpgcheck localinstall /tmp/libdvdcss2-1.2.10-5.fc14.x86_64.rpm /tmp/libdvdcss-1.2.10-5.fc14.x86_64.rpm

Skype
(Thanks to Riccardo Riva)


wget -O /tmp/skype-beta-fc10.i586.rpm http://www.skype.com/go/getskype-linux-beta-fc10
yum install -y qt-x11.i686 libXScrnSaver.i686 alsa-plugins-pulseaudio.i686
yum install --nogpgcheck -y /tmp/skype-beta-fc10.i586.rpm

Install Google Chrome with YUM on Fedora 14

1 comment

Over at “if !1 0“, they have a straight forward how-to for installing Chrome from a repository in Fedora 13 or 14. All you have to do is add a repository file, and install.

If you want to use the built in version of Flash, you’ll need the 32 bits version and repository. Also note, that you’ll have to do an update after the initial install, as the latest version is NOT automatically installed at once.

emacs /etc/yum.repos.d/google.repo

[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

[google64]
name=Google - x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

yum install google-chrome-stable
yum update google-chrome-stable

* For 32 bits, if installing on a 64 bit machine:

yum install google-chrome-stable.i386
yum update google-chrome-stable.i386
yum install libpk-gtk-module.so libcanberra-gtk-module.so libasound_module_pcm_pulse.so

Bad Behavior has blocked 114 access attempts in the last 7 days.