<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.local-guru.net,2005:/blog/tag/ruby</id>
  <link type="text/html" href="http://www.local-guru.net" rel="alternate"/>
  <link type="application/atom+xml" href="http://www.local-guru.net/blog/tag/ruby.atom" rel="self"/>
  <title>GuruBlog : Articles about ruby</title>
  <subtitle>local-guru.net</subtitle>
  <updated>2010-08-22T14:02:35+02:00</updated>
  <generator>GuruBlog engine</generator>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/312</id>
    <published>2010-08-22T14:02:35+02:00</published>
    <updated>2010-08-22T14:02:35+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2010/8/22/curling-animation-ii" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Curling Animation II</title>
    <category term="art" scheme="http://www.local-guru.net/blog/tag/art"/>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="animation" scheme="http://www.local-guru.net/blog/tag/animation"/>
    <category term="contextfreeart" scheme="http://www.local-guru.net/blog/tag/contextfreeart"/>
    <content type="html">&lt;p&gt;I made another animation with &lt;a href="http://www.contextfreeart.org/"&gt;Context Free Art&lt;/a&gt; and a small ruby script. The scroll down to see the sourcecode I
have used for this file. This animation uses the same technique i used for &lt;a href="http://www.local-guru.net/blog/2010/06/03/curling-recursion"&gt;my first one&lt;/a&gt;&lt;/p&gt;

&lt;object width="500" height="500"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=14333855&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=14333855&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="500"&gt;&lt;/embed&gt;&lt;/object&gt;


&lt;p&gt;&lt;a href="http://vimeo.com/14333855"&gt;Curling Recursion 2&lt;/a&gt; from &lt;a href="http://vimeo.com/localguru"&gt;Nikolaus Gradwohl&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;



</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/273</id>
    <published>2010-06-05T18:17:00+02:00</published>
    <updated>2010-06-05T18:17:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2010/6/5/blinking-logfile-map" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Blinking Logfile Map</title>
    <category term="Creativity" scheme="http://www.local-guru.net/blog/tag/30daysofcreativity"/>
    <category term="arduino" scheme="http://www.local-guru.net/blog/tag/arduino"/>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="hardware" scheme="http://www.local-guru.net/blog/tag/hardware"/>
    <category term="visualization" scheme="http://www.local-guru.net/blog/tag/visualization"/>
    <content type="html">&lt;p&gt;I always wanted to see where the readers of my blog are comming from, so I took a picture frame and inserted a world map, a handfull of leds and an arduino. Some soldering and some rubyscripts later I had my hardware geo-aware logfile visualization.&lt;/p&gt;

&lt;p&gt;I have a script running at the server that parses new ip adresses from the log file and geocodes them. Than the continent code is
sent to my mac where i have a little script that forwards the continent code to the serial port. And finally the arduino in the
picture frame is making the leds blink. The whole project was hacked together as a weekend project so the scripts might need some
"fine-tuning" :-)&lt;/p&gt;

&lt;p&gt;This is my day 5 project for &lt;a href="http://30daysofcreativity.com/"&gt;30DaysOfCreativity&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so please read my blog to make the leds blink :-)&lt;/p&gt;

&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/blinklog1.jpg" alt="blinklog" /&gt;
&lt;img src="http://www.local-guru.net/img/guru/blinklog2.jpg" alt="blinklog" /&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/271</id>
    <published>2010-06-03T10:30:00+02:00</published>
    <updated>2010-06-03T10:30:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2010/6/3/curling-recursion" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Curling Recursion</title>
    <category term="Creativity" scheme="http://www.local-guru.net/blog/tag/30daysofcreativity"/>
    <category term="art" scheme="http://www.local-guru.net/blog/tag/art"/>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="video" scheme="http://www.local-guru.net/blog/tag/video"/>
    <category term="context" scheme="http://www.local-guru.net/blog/tag/context"/>
    <category term="free" scheme="http://www.local-guru.net/blog/tag/free"/>
    <content type="html">&lt;p&gt;I made this animation with &lt;a href="http://www.contextfreeart.org/"&gt;Context Free Art&lt;/a&gt; and a small ruby script. The scroll down to see the sourcecode I
have used for this file&lt;/p&gt;

&lt;object width="500" height="500"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12259780&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=12259780&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="500"&gt;&lt;/embed&gt;&lt;/object&gt;


&lt;p&gt;&lt;a href="http://vimeo.com/12259780"&gt;Curling Recursion&lt;/a&gt; from &lt;a href="http://vimeo.com/localguru"&gt;Nikolaus Gradwohl&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;



</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/209</id>
    <published>2009-11-28T05:23:00+01:00</published>
    <updated>2009-11-28T05:23:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/11/28/set-operations-on-ruby-arrays" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Set operations on ruby arrays</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <content type="html">&lt;p&gt;Ruby provides some very interesting set operations on arrays.&lt;/p&gt;

&lt;p&gt;given the two arrays A and B wich look like this&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;A = ["A", "B", "C", "D"]
B = ["C", "D", "E"]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are three set operations we can use that union, intersection and difference.&lt;/p&gt;

&lt;h2&gt;Union &lt;/h2&gt;

&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/ruby_set_union.png" alt="union" /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;A | B
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;contains all elements from both sets without doublicates. So this
results in ["A", "B", "C", "D", "E"]&lt;/p&gt;

&lt;h2&gt;Difference&lt;/h2&gt;

&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/ruby_set_difference.png" alt="difference" /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;A - B
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;contains all elements from set A that are not in set B. So this
results in ["A", "B"]&lt;/p&gt;

&lt;h2&gt;Intersection&lt;/h2&gt;

&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/ruby_set_intersection.png" alt="intersection" /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;A &amp;amp; B
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;contains all elements that are in set A and in set B. So this
results in ["C", "D"]&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/203</id>
    <published>2009-11-07T07:14:00+01:00</published>
    <updated>2009-11-07T07:14:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/11/7/ruby-caldav-library-0-3" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Ruby Caldav Library 0.3</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="caldav" scheme="http://www.local-guru.net/blog/tag/caldav"/>
    <content type="html">&lt;p&gt;have made a new version of my &lt;a href="http://www.local-guru.net/blog/pages/rubycaldav"&gt;ruby caldav lib&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;version 0.3 is a bugfix release, to make it work with the kde4 calendar&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/190</id>
    <published>2009-09-06T04:48:00+02:00</published>
    <updated>2009-09-06T04:48:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/9/6/mapping-linux-input-events-to-osc" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Mapping linux input events to OSC</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="osc" scheme="http://www.local-guru.net/blog/tag/osc"/>
    <content type="html">&lt;p&gt;In linux every input device registers under /dev/input/eventX and sends events in 16 byte blocks.
these data chunks contain a timestamp the event type, the event code and a value
depending on the event type the semantic of value changes. for a event type 1 (key event) value 1 means pressed
and value 0 mean released.&lt;/p&gt;

&lt;p&gt;here is a little ruby program that reacts to key press events and sends osc messages. which could trigger drum sounds,
start play back, ...&lt;/p&gt;

&lt;p&gt;key press events are not only sent by keyboards but also by mice, joystics, gamepads, a DDR mat, a buzz buzzer, ...&lt;/p&gt;

&lt;p&gt;the code example is used to map keys of my PS3 Controller to drum sounds.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'osc';

c = OSC::UDPSocket.new

hh = OSC::Message.new('/drum', 's', "hh" )
bd = OSC::Message.new('/drum', 's', "bd" )
sn = OSC::Message.new('/drum', 's', "sn" )

File.open("/dev/input/event7") do |f|
  while true
    event = f.read(16).unpack("llSSl")
    time = event[0] + event[1] / 1000000.0
    type = event[2]
    code = event[3]
    value = event[4]

    puts "Ti: #{time} T: #{type} C: #{code} V: #{value} " if type == 1

    c.send( bd, 0, 'localhost', 3334 ) if type == 1 &amp;amp;&amp;amp; code == 298 &amp;amp;&amp;amp; value == 1
    c.send( sn, 0, 'localhost', 3334 ) if type == 1 &amp;amp;&amp;amp; code == 293 &amp;amp;&amp;amp; value == 1
    c.send( hh, 0, 'localhost', 3334 ) if type == 1 &amp;amp;&amp;amp; code == 303 &amp;amp;&amp;amp; value == 1
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code was inspired by 2 articles i found recently the first one is about how to use a
&lt;a href="http://t-a-w.blogspot.com/2007/05/using-ddr-dance-mat-as-musical.html"&gt;DDR-mat to trigger Drum Sounds&lt;/a&gt;
and the second one shows how to
&lt;a href="http://wiki.openmoko.org/wiki/Accelerometer_data_retrieval"&gt;read the accelerometer data from a openmonoko phone&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/152</id>
    <published>2009-04-13T14:57:00+02:00</published>
    <updated>2009-04-13T14:57:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/4/13/ruby-osc-seqencer-version2" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">ruby osc seqencer version2</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="osc" scheme="http://www.local-guru.net/blog/tag/osc"/>
    <content type="html">&lt;p&gt;i updated my &lt;a href="http://www.local-guru.net/blog/2009/01/20/osc-sequencer-in-ruby"&gt;osc sequencer in ruby&lt;/a&gt;. now it doesn't just send osc events but also react to it. i made a small
processing sketch that sends osc play,pause,stop events for each track in the sequencer.
i also refactored the ruby code a bit, to use classes. next steps i plan are to separate the sequencer code
from the sequences and allow sequences to be added or deleted at runtime via osc messages.&lt;/p&gt;

&lt;p&gt;the code isn't very reusable now, so i still considere this more as a prove of concept, but i like the idea
of separating the frontend and the backend via osc events and having sequences that can run independently.&lt;/p&gt;

&lt;p&gt;that should enable some nice osc controlled audio/video installations.&lt;/p&gt;

&lt;p&gt;write me a comment or mail if you have some ideas for improvement or if you use the code in one of your
projects&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/126</id>
    <published>2009-02-15T08:15:00+01:00</published>
    <updated>2009-02-15T08:15:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/2/15/processing-ical-flowers-2-0" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">processing ical-flowers-2.0</title>
    <category term="processing" scheme="http://www.local-guru.net/blog/tag/processing"/>
    <category term="arduino" scheme="http://www.local-guru.net/blog/tag/arduino"/>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="visualization" scheme="http://www.local-guru.net/blog/tag/visualization"/>
    <category term="caldav" scheme="http://www.local-guru.net/blog/tag/caldav"/>
    <category term="ical" scheme="http://www.local-guru.net/blog/tag/ical"/>
    <category term="calendar" scheme="http://www.local-guru.net/blog/tag/calendar"/>
    <category term="ical4p" scheme="http://www.local-guru.net/blog/tag/ical4p"/>
    <category term="i2c" scheme="http://www.local-guru.net/blog/tag/i2c"/>
    <content type="html">&lt;p&gt;I made a new version of the &lt;a href="http://www.local-guru.net/blog/2008/12/06/processing-ical-flowers"&gt;ical flowers sketch&lt;/a&gt;
i wrote in dezember. This time it doesn't only show a flower for every event in my calender, it also shows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the current weather (using the &lt;a href="http://code.google.com/p/rubyweather/"&gt;rubyweather&lt;/a&gt; library)&lt;/li&gt;
&lt;li&gt;the current temperature outside&lt;/li&gt;
&lt;li&gt;the min/max temperature outside&lt;/li&gt;
&lt;li&gt;the current temperature inside ( using my &lt;a href="http://www.local-guru.net/blog/2009/02/02/i2c-thermometer-on-arduino"&gt;arduino i2c thermometer sketch&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;the sky color changes depending on the current time&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/icalflowers2-sc1.png" alt="ical-flowers screen1" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://www.local-guru.net/img/guru/icalflowers2-sc2.png" alt="ical-flowers screen2" /&gt;&lt;/p&gt;

&lt;p&gt;the system consists of a ruby-proxy, an arduino sketch and a processing sketch.&lt;/p&gt;

&lt;p&gt;the ruby proxy starts a web-server on port 2000. It fetches the current weather using the
&lt;a href="http://code.google.com/p/rubyweather/"&gt;rubyweather gem&lt;/a&gt;, fetches the events from the configured caldav calenders, and
fetches the current temperature from the arduino using &lt;a href="http://ruby-serialport.rubyforge.org/"&gt;ruby-serial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the arduino sketch is basicaly the same as &lt;a href="http://www.local-guru.net/blog/2009/02/02/i2c-thermometer-on-arduino"&gt;in this blog post&lt;/a&gt;. the only change is
that the arduino only sends the temperature when the host sends a 'C' over the serial line&lt;/p&gt;

&lt;p&gt;the processing sketch finally fetches the data via http from the proxy and displays it ( using my &lt;a href="http://www.local-guru.net/blog/pages/ical4p"&gt;icap4p library&lt;/a&gt;.
the screen is updated every 1/2 hour using the method &lt;a href="http://www.local-guru.net/blog/2009/01/29/extra-low-framerates-in-processing"&gt;described here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the code can be downloaded &lt;a href="http://www.local-guru.net/projects/flowers-2.0.zip"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it's published under the LGPL&lt;/p&gt;

&lt;p&gt;have fun :-)&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/124</id>
    <published>2009-02-10T03:13:00+01:00</published>
    <updated>2009-02-10T03:13:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/2/10/ruby-symbols-vs-string-vs-constant" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">ruby symbols vs string vs constant</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="symbol" scheme="http://www.local-guru.net/blog/tag/symbol"/>
    <content type="html">&lt;p&gt;on saturday i was asked by a ruby-newbie (sorry - i had to write it :-) ) whats the difference between
a symbol, a string and a constant in ruby. even tough there are realy, realy many articles about ruby symbols
( a google search for "ruby symbols" results in 1,340,000 hits - so this is the 1,340,00&lt;strong&gt;1&lt;/strong&gt; aricle covering the
topic) there is obviously still some confusion out there. So i try my own definition here.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/115</id>
    <published>2009-01-28T04:16:00+01:00</published>
    <updated>2009-01-28T04:16:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/1/28/ruby-caldav-library-0-2" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Ruby Caldav Library 0.2</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="caldav" scheme="http://www.local-guru.net/blog/tag/caldav"/>
    <content type="html">&lt;p&gt;I have made a new version of my &lt;a href="http://www.local-guru.net/blog/pages/rubycaldav"&gt;ruby caldav lib&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;version 0.2 is a bugfix release, there are no new features but i removed some essential typos&lt;/p&gt;
</content>
  </entry>
</feed>

