Skip to content

Ruby Serialport and Arduino - that's easy!

May 14, 2009

Yeah, just controlled my Arduino via the ruby irb console using ruby serialport. Damn easy! (well at least on a Mac, running OS 10.5.7) Hehe, soon more to come…

More to get you started with Arduino and Ruby:
http://www.arduino.cc/playground/Interfacing/Ruby

[update] Mac Os X 10.5.7 is out - all fine except volume control

May 13, 2009

Yeah Mac Os X 10.5.7 just got released. All fine for me, except my external USB soundcard Terratec Aureon 5.1 can’t be volume controlled anymore - strange!? Any idea what’s wrong?

[update - solved!]
Apparently downgrading the USB Sound kernel back to 10.5.6 Version solves the issue. See the comments and the Apple Discussion-board for more… Thx to sonderpop for that hint!

Second try: 2x5 LED Matrix Arduino controlled

April 28, 2009

This time a more sophisticated example. I started to develop an LED Matrix controller and editor in Processing (like every does his first steps on arduino, I think).
By now, you can create a sequence by selecting the LEDs to light up and move over to the next frame. Finished, run it on the Arduino and control the speed - a nice and quick toy way to create any light patterns you can think of easily.

http://www.youtube.com/watch?v=Vmijzo2zT-s

More examples and source code soon to come…

My first Arduion test: 10 LEDs running light

April 24, 2009

Check this out:
http://www.youtube.com/watch?v=irVW4U8zq_k

That my first proper Arduino test, controlling a 10 LED running light. I attached a small button via interrupt as well to start & stop the light. More to come soon, stay tuned!

Here the (very,very ugly) source code:

[c]
int ledPin = 3; // First LED connected to digital pin 13
volatile int stop = LOW;

void setup()
{
Serial.begin(38400);
for( int i = 0; i < 10; i++) {
pinMode(ledPin + i, OUTPUT);
}
attachInterrupt(0, stopit, RISING); //Button attached to Pin 2
}

int i = 0;
void loop()
{
for( i = 0; i < 7 && !stop; i++) {
blink(ledPin + i);
}
for( i; i >= 1 && !stop; i–) {
blink(ledPin + i);
}
for( i = 0; i < 10 && !stop; i++) {
blink(ledPin + i);
}
for( i; i >= 3 && !stop; i–) {
blink(ledPin + i);
}
for( i; i < 10 && !stop; i++) {
blink(ledPin + i);
}
for( i = 9; i >= 1 && !stop; i–) {
blink(ledPin + i);
}
}

void stopit()
{
delayMicroseconds(1000);
stop = !stop;
}

void blink( int pin ) {
digitalWrite(pin, HIGH);
delay(120 - abs( pin - 8 ) * 20);
digitalWrite(pin, LOW);
}
[/c]

Arduion has arrived

April 17, 2009


Here it is! Yeah, finally my Arduino (ordered at Watterott) has been delivered. Can’t wait to get my hands on it. Stay tuned for future reports!

All about this great ‘toy’ here: www.arduino.cc

I want to have an Arduino - now!

April 07, 2009

http://www.youtube.com/watch?v=PeScmRwzQho

www.arduino.cc now!

MySQL User defined Variables - good thing to know!

April 02, 2009

Have you ever heard of user defined variables in MySQL? I hadn’t and nearly freaked out when I found out. That’s the thing I was always looking for, that’s so cool, and fasten up your SQL live a lot!

Now, renumbering a table is as easy as never before:

[text]
Set @a = 0;
UPDATE my_table SET id=@a:=@a+1
[/text]

Check out the docu and examples:
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html

How to alias and create a new named scope out of existing ones

March 26, 2009

Named scopes in Rails are just awesome. They so much DRY and beautify your code! But did you ever had the trouble to create a new named_scope out of others? E.g. aliasing multiple ones to a new one. Luckily I now figured out how this works in a nice way.
The magic key is the method scope( :find )

This method called on a Scope class returns the Hash used for the ActiveRecord .find() call. First it’s a nice way to debug your scopes, second it’s perfect for our need to chain multiple scoped into one. Check this out:

[ruby]
class Fu < ActiveRecord::Base
named_scope :has_moo, :conditions => { :moo => true }
named_scope :has_foo, :conditions => { :foo => true }

named_scope :has_moo_and_foo, lambda { has_moo.has_foo.scope(:find) }
end
[/ruby]

We chain the two scoped has_moo and has_foo together into a new one called has_moo_and_foo. As the return value can only be a Hash we use the above mentioned scope(:find) to transform it into one.

Now this works:

[ruby]Fu.has_moo_and_foo.all[/ruby]

Sweet! Imagine how great this would be if we can return a scope object instead of a hash as well??

See my pastie here too.

LED Light Towers Installation

March 08, 2009

Hey, Check this out, a very nice LED tower installation:

http://www.youtube.com/watch?v=FsHMFkJkohM

see more great stuff at http://www.brilldea.com/

[via Nercode]

How to deal with recurrency in Ruby & Rails

January 21, 2009

I did a short eval of projects dealing with re currency in Ruby and Ruby on Rails. Here a short list & rough of interesting projects dealing with repeating time (intervals):

Common used lilbrary: http://runt.rubyforge.org
A better runt(?): http://github.com/nickstenning/recurring_event
Date extension, yahoo dev, rspec like: http://github.com/jhubert/ruby-date-recur

http://recurring.rubyforge.org
http://github.com/EdvardM/recurrence
http://github.com/fnando/recurrence

Check this as well:
http://stackoverflow.com/questions/85699/whats-the-best-way-to-model-recurring-events-in-a-calendar-application

Love ActiveScaffold: Show always Searchbox

October 05, 2008

ActiveScaffold is a great plugin to build edit form easily. Nicely AJAX and nested forms support (well with limits ;-). One thing which bugged me all the time, was the extra click you had to do to show the searchbox. Well I solved it like this:

[ruby]
def index
active_scaffold_config.list.label += render_to_string( :action => :search, :layout => false )
super
end
[/ruby]

I know, it’s kind of bad hack, as the label actually isn’t supposed to contain a form - but it works out quite well!

A short collection of Content Management Systems (CMS) for Ruby on Rails

July 01, 2008

Here is a short collection of current Content Management Systems (CMS) written in Ruby and mostly suited to use with Ruby on Rails. Check out Ananablau as well for a nice PDF slide.

Comatose (29. June 2007)
Comatose is a micro CMS designed for being embedded into existing Rails applications
http://railsbased.org/projects/8-Comatose.html

Geego
Geego is for developers and designers that want to provide fully updatable websites for their clients.
http://www.geegocms.com/

Mephisto (27. July 2006)
Complete Blog System, Mephisto is a publishing system that makes it super easy to setup a blog or website.
http://mephistoblog.com/

Typo
Complete Blog System, Similar to Mephisto
http://wiki.github.com/fdv/typo/

Radiant CMS
Radiant is a no-fluff, open source content management system designed for small teams.
Looks cool but no direkt RoR integration?
http://radiantcms.org/

Railfrog (3. July 2007)
Railfrog is a user-friendly, open-source website deployment and content management system built with Ruby on Rails.
dead project?!
http://railfrog.com/

Rubricks (31. July 2007)
Rubricks is a component based open source CMS powered by Ruby on Rails.
http://rubricks.org/

Seymore (04/02/2007)
Seymore is an open source content management system which integrates directly into pages.
http://www.slicedsoftware.com/software/seymore/

SimpleCMS , (29. December 2007),
small simple, inline edit. Simple CMS is a very easy to use and pretty advanced CMS plugin.
http://pullmonkey.com/2007/12/30/simple-cms-plugin-for-rails-demo

CMSPlugin
CMSplugin provides your Rails application with a “CMS framework”. That means authentication, authorization, roles, permissions, categories, tags, etc… but from a very flexible scope.
http://cmsplugin.rubyforge.org

open rcms (25.6.2007)
http://rcms.oopen.de/Home/

Roxanne
An in-place editor for your entire website. Roxanne is a simple Site-Management Tool to quickly manage your content. See first steps to get the idea behind Roxanne.
http://www.m42.ch/projects/roxanne/information.php

Substruct
The first and most robust Ruby on Rails open source e-commerce project.
http://code.google.com/p/substruct/

Goldberg (promising)
http://www.goldberg.240gl.org

Beautify your views using "return"

June 06, 2008

A nice way to keep your views clean and not to spoil them with condition clauses, is to use the ‘return’ statement like you would do in a method:

Take this very simple exmaple:

ugly:
[ruby]
unless @place

end
[/ruby]

nice:
[ruby]
return if @place.nil?

[/ruby]

UPDATE:
There’s one pitfall, I forgot to mention: Every outout BEFORE the return statement will be discarded, so this part:
[ruby]

return if @place.nil?

[/ruby]

Will result in an empty output as well. This is quite a pitty and I’m not sure if it’s a bug or feature. A may raise it soon..

SEO - Notes

January 23, 2008

This is just a list of SEO Notes I did years(!!!) ago. it’s mainly for me to remember stuff. Sorry this is in german.

guter strukturierter inhalt als text!! gute name/keywords in anker
guter individueller title, description, keywords,
interne links -> grüner, stockstreet, ompro
social bookmarks delicous, digger, mister-wong,
rss feeds -> feedburner
alt und title bei images,
h1, h2 tags
mehr css, weniger tables
check google sitemaps, analytics
linktausch! linkeinkauf!
robots.txt
keine (Wenige) params in URL
URL verlinken mit / am ende
keine frames! schon gar nicht iframes!!
eintragen in profiles flickr,
nutzen mit myspace, wikipedia, ebay, studvz, openbc, foren, protale, amazon??, blogs!!
achtung vor duplicate content!
301/302 weiterleiterungen, keine multidomains
google adsense????
achtung vor code injection -> Suchanfragen!!!!
sessionid killing
gute Kataloge nutzen: dmoz, bellnet, http://dir.yahoo.com/, http://botw.org/
finde den HUB
credit, depotrechner, howto, tutorials fancy mit ajax gut verlinken
yahoo searchbuilder, allregster.com ?? euregster.com ??

Top Words:
Poker, Datenrettung, Kredit, Privatekrankenversicherung

My first AppleScript: Copy Address Book entries

May 10, 2007

Tatataa! I just wrote my frist AppleScript. For displaying the buddypicture of my Address Book contacts in Adium, I had to copy the ICQ entry to a new Jabber enrty with appending “@jit.jabber.fsinf.de”. The code follows:

tell application "Address Book"
set thePeople to every person whose ICQ handles is not {} and Jabber handles is {}
repeat with eachPerson in thePeople
set icqnr to value of ICQ handles of eachPerson
set jabberid to (item 1 of icqnr) & "@jit.jabber.fsinf.de"
make new Jabber handle at end of Jabber handles of eachPerson with properties {label:"Home", value:jabberid}
end repeat
save addressbook
end tell

It worked out fine. Now I see you all in my buddylist ;-)