Author Archive

Sunday, March 28th, 2010

[A note for casual readers: These notes are not meant to be objective representations of what different speakers said at Scottish Ruby Conference. They are my interpretations in my context.]

[Update 2010-03-29, morning: added more links. 2010-03-29, evening: re-phrased note on gender distribution and separated it from note on sexism, since I don't think of them as related and don't want others to think so. 2010-04-01: links to other summaries.]

Concurrency and real time are great to have and quite attainable if we step outside the comfort zone that Rails gives us. Thanks to Jim Weirich for the reminders and to Makoto Inoue and Martyn Loughran for valuable tips and tools: js-model, dragban, pusher demo, . Presentation here, and some background. And I really want to do some Erlang.

What we do is an art that is based on science and while the artistery has received a lot of attention lately, we can benefit from revisiting the science. Jim Weirich told us about Structure and Interpretation of Computer Programs. It’s available online and there is a mailing list to discuss the content and/or the exercises. I think Jim would have been able to sell 50 copies of the book on the spot if he had brought any.

Lifecycle management should be done with proper tools, not timestamps with funny names (approved_at, published_at, etc). And lifecycle is more than state machines, it’s also workflow and permissions. David Bock showed off Stonepath and hinted at Stonewall. He uses acts_as_state_machine but says that it should probably be really easy to use state_machine instead. (NB: A new version of state machine was released two weeks ago with a lot of important fixes!)

Ever since I read about ticgit in Scott Chacon’s Git Internals I have wanted to do something with git besides source code control but I always thought I’d need to learn 100 git plumbing commands. Scott demonstrated how to do very useful things with just four or five commands, so that’s something I’ll put in my toolbox.

Gwyn Morfey introduced a very useful image in his talk “Write Bad Code”. We may need to get into technical debt in order to avoid the area of death, just like we may need to get into financial debt in real life to avoid starving or bankruptcy. He also gave a good number of rules for classifying the situations where it is applicable and how to act in those situations.

Lots of people retweeted Tim Bray’s sentiment that “if your webapp doesn’t work on a mobile device nowadays then it doesn’t work”. I definitely think that is true in most cases, but I’m worried that it will be wielded like the Sword Of Truth in the future. It’s not black or white, and while most webapps should be written to work on a mobile device, I think there are loads of valid exceptions.

I read about CRC Cards (Class, Responsibility, Collaboration) many years ago and threw off the idea as a tool for people who needed something to hold in their hands while they learned about object oriented design and analysis. Sam Wessel ran a BoF workshop with Kevin Rutherford where we got to work through a simple analysis exercise. It was a real eye opener and the most valuable session of the conference. I learned two things:

  1. it is useful to have a class for the whole of the system and not just the parts, and
  2. I should learn about CRC. (I shall try to avoid the temptation to think that I can actually use it on my own just because I’ve sat at the feet of masters.)

I’m not a big friend of mocking and thus went to a BoF where Brian Swan and Kevin Rutherford debated mocks. Interesting debate, but according to show of hands at the end, I was the only person who changed their position to whatever slight extent. Apparently there is now a nicer syntax for setting expectations so that you can do the stubbing in the setup and the expectation checks in the actual it-clauses. And Kevin says that (contrary to Brian’s experience, and mine), he feels that he can refactor quite freely without breaking loads of mocks. I need to learn more about mocks or modelling, or both.

WebMock by Bartosz Blimke does the same thing FakeWeb, but better. It has support for regexp matching of urls, checks for POST data, and nice assertions. Worth checking out.

Redcar by Daniel Lucraft aims to be “a cross-platform programmer’s editor written in Ruby”. I couldn’t install it, probably because I have installed gems and rubies in too many ways on my laptop. Will need to clean up and try again.

Things I should check out: 12 hours to rate a rails application, Story mapper (big picture planning for Pivotal Tracker), Distributed Architectures with Rack (mentioned in Tim Bray’s blog).

Non-coding observations

  • When going to a country where it is hideously expensive to use my phone for data, I should bring an old phone that can run my normal sim card and buy a pay-as-you-go card for my iphone at the destination. Doubly so since there is really no reason to believe that anyone can ever create a wireless network that can support 300 developers at the same time, all the time.
  • RubyConf India had 28 female attendees out of 400 total; Scottish Ruby Conference had slightly less, I think.  I wonder what we can do as a community to raise that percentage.  I wonder what we can do as a society.  I wonder what I can do.
  • I also noted that a few presenters thought it appropriate to portray Ruby developers as geeky manboys and women as some kind of more or less attainable prize or decoration. That is so not cool.
  • Quality of presentations vary from marvellous and eyeopening to YOU HAVE ROBBED ME OF 45 MINUTES OF MY LIFE AND MADE ME LOSE FAITH IN HUMANITY. Unless the presenters are well known, I should always find someone who can vouch for the presenter beforehand, or at least talk to the presenter to find out what I can expect. In the choice between an interesting presentation and an interesting presenter, prefer the latter.
  • If I don’t manage to do the above, I should make sure to find a seat where I can sneak out of the room without looking rude.
  • Considering that the lack of equal opportunities for men and women is a far greater problem than my having 45 minutes ripped from my day, I’m forced to make the observation that I have grown slightly numb to male chauvinism. I don’t like that.

Links to others’ summaries:

Category: Programming, Ruby  | Tags: ,  | One Comment
Friday, August 14th, 2009

SQLite3 is truly dynamically typed. To a fault:

sqlite> select count(*) from posts where external_id = 199252;
0
sqlite> select count(*) from posts where external_id = '199252';
1
sqlite> select count(*) from posts where external_id = 199793;
1
sqlite> select count(*) from posts where external_id = '199793';
0

One day I suppose I will find it useful to store different data types in the same column, and without implicit conversion. I look forward to that day. Right now, I will have to spend a few hours cleaning up the mess that this caused.

Category: Programming  | Tags:  | Leave a Comment
Wednesday, August 05th, 2009

After last week’s got.rb meeting we went out to grab a beer and continue our geeky discussions.  I just want to make a note to myself that the wonderful beer I had (after CJ refused it) was a Gueuze Fond Tradition from Belgium.  It’s not available at Systembolaget, much like this summer’s first favourite, Gjutarns Bästa Bitter (et al.) from Skebo Bruksbryggeri.  Note within note: according to the homepage, Skebo’s beers should be available at Delirium and three more venues in Gothenburg!

Category: Life outside work  | Tags:  | Leave a Comment
Sunday, June 14th, 2009

All hackers want to live on the edge. What we rarely reflect on is the fact that most things have more than one edge. Adaptation curves have two: one where the early adopters build up their reputation for cool and one where I found myself this afternoon.

Apparently I should have let go of Fedora 6 some time ago. I installed this particular server in December 2006 when FC6 was the cool new girl on the block, and it has been running smoothly since then. But today when I tried to (yum) install a package, there were no servers to be found:

# yum search libxslt-devel
Loading "installonlyn" plugin
Setting up repositories
http://archive.kernel.org/fedora-archive/fedora/linux/core/6/i386/os/repodata/repomd.xml:
  [Errno 14] HTTP Error 404: Server: nginx/0.5.0
...
Trying other mirror.
core                      100% |=========================| 1.1 kB    00:00
Error: Cannot find a valid baseurl for repo: extras

Oops. I looked in /etc/yum.repos.d/fedora-extras.repo which is provides the base URL:

[extras]
name=Fedora Extras $releasever - $basearch
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=extras-$releasever&arch=$basearch
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

In earlier experience, the problem has been that the DNS service for the repo that mirrorlist recommends is down, and this is what some googling suggested too. So I went to mirrors.fedoraproject.org to see what it said. The answer surprised me:

# repo = extras-6 arch = i386 error: invalid repo or arch
# following repositories are available:
# repo=core-2, arch=i386
# repo=core-2, arch=x86_64
# ...
# repo=core-6, arch=x86_64
# ...

So core-6 is in the list but extras-6 is not. I tried some different combinations thinking I had got it wrong, but to no avail. Instead, on a whim, I checked out the site’s root where I could navigate to a human-readable list of mirrors and I started checking them out one by one. Uni-Bayreuth seemed to have what I wanted, so I edited fedora-extras.repo like this:

[extras]
name=Fedora Extras $releasever - $basearch
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=extras-$releasever&arch=$basearch
baseurl=http://ftp.uni-bayreuth.de/linux/fedora/linux/extras/$releasever/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

and ran yum search libxslt-devel again. This time it complained about updates instead (Error: Cannot find a valid baseurl for repo: updates). Unfortunately Bayreuth didn’t have the updates catalog which sent me searching in a few other places until I finally decided to try to make do without it by setting enabled=0 in fedora-updates.repo:

[updates]
name=Fedora Core $releasever - $basearch - Updates
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-fc$releasever&arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora

It worked, and I was able to install the packages I wanted, but I really need to get myself a newer OS. I’ll combine that with a move to another host; FS-data have let me down once too many, and I’ve never fancied upgrading the OS on a production server anyway.

Category: Server Configuration  | Tags: ,  | 3 Comments
Sunday, April 05th, 2009

Git bisect is the hero of the week! It turned out that some time between now and three weeks ago, the login functionality broke in the Rails app we’re developing. It didn’t break completely, of course, just in certain environments. And looking at the logs, I had no idea what the error could be, so I just had to work it out from the diff between the last working commit and next. Well, between three developers, there can be quite a few commits during three weeks and with a lesser version control system I would have had to

  1. checkout the previous revision,
  2. restart the server (because plugins, gems and even Rails can change between versions),
  3. try to log in,
  4. see if works and stop if it does,
  5. repeat from 1.

With git, I can ask git itself to perform a binary search among all the revisions between now and three weeks ago. It would go like this:

  1. git bisect start HEAD 57c3aaa,
  2. restart the server,
  3. try to log in,
  4. see it fail or succeed,
  5. say git bisect bad or git bisect good to make Git checkout the next node in the binary search tree
  6. repeat from 1 until Git says that it found the culprit.

It doesn’t look a lot better, but it is if you have 300 commits. Of course there is nothing to stop you from doing a manual binary search with Subversion, or even to step back one day at a time to narrow it down, and we didn’t actually have 300 commits. But where Git really shines is in the fact that if I can write a program that can tell if a version is good or bad, all I have to do is

  1. git bisect start HEAD 57c3aaa,
  2. git run ../my-test-probe.rb

and sit back and wait. Provided of course that the program also knew how to start and stop the server. Well, here is that program, for your debugging pleasure, and mine:

Wednesday, April 01st, 2009

PeepCode publishes wonderful screencasts and pdf books on subjects that should be of interest to any Rails developer. The pdfs seem to be adapted for screen reading – they are in landscape mode, not in standard paper sizes (as far as I can tell) and they have big print. So far so good, but I spend enough time in front of computer screens and like reading paper. I have tried various pdf rendering options combined with cropping, but the solution that worked best for printing Scott Chacon’s Git Internals PDF on A4 paper was as simple as printing it 2up at 118%.

Category: The daily grind  | Tags: , ,  | Leave a Comment
Wednesday, April 01st, 2009

FS-data was the first web hotel in Sweden to support Ruby on Rails (in August 2006, I think) and I’m glad they did. Unfortunately they haven’t touched their setup since, so patrons are still limited to (a) apps in subdirectories only and (b) FastCGI (FCGI). I have seen many complaints about FCGI, but I have only one: it’s really hard to know if it’s running my latest release. FS-data have added a control panel of sorts, but it’s pretty unreliable. Thus, I have to resort to killing. But what to kill?

$ ps -fe | grep rails
UID        PID  PPID  C STIME TTY          TIME CMD
wcj      27292  3558 27 13:41 ?        00:00:02 RAILS: /home/w/wcj/rails/sis/public/dispatch.fcgi
wcj      27365  3558 40 13:41 ?        00:00:02 RAILS: /home/w/wcj/rails/sis/public/dispatch.fcgi
...

With more than two processes I refuse to kill by PID – FCGI is just too quick to spawn new processes, and I’m not sure if they will run the right version of my app either. So it’s killall. But what to killall?

$ killall -9 'RAILS: /home/w/wcj/rails/sis/public/dispatch.fcgi'

does not work. So it’s ps to the rescue:

$ ps -eo pid,comm:30
  PID COMMAND
27365 rails_dispatche
27292 rails_dispatche

rails_dispatche, really? No final ‘r’? Whatever:

killall -9 rails_dispatche

It works and I’m happy again.

Thursday, November 20th, 2008

I read in New York Magazine this weekend that Malcolm Gladwell (author of The Tipping Point, Blink and Outliers) has a “regular biweekly ‘boys’ night out’” and that made me wonder if he went out with his friends every other Friday or perhaps every Tuesday and Saturday.  ”Biweekly” is a word that makes me uncomfortable since I hear it quite seldom, and it doesn’t seem to mean the same thing every time.  I’ve always thought that was because my otherwise near-perfect memory had a blind spot at that exact dictionary entry, so to speak.  Nevermind, I thought, if he invites me to join them I suppose he will be more specific, and if he doesn’t (quite likely) it doesn’t really matter, does it?

And then I read today’s Bloom County strip (re-runs from the ’80s) where Opus arrives at the barber’s for his “biannual haircut” and I decided to take action.  I can deal with not knowing Malcolm Gladwell’s party schedule, but I really want to know if my favourite penguin gets a trim twice a year or every two years.  (I have tried both intervals, and each has its charm.)

I started with “biweekly” and here’s what the dictionary says:

biweekly |bʌɪˈwiːkli|
adjective adverb
appearing or taking place every two weeks or twice a week [as adj. a biweekly bulletin [as adv. she followed her doctor’s instructions to undergo health checks biweekly.

Wow.  I never finished my course in Language Philosophy in 1992, but I remember the Morning Star Paradox quite well.  It goes something like this:

  • Mary belives that the Morning Star is Lucifer, and she believes that the Evening Star is the goddess Venus.  Her friend Tycho is aware of her beliefs, but…
  • Tycho knows that the Morning Star and the Evening Star refer to the same physical object, so…
  • Tycho thinks that Mary believes that Lucifer and Venus are one and the same.

I remember that this was a useful tool for understanding the difference between a reference and a referent or somesuch, but most of all I thought it was beautiful.  Mary has romantic beliefs about the existance of deities and their position in the sky, and while scientists normally shrug at romantic beliefs, they (we) all have to stick our noses into this one.  Dear Mary, you can believe that the Morning Star is Lucifer, and you can believe that the Evening Star is Venus, but you can’t believe both.  If you can’t see the beauty in this I probably can’t help you.

Anyway, here are today’s more or less contradictory words:

biweekly: (adj,adv) every two weeks or twice a week; (noun) a periodical that appears every two weeks or twice a week

bimonthly: (adj,adv) occurring or produced twice a month or every two months; (noun) a periodical produced twice a month or every two months.  (With the added note that “[i]n the publishing world, the meaning of bimonthly is more fixed and is invariably used to mean ‘every two months.’”)

biennal: (adj) taking place every other year, (noun) 1 a plant that takes two years to grow from seed to fruition and die. 2 an event celebrated or taking place every two years.

biannual: (adj) occurring twice a year

There are a few other things that come to mind when I see these words together.  One is that ‘biannual’ is never a noun.  Another is that the lexicographers chose to say “every two weeks or twice a week” but “twice a month or every two months”.  Order is not always significant in a dictionary, but it’s hard to fathom that not at least one of the two entries has a bias for ‘twice’ or ‘every two’.  But it’s of course impossible to know which one it is.

And thirdly, the note for ‘bimonthly’ as a noun makes me wonder if the notes are written by a different group of people from the ones who write the actual definitions, or if ‘publishing world’ is the key word here.  You and I might call a periodical that appears every two weeks bimonthly since it appears twice a month, but in the publishing world, it will be a biweekly instead.

Wow.

Category: Meta  | Tags:  | 2 Comments
Saturday, October 11th, 2008

Note to self: don’t leave your bike parked downtown (or indeed on public streets) over the night.  Apparently there is a great deal of pleasure to be had by thrashing other people’s bicycles.  And while I take pleasure from seeing my fellow man enjoying himself, I cannot really afford to sponsor it any more.

I parked my bike on Magasinsgatan last night in order to watch Rabalder perform Requiem. (The concert was a treat in a way that would have made Mozart green with envy.  He would have died to have electric guitars in his setting!)  After the concert, I left the bike there and chose to walk to the next event (this being Kulturnatta) together with friends.  I live three blocks away and planned to pick up the bike on my way home.  Of course, I pride myself by not living by plans, and when picking up the bike on the way home turned out to be a six block detour, I decided to leave it for today.

I’ll have to walk more than six blocks to the bike shop to have the three kicked-off spokes replaced, though.  Hopefully it will be cheaper than having the front wheel replaced, like last time, or replacing the night lights the time before that.

Category: Life outside work  | Tags: , ,  | 2 Comments
Thursday, October 09th, 2008

Apparently something called “click-jacking” can be used to hijack the microphone and camera on my laptop and the way to avoid that is to tell Flash that it can never ever have access to mike and cam.  Fine, done.

There is a patch coming out in a few weeks (or it may just be included in Flash 10 which I suppose will be a mandatory upgrade).  Fine again.  But how will I remember to go back and restore Flash’s access to my microphone and camera?  Well, hopefully I will see this blog entry the next time I write something.  Note to self.

Source: Macworld.

Category: Developer Client  | Tags: , ,  | Leave a Comment