lixo.org http://www.lixo.org letting the problem solve itself Sat, 05 Jul 2008 13:01:27 +0000 http://wordpress.org/?v=2.5.1 en Information radiator screen savers for MacOS X http://www.lixo.org/archives/2008/07/05/information-radiator-screen-savers-for-macos-x/ http://www.lixo.org/archives/2008/07/05/information-radiator-screen-savers-for-macos-x/#comments Sat, 05 Jul 2008 13:01:27 +0000 Carlos Villela http://www.lixo.org/archives/2008/07/05/information-radiator-screen-savers-for-macos-x/

I’ve been experimenting with information radiation and build monitors recently, and have extracted some of that into this tiny new project.

There is not a lot to it yet, just a quick hack that displays the current build status in giant NES-like fonts and a little spinning cube (see photo), but it works well as a demonstration of how simple it is to parse XML/RSS feeds in Quartz Composer, and how easy it is to build something fun, informative and that helps your team understand what’s going on. In our case, we have a very simple setup (CruiseControl.rb with the Git patches monitoring a single project), so there’s not a lot of information to show. Your mileage will definitely vary.

A slightly more important file, Build Monitor Template, is a bare-bones build monitor that’s already useful out of the box, although it’s your job to make it prettier. It displays all projects listed in the XML with a coloured status indicator next to them. It reads the same XML feeds as CCMenu, CCTray etc. Make sure you use those instead of the RSS feed in this case.

In order to use it as a screen saver, all you have to do is copy it over to /Library/Screen Savers, renaming at your leisure, and it should show up in your Desktop and Screen Saver preference pane. Make sure you set the correct XML feed URL in the Options dialog - you might want to try the CC Live one, as an example.

]]>
http://www.lixo.org/archives/2008/07/05/information-radiator-screen-savers-for-macos-x/feed/
Git tip: set your identification and colours http://www.lixo.org/archives/2008/06/26/git-tip-set-your-identification-and-colours/ http://www.lixo.org/archives/2008/06/26/git-tip-set-your-identification-and-colours/#comments Thu, 26 Jun 2008 18:45:06 +0000 Carlos Villela http://www.lixo.org/archives/2008/06/26/git-tip-set-your-identification-and-colours/

Absolute must-do for any new git users out there: set your name and email, so people can know who did what in the code!

git config –global user.name “John Doe”
git config –global user.email “john.doe@company.com”

Also, if you’re a command-line user (and who isn’t?!), make sure you configure it to add a splash of colour to its output. It’s really useful.

git config –global color.diff auto
git config –global color.status auto
git config –global color.branch auto

Oh, and in case you’re pair programming, this little script goes a long way:

#!/usr/bin/env ruby

def usage
  puts “./pair [name] [name]: pair two people”
  exit
end

usage if ARGV.size != 2

pair = [ARGV[0], ARGV[1]]

puts “pairing #{pair.first} and #{pair.last}”
`git config user.name “#{pair.first} & #{pair.last}”`
`git config user.email #{pair.first}+#{pair.last}@company.com`

And that’s it :)

]]>
http://www.lixo.org/archives/2008/06/26/git-tip-set-your-identification-and-colours/feed/
Hooked on Synthesis http://www.lixo.org/archives/2008/05/21/hooked-on-synthesis/ http://www.lixo.org/archives/2008/05/21/hooked-on-synthesis/#comments Wed, 21 May 2008 11:28:24 +0000 Carlos Villela http://www.lixo.org/archives/2008/05/21/hooked-on-synthesis/

Synthesis is an incredibly powerful tool, but until the Ruby Tuesdays meeting in the ThoughtWorks office last night I didn’t really grasp what it does.

It’s actually quite simple, but it changed the way I think about tests and mocks.

Say you have a Foo and a Bar, and they need to talk to each other so that your system can fly on pink unicorns. In fact, you expect the instance of Foo to tell an instance of Bar to frobble, giving it an instance of Baz to play with, and then, when the frobbling is done, Foo gets an integer back, and the rest is some complex logic that we won’t get into now (flying pink unicorns is difficult, as well as getting ahold of one). In a less noisy language:


bar.expects(:frobble).with(baz).returns(10)
foo.fly_pink_unicorn()

No problem there, and it should be fairly quick to make that a green bar. The problem starts when I rename frobble to frob in Bar but forget to change it in Foo. That test/spec/example/whatever we call it these days will still pass, as the expectation is still valid, and foo fulfills it nicely. It’s then up to you to figure out that this expectation has gone bonkers in the first place, and fix it.

What Synthesis does is to tell you that you forgot that. That’s it. Nice readable error message that tells you “hey, Bar doesn’t know about frobble, why did you ask it to do that?”, and fails the test. That opens a great big can of rainbows: when you don’t have to validate every assumption about your mocks anymore, suddenly what people usually call integration testing isn’t as necessary – you can have confidence in your system without having to write tons of fiddly set-up code or double-checking those interactions by hand.


]]>
http://www.lixo.org/archives/2008/05/21/hooked-on-synthesis/feed/
Making OpenCV prettier http://www.lixo.org/archives/2008/05/15/making-opencv-prettier/ http://www.lixo.org/archives/2008/05/15/making-opencv-prettier/#comments Thu, 15 May 2008 23:44:52 +0000 Carlos Villela http://www.lixo.org/archives/2008/05/15/making-opencv-prettier/

So while I’m on what ThoughtWorks calls the beach, which is the really nice place to go when you’re not assigned to a project, I’ve been playing with OpenCV, a lovely opensource library originally developed by Intel. It’s got a gigantic set of really interesting features related to real-time image manipulation and especially around real-time motion detection and face, hand and body recognition. If you’ve never played with computer vision, I highly suggest giving it a try. It’s tons of fun – and you get to brag about actually knowing what the hell a cascade of boosted classifiers working with Haar-like features means.

While I’m at it, I’ve been building a very small set of wrappers to make it all look a bit more OO (and probably a lot easier to read and write). As the README says:

This project has been set up only as a way of representing the knowledge the authors have gathered about OpenCV and is not intended to be a complete set of OO wrappers for the library – but contributions of any kind are definitely welcome.

Still, I’d much rather see code like:

currentFrame.sub(initialFrame).threshold(thresholdAmount)

than…

sub = cvCreateImage(...)
cvSub(currentFrame, initialFrame, sub)
result = cvCreateImage(…)
cvThreshold(sub, result, thresholdAmount, 255, CV_THRESH_BINARY)

But then maybe that’s just me.

Oh, while I’ve got your attention – doesn’t Apple make or sell those external Firewire iSights anymore? I managed to get ahold of one, and they’re lovely. Now that pretty much every Mac laptop has a built-in camera, maybe there’s no point, but they’re still incredibly useful in these kinds of setups.


]]>
http://www.lixo.org/archives/2008/05/15/making-opencv-prettier/feed/
Go for a walk http://www.lixo.org/archives/2008/04/25/go-for-a-walk/ http://www.lixo.org/archives/2008/04/25/go-for-a-walk/#comments Fri, 25 Apr 2008 09:21:15 +0000 Carlos Villela http://www.lixo.org/archives/2008/04/25/go-for-a-walk/

How many times have you had a conversation that started with “so while I was in the shower last night, I figured out how to…”, or something to that effect?

I naturally set out some time to think and daydream a little – about 10 minutes every two hours or so, while I have a cigarette (unfortunately, the nazi smoking ban hasn’t been enough to force me to quit just yet): most smokers will tell you that the hardest thing to give up are the ad-hoc social interactions you get with other people who wouldn’t otherwise only chat with or even meet.

But you don’t need to cover your lungs in filth just so you can have an excuse to think. When faced with a problem you want to solve, or even to find out where the real problems are in the first place, try what the native americans called the Medicine Walk:

The medicine walk is a day’s journey upon the face of the earth. It is also a mirror. In it, signs and symbols of your inward journey are reflected. The walk is a distilled form of the vision quest.

It doesn’t need to last a day, and it doesn’t need to sound like such an epic spiritual crusade either. Just get up and walk to place that’s about 10 or 20 minutes away, and that’s it. Take no distractions with you – no iPods, no phone, just about enough change to buy a cup of coffee once you get there, and then head back. Pay attention to the sounds, other people going about their lives, cars and buses passing by, the architecture of buildings, the colours and shapes and symbols around you. Look out for patterns, coincidences, and most importantly, pay attention to the internal dialogue going on in your head: it’ll be trying to pick apart the problem at hand, and you can follow some basic retrospective techniques to work some of it out once you’re in that state of mind.

After doing that on purpose for a bit, I noticed that going out for a walk works even better with a pair. You might need to take a longer break – I found that 20 to 30 minutes of walk time is ideal. That’ll give you about an hour to think, talk and socialise the ideas and problems at hand. Also, notice how easy it is to work out disagreements and suggest new things to try out; promenading has very different brainwave generating patterns, and is probably one of the best tools I have to stimulate creative thinking.


]]>
http://www.lixo.org/archives/2008/04/25/go-for-a-walk/feed/
Binary Guitar http://www.lixo.org/archives/2008/04/20/binary-guitar/ http://www.lixo.org/archives/2008/04/20/binary-guitar/#comments Sun, 20 Apr 2008 02:45:27 +0000 Carlos Villela http://www.lixo.org/archives/2008/04/20/binary-guitar/

The Binary Guitar is a little experiment (took about a day or two to put together) I played with a couple of months ago, and I thought it was fun enough to share.

Installation is seriously clunky – I have never tried it on anything but MacOS X Leopard running on a MacBook Pro so far, and even then there are lots of moving parts, but if you go through the pain of setting it all up, you should have some pretty decent sounds coming out of a USB Guitar Hero Controller (mine’s the X-Plorer, which comes with Guitar Hero II for the Xbox 360).

You’ll need:

Running:

  1. Install everything
  2. Open PD to MIDI.mipi in MidiPipe
  3. Open Binary Guitar.pd in PureData
  4. Go to Pure Data / Preferences / MIDI settings… and point the MIDI inputs and outputs to MidiPipe
  5. Open Binary Guitar.qtz in Quartz Composer
  6. Connect the X-Plorer Guitar. If everything’s working correctly, the Quartz Composer viewer should be black (rather
    than a checkered pattern)
  7. Open GarageBand, select your favourite virual instrument.
  8. Rock on!

Grab it in my github repository.


]]>
http://www.lixo.org/archives/2008/04/20/binary-guitar/feed/
JavaScript: Put everything in a namespace http://www.lixo.org/archives/2007/09/14/javascript-put-everything-in-a-namespace/ http://www.lixo.org/archives/2007/09/14/javascript-put-everything-in-a-namespace/#comments Fri, 14 Sep 2007 16:02:01 +0000 Carlos Villela http://www.lixo.org/archives/2007/09/14/javascript-put-everything-in-a-namespace/

Yes, everything. Put it in a namespace. Everything. No exceptions and no excuses, unless yours is “I have just been thawed.” In this case, I want to be the first to warmly welcome you to the 21st century.

Here’s a simple and reasonably OK way to do it and be nice to your friends, other libraries and the world at large:

var Article = Article ? Article : new Object();
Article.title = “Report: School Shootings Help Prepare Students For Being Shot In Real World”;
Article.save = function() {
  alert(”Saving ” + this.title);
}

You could save a few keystrokes, though. Just use the object literal notation directly:

var Article = Article ? Article : {
  title: “Report: School Shootings Help Prepare Students For Being Shot In Real World”,
  save: function() {
    alert(”Saving ” + this.title) 
  }
}

These two last examples are great if you’re not that concerned about exposing the ‘title’ attribute to the rest of the world. If there is a chance that problems could arise if some other piece of code changed it directly, there is a solution:

var Article = Article ? Article : function() {
  var private = {
    title: “Report: School Shootings Help Prepare Students For Being Shot In Real World”
  };

  var public = {
    getTitle: function() {
      return private.title;
    },

    save: function() {
      alert(”Saving ” + this.getTitle());
    }  
  }

  return public;
}();

I find this a bit hard to get used to, after so many years of developing in languages that explicitly allow me to set access control. It makes sense, though: by creating an anonymous function that returns the object I want to define, and then immediately calling it (note the ‘()’ at the last line), I can hide whatever I don’t want other parts of the code to see - it’s all tucked away in the local context of that anonymous function.

]]>
http://www.lixo.org/archives/2007/09/14/javascript-put-everything-in-a-namespace/feed/
The Project Game http://www.lixo.org/archives/2007/06/13/the-project-game/ http://www.lixo.org/archives/2007/06/13/the-project-game/#comments Wed, 13 Jun 2007 20:33:17 +0000 Carlos Villela http://www.lixo.org/archives/2007/06/13/the-project-game/

After reading A Theory Of Fun, I started seeing projects (and many other human activities) modelled as a game. In the book, Raph Koster describes a series of game development rules, and I found that they can be mapped to the software development project domain with some interesting results:

  • A project, just like a game, has roles. In projects, they’re specific to each role. These rules define the possible actions for each of them. (This one isn’t described in the book, but I added it just to contextualise.)
  • Role-specific rules should be unambiguous, intelligible and apply to all people in that role.
  • No project can be developed without the meaningful interaction of the people in all roles.
  • The outcome of a project has to be uncertain, otherwise it loses its appeal.
  • Rules and representation of a project are not independent but interact with each other.
  • People require clear and immediate feedback to understand the relationship between action and outcome.
  • People require a clear goal so they can perform meaningful actions within the project world.
  • Conflict and competition against time, budget and scope are essential for everyone’s motivation.
  • The challenges of a project should match the skills of the people involved: neither too easy (boring) nor too difficult (frustrating).
  • Projects can be developed without the need for even skill sets among the team. Instead the people learn through interaction, and this should be allowed and encouraged to happen.
  • People perform actions within the project world and observe how these actions change the state of the project.
  • People form a hypothesis about the meaning of a deliverable or action on the basis of their studies.
  • People recognise and learn fundamental patterns within the project and can apply these to different situations (and, of course, other projects).

The more I look at these, the more this matches the way I see people working in agile projects. I’m sure there’s a lesson to be learned here…


]]>
http://www.lixo.org/archives/2007/06/13/the-project-game/feed/
Tip: get your TODOs out of the comments http://www.lixo.org/archives/2007/06/06/tip-get-your-todos-out-of-the-comments/ http://www.lixo.org/archives/2007/06/06/tip-get-your-todos-out-of-the-comments/#comments Wed, 06 Jun 2007 13:16:47 +0000 Carlos Villela http://www.lixo.org/archives/2007/06/06/tip-get-your-todos-out-of-the-comments/

Developers in most projects I have seen try to establish some sort of convention around leaving TODOs in the code. The most common seems to be “if you see something funny, try to fix it immediately, but if it’d take too long and you’ve got something else to worry about, leave a comment next to it starting with TODO, your initials and maybe a date”.

You know what? Using comments for that is not as cool in Ruby, Python or Java, which has had static imports for a while now. How about creating a TODO method that takes in the initials, date and comment text, or whatever else you might find useful?

import static my.project.DevelopmentUtils.TODO;

…

public void doStuffThatSmellsFunny() {
   TODO(”CV, 21/jan”, “Clean this mess up after fixing #3849″);
   …
}

There are some advantages to this: you can actually put some code inside that method to do, say, logging. Another good thing is that now the TODOs can be tracked using the same refactoring tools and features of modern IDEs as just any other code in the project.

It may seem a bit cumbersome, but I’ve been trying that for a few days now and it feels quite pleasant to use. I got my TODO method to just spit out the message to the console so when I run tests, I can quickly get an idea of what areas of the code touch stinky or incomplete ones.

]]>
http://www.lixo.org/archives/2007/06/06/tip-get-your-todos-out-of-the-comments/feed/
Viral software (and in a good way) http://www.lixo.org/archives/2007/05/29/viral-software-and-in-a-good-way/ http://www.lixo.org/archives/2007/05/29/viral-software-and-in-a-good-way/#comments Tue, 29 May 2007 22:48:18 +0000 Carlos Villela http://www.lixo.org/archives/2007/05/29/viral-software-and-in-a-good-way/

I’ve been hanging out with friends in São Paulo over the last few days, getting unreasonably drunk, eating too much and attending the Google Developer Day, not necessarily in that order, so I missed the announcements that Facebook had opened up their API.

As a software developer with a healthy affection for all things related to network effects and emergent behaviours, this is brilliant.

The applications provided get added to a central registry inside Facebook, from where you can pick and choose the ones you want added to your profile. They still have to be deployed separately (as Facebook doesn’t host them for you), but the user doesn’t see any of that - all of it is a very simple and well-designed UI, so “installing” an application to your profile is a hell of a lot easier than installing a desktop application to your machine, and gives the user instant feedback.

Leaving important considerations on data ownership and privacy aside, which I won’t comment on since I haven’t read the agreements in much detail, I can see this thing eating a huge chunk of what we nowadays use disconnected internet applications for. Instant, mobile and email-like messaging, discussion groups, photo sharing and some other basic kinds of applications are already there, as are little data aggregation tools, like the del.icio.us and Magnolia importers. If this API is successful (and so far, nothing suggests otherwise), other social networks could as well be dragged inside Facebook if they support any kind of external API. And, if not, there are always screen scraping tools like Hpricot.

Something to watch out for, definitely. Ten years ago, we were wondering what kinds of applications could be made to run on the internet. Facebook is making us wonder what kinds of applications can be made to run on top of a social network. Which ones would you try?

]]>
http://www.lixo.org/archives/2007/05/29/viral-software-and-in-a-good-way/feed/