Since a friend of mine told me of using OpenOffice as a daemon to run tasks automatically, I thought that would be nice to try it as a part of a proof of concept to a slideshare mini clone. It would be a matter of uploading the original file, convert it using OO and displaying a page along with it. There`s an API and many clients. I choose not to develop a new client and used JodConverter. Of course I would have to develop a new converter if I wanted to inject or run customized procedures over a document.

Read the rest of this entry »

I’ve been using inkscape to draw diagrams, specially abusing its import openclipart feature, but I found out that for simple sequence diagrams, there is another great tool:

Their API is clean and the text parsing very accurate.Choose “Napkin” in the style combo and click draw to see their demo.

I found it via another gem, this caching 101 page for dummies. Things like this and this ‘Threads primer’ are necessary reminder nowadays. There are a lot of butchered applications and architectures popping everywhere, and without these kind souls providing the best of them going thru basic concepts, we’re all doomed.

There goes my contribution, a kind of memcached 101, both in napkin and blue modern styles !

memcached 101 napkin style

memcached 101 napkin style

memcached 101 blue modern style

memcached 101 blue modern style

Paste the code below to generate these diagrams. Note the alt 'command' I used to put both cases in the same diagram.
Gotta love that.

Alice->Application: Asks for her Profile
Application->Memcached: is Alice profile there \?
alt Data is not cached yet
 Memcached->Application: No, it's not here
 Application->Database: get me Alice's Profile
 Database->Application: here is the data - it took me a lot of time, k \?
 Application->Memcached: set Alice Profile there
else data is already cached yay
 Memcached->Application: Got it
Application-->Alice: Response (her profile data)

icalendar gem

November 19, 2007

ICalendar (iCal) is a standard for calendar data interchange. There’s a gem called icalendar, which helps to parse and generate such file, so you may use data from your google or exchange calendar to feed your app (or make it generate data to feed your calendar, e.g., a link to Digg or Facebook in each post of your blog to setup a TODO item).

To parse a .ics file (iCal invite or TODO item) it’s just a matter of looping thru the elements in a given calendar. A ics file may hold more than one calendar, end each calendar may contain events and TODO itens.

#!/usr/bin/env ruby
require 'rubygems'

require 'icalendar'

if (ARGV.size < 1) then
 puts "Usage: ical_parse.rb <calendar.ics>"

cal_file =[0])

cals = Icalendar.parse(cal_file)
if (cals.size==0) then
 puts "Empty calendar"

cals.each {|c|

 puts "\nEvents\n\n"

	if ( == 0) then

 	puts "Empty event list"

 else { |e|

 		puts "---------------------------------------"

 		puts "Seq:"+e.sequence.to_s
 		puts "UID:"+e.uid.to_s
 		puts "DTSTART: "+e.dtstart.to_s
 		puts "summary: " + e.summary
 		puts "location: " + e.location
 		puts "description: "+e.description

 		if (not e.attendees.nil?) then

 			puts "attendee: "
 				puts "\t"


 		puts "---------------------------------------"



	puts "\nTODO\n\n"

 if (t.size == 0) then

 	puts "Empty TODO list"


 	puts "---------------------------------------"

 	t.each {|oi|

 		puts "Seq:"+oi.sequence.to_s
 		puts "UID:"+oi.uid.to_s
 		puts oi.dtstart
 		puts "summary "+oi.summary


 	puts "---------------------------------------"




A friend of mine gave me a netgear wifi router and I decided that would be fun to have a systray applet to check for connected stations. The basic parsing was easy, but then came the GUI part. The first idea was do it in a multi plataform fashion, and later on I just decided to do it with the most important toolkits (in general) that I found bindings for: GTK and WxWidgets.

Alto I dig WxWidgets, I found the GTK binding more mature and (I never thought I would say that) easier to use. I I really think GTK is counterproductive when programming in C (or worse, C++) for Linux, but thankfully GUI programming is not my daily job.

So that’s my first GUI app in Ruby. I kinda tried to follow code guidelines for each toolkit (when I could found them) and keep the same overall structure (separated dialogs, timer control for scraping the router’s info, etc).

If I had to do another GUI app in Ruby (which I’m planning, a SciTE project manager), I would use GTK and chill out about the multi-plataform-OS stuff. Usually these kind of scripts tend to be used only by who programmed them and as example to other programmers rather than morph into a full fledged project.

WxWidget version

GTK Version