Moved blog to keoko.net

February 7, 2009

Finally I moved the blog to http://www.keoko.net.

Advertisements

Programming Erlang

December 24, 2008

My current interests in XMPP leaded me to ejabberd (XMPP server) and this to some XEPs PubSub and POSH, and this to wondering about using XMPP as a queue system. Then I discovered some discussions comparing AMQP vs XMPP and realized that both RabbitMQ (an implementation of AMQP) and ejabberd were programmed in Erlang. I was astonished that three of the currently most interesting projects were implemented in the same language (if we include couchDB).

This is why I decided to read “Programming Erlang”. I’ve nearly read half of the book and my expectations has been really exceeded:

  • smooth pace of the book goes from basic knowledge to the hardest part (sequential programming -> advanced sequential programming -> concurrent programming -> distributed programming -> programming multicore CPUs).
  • clear and easy to understand examples.
  • some complete examples such as an IRC Lite implementation gives you the concepts in action.
  • interesting concepts: functional programming, concurrency, distributed programming, fault-tolerant programs.

As missing parts (not sure if they are cover at the end of the book), I found out the following:

  • a bit of history of Erlang. Why erlang?
  • Comparison between Erlang and other concurrency oriented languages such as Scala, Clojure, Stackless Python, …

To sum up, really a MUST READ if you are curious about other programming languages apart from Java, Python or Ruby.

My interests with Wordle

December 24, 2008

Below you can get an idea of my interests. The image is generated through my delicious tags with the wordle service.

After reading “Beyond REST? Building Data Services with XMPP PubSub” and other articles about PubSub with XMPP, I decided it would be worth to test it. However, I didn’t find any complete step by step guide in how to test it with ejabberd as XMPP server and XMPP4R as XMPP client.

Below are the steps I followed to test a subscriber (user “sub”) waiting for items published to the node (”home/localhost/pub/updates”) for the publisher (user “pub”). Note you can add as many subscribers/publishers as you want.

  1. install ejabberd (XMPP server). I followed instructions of this article (spanish) or article (english) without any surprise.
  2. create two ejabberd users: “pub” (the publisher) and “sub” (the subscriber).

    sudo ejabberdctl register pub localhost pub
    sudo ejabberdctl register sub localhost sub

  3. install XMPP4R Ruby gem.
    sudo gem install xmpp4r
  4. create file nodecreator.rb. See code below.
    
    #! /usr/bin/ruby
    require "rubygems"
    require "xmpp4r"
    
    require "xmpp4r/pubsub"
    require "xmpp4r/pubsub/helper/servicehelper.rb"
    require "xmpp4r/pubsub/helper/nodebrowser.rb"
    require "xmpp4r/pubsub/helper/nodehelper.rb"
    
    include Jabber
    Jabber::debug = true
    
    service = 'pubsub.localhost'
    jid = 'pub@localhost/laptop'
    
    password = 'pub'
    client = Client.new(JID.new(jid))
    client.connect
    client.auth(password)
    
    client.send(Jabber::Presence.new.set_type(:available))
    pubsub = PubSub::ServiceHelper.new(client, service)
    pubsub.create_node('home/localhost/pub/')
    pubsub.create_node('home/localhost/pub/updates')
    
  5. create file publisher.rb. See code below.
  6. 
    #! /usr/bin/ruby
    require "rubygems"
    
    require "xmpp4r"
    require "xmpp4r/pubsub"
    require "xmpp4r/pubsub/helper/servicehelper.rb"
    require "xmpp4r/pubsub/helper/nodebrowser.rb"
    require "xmpp4r/pubsub/helper/nodehelper.rb"
    include Jabber
    Jabber::debug = true
    jid = 'pub@localhost/laptop'
    
    password = 'pub'
    service = 'pubsub.localhost'
    node = 'home/localhost/pub/updates'
    # connect XMPP client
    client = Client.new(JID.new(jid))
    # remove "127.0.0.1" if you are not using a local ejabberd
    client.connect("127.0.0.1")
    client.auth(password)
    client.send(Jabber::Presence.new.set_type(:available))
    # create item
    pubsub = PubSub::ServiceHelper.new(client, service)
    item = Jabber::PubSub::Item.new
    xml = REXML::Element.new("greeting")
    xml.text = 'hello world!'
    
    item.add(xml);
    # publish item
    pubsub.publish_item_to(node, item)
    
  7. create file subscriber.rb. See code below.
    
    #! /usr/bin/ruby
    require "rubygems"
    require "xmpp4r"
    require "xmpp4r/pubsub"
    require "xmpp4r/pubsub/helper/servicehelper.rb"
    
    require "xmpp4r/pubsub/helper/nodebrowser.rb"
    require "xmpp4r/pubsub/helper/nodehelper.rb"include Jabber
    #Jabber::debug = true
    jid = 'sub@localhost/laptop'
    password = 'sub'
    node = 'home/localhost/pub/updates'
    service = 'pubsub.localhost'
    
    # connect XMPP client
    client = Client.new(JID.new(jid))
    # remove "127.0.0.1" if you are not using a local ejabberd
    client.connect("127.0.0.1")
    client.auth(password)
    client.send(Jabber::Presence.new.set_type(:available))
    sleep(1)
    # subscribe to the node
    pubsub = PubSub::ServiceHelper.new(client, service)
    pubsub.subscribe_to(node)
    subscriptions = pubsub.get_subscriptions_from_all_nodes()
    puts "subscriptions: #{subscriptions}\n\n"
    puts "events:\n"
    
    # set callback for new events
    
    
    pubsub.add_event_callback do |event|
    begin
    event.payload.each do |e|
    puts e,"----\n"
    end
    rescue
    puts "Error : #{$!} \n #{event}"
    
    end
    # infinite loop
    loop do
    sleep 1
    end
    
  8. run nodecreator.rb. It creates the XMPP node “home/localhost/pub/updates”. It creates first the node “home/localhost/pub” and then the “home/localhost/pub/updates”. Seems quite obvious but I spent some hours after I got it.
  9. check the nodes have been created. I used the discovery service functionality of Psi client.psi_service_discovery
  10. run subscriber.rb file. The “sub” user subscribes to the node ‘updates’ and waits for items in the “updates” node. Be aware you should close any XMPP connection with users “pub” and “sub” in case you are using any XMPP client such as Pidgin, Psi,… otherwise it won’t work.
  11. run publisher.rb file. It will send a message “<greetings>hello world!”</greetings> to the subscriber. Run it as many times as you want.
  12. If everything goes well yo will see in the subscriber screen a message like this.
    
    subscriptions: <subscription node='home/localhost/pub/updates' jid='sub@localhost' subscription='subscribed' xmlns='http://jabber.org/protocol/pubsub'/>
    
    events:
    <items node='home/localhost/pub/updates'><item id='3376'><greeting>hello world!</greeting></item></items>
    ----
    

Good Luck!

For this test, I used the following versions:

  • Operating System: Ubuntu 8.04
  • Ruby: 1.8.6
  • XMPP4R: 0.4
  • ejabberd: 1.1.4

I installed successfully Ubuntu 8.04 in a HP Compaq 8510p laptop. My applications at the moment are:

  • text editor: vim 7.1
  • web browser: Firefox 3.0.3 (webdeveloper, firebug, firecookie, YSlow, vimperator, del.icio.us)
  • IM client: pidgin 2.4.1
  • java editor: eclipse 3.3.2
  • web server: apache2 2.2.8 (php5, “mod_ruby”)
  • gnome-do (quicksilver for gnome)
  • glipper (similar to klipper)
  • network protocol analyzer: wireshark
  • virtual machine: VirtualBox 1.5.6_OSE with Windows XP.
  • oracle client: SQLDeveloper

There is still a list of issues pending to fix:

  • battery life. I followed the tips (powertop, cpufrequtils,  …) of this article although not sure anot the improvement.
  • screen resolution. 1200×800 maximum resolution. I installed fglrx driver through envy but does not improve the resolution (1680*1050 seems the maximum, see this article).
  • CD/DVD writer. brasero nor cdrecord command tool worked.
  • video codecs. AVI files are reproduced very slowly.
  • email client with Exchange support. Evolution does not manage properly meeting requests.
  • glipper. It crashes in every start up.
  • rubygems. Rubygems from repository does not work properly. You have to install it manually.

Phusion Passenger installed

October 11, 2008

I eventually decided to install phusion passenger for his simplicity on rails deployment. My first intention was to install Apache + Mongrel, but after reading Sam Ruby’s article and the following lines in this article I changed my mind:

“The de-facto Ruby (and Rails) deployment system seems to change rapidly (remember Apache+FastCGI, then lighttpd+FastCGI, then Apache+Mongrel, then Nginx+Mongrel…?) and while Passenger may or may not be a de-facto standard in a few years’ time, it’s certainly becoming the standard for now, so jump on board!”

Really quick the install and set up in Ubuntu.

I’ve just installed Apache 2.2 and WordPress 2.3.3 after looking into some alternatives, mainly ruby-based solutions:

Alternative web servers:

  • lighttpd + fastcgi (old recommended solution)
  • apache + mod_ruby (“class sharing issue”)
  • nginx + mongrel (seems the de facto RoR solution)
  • SCGI?

Ruby-based weblogging systems:

  • typo (complex?)
  • mephysto (seems the most appropiate)
  • radiant (more a CMS than a blogging system)

The decision was made because I’m really new in Ruby and RoR and I would like to start taking notes about my progress in this area

wordpress widgets

May 30, 2007

Today I have been playing with wordpress widgets. My surprise was that I was unable to add third-party widgets such as now reading widget (I am using the wordpress blog service). Maybe I am not looking at the right place. So, for the moment, I will have to conform with default widgets like search, tag cloud, flickr, …

gizmo installed

May 26, 2007

I have just installed gizmo, another voIP service similar to Skype but using SIP instead,  on my Ubuntu Feisty with some minor issues:

  1. download gizmo deb package from here
  2. mv ~/.asoundrc.asoundconf ~/.asoundrc.asoundconf.bak
  3. sudo mv /etc/asound.conf /etc/asound.conf.bak
  4. mv .asoundrc .asoundrc.bak
  5. sudo /etc/init.d/alsa-utils restart
  6. sudo dpkg -i ~/Desktop/gizmo-project_3.0.1.68_i386.deb

Now it’s up and running but no friend with gizmo to call!