Skip to content

Talk: Short introduction to Rainbowduino and mtXcontrol

July 23, 2011

I gave a short talk at Hack and Tell in Berlin. I briefly introduced the Rainbowduino device and my work on mtXcontol. Watch me here:

Here are the slides:

Thanks to David for recording!

Optical Illusion: a non straight line of code?

June 24, 2011

A bit of fun: Look at this, a Screenshot I took ages ago and just found to share. It’s taken from a piece of code I was writing within jEdit by that time.

It totally looks like the two long line go up, but if you apply a ruler, you see, it’s indeed straight:

A optical Illusion - weird, right?

Short Introduction to Rails

May 10, 2011


Overview useful components:

Must haves:

  • homebrew /macports
  • git
  • rvm

Load RVM extensions + completion

    [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
    [[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion

create proj folder:

 $ mkdir  'test'

create .rvmrc

  $ rvm use ruby-1.9.2-rc2@test --create

Init git

  $ git init

Interesting gems:

  rake (0.8.7)
  bundler (1.0.7)
  cheat (1.3.0)
  gemedit (0.9.0)
  gist (2.0.0)
  git (1.2.5)
  hirb (0.3.5)
  jeweler (1.5.1)
  what_methods (1.0.1)
  wirble (0.1.3)
  awesome_print (0.3.1)

Useful commands:

  • rails gems
    $ gem install rails
  • create rails project
    $ rails new . -d mysql -J
  • check Gemfile for needed gems
    $ bundle install
  • check DB file
cp database.yml database_example.yml
  $ cat 'db/database.yml' >> .gitignore

getting started

Scaffold: rails g scaffold Sentence text:text type:string language:string Database: rake db:migrate See all rake commands: rake -T

Rails console

  • reload!
  • _ show last result
  Sentence.find( :first)
  Sentence.find( :first, :conditions => {} )

## AEL

Sentence.first.where( :language => 'de' )
 Sentence.where( :language => 'de' ).order("RAND()").limit(1)

HowTo: ultra mega fast rails routes lookup

March 16, 2011

I was quite annoyed by the wasted time it took each time I grep the rails routes table.
Wait, can’t this be cached? - Sure it can!
So I came up this nice little alias to cache the output once:
` alias route=’CF=tmp/routes_cache; [[! -s $CF]] && rake routes > $CF; cat $CF | grep ‘ `

now it’s ultra fast, try e.g.:
` $ route root `

HowTo: parse invalid, irregular HTML having < or unlcosed tags

February 03, 2011

I had the ‘problem’ that user feedback included lot of love - mostly by writing ‘hearts’. Unfortunately expressing hearts is done by ‘<3’ which turns the input into invalid HTML. Bummer. So if you still want allow other basic tags, you have a problem. Here’s how I solved it:

First I checked Stackoverflow - Tian had similar problem over there: Nokogiri: Parsing Irregular “

As a quick fix I came up with this method using a reqular expression to identify unclosed tags:

def fix_irregular_html(html)
regexp = /]*)(

#we need to do this multiple time as regex are overlapping
while (fixed_html = html.gsub(regexp, “<\1\2”)) && fixed_html != html
html = fixed_html


See full code including test here:

It works out well for me, I appreciate any feedback and improvements

See full code and test here:

Mac OS X Terminal: visual indication for your ssh connection

January 14, 2011

Here’s a HowTo for a nice visual indication to see quickly if your Mac OS X Terminal is running which ssh connection.

The trick is to change your Terminal Theme before you ssh and change it back afterwards.

1. Create Theme:
got to Terminal -> Preferences -> Settings create a new theme (or copy existing one) and adjust to your needs, e.g. a light red background etc. Give it a nice name e.g. “SSH-Theme”

2. Add this function to your .bashrc

function tabc() { NAME=$1; if [-z "$NAME"]; then NAME="Default"; fi osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\"" }

“Default” is my default Terminal theme, name this whatever u have

tabc SSH-Theme #switch to theme with name tabc #switch to default theme

3. Create alias to ssh to server:

alias sshmyserver="tabc SSH-Theme; ssh; tabc"

That’s it - your are done! Now, if you type sshmyserver, your Terminal color will change, ssh will start, and when you end ssh, everything will be back again..

Btw. for Terminal on Mac OS X, I very recommend Visor - a quake like console


That’s how you do it with iTerm:

function tabc() { COLOR=$1; if [-z "$COLOR"]; then COLOR="{0, 7722, 9941}"; fi osascript -e "tell application \"iTerm\" to set background color of current session of current terminal to $COLOR" }

alias sshmyserver=”tabc ‘{18000, 2500, 2500}’; ssh; tabc”

cubeXcontrol - a Rainbow Cube Editor

December 31, 2010

Please express your Love and vote for cubeXControl here - Thanks!

Apparently the current Version doesn’t work with Windows. I’m very sorry for that, but at the moment I don’t have any Win machine to test this. So please feel free to try yourself and fix it! Thx!

I’m proud to present a first version which was on my this years TODO list for so long, but due to all the changes therefore very less time never got startet. But thanks to the Seeedstudio Rainbowduino Carnival 2010 I got a big motivation boost and found some time to get my fingers dirty again. So check this out, my this years contribution for the carnival:

cubeXcontrol - a Rainbow Cube Editor

Well, you know the mtXcontrol, the Rainbowduino Editor and the awesome Seeedstudio Rainbow Cube I mentioned here ? Now it’s time  to bring them together:

cubeXcontrol is an editor to control and create patterns for the 4x4x4 RGB Rainbow Cube powered by a rainbowduino. It comes with an extra window showing a 3D model of the Cube, allowing to rotate in all directions and to zoom. Click on boxes to set the LED color easily.

The editor is of course heavily based on the latest mtXcontrol version, with the latest rainbowduino firmware. Both are unfortunately still in beta stage, but come with great new features like auto port detection.

Get the sources here:

And the Rainbowduino driver:

Happy cub’ing!

AppleScript to create keyboard shortcuts

October 29, 2010

Last week my company laptop got stolen, so I had to setup my system again using this list. The positive part of each new system setup is you think more and more how to automate your setup..

This time I was really annoyed with setting up keyboard shortcuts, so I came up with this little AppleScript which does the work:

[gist id=652031 file=create_shortcuts.scpt]

The key is ‘GUI scripting’ - a specify way of AppleScript to simulate clicks, keystrokes etc. for *any* (native?) App. You only have to know the ids of the GUI elements which you can get with this very nice tool:

Good source to start your Mac Os X Automation is:

What? - irb extension gem to find your methods

September 24, 2010
If Samuel just would have asked me, I got an answer:

Oldies, but Goldies: ‘Methodfinder’ is a really nice extension for your ruby/rails irb and shipped with the ‘what_methods’ gem. I’m using quite a lot and can’t go without it anymore (aka. I’m too stupid to remember all those method names ;-).

gem install what_methods

See more hints by Dr. Nic blog here

mtXcontrol sneak preview - rainbowduino beta library goes master and slave

September 05, 2010

Now, as I’m finally getting settled, it’s time to kick of mtXcontrol development again. So first, I’ll continue working on the raw rainbowduino interaction which is the firmware, a communication protocol and a processing library, all summerized in the Processing library -Rainbowduino-. Current development going on, here, check it out. It’s still in a beta state, but ready and good for testing.

Just to make you curious here some new cool upcoming features:
* support for multiple & cascading Rainbowduinos
* auto port detection
* plug and play
* (auto) firmware upload
* Rainbow Cube support
* updated, more robust protocol

The video above show a quick preview of the upcoming Rainbowduino Firmware release ‘Master and Slave’.

You see two Rainbowduinos, the left one as Master connected via Serial to Mac, the right one as Slave connected via I2C to master. The blinking LEDs are merely debug output, interesting part is the changing brightness of the slave. The command to change brightness is send via Serial, received by the master and forwarded to the slave via I2C. With that multiple rainbowudinos can be connected in a row easily.

And the Best: both run the same(!!!) firmware. The master/slave role and I2C address are auto detected on startup. As easy as that!

Stay tuned!!

SoundCloud it is....

September 02, 2010

After having enjoyed a wonderful summer with lot of travels and being in more or less ‘offline’ mode, I’m back ‘online’ and I started my new Job at

It’s like Fickr but for Music - upload your tracks and share them among the community and fans.

It’s kick ass! ;-) Take a look around the office, check this out:

Oauth-CLI - test your Twitter and other OAuth APIs easily

July 01, 2010

By the time I was working at Qype, I often had to deal with OAuth APIs. Doing example request works to a certain point quite good with a Plugin the for Firefox. But when it comes to Authorized or POST Request you’re stuck!

So I developed a tiny command line client, which allows you to send request easily. It comes as a gem and easily to install:

gem install oauth-cli

After installation, execute oauthc. You either make onetime calls, with giving all required data as parameter, or just go into interactive mode, to get a shell for multiple calls and history. For not stating all connection data over and over again, it comes with multiple profile support, a wizard to create those easily and presets for Twitter and Qype.

See this nifty example call:
oauthc -p twitter get statuses/friends.json

I hope you like it - Bug reports, suggestions, updates go to:

See Readme:

See Source:

Skypehotdeploy - How to autocommit & deploy a file

April 27, 2010

At Qype we had the problem of a college sending me a file which needed to get into the development trunk and updated on the production system. Problem was, he had

Skype auto accept file,

folder action on download folder.

my hotdeploy()

on adding folder items to this_folder after receiving these_items
my hotdeploy()
end adding folder items to

on hotdeploy()
set usr_home to “/Users/tobiasb/”
set prj_folder to usr_home & “Sites/qype_admin/”
set filename to “report_queries.yml”

set srcs to usr_home & “Downloads/” & filename
set dest to prj_folder & “config/” & filename

tell application “Finder” to set file_exists to exists srcs as POSIX file
if file_exists then
say “here we go”
do shell script “mv “ & srcs & “ “ & dest
set diff to do shell script “/opt/local/bin/svn diff “ & dest
if not diff is equal to “” then
#set commit to “/opt/local/bin/svn ci –quiet -m’SkypeAutoCommiter: updated report queries’ “ & dest & “;”
#set hotdeploy to “cd “ & prj_folder & “; /usr/bin/cap production qype:hotdeploy FILES=config/” & filename & “;”
#set out to commit & hotdeploy
set out to do shell script “/Users/tobiasb/bin/”
my message(“done”)
say “done”
my message(“no changes”)
end if
return “no file”
end if
on error the error_message number the error_number
my message(“error”)
say “error”
set the error_text to “Error: “ & the error_number & “. “ & the error_message
display dialog the error_text buttons {“OK”} default button 1
return the error_text
end try
end hotdeploy

on message(msg)
tell application “Skype” to send command “MESSAGE justalii SkypeAutoCommiter: “ & msg script name “to Alli”
#say msg
end message

My Snow Leopard (Development) System: Ruby, Rails, Arduino & Co.

April 27, 2010

- updated to Lion -

Here’s a (maybe incomplete) list of my Mac OS X Development system setup. Mainly for me to remember, but maybe a help for you too:

Main Development Setup
Snow Leopard Lion
xCode (or latest iPhone SDK)
Mac Ports, now I prefer Homebrew
Ruby: rvm + rubygems + rails etc.
Database: Mysql 5.1 + Sequel Pro
OpenVPN: Tunnelblick, or Cisco VPN client + Shimo VPN Menubar Addon
Terminal Console Extension: SIMBL + Visor iTerm 2
TextMate + Missing Drawer + Get Bundles + Rails + AckMate
jEdit + FTP + …
Git + GitX (Experimental)
FTP & Co: Cyberduck
Hudson status: CCMenu
Share Files: Dropbox
Google Chrome
Firefox + Firebug

Extended Development

Nice to have:
System Notification: Growl + Growl Mail
Read RSS: NetNewsWire Now using RSS within Apple Mail
IRC Client: Colloquy and hide join messages Adium
Skype and Tweetie original Twitter client
Control iTunes: SizzlingKeys Bowtie
Spotify and Spotify Menubar and more goddies iScrobbler
All Codecs: Perian
Dasboard widgets: IP + App Update
Copy&Paste History: Flycut
Track Work: MacTimeLog
Word replacement: iWork
Keep your Notes: Journler
Extend Finder: TotalFinder
Mail Archiver and other MailPlugins

Install hints
mac ports
sudo port selfupdate sudo port install git-core +svn +bash_completion sudo port install ImageMagick +no_x11 sudo port install wget

ruby gems
sudo gem self update sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config sudo gem install rails sudo gem install passenger sudo gem install piston

Safari open always in tabs:
defaults write TargetedClicksCreateTabs -bool true

Safari enable Development mode:
defaults write WebKitDeveloperExtras -bool true defaults write IncludeDebugMenu 1

Safari Plugins:

TextMate install bundle
cd ~/Desktop && svn co <>

Well, that’s it! Stay tuned for updated…

BCD3000 Djay Midi Mappings

April 02, 2010

Some while ago I bought this nice Midi Controller BCD3000 by Behringer. It’s an easy to use device which brings way more fun mixing your MP3. For easy party playing mode I very like Djay, which is a simple but very powerfull mixing software. It now support Midi devices as well!
Unfortunately I couldn’t find any predefined Midi Mappings for Djay and BCD3000. So I created my own. Please download the file here. For now, all basic features are mapped, I may add sophisticated ones soon. It’s hosted on github, so please fork it and add you changes.

Happy DJing!