Tk docs and best practices

I’ve been using Ruby/Tk some time. It is quite good GUI toolkit, however very poorly documented. Well there is a lot documentation, but it is hard to start writing Ruby/Tk applications, since documentation is meant for advanced users. And how to become one?

A lot of docs to read

Well it may change in future. First, there was new Tcl/Tk release (8.5) and this may put some new life into Tk world. This release is first from long time, and brings a lot new features to build modern GUI. Currently Tk 8.5 is not ported to Ruby, but I hope it will change in future.

And as for Tk’s documentation for newcomers – I’ve recently discovered site TkDocs which author promises try to make Tk documentation more user friendly. There is also group devoted to Ruby/Tk toolkit on Google.

You can keep an eye how work over new docs site is going on TkDocs blog.

I want my console!

When I had my first contact with Rails I was astonished. One of the coolest features for me was console. Total control of live application or just live testing. What You want. It must have been similar feeling to operate this console. Total control!

Console, but slightly different
Image from SXC

But best yet to come. I’m writing in Ruby also other applications. Read other – no Rails. In those applications You can have own console, too. Think about it, interactive shell to play with all data objects in Your program. How easy becomes testing ideas (like what would be if I changed that)? And having own console is easier than it seems.

I have looked through Rails console code and it turned out it is only few lines of code. So, here You have recipe for generic console. How to write own console in less than 5 lines of code:

irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'

libs =  " -r irb/completion"
libs << " -r config/setup"
exec "#{irb} #{libs} --simple-prompt"

I have put in my application all config data and require into config/setup. After executing this file with Ruby interpreter You have interactive shell to play with Your application.

OpenID: Simple Registration and 37signals

OpenID protocol has extension called Simple Registration (sreg). It is meant to exchange some additional info about user, not only authentication info. That way user logging first time with it’s OpenID account to some service didn’t have to write again data like date of birth, country or time zone.

Digital ID

When I was using OpenID first time as developer I was stuck over one simple issue. Whole process was successful but for some users application did requested data via Simple Registration every time user was logging in. It took me a little time to find cause.

OpenID id is full blown URL (with additional parameters after host name), however most often used in form http://username.identity.provider.com/. My problem was when user typed URL without trailing slash. Authentication was successful, but I was checking user database against what user typed in. Since there was no such user I was requesting additional data via sreg. When authentication was successful I was creating user from data returned from OpenID provider. But this id was with added trailing slash (like I was typing in http://netmaniac.openid.pl and server returns http://netmaniac.openid.pl/). Difference is minor ;) but when I was trying to log again in user database is no http://netmaniac.openid.pl (missing trailing slash)…

I felt much better when I wanted to write bug report to 37signals (minor issue with Highrise). Well it seems that they allow to use OpenID as login but in strange way. You have to sign into 37s forum and use OpenID only as authorization service. Strange is that when You try to login with OpenID without creating account on 37signals site, it asks OpenID provider for data required to complete registration (mandatory fields) through Simple Registration and then You got Sorry, no user by the identity URL "http://netmaniac.openid.pl/" exists.

PS
As a result I did not report bug – somehow disappointed by not fully supported OpenID I lost my will to fill another account creation form ;)

FreeBSD from a scratch for Rails

I had to prepare short information how to setup FreeBSD server to get Rails up and running. Not for production purposes but for development. Having it written down I decided to share with this. Here goes little howto (more on the way!):

First You need FreeBSD. Fortunately we have virtualization nowadays! So I recommend You get VMWare Player and search for system images with FreeBSD pre-installed to download. Like those.

So You have downloaded and installed software. Now we can start with configuration. Whole process can take up to few hours depending on internet connection speed and CPU computing power. But most of time it can be left unattended so You can work on other things in this time.

So let’s start!

Continue reading

Rails hits mainstream – finally?

This is exactly what makes Rails a ghetto. A bunch of half-trained former PHP morons who never bother to sit down and really learn the computer science they were too good to study in college.

This happens to every technology which hits mainstream. Anyway – good reading (and remember to read more on Zed’s blog than this rant only) for anyone interested in making money with Rails as programmer.

PS.
I still prefer Rails over many other solutions as freelancer. Despite many drawbacks it has became enough popular to provide job for freelancers like me.