Sunday monday fun: gowalla gem, google maps, some Javascript stuff, and a Rails app.

Gowalla spots Google Maps Mashup [http://gowallamaps.heroku.com]

It tries to use HTML5 geo location to get a position on the map (defaults to somewhere on USA). Probably best used on the iphone (tried on a friend’s Android and it failed :S). Screenshot:

Simple hack, and a reminder for Gowalla to open up their API :) Thnks @pengwynn for the awesome gem :)

ActivityStreams is the next big thing TM. It defines a protocol to syndicate activities taken from web applications (mainly social ones) and services. Just imagine a common spec for describing the activities a user do on Facebook, FriendFeed, Delicious, etc.

The protocol originally targeted the Atom XML Standard, via an extension. Later, some work has been done on standardizing a JSON format too.

With that in mind, I’ve tried to implement a Ruby parser that defines a common API to access both the Atom and the JSON specification. Is is now available on github and also as a Ruby gem.

Here’s a simple demonstration on how it works. We take the excellent Cliqset feed proxy and get an activity streams annotated Twitter Atom feed:

The JSON API is very similar. Some documentation is up on rdoc.info and it is worth checking the spec too. Have fun :)

Quick post to let you know about my latest hack: basic support for OpenCL on MacRuby and Snow Leopard.

  • it is my first Ruby C extension ever
  • it is my first OpenCL approach ever
  • it is my first MacRuby hack (ever)

With this in mind, don’t expect real world usage from this code, nor that it will get merged into upstream: it was just written for fun!

The MacRuby branch with the changes is located here

Example

The hello world on OpenCL is probably “calculate each element’s square on a given array”. The code below shows how this can be done in MacRuby:

This code runs the same computation on all available OpenCL devices on your hardware. The results on my hardware (2 GPUs, 1CPU) are:

It was fun, and maybe it can inspire someone :) The OpenCL API is kinda complex and I’m not sure if there’s a good way of making it Rubyish enough. Suggestions are welcome! Have fun :)

HTML5 is here! Urray!

I was tired of hearing about one of the new innovation in HTML5: the WebSocket API.

After reading the excelent blog post about WebSockets and Ruby by Ilya Grigorik I got inspired by this experiment which is a simple example of a twitter-to-browser usage of websockets.

Since the excelent em-websocket was available on github, I decided to write my own “from twitter to the browser” real time updates, with no polling.

You can check the final result on my github repo.

General overview

Twitter Stream API → Filter → RabbitMQ → AMQP → Eventmachine → WebSocket → HTML5 Brwser

Too much buzzwords? Lets look at some code.

Filter

The filter is responsible for eating the Twitter Stream API and puting the tweets on a queue (RabbitMQ in my case) using AMQP:

Pretty easy right? Notice I am using a fanout exchange, which will allow me to broadcast the same message to all queues (clients) latter on.

Server

Now we just need to build a server that accepts websocket connections, and for each client deliver each message that arrives on the fanout exchange. The code will make this clear:

So simple, yet so awesome!

Client

The client just have to connect the websocket, and for each JSON piece that arrives on the socket, present them on the screen:

It seems we’ve ended writing almost more JS than Ruby :P Note that I’ve only tested this on Webkit nightly and latest Google Chrome beta for Mac.

Overall it was a great and easy experience building this simple system, but it allowed me to realize how simple we can build scalable push systems with the WebSocket API!

update: seems like Ilya Grigorik liked it :)

Are you tired of calling your friends and family at prices from the last century? Do you feel frustrated every time you have to top-up the credit of your mobile phone, just because you are obliged to? Do you hate the obvious portuguese cartel around mobile operators?

Well, fell no more! Enter the VoIP world!

Betamax created lots of providers specialized in VoIP. Although almost all of them offer free calls to Portuguese landline numbers, I never realized how competitive they were on the mobile side.

So I dig a little, and found some pretty competitive Betamax VoIP providers:

  • 12voip.com – 4.5 cent/min
  • voipraider.com – 5.0 cent/min
  • webcalldirect.com – 6.0 cent/min

The best thing about these providers is

  • No required monthly payment
  • You can use your own phone number as Caller ID (so people still answer your calls).
  • They all support the SIP protocol (great for non-windows users like me)
  • Same price for all the mobile operators (so you can jump the wall garden)

I hope that this information helps you lowering your phone bill. Spread the word, and maybe your mobile operator starts lowering the prices too!

About

photo of Ruben Fonseca

My name is Ruben Fonseca. I'm a Computer Science and Systems Engineer from Portugal that loves FLOSS.

I'm currently taking some time off to myself, but feel free to contact me anytime at or via LinkedIn:

View Ruben Fonseca's profile on LinkedIn

Feeds

Social

Follow rubenfonseca on Twitter