ruby-oci8 and libaio

Not of concern to most people reading this via a feed, but it’s one of those things I think is nice to write up as a public service, should anyone else encounter the same error. I’m stuck doing some Rails work with Oracle, and so I needed to get ruby-oci8 working:

http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html

These instructions are pretty good. I followed them, the gem said it had been installed correctly…. and yet:

ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 library or gem.
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in
`establish_connection':RuntimeError: Please install the oracle_enhanced adapter:
`gem install activerecord-oracle_enhanced-adapter` (LoadError)

Argh! After some straceing, I finally figured out what was missing: the libaio1 package. You need to have it or things will fail like this. It’s very odd that the installation doesn’t complain about it.

Custom Twitter Sites, BikeChatter.com Updates

I’ve been hacking away at http://www.bikechatter.com, adding a few things like votes and tags so that you can choose which broad categories you want to follow. The first will let people vote for the most interesting tidbits that come through twitter, whereas the second will let me add more people without overloading those who are, say, not interested in reading what coaches have to say, or are only interested in professional women racers, etc… I don’t think I’ll bother with individuals – if you want that, just add them to twitter yourself! At most I might see about putting in an ‘exclude list’… but we’ll see; I’d prefer to keep things simple.

Since I love cycling so much, adding stuff to this site has always just been kind of a fun side project, something to relax with in the evenings, rather than something I thought about in monetary terms. However, the basic idea seems to be popular, and as luck would have it, I’ve been approached by someone looking to buy the code behind BikeChatter to drive their own custom twitter site. If someone has gone to the trouble of writing me, there must be other people interested too, so I thought I’d publicly state that I’d be willing to do similar deals with people interested in having their own custom twitter site. Interested? Write me at davidw@dedasys.com . I’d be happy to tell you what the code can and cannot do, and discuss any ideas you may have, in order to let you know if it’s a good fit, or if you’d have to do a lot of work.

The code is pretty straightforward Ruby on Rails. I use Postgres as a database, but others should work fine too. As is obvious, I’m not much of a design guy, but it shouldn’t be too hard to plug in your own look and feel.

The Erlang Paradox

There has been a nice series of interviews with the creators of various programming languages. In this one, it’s Joe Armstrong‘s turn. The creator of Erlang, he’s a very bright guy and well worth reading. One thing that has always struck me as interesting about Erlang, as compared to most of the “open source” style languages I’ve tended to use, is how it was incubated for a long time within Ericsson. It spent years there, and millions of lines of code were put into production use, prior to being open sourced, and certainly before the world at large took much notice of it.

This has been both good and bad for the language. The obvious upside is that a lot of smart people were paid to work on and improve it. Many new languages don’t really get that opportunity, unless they come out of an academic environment. Rather than being a spare time project, or something that slowly builds up speed over the years, Erlang, as far as the rest of the world was concerned, burst forth from Joe’s forehead, fully formed. This is not something like Ruby, where the early adapters were small companies like 37 signals, willing to live on the edge and not follow the pack. Quite the contrary, Erlang was backed by a huge, established player in the telecom market, focused particularly on applications where reliability is paramount. Certainly not a language you can call a ‘toy’!

The downside to all this, though, is that, esentially, they can’t really change the language much without being very, very careful. Here’s what Joe says about what he might have done differently:

Looking back, is there anything you would change in the language’s development?

Removing stuff turns out to be painfully difficult. It’s really easy to add features to a language, but almost impossibly difficult to remove things. In the early days we would happily add things to the language and remove them if they were a bad idea. Now removing things is almost impossible.

The main problem here is testing, we have systems with literally millions of lines of code and testing them takes a long time, so we can only make backwards compatible changes.

Some things we added to the language were with hindsight not so brilliant. I’d happily remove macros, include files, and the way we handle records. I’d also add mechanism to allow the language itself to evolve.

Which is an interesting contrast to more “traditional” open source languages like Ruby and Python, which, over the years, have from time to time bitten the bullet and unloaded stuff they don’t like. On the other hand, Erlang is solid code that you can count on if you do need to write systems with little to no downtime.

What do you think of the two approaches?

Swap Desktops

This weekend’s hacking efforts:

What it does:

I like to have my “workspace” in virtual desktop 1, where I have 3 emacs windows, and 4 urxvt windows (bash shells). Sometimes, however, it’s a bit of a pain to swap back and forth between client work and DedaSys work. One obvious approach is to replicate the window setup in a different virtual desktop. However, I’m used to having everything “just so”, so that I can quickly move to the desktop south of the main one to have my browser, east to get to the shells that connect to host things run on, and so on. And if I put my ‘local’ workspace on a different virtual desktop, it would screw all that up, so I wrote the above code. It utilizes the wmctl program to swap virtual desktop N with virtual desktop M, meaning it takes all windows from N, and puts them on M, and all the windows from M and puts them on N. If I have a bit more time, perhaps I’ll take a stab at the C code in wmctl and add a new option to swap virtual desktops.

Android Scripting

This is cool to see, even though it will doubtless take away some market share from Hecl:

http://google-opensource.blogspot.com/2009/06/introducing-android-scripting.html

Importantly, I think it helps to establish that Android is the phone OS for those who want to be able to hack on stuff. With the Apple phones, you’re not supposed to even run interpreters on them. Yuck.

In any case, I think that it still leaves some space for Hecl:

  • Their system uses natively compiled languages that use a JSON RPC system to talk. This makes managing them a bit trickier – Hecl is written entirely in Java and compiled as a ‘native’ Android application.

  • Hecl is very easy to embed, and doesn’t carry around a lot of baggage.

  • Hecl is small – apparently this system clocks in at something like 12 megs! Hecl is something like 500K.

Another cool thing is that this is, like most everything that Google has done with Android, open source under the Apache license (the same one as Hecl), which means that if I get a free moment, I’ll try grabbing some of their console code and integrating it to make a nice Hecl console for Android.

Objective C vs Cocoa

I’ve been adding a few things to LangPop.com, specifically ColdFusion (it’s not something I’m interested in, but I’ve had a lot of requests for it…) and Objective C, which is quite popular indeed, thanks to Apple.

Indeed, it is Objective C that is a bit problematic: “Cocoa” is more widely used than the name of the language itself! On http://search.yahoo.com, Cocoa programming turns up a lot more hits than Objective C programming:

  • “objective c programming: 71,300
  • “cocoa programming” : 608,000

That’s an order of magnitude!

Now, on one hand, I aim to measure popularity of the language itself, not of libraries. I simply can’t add every popular library, toolkit or framework for every language – it would be a huge task, and would likely only really make the results worse. However, it might not be entirely fair to leave that many actual users uncounted just because they all use Objective C in one particular environment. And just to further complicate things, while most people using Cocoa are writing Objective C code, there are other bindings for it…

My inclination, for simplicity’s sake, is still to simply go with Objective C. What do you think?

Ovi and Hecl

Granted, Hecl’s demo application is not the sort of things end users are going to want to use on a day to day basis, but I thought I’d use it to go through the process and see what I could see about Ovi.

Unfortunately, it didn’t go well, I got this the other day:

Comments from the QA team:
FAILED due to the devices not compatible by OVI store, OVI supported devices are can be found from the link
https://publish.ovi.com/help/content_providers (public, Qa in progress -> Qa failed)

The file failed QA on the following target(s):

  • Device: Unpublished Protos – XXXxYYY – Another Test Device

Which isn’t all that clear, putting it mildly. Hrm. Maybe I’ll try with something else just to see what can be seen.

Ruby, Soap4R, WSSE Authentication

I’ve been doing some work for a client, where we have to interact with a web service front end for Oracle (which also means that everything reflects Oracle’s “delightful” shortened table names, like UsrAddrsPhn…). I didn’t find a lot out there to do this in Ruby, except this helpful post:

http://willcannings.wordpress.com/2008/07/06/wsse-authentication-in-ruby-soap4r/

However, it wasn’t quite enough for what we’re doing, as we have to deal with a nonce parameter as well.

Here’s the snippet of code I created:

require 'rubygems'
gem 'soap4r'
require 'base64'

require 'soap/rpc/driver'
require 'soap/wsdlDriver'

wsdl_url = ARGV.shift
proxy    = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver

# run ruby with -d to see SOAP wiredumps.
proxy.wiredump_dev = STDERR if $DEBUG

require 'soap/header/simplehandler'
require 'soap/element'
require 'xsd/datatypes'

class WsseAuthHeader < SOAP::Header::Handler
  NAMESPACE= 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
  USERNAME  = 'Not really the username'
  PASSWORD  = 'Put your own password here'

  def initialize()
    super(XSD::QName.new(NAMESPACE, 'Security'))
  end

  def on_outbound
    security = SOAP::SOAPElement.new('wsse:Security')
    security.extraattr['xmlns:wsse'] =
      'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
    unt = SOAP::SOAPElement.new('wsse:UsernameToken')
    unt.extraattr['xmlns:wsu'] =
      'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
    un = SOAP::SOAPElement.new('wsse:Username', USERNAME)
    unt.add(un)
    pw = SOAP::SOAPElement.new('wsse:Password', PASSWORD)
    pw.extraattr['Type'] =
      'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
    unt.add(pw)
    # Create a nonce...
    nonce = SOAP::SOAPElement.new('wsse:Nonce', Base64.encode64((rand() * 1000000000).to_i.to_s))
    nonce.extraattr['EncodingType'] =
      'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
    unt.add(nonce)
    # The time format returned by XSDDateTime isn't quite right, so we
    # fiddle with it a bit.
    unt.add(SOAP::SOAPElement.new('wsu:Created',
                                  XSD::XSDDateTime.new(Time.now.utc - 30).to_s.gsub(/..*/, "") + "Z"))
    security.add(unt)
    return SOAP::SOAPHeaderItem.new(security, true)
  end
end

proxy.headerhandler << WsseAuthHeader.new()

... call proxy methods to interact with web service ...

The key thing is to dress up the outgoing header with all the right XML, including Nonce and Created parameters. This code was created by matching the XML generated by the Java code used to interact with this “JAX-WS” web service.

All in all, it’s a bit of a mess compared to a nice REST style web service. Hopefully the above code will be useful to others who are in a similar situation.

Improving github?

I’ve written several articles (*) lately that are, if not exactly critical of github, certainly question some of the community dynamics that have sprung up around it. I’m not the only one:

http://www.cubiclemuses.com/cm/articles/2009/04/28/a-community-of-rockstars/

However, I think the Github guys have actually done really great work, and done some cool stuff. And I think – and hope – that they’re here to stay, so instead of focusing on what’s not quite right about it, I thought I’d toss out some ideas on how it could be fixed. Some of them may not be great, but hey, that’s what you get for free – go ahead and throw out your own ideas too.

  • When you clone a project, it’s techncially a “fork”, but it’s not necessarily a fork in the real open source sense of “ok, I think I’m better able to develop this code, so I’m going my own way”, ala xemacs or x.org, or the bsd’s splitting apart. It might be nice if github gave people the means to indicate what sort of fork they’re creating – if it’s just a place to play with and publish some code, or if they think their code should be the one others reference.
  • Perhaps it should be optional to copy the wiki and issues tabs on your new fork. If you’re not really aiming to supplant the main project, do you really need those? You might need the issue tracker.
  • It might be an interesting experiment to let people vote on which one is the main project. Forkers could also indicate which one they want to keep working with as the main branch and maintainer.
  • Perhaps github could add some visual encouragement for people to send their patches on to the main branch of a given project.

Anyway, just a few ideas off the top of my head.

(*)
* https://journal.dedasys.com/2009/01/10/developer-project-or-project-developer-s
* https://journal.dedasys.com/2009/01/21/more-github
* https://journal.dedasys.com/2009/01/22/github-part-iii
* https://journal.dedasys.com/2009/04/29/will-the-real-exception_notification-please-stand-up

Will the real exception_notification please stand up?

A while ago, I wrote about some concerns of mine regarding git and github. Today, I was looking around, because I wanted to add the exception_notification code to a site of mine, and ran into this:

http://github.com/rails/exception_notification/network

Scroll all the way to the right, and you’ll see that there are a bunch of relatively current forks, and none of them seem to share recent changes. So which one is the ‘real’ one? My guess would be the one belonging to ‘rails’, but who knows… maybe that one has been abandoned?

Once again, this is nothing ‘new’: it has always been possible to fork open source code. What I wonder about is the mentality of just going off to work on your own stuff without contributing anything back. The results are a bunch of different forks, each of which may potentially contribute something interesting, but none of which appears to have collected all the new work.