Archive for the 'techno stuff' Category

HAR2009 and a social experiment

Last 4 days I spent at Hacking At Random, a festival for hackers held here in the Netherlands and I really enjoyed everything that was going on there. The atmosphere was great and I had great conversations with a lot of people from all over the world. This time, I really liked that a small project was born amongst the people I was with (mainly pruts.nl members). At the festival, visitors had the ability to register their DECT telephone to Eventphone, so you could use your own phone to call other visitors and even call to the outside world. More than 800 visitors (out of 2200) had their phone registered which made meeting people very easy. Next to using a DECT phone, you were also able to hookup SIP enabled stuff to the telephony network.

Since we wanted to stimulate social interaction at the festival, we set up an Asterisk server and connected it to the telephony network via SIP. Then we took the whole address book that is published by Eventphone and put it in a database. After writing some scripts, we had the possibility to randomly select a phone extension and call this. After listening to an announcement, the call was put into a conference call. Since not all phones were connected and not everybody picked up, we participated in the calls sometimes, to keep things alive. Normally a person would pick up the phone and we'd pretend that we were also randomly called, so that an actual conversation was held. When more people picked up and added to the call, we stopped talking and let the others (mostly 2) people have their conversation.

The nice thing about this was that everybody reacted in a very positive way. People who were called and also the (not so many) people we told what we were up to were all enthusiastic by the whole thing.

Ruby SOAP – the story continues..

As written before, I've been struggling with Ruby and SOAP. Apart from the fact that I really don't understand why the world likes to use SOAP, I've ran into a couple of issues I'd like to share for future generations:

  • soap4r and ActionWebService don't play nicely. The SOAP implementation that is included in the standard Ruby distribution isn't very nice at all (issues with validating WSDLs), so I tried using soap4r to make SOAP requests to remote services. Single scripts worked eventually, but when including this in a Rails project that also acts as a SOAP server (using AWS), things broke majorly. Not spending too much time, I decided to make SOAP requests from external scripts that I call with exec().
  • soap4r doesn't set the xsi:nil attribute to elements that allow this when the content is nil, but the element is a ComplexType. The solution here was to manually construct the SOAP elements (using SOAP::SOAPElement).
  • On my development machine (OSX with Ruby 1.8.6) things finally worked fine, but when deploying to a production environment (Linux with Ruby 1.8.7), things broke when calling "id" on a SOAP result object with the message "warning: Object#id will be deprecated; use Object#object_id" and instead of the id in the SOAP result, I got the object_id (which is an internal id for the object and utterly useless for my purposes). The solution here was to not call methods on the result object, but treating it as a Hash. So result.id becomes result['id'].

Rails and SOAP part II

As written in a previous last post, I've been busy with Rails and SOAP. I've been figuring out how to pass hashes to my remote calls instead of an argument list.

The default API requires something like:

api_method :get_my_thingy, :expects => [:id => :int, :name => :string], :returns => [Thingy.struct]

When calling this (e.g. with a ruby soap thingy) it looks something like:

soap.getMyThingy(2, "foo")

But I would like to do:

soap.getMyThingy(:id => 2, :name => "foo")

For this to happen, I introduced an OptionStruct:

module ActionWebService
 class OptionStruct < ActionWebService::Struct
 member :id, :int
 member :name, :string
 end
end

After this, the API should be like:

api_method :get_my_thingy, :expects => [OptionStruct], :returns => [Thingy.struct]

See my previous post for the Thingy.struct

Rails and SOAP

For a project, I'm currently implementing a SOAP API in Rails. The Rails application will function as a SOAP server and I'm using the datanoise activewebservice plugin for this. Implementing a SOAP API is pretty easy with this, however, I ran into some problems with returning complete model objects.

I have a model called Customer that I want to expose via my API. After setting up the API controller, I specified the following in /app/services/customer_api.rb:

class CustomerAPI < ActionWebService::API::Base
  api_method :get, :expects => [:int], :returns => [Customer]
end

Implemented with:

def get(id)
  return Customer.find(id)
end

Requesting the WSDL nicely gives the definition of Customer, but when making a request for a specific customer errored with the message "Cannot map Customer to SOAP/OM.". It appears that boolean values (in Ruby presented as true/false) and emtpy values (presented in Ruby as nil), were the problem. SOAP wants them as "true", "false" and "".

I solved this by extending my models with a to_struct() method that returns all attributes in a Struct. I extended both ActiveRecord::Base instances to get the instance method to_struct() inside my models and I extended ActiveRecord::Base class so it would return a Struct. The latter is needed, since the SOAP plugin wants to know the attributes and types of the Struct, without actually creating one. Here's what I did:

To extend ActiveRecord::Base with class methods create a module and put the following in your /config/environment.rb:

require 'model_extensions'
ActiveRecord::Base.send(:extend, ModelExtensions)

Then in the module:

module ModelExtensions
  def struct
    # Check if the DataStruct is already defined
    begin
      eval("#{self}::DataStruct")
    rescue
      # Define the DataStruct class and fill it with
      # members that resemble the model
      class_eval <<-EOF
        class DataStruct < ActionWebService::Struct
          #{self}.columns.map{|c| member c.name.to_s, c.type.to_s}
        end
      EOF
    end
    return eval("#{self}::DataStruct")
  end
end

Now to create a DataStruct in a model, we define the following:

module ActiveRecord
  class Base
    def to_struct
      # Get a DataStruct and instantiate
      struct = self.class.struct.new
      # Set the attributes after clean-up
      self.attributes.each do |k,v|
        v = (v.nil?) ? "" : ((v == true) ? "true" : (v == false) ? "false" : v)
        struct.send("#{k}=", v)
      end
      return struct
    end
  end
end

To finish off, we change the API implementation a bit to the following:

class CustomerAPI < ActionWebService::API::Base
  api_method :get, :expects => [:int], :returns => [Customer.struct]
end

Implemented with:

def get(id)
  return Customer.find(id).to_struct
end

iPhone jailbreak and vendor lock-in

Last week, I jailbroke my iPhone. This means that I can install applications without having to use the Apple appstore. Of course, this is nice. Outside of the appstore, there are lots of packages that you can install and applications that haven't been published by Apple (yet). I mainly jailbroke it because I wanted to use SyncJe for SyncML stuff.

When the first generation iPhone was there (without SDK) I understand that there was a need for jailbreaking, but nowadays, with a huge appstore, this need seems to be less, at least for normal users. iPhone hackers obviously want to be able to install additional tools on the device, but what I noticed is that the software that you can dowload on a jailbroken iPhone is often pretty crappy. Stuff crashes or doesn't really work the way you want it to (if you can install it at all; SyncJe doesn't on my phone). Since there are lots of free packages at the appstore, I prefer using them, in favour of the ones you can download from other sources. Another problem with these non-appstore packages is that there seems to be a huge number of sources, all providing different packages. Currently there are 2 installer packages (Installer.app and Cydia) which both contain a subset of available packages.

I like centralized repositories that contain packages that went through a quality check. The same applies for my Linux systems, where I don't want to add 100 extra sources to my apt config, just to run specific software, from which I don't know the quality. Of course, the whole appstore thing creates a vendor lock-in, which in a way is kind of bad, but on the other hand often guarantees some sort of quality control.

iPhone

Today, I got an iPhone 3g! And yes, it's very very very sexy. I hadn't played a lot with iPhones from friends, but I must say that it rocks. The interface is so nice and snappy. The only thing I don't like it that it seems that Apple doesn't really care about integrating with other systems than with their own platform. I happen to own an iMac, but even then, I had to jump through hoops to get my stuff migrated from my 'old' Nokia n61i.

I happen to use Zyb.com as an online backup for my contacts and calendars. My Nokia played nice with it and synced things with SyncML, but Apple decided not to support this. 3rd party apps aren't really that great or don't support syncing calendars. What I finally did was using the "Funambol" application to sync my contacts with Zyb, but because Apple closed the format of the iCal database, Funambol only does the contacts (same for Synthesis SyncML2iPhone). Then I exported my calendars from the Zyb site to vcalendars and imported them in Apple's desktop iCal application. From there, I could sync my calendar with iTunes.

The problem I'm facing is that I now can sync my contacts from my phone to Zyb, but not my calendar, which kind of sucks. I'm still trying to figure out a way to (except from installing an Exchange server) sync all my things (calendar, notes, etc).

It’s not about usability

When it comes to applications or websites for the masses, it's not about usability, it's about userbase. I noticed this yesterday, when a new friend of mine invited me to use facebook. Currently I'm using Hyves, a Dutch social network to keep in touch with friends and Linkedin for some business contacts. Since a few months I'm also familiar with vkontakte, a big Russian network, but I don't have my own account there. During my recent trip to St. Petersburg, I made some new friends and one asked me if I had a facebook account. I didn't have one yet, but I decided to get one, just to keep in contact with my international friends. I've been playing around with it for some time now and I must say that it's so much better than Hyves. Basically Hyves sucks; it's slow, ugly and very hairy in navigation. But why is it the biggest network in the Netherlands? Not because it's user friendly, but because everybody uses it. Obviously the nature of social networks contributes to this kind of behaviour; who wants to be on a network without any friends? But I think this statement is also true for a lot of other software. Since the days of byte-islands have passed a long time ago, it's necessary to interface, and so, using what everybody uses is key. This is true for file formats, but also for usage of applications in general. The people I know are mostly geeks or have some affinity with IT. For them it's easy to use something out of the ordinary, because they can manage (converting file formats, jumping through holes to get their linux machine hooked up to a mac, finding out how a different system works, etc), but for the masses the most important thing seems to be able to do what everybody does. Only to be able to ask a non geeky friend how things work. The geeky geeky friend wouldn't know it anyway; my usual response normally is "ooh, I don't know this windows stuff.. I use Linux.."

OpenPanel released

A couple of days ago, OpenPanel, an open source control panel for web hosting has been released. The guys at PanelSix just released the beta version and their stuff looks very promising. I haven't had the chance to play with it, but what I hear from others, it's absolutely awesome. Plesk and other panels are usually a pain in the ass, because they are far from transparent. This stuff seems really promising, since it's open source and even has a CLI, which enables you to script hosting setups!
Anyway, check it out!

Digital life expanded

In regards to my last post about digital life, I have expanded my digital life a bit more over the last few weeks. It started with adding Jabber to my list, after EURUKO08 and last week I signed up for a del.icio.us account. Also, my old ICQ number popped-up in my head again, so I also started idling on that network again. It's nice that I was able to tie most of these things together. In jabber, I now have transports for jabber, MSN and ICQ and enabled twitter notification to my jabber account. My delicious network is now a feed in my Google Reader and in Firefox I installed the Google Reader notification plug-in. I know that more integration is possible, but for me, this is enough. Mail notification in my email client, IM stuff in jabber and slower media in my browser. And of course IRC. I know I can add this to jabber as well, but for me, irssi works best.

Published!

As written before, I wrote an article for the 2006 Hacker's Quarterly magazine, about an April Fools' joke I pulled on Wiard once. A couple of months ago, I got an email that said that the article would be published, but didn't say exactly when. Today, I checked the 2600.com website and found that my article is in the Spring 2008 issue!