ruby

Fun with Ruby Block Parameters

I always forget what kinds of crazy things you can do with Ruby’s blocks and their parameters, so here’s a little write-up on them. I regularly forget things I’ve learned (must be an age thing), and I found that not even books on the Ruby language fully cover all the gory details on block (and method) parameters. So consider this my personal reference of crazy Ruby block syntax features for future use.

EventMachine, How Does It Work?

At this year’s Scottish Ruby Conference, I gave a talk about EventMachine, slides are available. Amidst the hype around Node.js it’s too easy to forget that Ruby has had evented I/O libraries for years. EventMachine, libebb, rev, cool.io, to name a few. As a general introduction I recommend reading Dan Kegel’s article on the C10K problem, the problem of handling 10000 server connections on a single machine. It introduces all the evented approaches that have been implemented in the different operating systems over the last some 15 years.

Making TextMate And rvm Play Nice

After being annoyed with running multiple versions of Ruby just by using MacPorts I finally gave in and tried out rvm, the Ruby Version Manager. That stuff got even more annoying when I tried to make Bundler behave well with multiple Ruby versions, because it just doesn’t by default. It’s not really a problem with normal gems, but Bundler falls apart with its defaults when you’re trying to run gems with native extensions. Hint: Set bundle_path to include RUBY_VERSION and make some links from one cache directory to another to not have every gem cached for every Ruby version.

Ruby 1.9 Tidbits

Things that don’t really justify their own separate posts.

A Ruby Meta-Programming Riddle

When we were at Scotland on Rails (excellent conference by the way, you should definitely go), and we sat in Dave Thomas’ keynote, where he talked about the “Ruby Object Model”, funnily enough we ran across a meta-programming wonder in that very session. It has been keeping me busy for a couple of hours, and I’d like to share my revelations. With some of them I’m not completely in the clear, but maybe they’ll be a start for discussion. It’s more a tale of one of my adventure through the Ruby object model than a fancy tutorial, so if you’re up for that kind of thing, keep going. If not, just keep on reading.

Ruby 1.9 Upgrading Woes

Actually, not so much woes, as general musings. I just finished upgrading a project I’ve been maintaining for the last 15 months or so to Ruby 1.9, and I thought I’d share some of my experiences with the process. Looking back it wasn’t so hard after all, but there were some pitfalls.

Remembering super

Yehuda Katz recently wrote a post about good old super, probably one of the most underused keywords in Ruby, sadly enough. What can I say, it hit right home. It pretty much nailed what’s wrong with alias_method_chain, and pretty much put in words how I felt about it too. It helped to explain why I get a weird feeling in my stomach when I see how plugins like authlogic implement some of their functionality. To sum up: it just feels wrong.

The Curious Case Of The Bang Method

One of the cool things about Ruby is the possibility to make your method’s intent more expressive using the question mark or the bang. There’s no need to argue about the use of the question mark method, their intent is to ask something, whether it’s the the status of an object or if the current weather is suitable for getting out your longboard. Their result will usually be true or false, including nil or not nil.

XRay Goggles For Your Ruby Processes

The guys over at Pivotal Labs wrote a small piece on a neat tool called XRay. It hooks into your Ruby code to provide Java-like signal handlers which dump the current stack trace into whatever log file seems fit. Using Passenger that’ll be your Apache’s error log file.

When Overusing self Turns Into self.pity

There’s something I see in lots of projects is an overuse of self. Sure, it looks a lot nicer than this, but its overuse can clutter code quite easily. Here’s a rather simple example.

Integrity And Passenger Play Nice

I wanted to play the field of continuous integration tools a little bit more, so I finally gave Integrity a go. Its promise of being lightweight sure was tempting.

New Tools For My Toolbox

For a new project I wanted to try some new things, the moment just seemed right, so let me just give you a quick round-up.

Running Webistrano Tasks Using Capistrano

It’s no secret that I totally dig Webistrano. It’s superior to just using Capistrano in so many ways. Although I’m still working on Macistrano (it’s bound to be released soon as well, I promise), some people I told Webistrano about asked me if they still could use a simple cap deploy to fire off a deployment.

Refactoring Rails Controllers

This post has been lying in my drafts folder for a while now, and since I’m trying out new approaches to shrink oversized controllers, it’s about time to put this out, and get ready for describing alternatives.

JetBrains Releases RubyMine

IntelliJ used to be my favorite Java IDE, it was seriously the tool that made the pain of working with the Java enterprise stuff bearable.

Merb’s run_later Coming to a Thread-safe Rails Near You

At RailsConf Europe, Yehuda Katz showed off a small yet totally useful feature of Merb. A method called run_later that does nothing more than queue the block it receives as an argument to be executed after the request is done.

Undefining Class Methods in Ruby

To get a weird RSpec mock error working again, I tried to look for a solution to dynamically add and remove methods on each spec run due to some odd ends in the current RSpec edge version. Sounds weird I know, but what are you gonna do. I went for a different solution in the end, but still this was good to know.

RailsConf Europe 2008 Recap

RailsConf Europe 2008 is over (and has been for a few days now, I know), so it’s time for a recap. In all it was much better than I expected, last year’s conference was a bit of a disappointment, so my expectations were low enough to be positively surprised.

A Busy Month

That’s what it’s been. And who needs to work when there’s so many nice projects to work on, eh? Well actually, I did work, but in my free time I also worked on some other things, a new one, and existing projects.

Rails 2.0: It’s Done

After more than two days of removing deprecation warnings, adding plugins, fixing some custom additions, going through the whole application, it’s finally done. We’re running Rails 2.0. Nothing more gratifying than seeing this, well except for the application running without problems:

Friday Tab Sweep (21.03.2008)

Lots of open tabs to be swept. Brace yourselves.

Git

Can you tell I’m looking into Git right now?

Ruby

Rails

Mac OS X

  • Secrets. An ever-growing list of hidden preferences. Comes with a handy-dandy preference pane.

Ruby Tidbits: How Private is Private?

Several of my friends are picking up Ruby these days. Just like me, they’re coming mostly from the Java world. Good thing about that is that they’re asking me questions about Ruby. Always a great opportunity to dig more into the language, and to write down some tidbits that came up.

How to Process Multiple ActiveMessaging Queues Concurrently

The title totally overemphasizes the topic, but here we go. By default ActiveMessaging will process all your queues in one thread. All messages from all queues will be processes sequentially. This isn’t always what you want. Especially in scenarios where you have both long-running tasks being kicked off through messages, and rather short-lived tasks that you just fire and forget.

ActiveMessaging has a rather simple and not-so-obvious way of dealing with that: processor groups. There’s some documentation on them, but it doesn’t bring out the real beauty of them.

Basically you split your processors in groups, how finely grained is up to you. A simple way would be to just separate long-running from short-lived tasks. You just have to define these in config/messaging.rb:

ActiveMessaging::Gateway.define do |s|
  s.destination :index_update, '/queue/IndexUpdate'
  s.destination :giant_batch_job, '/queue/GiantBatchJob'
  s.processor_group :short, :index_update_processor
  s.processor_group :long, :giant_batch_job_processor
end

Now that you have these, how do you get them to run in different threads? If you just use script/poller start, it will continue to work through all messages from all queues. You need to start each processor group individually:

$ script/poller start ---- process-group=short
$ script/poller start ---- process-group=long

Keep in mind though that you can’t stop just one poller for one particular processor group. Running script/poller stop will tear them all down. Which comes in handy during deployments. That way you only have to ensure that all your process groups are started during the deployment, but not about stopping every one of them.

ActiveMessaging will run each group in a separate thread which all are monitored by the poller_monitor. The latter will only be started once, courtesy of the daemons package.

Serializing Data with ActiveMessaging and Filters

I’ve been playing around with ActiveMessaging recently. Well, actually more than that. I integrated it into a project for asynchronous processing. It’s a pretty neat plugin. We’re using StompServer as a message broker, and therefore the Stomp protocol to publish and poll the messages.

Now Stomp is a pretty simple protocol and breaks down when you’re trying to deliver “complex” data structures like hashes, arrays or **gasp** objects. That’s not a bad thing per se, since we can serialize them with YAML. Of course you could just always do that by hand before publishing a message, but let’s face it, that’s just tedious.

The author of ActiveMessaging recently added support for filters. They can be run after publishing a message and/or before processing it on the polling side. I hear it clicking on your end, why not use filters to do the serializing work for us? Right on!

Here’s a simple filter to serialize the message when it’s sent:

class SerializeToYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    if message.body.respond_to?(:to_yaml)
      message.body = message.body.to_yaml
    else
      message.body = YAML::dump(message.body)
    end
  end
end

It uses the to_yaml method mixed in by Rails, if it’s available. Otherwise it just dumps the object with the YAML::dump method.

The receiving end is even easier.

class DeserializeYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    message.body = YAML::load(message.body) rescue message.body
  end
end

The filter respects potential deserializing errors and just returns the message body in that case. Otherwise it just loads the objects from the message body. And that’s the whole story.

Now you need to configure it in config/messaging.rb and you’re good to go:

ActiveMessaging::Gateway.define do |s|
  s.filter :deserialize_yaml_filter, :direction => :incoming
  s.filter :serialize_to_yaml_filter, :direction => :outgoing
end

The benefit? This way you can send more complex data structures (as opposed to just strings) through the broker:

publish :my_queue, :action => 'do_stuff', :with => 'User', :id => 1

But remember to keep it simple. Don’t try to stuff large objects through there. Sending over the user itself is very likely not a good idea, even more so when it’s an ActiveRecord object.

More to come on a13g and Stomp.

Friday Tab Sweep (18.01.08)

  • PeepCode on RSpec User Stories. The user stories look awesome as a replacement for Rails integration tests. The PeepCode is a good introduction on the topic, but falls awfully short on that issue. Using basic steps like saving an object, checking if it’s valid and checking whether it was actually stored in the database is a little bit too simple in my book, and something you shouldn’t be testing all that much anyway.

Rails/Ruby Books Galore

The book market is being swamped with new books. It seems like every day I discover a new announcement for an upcoming book on Ruby or Rails. Let’s see what’s currently in stock, and what’s waiting for us next year.

Mocha and RSpec Don’t Play Nice

Mocking is a great part of RSpec, and from the documentation it looks insanely easy. What had me frustrated on a current project is the fact that the mocks and stubs wouldn’t always do what I’d expect them to do. No errors when methods weren’t invoked, and, the worst part, mocks wouldn’t be cleaned up between examples which resulted in rather weird errors. They only occurred when run as a whole with rake spec but not when I ran the specs through TextMate.

I was going insane, because noone on the mailing list seemed to have any problems, same for friends working with RSpec. Then I had another look at the RSpec configuration.

Turns out, the reason for all of this is that Mocha was used for mocking. Switching the configuration back to use RSpec’s internal mocking implementation, everything worked like a charme from then on.

So what you want to have in your SpecHelper isn’t this:

Spec::Runner.configure do |config|
  config.mock_with :mocha
end

but rather

Spec::Runner.configure do |config|
  config.mock_with :rspec
end

or no mention at all of mock_with which will result in the default implementation being used which is, you guessed it, RSpec’s own.

Dave Thomas on MetaProgramming in Ruby

Over at InfoQ, there’s a nice talk of Dave Thomas at last year’s QCon. He talks about meta programming, and how it’s used in Rails to achieve all the magic that makes it what it is. Not to the tiniest details, but he explains Ruby’s mechanisms which Rails uses to achieve the magic.

A Weird Ruby Bug

I ran across a weird bug the other day that seems to have been fixed in Ruby 1.8.5. It’s nonetheless quite an interesting one. When you use a hash as a method parameter, and that hash happens to contain the key :do and you call the method without parentheses, like so:

Friday Links (30.11.07)

  • QuickLook and TextMate, sitting in a tree. Makes QuickLook even better. It integrates the TextMate syntax highlighting into QuickLook, and integrates QuickLook into TextMate. Looks pretty neat. TextMate in QuickLook

Singing the Paypal Subscription Blues

For a recent project I had the pleasure to work with Paypal, especially with the Instant Payment Notification API. I haven’t heard a lot of things before I tried to marry it with Rails, but what I’d heard made me assume it wouldn’t be a piece of cake. And I was right.

I’d love to share some code with you, but Vasillis Dimos beat me to it. He wrote two posts on Paypal IPN and Rails, one dealing with the basics and the other about mocking IPN, which you really need to do to test your code. Really.

Personally I did the testing a little differently, since all my payment handling logic was in the model. I didn’t use ActiveMerchant either, but just the Paypal gem. But in general things are similar. Outside of the US and the UK you’re pretty much out of choices for payments, since there’s no Web Payments Pro available here, so IPN is (sadly) the way to go. It’s a real PITA and here’s why:

  • Paypal needs to reach your development machine from the outside. For testing this is not an issue of course, but when you need to do testing with the Paypal sandbox (which is painfully slow) and, god forbid, the real Paypal, there’s no way around that.
  • The payment flow is unnatural. You have to handle the payment outside of the user’s page flow. You have to rely solely on the stuff you get from Paypal, no session, no cookie, no user. It takes a lot of care to handle all that and there still might be a hole in your code that could be exploited.
  • IPNs might come in late, sometimes only after the user already got back to your site. Now you want to present him with a nice success message, but that’s not gonna happen then. That’s a rare case though. The IPN come in slower from the sandbox, that’s for sure. It’s up to you how to handle that. You can act in the favor of the user, or you can just make him wait till everything fell into place.
  • In rare cases you won’t get an IPN from Paypal, for whatever reason. I’ve seen this happen. Be prepared to create the successful payment by hand or have something like a small GUI at hand to do it.
  • For subscriptions six different notification types need to be handled. And their even spread out over two different fields in the notification.

Some advice on how to get it right:

  • Log everything. Store the IPNs in the database, in the log files, wherever. Just log them. Their your proof of things that happened. Just storing them with their raw post data should do while leaving the most important fields separately in different columns.
  • Use mocks. It’s not hard. But it’s totally worth it. When you want to test all events that Paypal might send you, which is a lot for subscriptions, it’s a painful development cycle. And some events aren’t even fully testable by hand.
  • Decide on strategy to handle fraud. While your IPN URL is not really public (nothing should link here, and it’s hopefully transmitted to Paypal encrypted) it’s not exactly safe to just accept everything.
  • Don’t return errors in your IPN handler. Paypal will try it again.
  • Store a pending payment and make it a full one when the corresponding IPN arrives.

All that said, it was an experience, and while not always pleasant, at least I learned something. But Paypal is far from being a pleasant way to handle payments, if you want to make it secure and protect your the integrity of your application and prevent fraudulent users from abusing your services, all of which should be your primary interests.

Best Practices on Rails

This morning, on day two, Marcel Molina and Michael Koziarski did a little Best Practices session, a welcome change to the keynotes and sessions. It was very code-oriented. I did even take something out of it I didn’t know before. Though I wish it would’ve gone into a little bit more detail (which I actually wish for a lot of the other sessions as well, but more on this in a later post), it was something that you could relate to on a practical level.

RailsConf Europe 2007 Day One

Day one of the RailsConf Europe is over (for me anyway), and so here’s my summary of what I’ve seen and heard today.

It all really started yesterday with Dave Thomas’ keynote on “The Art of Rails”. The talk was inspiring. It wasn’t really any new stuff, basically a nice speech with visuals about what the Pragmatic Programmers have already written about. The comparison to art sounds far-stretched for a lot of people, and it might even be. Still, there’s a lot to learn from art that can be applied to software development. Casper Fabricius published a nice summary.

The morning keynote by David Heinemeier Hansson was okay. It wasn’t great. It pretty much summed up all the neat new features of Rails 2.0. There’s another nice summary over at the blog of Casper Fabricius.

My sessions schedule started out with Benjamin Krause’s “Caching in Multi-Language Environments.” He actually patched the REST-routing in Rails to support the content language as a parameter for a resource URI, e.g. /movies/231.html.de. Neat stuff. He also implemented a language-based fragment cache using memcached. Both will be available later this week on his blog.

Next up was Dr. Nic’s talk on meta-programming with Ruby and Rails. My word, I love his Australian accent. His talk was highly entertaining, I was laughing a lot. But it was also inspiring. He’s very encouraging about trying out the meta-programming features of Ruby and doing some weird, funny and useful stuff with it. He already put up his slides for your viewing pleasure.

The afternoon was filled with the wondrous joys of JRuby and Rubinius, held by their respective maintainers Charles Nutter, Thomas E Enebo and Evan Phoenix on both of which I’m hooked now. Especially Rubinius impressed me a lot.

Roy Fielding’s talk on REST was something I was really looking forward too, but it turned out to be more of a summary of his dissertation. The part on REST was good, but he spent an awful lot of time telling history and the theories behind REST.

The smaller diamond-sponsor keynotes by Jonathan Siegel of ELC Tech and Craig McClanahan were short, but pretty good I’d say.

In all, the day was pretty good, and I’m looking forward to tomorrow.

ActiveRecord and a custom method_missing

Don’‘t be tempted to overwrite method_missing in an ActiveRecord-based model class. It will open a can of worms that’s hard to close without removing your custom version again.

Friday Rails Links

It’s been a week full of Rails joy, and a little pain as well, but that’s not to looked for in Rails itself, but just some code.

Random Rails Links

Continuous Integration for Ruby and Rails

Due to some developers not so keen about running the tests I got back to my trusty friend Continuous Integration for a project I’m currently working on. Being a big fan of CruiseControl I looked for similar solutions for the Rails and Ruby market. There are several tools you can use, and they have several ups and downs.

Smalltalk on AP4R

After playing around with AP4R, the new kid on the asynchronous Ruby block, for a little while, I held a small presentation at last week’s meeting of the Ruby User Group Berlin. While it is more of an introduction than a field report I put up the slides as PDF anyway.

JRuby 1.0 is out

If that’s not exciting, then I don’t know what is. Original Ruby finally has got competition. I tip my hat to the team that developed JRuby in such a short time frame and now fully conforms with Ruby 1.8.x. Though I’m not keen to run JRuby in Glassfish, it’s nice to have the option to integrate a Rails application with J2EE services. Think of that EAI buzzword that came up a few years ago.

Smalltalk about BackgrounDRb

I held a small presentation about BackgrounDRb yesterday at the meeting of the Ruby User Group Berlin. It wasn’t a very big presentation, since actually, there’s not a lot to say about BackgrounDRb. But if you want to check it out, you can get the slides and the little sample application.

Deploying in a chroot Environment with Capistrano

A chroot environment seems to be rare these days. Everything is virtualized, load-balanced and what have you. I recently found myself trying to deploy into a chroot’ed Lighttpd environment with Capistrano and immediately ran over several pitfalls. The biggest problem is that Capistrano uses absolute links for directories like current and the links to the log directory.

RubyFX Script Announced

At first I was rather disappointed by what Sun announced with JavaFX, the newest competitor in the RIA market. In my taste F3 looks rather ugly and has a way too expressive syntax, compared to, say SVG. The target’s not the same between these two, I know that, but comparing what code you need to draw, SVG is a winner. Anyway, that’s not really the point.

Microsoft announces IronRuby

Now that’s something. Microsoft announced IronRuby at their MIX07 conference. IronPython developer Jim Hugunin provides some details about extensions to the .NET CLR made to improve support for scripting languages. The extension is called Dynamic Language Routine.

Namespace Your Rails Model

I had a nice revelation earlier this week, when I finally tested some code I wrote in the wild, the wild being BackgrounDRb. The code used some pretty common class and module names. I didn’t expect many problems when I used something along the lines of Sync or Synchronizer. When running the code in test cases there wasn’t any problem.

A Fix for Rails 1.2

While setting up a new project with Rails 1.2.3 I ran across a weird issue in my tests. Somewhere from the CGI class (belonging to Ruby’s core lib and extended by Rails) a nil object was used and threw an error. Turns out this was introduced in 1.2.2 with a fix that was supposed to improve CGI handling on Windows.

Back to Top ↑

rails

Form Objects with ActiveModel

When I built the billing process for Travis CI’s commercial offering, I decided to try out some new things to avoid callbacks in ActiveRecord models, including validations.

ActiveRecord’s Callbacks Ruined My Life

Recently I’ve been having a foul taste in my mouth, or just a bad feeling, if you will. Whenever I started adding validations and callbacks to a model in a Rails application. It just felt wrong. It felt like I’m adding code that shouldn’t be there, that makes everything a lot more complicated, and turns explicit into implicit code. Code that is only being run depending on the persistence state of an object. Code that is being hard to test, because you need to save an object to test parts of your business logic. Don’t get me started on observers, I never was a fan of them. Putting stuff that should be run when an object was saved elsewhere is the worst kind of hiding business logic.

Redis and Rails sitting on the Couch

I’ve been spending some quality time with two of my new favorite tools lately (CouchDB and Redis, duh!), and while integrating them into Scalarium some needs and as a result some smaller hacks emerged. I don’t want to deprive the world of their joy, so here they are.

Daily AWS Wtf and German Rails Conference

I’ve started a new blog (don’t worry, I have not abandoned this one), specifically targeting experiences, wtf’s and workarounds for the latter on Amazon’s Web Services. I’ve been working quite a lot with them recently, and there’s heaps of dark corners around, and things you need to be aware of. That’s what that blog is about. Head on over to Daily AWS Wtf and give it a read. It’s powered by the people of Peritor, so there’ll be other people writing too.

Crumble - Breadcrumbs for Rails Applications

I recently had to improve the breadcrumbs situation on one of my projects. Until now, breadcrumb definition were sprinkled across the controllers. While that was okay for a while, the current breadcrumbs have become a bit more complex, and I wanted to get them out of the controllers. One option would’ve been to put them into the model, but seriously, who does that? Plus, I have a lot of breadcrumbs that are not exactly related to a model, and if they are, it’s not always an ActiveRecord model.

run_later Gets Some Rails 2.3 Middleware Love

Apart from the awesome new features for users of the framework, Rails 2.3 got a lot of love on the inside too. It’s no secret it’s running on Rack now, and that switch made some of the internal code a lot easier on the eyes. They also added a Rails-internal middleware stack, on which some of the framework’s functionality builds already.

RailsWayCon: Call For Papers

On the heels of RailsConf Europe’s cancellation comes the call for papers for one of the viable alternatives, the RailsWayCon. It’s happening from May 25th to 27th in Berlin, so other than going to Scotland on Rails like yours truly, this is the conference to go to.

Integrity And Passenger Play Nice

I wanted to play the field of continuous integration tools a little bit more, so I finally gave Integrity a go. Its promise of being lightweight sure was tempting.

Refactoring Rails Controllers

This post has been lying in my drafts folder for a while now, and since I’m trying out new approaches to shrink oversized controllers, it’s about time to put this out, and get ready for describing alternatives.

acts_as_solr is Dead, Long Live acts_as_solr

On a current project we recently switched from Ferret to using Solr as our search engine. That switch was more than necessary, but that’s material for a different blog post. Let’s just say, the switch was more than worth it, and Solr just rocks our socks off.

Vim - My College Sweetheart

It’s true, I did write my diploma thesis using Vim. Old-school with LaTeX and C++. When I came to the Mac five years ago I was still using the now pretty much dead Carbon version of MacVim. And well, it just didn’t feel right. I’m very comfortable on the command line, but on the Mac I wanted something that integrated well with the rest of that system, that behave like a real Mac application.

JetBrains Releases RubyMine

IntelliJ used to be my favorite Java IDE, it was seriously the tool that made the pain of working with the Java enterprise stuff bearable.

Merb’s run_later Coming to a Thread-safe Rails Near You

At RailsConf Europe, Yehuda Katz showed off a small yet totally useful feature of Merb. A method called run_later that does nothing more than queue the block it receives as an argument to be executed after the request is done.

Migrating a Project to use Rails UTC-based Migrations

A confusing title, I know. But I recently upgraded a rather big project to use Rails 2.1. Everything went pretty smoothly, but one thing bugged me, since it’s not really documented anywhere: What happens if you migrate from the old numbered migration scheme to the new one using UTC timestamps?

RailsConf Europe 2008 Recap

RailsConf Europe 2008 is over (and has been for a few days now, I know), so it’s time for a recap. In all it was much better than I expected, last year’s conference was a bit of a disappointment, so my expectations were low enough to be positively surprised.

A Busy Month

That’s what it’s been. And who needs to work when there’s so many nice projects to work on, eh? Well actually, I did work, but in my free time I also worked on some other things, a new one, and existing projects.

Rails 2.0: It’s Done

After more than two days of removing deprecation warnings, adding plugins, fixing some custom additions, going through the whole application, it’s finally done. We’re running Rails 2.0. Nothing more gratifying than seeing this, well except for the application running without problems:

Friday Tab Sweep (21.03.2008)

Lots of open tabs to be swept. Brace yourselves.

Git

Can you tell I’m looking into Git right now?

Ruby

Rails

Mac OS X

  • Secrets. An ever-growing list of hidden preferences. Comes with a handy-dandy preference pane.

How to Process Multiple ActiveMessaging Queues Concurrently

The title totally overemphasizes the topic, but here we go. By default ActiveMessaging will process all your queues in one thread. All messages from all queues will be processes sequentially. This isn’t always what you want. Especially in scenarios where you have both long-running tasks being kicked off through messages, and rather short-lived tasks that you just fire and forget.

ActiveMessaging has a rather simple and not-so-obvious way of dealing with that: processor groups. There’s some documentation on them, but it doesn’t bring out the real beauty of them.

Basically you split your processors in groups, how finely grained is up to you. A simple way would be to just separate long-running from short-lived tasks. You just have to define these in config/messaging.rb:

ActiveMessaging::Gateway.define do |s|
  s.destination :index_update, '/queue/IndexUpdate'
  s.destination :giant_batch_job, '/queue/GiantBatchJob'
  s.processor_group :short, :index_update_processor
  s.processor_group :long, :giant_batch_job_processor
end

Now that you have these, how do you get them to run in different threads? If you just use script/poller start, it will continue to work through all messages from all queues. You need to start each processor group individually:

$ script/poller start ---- process-group=short
$ script/poller start ---- process-group=long

Keep in mind though that you can’t stop just one poller for one particular processor group. Running script/poller stop will tear them all down. Which comes in handy during deployments. That way you only have to ensure that all your process groups are started during the deployment, but not about stopping every one of them.

ActiveMessaging will run each group in a separate thread which all are monitored by the poller_monitor. The latter will only be started once, courtesy of the daemons package.

Serializing Data with ActiveMessaging and Filters

I’ve been playing around with ActiveMessaging recently. Well, actually more than that. I integrated it into a project for asynchronous processing. It’s a pretty neat plugin. We’re using StompServer as a message broker, and therefore the Stomp protocol to publish and poll the messages.

Now Stomp is a pretty simple protocol and breaks down when you’re trying to deliver “complex” data structures like hashes, arrays or **gasp** objects. That’s not a bad thing per se, since we can serialize them with YAML. Of course you could just always do that by hand before publishing a message, but let’s face it, that’s just tedious.

The author of ActiveMessaging recently added support for filters. They can be run after publishing a message and/or before processing it on the polling side. I hear it clicking on your end, why not use filters to do the serializing work for us? Right on!

Here’s a simple filter to serialize the message when it’s sent:

class SerializeToYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    if message.body.respond_to?(:to_yaml)
      message.body = message.body.to_yaml
    else
      message.body = YAML::dump(message.body)
    end
  end
end

It uses the to_yaml method mixed in by Rails, if it’s available. Otherwise it just dumps the object with the YAML::dump method.

The receiving end is even easier.

class DeserializeYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    message.body = YAML::load(message.body) rescue message.body
  end
end

The filter respects potential deserializing errors and just returns the message body in that case. Otherwise it just loads the objects from the message body. And that’s the whole story.

Now you need to configure it in config/messaging.rb and you’re good to go:

ActiveMessaging::Gateway.define do |s|
  s.filter :deserialize_yaml_filter, :direction => :incoming
  s.filter :serialize_to_yaml_filter, :direction => :outgoing
end

The benefit? This way you can send more complex data structures (as opposed to just strings) through the broker:

publish :my_queue, :action => 'do_stuff', :with => 'User', :id => 1

But remember to keep it simple. Don’t try to stuff large objects through there. Sending over the user itself is very likely not a good idea, even more so when it’s an ActiveRecord object.

More to come on a13g and Stomp.

Friday Tab Sweep (18.01.08)

  • PeepCode on RSpec User Stories. The user stories look awesome as a replacement for Rails integration tests. The PeepCode is a good introduction on the topic, but falls awfully short on that issue. Using basic steps like saving an object, checking if it’s valid and checking whether it was actually stored in the database is a little bit too simple in my book, and something you shouldn’t be testing all that much anyway.

Rails/Ruby Books Galore

The book market is being swamped with new books. It seems like every day I discover a new announcement for an upcoming book on Ruby or Rails. Let’s see what’s currently in stock, and what’s waiting for us next year.

Mocha and RSpec Don’t Play Nice

Mocking is a great part of RSpec, and from the documentation it looks insanely easy. What had me frustrated on a current project is the fact that the mocks and stubs wouldn’t always do what I’d expect them to do. No errors when methods weren’t invoked, and, the worst part, mocks wouldn’t be cleaned up between examples which resulted in rather weird errors. They only occurred when run as a whole with rake spec but not when I ran the specs through TextMate.

I was going insane, because noone on the mailing list seemed to have any problems, same for friends working with RSpec. Then I had another look at the RSpec configuration.

Turns out, the reason for all of this is that Mocha was used for mocking. Switching the configuration back to use RSpec’s internal mocking implementation, everything worked like a charme from then on.

So what you want to have in your SpecHelper isn’t this:

Spec::Runner.configure do |config|
  config.mock_with :mocha
end

but rather

Spec::Runner.configure do |config|
  config.mock_with :rspec
end

or no mention at all of mock_with which will result in the default implementation being used which is, you guessed it, RSpec’s own.

Friday Links (30.11.07)

  • QuickLook and TextMate, sitting in a tree. Makes QuickLook even better. It integrates the TextMate syntax highlighting into QuickLook, and integrates QuickLook into TextMate. Looks pretty neat. TextMate in QuickLook

Singing the Paypal Subscription Blues

For a recent project I had the pleasure to work with Paypal, especially with the Instant Payment Notification API. I haven’t heard a lot of things before I tried to marry it with Rails, but what I’d heard made me assume it wouldn’t be a piece of cake. And I was right.

I’d love to share some code with you, but Vasillis Dimos beat me to it. He wrote two posts on Paypal IPN and Rails, one dealing with the basics and the other about mocking IPN, which you really need to do to test your code. Really.

Personally I did the testing a little differently, since all my payment handling logic was in the model. I didn’t use ActiveMerchant either, but just the Paypal gem. But in general things are similar. Outside of the US and the UK you’re pretty much out of choices for payments, since there’s no Web Payments Pro available here, so IPN is (sadly) the way to go. It’s a real PITA and here’s why:

  • Paypal needs to reach your development machine from the outside. For testing this is not an issue of course, but when you need to do testing with the Paypal sandbox (which is painfully slow) and, god forbid, the real Paypal, there’s no way around that.
  • The payment flow is unnatural. You have to handle the payment outside of the user’s page flow. You have to rely solely on the stuff you get from Paypal, no session, no cookie, no user. It takes a lot of care to handle all that and there still might be a hole in your code that could be exploited.
  • IPNs might come in late, sometimes only after the user already got back to your site. Now you want to present him with a nice success message, but that’s not gonna happen then. That’s a rare case though. The IPN come in slower from the sandbox, that’s for sure. It’s up to you how to handle that. You can act in the favor of the user, or you can just make him wait till everything fell into place.
  • In rare cases you won’t get an IPN from Paypal, for whatever reason. I’ve seen this happen. Be prepared to create the successful payment by hand or have something like a small GUI at hand to do it.
  • For subscriptions six different notification types need to be handled. And their even spread out over two different fields in the notification.

Some advice on how to get it right:

  • Log everything. Store the IPNs in the database, in the log files, wherever. Just log them. Their your proof of things that happened. Just storing them with their raw post data should do while leaving the most important fields separately in different columns.
  • Use mocks. It’s not hard. But it’s totally worth it. When you want to test all events that Paypal might send you, which is a lot for subscriptions, it’s a painful development cycle. And some events aren’t even fully testable by hand.
  • Decide on strategy to handle fraud. While your IPN URL is not really public (nothing should link here, and it’s hopefully transmitted to Paypal encrypted) it’s not exactly safe to just accept everything.
  • Don’t return errors in your IPN handler. Paypal will try it again.
  • Store a pending payment and make it a full one when the corresponding IPN arrives.

All that said, it was an experience, and while not always pleasant, at least I learned something. But Paypal is far from being a pleasant way to handle payments, if you want to make it secure and protect your the integrity of your application and prevent fraudulent users from abusing your services, all of which should be your primary interests.

Best Practices on Rails

This morning, on day two, Marcel Molina and Michael Koziarski did a little Best Practices session, a welcome change to the keynotes and sessions. It was very code-oriented. I did even take something out of it I didn’t know before. Though I wish it would’ve gone into a little bit more detail (which I actually wish for a lot of the other sessions as well, but more on this in a later post), it was something that you could relate to on a practical level.

RailsConf Europe 2007 Day One

Day one of the RailsConf Europe is over (for me anyway), and so here’s my summary of what I’ve seen and heard today.

It all really started yesterday with Dave Thomas’ keynote on “The Art of Rails”. The talk was inspiring. It wasn’t really any new stuff, basically a nice speech with visuals about what the Pragmatic Programmers have already written about. The comparison to art sounds far-stretched for a lot of people, and it might even be. Still, there’s a lot to learn from art that can be applied to software development. Casper Fabricius published a nice summary.

The morning keynote by David Heinemeier Hansson was okay. It wasn’t great. It pretty much summed up all the neat new features of Rails 2.0. There’s another nice summary over at the blog of Casper Fabricius.

My sessions schedule started out with Benjamin Krause’s “Caching in Multi-Language Environments.” He actually patched the REST-routing in Rails to support the content language as a parameter for a resource URI, e.g. /movies/231.html.de. Neat stuff. He also implemented a language-based fragment cache using memcached. Both will be available later this week on his blog.

Next up was Dr. Nic’s talk on meta-programming with Ruby and Rails. My word, I love his Australian accent. His talk was highly entertaining, I was laughing a lot. But it was also inspiring. He’s very encouraging about trying out the meta-programming features of Ruby and doing some weird, funny and useful stuff with it. He already put up his slides for your viewing pleasure.

The afternoon was filled with the wondrous joys of JRuby and Rubinius, held by their respective maintainers Charles Nutter, Thomas E Enebo and Evan Phoenix on both of which I’m hooked now. Especially Rubinius impressed me a lot.

Roy Fielding’s talk on REST was something I was really looking forward too, but it turned out to be more of a summary of his dissertation. The part on REST was good, but he spent an awful lot of time telling history and the theories behind REST.

The smaller diamond-sponsor keynotes by Jonathan Siegel of ELC Tech and Craig McClanahan were short, but pretty good I’d say.

In all, the day was pretty good, and I’m looking forward to tomorrow.

Bratwurst On Rails

I can safely say that “Bratwurst On Rails” was a success. A lot of people showed up at the Kalkscheune, ate Bratwurst and had a good time.

Write Tests for even the Smallest Projects

For Bratwurst on Rails I implemented a small application to allow for easy signup. We could’ve used something like upcoming or wevent, but first we wanted to give people an opportunity to tell us what they like to eat and second, we needed to have room for our sponsors.

Why an IDE for Rails?

Several friends tried out Ruby and Rails over the last months. Apart from the fact that most of them like it, but have to get used to the different syntax, there’s one question that popped up several times, and that I’ve already discussed with several long-time Rails users: What IDE are you using?

Friday Rails Links

Have a RESTful weekend with some REST-related reading, some of it already a little older, but it’s gotten more important to me recently:

RailsConf Europe is a sell-out

Yep. It’s sold out. Compared to the RailsConf in Portland it took a while, but now you can expect to meet something around 800 people there. I’m really looking forward to it, as well as Bratwurst on Rails which will be doing pretty good as well regarding participants.

ActiveRecord and a custom method_missing

Don’‘t be tempted to overwrite method_missing in an ActiveRecord-based model class. It will open a can of worms that’s hard to close without removing your custom version again.

Friday Rails Links

It’s been a week full of Rails joy, and a little pain as well, but that’s not to looked for in Rails itself, but just some code.

Random Rails Links

Continuous Integration for Ruby and Rails

Due to some developers not so keen about running the tests I got back to my trusty friend Continuous Integration for a project I’m currently working on. Being a big fan of CruiseControl I looked for similar solutions for the Rails and Ruby market. There are several tools you can use, and they have several ups and downs.

Smalltalk on AP4R

After playing around with AP4R, the new kid on the asynchronous Ruby block, for a little while, I held a small presentation at last week’s meeting of the Ruby User Group Berlin. While it is more of an introduction than a field report I put up the slides as PDF anyway.

Bootstrapping a Web Project with Java and Rails

For a current gig I had to set up a Java web project from scratch. The set-up isn’t that unusual:

  • Spring 1.2 (yes, it’s rather old, but the project uses a portlet framework which used to work with Spring 1.1, and I don’t want to make the big jump just yet, the upgrade to Spring 1.2 went just fine though)
  • Hibernate 3.2 (hence the upgrade to Spring 1.2)
  • Tomcat 4.1.38 (again, the framework, and it’s a very stable version)

JRuby 1.0 is out

If that’s not exciting, then I don’t know what is. Original Ruby finally has got competition. I tip my hat to the team that developed JRuby in such a short time frame and now fully conforms with Ruby 1.8.x. Though I’m not keen to run JRuby in Glassfish, it’s nice to have the option to integrate a Rails application with J2EE services. Think of that EAI buzzword that came up a few years ago.

Smalltalk about BackgrounDRb

I held a small presentation about BackgrounDRb yesterday at the meeting of the Ruby User Group Berlin. It wasn’t a very big presentation, since actually, there’s not a lot to say about BackgrounDRb. But if you want to check it out, you can get the slides and the little sample application.

Deploying in a chroot Environment with Capistrano

A chroot environment seems to be rare these days. Everything is virtualized, load-balanced and what have you. I recently found myself trying to deploy into a chroot’ed Lighttpd environment with Capistrano and immediately ran over several pitfalls. The biggest problem is that Capistrano uses absolute links for directories like current and the links to the log directory.

Namespace Your Rails Model

I had a nice revelation earlier this week, when I finally tested some code I wrote in the wild, the wild being BackgrounDRb. The code used some pretty common class and module names. I didn’t expect many problems when I used something along the lines of Sync or Synchronizer. When running the code in test cases there wasn’t any problem.

A Fix for Rails 1.2

While setting up a new project with Rails 1.2.3 I ran across a weird issue in my tests. Somewhere from the CGI class (belonging to Ruby’s core lib and extended by Rails) a nil object was used and threw an error. Turns out this was introduced in 1.2.2 with a fix that was supposed to improve CGI handling on Windows.

Back to Top ↑

miscellany

Hello From Jekyll

I got a little sick of having to maintain an unmaintained blog engine (I’m looking at you SimpleLog), so I did what all the cool kids are doing, I switched the blog to using Tom Preston-Werner’s excellent Jekyll. I threw in a few tweaks of my own, and tweaked my Rakefile and Apache to support things that SimpleLog can do, but the static nature of Jekyll can’t. Thankfully, the URL format of both is pretty similar, so it was pretty easy to set up redirects from the old URLs to the new ones.

New Tools For My Toolbox

For a new project I wanted to try some new things, the moment just seemed right, so let me just give you a quick round-up.

ScreencastWeek at Upstream Berlin

The guys at Upstream Agile in Berlin are having a Cockpit Night again, and this time it’s screencast week. On the menu will be the first four of the Erlang screencasts (on January 21) and the first two of the new Objective-C 2.0 series (on January 22), both kindly provided by The Pragmatic Programmers.

Things Learned in 2008: TATFT

All right, so I didn’t exactly learn that testing all the fucking time is effing important over the last 12 months, it’s become clearer and clearer ever since I was first introduced to JUnit. But it did become crystal clear to me how important it really is. I’ve worked with a lot of legacy code, I’ve refactored a lot of it into more reasonable and manageable slices, and I’ve thrown a fresh set of tests at them. I swore at it, I cursed it, but in the end I was very satisfied with the result. The more code I worked with that wasn’t covered by a decent test suite the clearer the picture of always testing became to me.

Spring’s New Maintenance Policy

If Rails was anything like Spring, we wouldn’t see a 2.1.2 release anymore:

“After a new major version of Spring is released, community maintenance updates will be issued for three months to address initial stability issues. Subsequent maintenance releases will be available to SpringSource Enterprise customers. Bug fixes will be folded into the open source development trunk and will be made available in the next major community release of the software . . . “

Right on. I can understand that SpringSource has to make money somehow, but way to screw over the community like that. But given the enormous amounts of money put into it by investors it’s no surprise really.

Via TheServerSide.

Amazon Elastic Block Storage

Well, they had it coming. Neither S3 nor SimpleDB could’ve been the final storage solution for EC2.

Stop Using FTP

Steven Frank gives you a whole bunch of reasons not to use FTP anymore. For me, SFTP (the SSH version), together with scp, have replaced FTP long ago. FTP reminds me of the good old PHP days, when your deployment would consist of just copying your files over FTP, without backup of course, and then frantically trying to revert the change that cause your production application to break.

The iPhone AppStore

A lot has been said about Apple’s AppStore. There are mixed opinions, and I’m sort of in both camps, if that’s possible. While I think it’s probably the best part about the new iPhone (just like Bill de hÓra), building and distributing your application doesn’t come without sacrifices.

Amazon S3 is Down

And if you listen really carefully, you can hear thousands of Web 2.0 companies screaming. Strangely enough, uploads are running almost smoothly.

Update: And we’re back on ;)

Abandon Ship!

Well, not quite. It’s been quite around here lately. I’ve been swamped with work over the last two months which is, of course, not a bad thing. The good thing is that I’ve seen several projects going live over the last few weeks.

Random Friday Links

10 Things I’ve been Doing Lately

  1. Integrating Ferret, a very nice search engine for Ruby, in a project with acts_as_ferret.
  2. Learning ten finger typing.
  3. Writing an article about one of my favorite clothing labels, New Zealand based Huffer, for the magazine of two friends.
  4. Been hiking though snowy mountains in Norway on my summer holiday.
  5. Reading “RESTful Web Services” by Leonard Richardson and Sam Ruby. A highly recommended book on REST which I’m starting to like.
  6. Doing my first real-life project with the features of Java 5. That might sound a little ridiculous, but the clients using Java I worked for over the last year all used Java 1.4, mainly for political reasons or restrictions of the application server environment (WebLogic 8.2 is a no-go with Java 5).
  7. Finding more and more joy in photography, and at the same time starting to really like Lightroom.
  8. Playing with AP4R, an asynchronous job processor for Ruby and Rails. It looks like a very nice and more reliable way to do background tasks than BackgrounDRb. The latter now has a new maintainer by the way. Maybe that will bring the mostly stalled development back up to par.
  9. Working in my office. Something I really enjoy. Having a decent and quiet place to work in is important for a freelancer.
  10. Looking for a new mobile. In case you’re wondering the iPhone doesn’t appeal to me.

Catching Up

So I spent some time off in Bergen (in Norway), and had a wonderful time. We went hiking in the mountains, in a lot of snow, of course, and had a good time there, and made new friends.

Welcome Aboard

So this is it. My new blog. It doesn’t look like much, but I’m working on it. Here’s where I’ll write about my adventures as a freelancer, things related to Rails and things that bother me, things I like and my view on life as a freelancer and Mac OS X nerd.

So what is Paperplanes? Paperplanes is the name of my business as a freelancer.

Who are you? I’m an almost 30-year-old freelance software developer, living in Berlin/Germany. I’ve been freelancing for almost a year now, and so far I can’t complain.

What do I do? I used to do a lot of Java-based work. You can read the results of that over at my Java-related blog Javaddicts.

So why a new blog? As a freelancer, I’ve been doing much more than program Java. Lately I find myself writing more and more apps with Rails which I really enjoy.

What’s gonna happen next? The design for the page has been in my drawer for almost a year now, and it’s time to finish it. So that’s what I’ll do.

Back to Top ↑

thedailygrind

Vim - My College Sweetheart

It’s true, I did write my diploma thesis using Vim. Old-school with LaTeX and C++. When I came to the Mac five years ago I was still using the now pretty much dead Carbon version of MacVim. And well, it just didn’t feel right. I’m very comfortable on the command line, but on the Mac I wanted something that integrated well with the rest of that system, that behave like a real Mac application.

A Busy Month

That’s what it’s been. And who needs to work when there’s so many nice projects to work on, eh? Well actually, I did work, but in my free time I also worked on some other things, a new one, and existing projects.

Rails 2.0: It’s Done

After more than two days of removing deprecation warnings, adding plugins, fixing some custom additions, going through the whole application, it’s finally done. We’re running Rails 2.0. Nothing more gratifying than seeing this, well except for the application running without problems:

MySQL No-Nos: ORDER BY RAND()

It’s a classic. You want to return random rows from a table, say a collection of random users in your social network. Easy, MySQL’s ORDER BY RAND() to the rescue. After all, everybody’s doing it. At least on my last search on that topic, all the PHP kids did it.

For The Love of Light

Jenifer Altman, a very talented Polaroid and Hasselblad (did I mention I want one of these?) shooter, is working on a project to celebrate and honour the art of Polaroid photography before it completely dies (I still have high hopes that’s not gonna happen) within the next year. The project’s titled “For The Love of Light”, and I was invited to take part in that project, and I’m rather thrilled about that. Around mid-July the project will eventually be turned into a book which will be available to the public. The artists include awesome photographers from 10 different countries, and the result will, no doubt, be awesome.

A Weird Ruby Bug

I ran across a weird bug the other day that seems to have been fixed in Ruby 1.8.5. It’s nonetheless quite an interesting one. When you use a hash as a method parameter, and that hash happens to contain the key :do and you call the method without parentheses, like so:

Singing the Paypal Subscription Blues

For a recent project I had the pleasure to work with Paypal, especially with the Instant Payment Notification API. I haven’t heard a lot of things before I tried to marry it with Rails, but what I’d heard made me assume it wouldn’t be a piece of cake. And I was right.

I’d love to share some code with you, but Vasillis Dimos beat me to it. He wrote two posts on Paypal IPN and Rails, one dealing with the basics and the other about mocking IPN, which you really need to do to test your code. Really.

Personally I did the testing a little differently, since all my payment handling logic was in the model. I didn’t use ActiveMerchant either, but just the Paypal gem. But in general things are similar. Outside of the US and the UK you’re pretty much out of choices for payments, since there’s no Web Payments Pro available here, so IPN is (sadly) the way to go. It’s a real PITA and here’s why:

  • Paypal needs to reach your development machine from the outside. For testing this is not an issue of course, but when you need to do testing with the Paypal sandbox (which is painfully slow) and, god forbid, the real Paypal, there’s no way around that.
  • The payment flow is unnatural. You have to handle the payment outside of the user’s page flow. You have to rely solely on the stuff you get from Paypal, no session, no cookie, no user. It takes a lot of care to handle all that and there still might be a hole in your code that could be exploited.
  • IPNs might come in late, sometimes only after the user already got back to your site. Now you want to present him with a nice success message, but that’s not gonna happen then. That’s a rare case though. The IPN come in slower from the sandbox, that’s for sure. It’s up to you how to handle that. You can act in the favor of the user, or you can just make him wait till everything fell into place.
  • In rare cases you won’t get an IPN from Paypal, for whatever reason. I’ve seen this happen. Be prepared to create the successful payment by hand or have something like a small GUI at hand to do it.
  • For subscriptions six different notification types need to be handled. And their even spread out over two different fields in the notification.

Some advice on how to get it right:

  • Log everything. Store the IPNs in the database, in the log files, wherever. Just log them. Their your proof of things that happened. Just storing them with their raw post data should do while leaving the most important fields separately in different columns.
  • Use mocks. It’s not hard. But it’s totally worth it. When you want to test all events that Paypal might send you, which is a lot for subscriptions, it’s a painful development cycle. And some events aren’t even fully testable by hand.
  • Decide on strategy to handle fraud. While your IPN URL is not really public (nothing should link here, and it’s hopefully transmitted to Paypal encrypted) it’s not exactly safe to just accept everything.
  • Don’t return errors in your IPN handler. Paypal will try it again.
  • Store a pending payment and make it a full one when the corresponding IPN arrives.

All that said, it was an experience, and while not always pleasant, at least I learned something. But Paypal is far from being a pleasant way to handle payments, if you want to make it secure and protect your the integrity of your application and prevent fraudulent users from abusing your services, all of which should be your primary interests.

Do Java’s Date Classes Make Any Sense?

I just spent the last hour banging my head on my desk trying to get any kind of date type (whether java.util.Date or a simple timestamp) from the current time and a timezone identifier (something along the lines of Etc/GMT+12). You’d think this is an easy task. Obviously the GregorianCalendar takes a timezone as a constructor argument, so it really should be.

The Perils of Using final

I’m currently working with a proprietary framework. Which is not bad per se. Compared to others I’ve worked with it’s a nice framework to work with. It uses Spring heavily which is a plus and makes working with it quite flexible.

RailsConf Europe 2007 Day One

Day one of the RailsConf Europe is over (for me anyway), and so here’s my summary of what I’ve seen and heard today.

It all really started yesterday with Dave Thomas’ keynote on “The Art of Rails”. The talk was inspiring. It wasn’t really any new stuff, basically a nice speech with visuals about what the Pragmatic Programmers have already written about. The comparison to art sounds far-stretched for a lot of people, and it might even be. Still, there’s a lot to learn from art that can be applied to software development. Casper Fabricius published a nice summary.

The morning keynote by David Heinemeier Hansson was okay. It wasn’t great. It pretty much summed up all the neat new features of Rails 2.0. There’s another nice summary over at the blog of Casper Fabricius.

My sessions schedule started out with Benjamin Krause’s “Caching in Multi-Language Environments.” He actually patched the REST-routing in Rails to support the content language as a parameter for a resource URI, e.g. /movies/231.html.de. Neat stuff. He also implemented a language-based fragment cache using memcached. Both will be available later this week on his blog.

Next up was Dr. Nic’s talk on meta-programming with Ruby and Rails. My word, I love his Australian accent. His talk was highly entertaining, I was laughing a lot. But it was also inspiring. He’s very encouraging about trying out the meta-programming features of Ruby and doing some weird, funny and useful stuff with it. He already put up his slides for your viewing pleasure.

The afternoon was filled with the wondrous joys of JRuby and Rubinius, held by their respective maintainers Charles Nutter, Thomas E Enebo and Evan Phoenix on both of which I’m hooked now. Especially Rubinius impressed me a lot.

Roy Fielding’s talk on REST was something I was really looking forward too, but it turned out to be more of a summary of his dissertation. The part on REST was good, but he spent an awful lot of time telling history and the theories behind REST.

The smaller diamond-sponsor keynotes by Jonathan Siegel of ELC Tech and Craig McClanahan were short, but pretty good I’d say.

In all, the day was pretty good, and I’m looking forward to tomorrow.

Bratwurst On Rails

I can safely say that “Bratwurst On Rails” was a success. A lot of people showed up at the Kalkscheune, ate Bratwurst and had a good time.

Why an IDE for Rails?

Several friends tried out Ruby and Rails over the last months. Apart from the fact that most of them like it, but have to get used to the different syntax, there’s one question that popped up several times, and that I’ve already discussed with several long-time Rails users: What IDE are you using?

MarsEdit 2.0 loves Flickr

MarsEdit 2.0 has been released recently. It’s been my blog editor of choice for more than two years now, and the UI facelift it got was long overdue. No more drawers, just like Apple Mail, and best of all, Flickr integration.

Film is the new Black

Okay, maybe that statement is a slight exaggeration. I started getting into photography about a year ago, and that was mainly thanks to my girlfriends diploma thesis. I started with a simple point & shoot, but it soon gets annoying to be held back by its restrictions, especially when there’s a Nikon D80 in the same household.

IDEA still makes Java Fun

Since I’ve started freelancing I worked less and less in a Java environment. Which is quite a good thing for me, since I get to do what I enjoy. I worked in a J2EE environment for three years. Though I never got to feel the pain of using entity beans, I still started loathing it over time. It just felt too heavy-weight. Testing is a pain, deployment takes ages, and it just can get frustrating what with all the waiting and the complexity involved.

Back to Top ↑

nosql

Riak Handbook 1.1 is out!

I’m happy to report that the Riak Handbook has hit a major update, bringing a whopping 43 pages of new content with it. If you already bought the book, this is a free update, and instructions how and where to download it were sent in a separate email.

A Tour of Amazon’s DynamoDB

Amazon’s recent release of DynamoDB, a database whose name is inspired by Dynamo, the key-value database the distributed datastore they’ve been running in production for a good five to six years now. I think it’s great they’ve finally done it, though from my obverservations, there’s little resemblance of what the original Dynamo paper describes, but I’m getting ahead of myself. Traditionally Amazon hasn’t been very open about how they implement their services, so some of what I’m stating here may be nothing more than an educated guess. Either way, the result is pretty neat.

Storing User Timelines in Riak

The idea of building and storing user timelines (think Twitter) in Riak confused me at first. It sounds like such a spot-on case for time series databases. Yet Yammer managed to make the idea pretty popular. The whole thing lacked implementation though, because they kept their to themselves, which I don’t blame them for at all.

The Simple Magic of Consistent Hashing

The simplicity of consistent hashing is pretty mind-blowing. Here you have a number of nodes in a cluster of databases, or in a cluster of web caches. How do you figure out where the data for a particular key goes in that cluster?

An Update On The NoSQL Handbook

A couple of months ago I set out to write a book on NoSQL. It’s about time I give an update on how it’s been going, and when you can expect a book in your hands, or rather, on your screen.

MongoDB, Data Durability and Improvements coming in 1.8

Last weekend I tweeted two links to two tweets by a poor guy who apparently got his MongoDB database into an unrecoverable state during shutdown whilst upgrading to a newer version. That tweet quickly made the rounds, and the next morning I saw myself staring at replies stating that it was all his fault, because he 1.) used kill -9 to shut it down because apparently the process hung (my guess is it was in the middle of flushing all data to disk) and 2.) didn’t have a slave, just one database instance.

June - A Month of Conferences

June was an exhausting month for me. I spoke at four different conferences, two of which were not in Berlin. I finished the last talk today, so time to reciprocate on conferences and talks. In all I had good fun. It was a lot of work to get the presentations done (around 400 single slides altogether), but in all I would dare say that it was all more than good practice to work on my presentation skills and to loose a bit of the fear of talking in front of people. But I’ll follow up on that stuff in particular in a later post.

Notes on MongoDB

For an article in a German magazine I’ve been researching MongoDB over the last week or so. While I didn’t need a lot of the information I came across I collected some nicely distilled notes on some of its inner workings. You won’t find information on how to get data out of or into MongoDB. The notes deal with the way MongoDB treats and handles your data, a high-low-level view if you will. I tried to keep them as objective as possible, but I added some commentary below.

NoSQL And You - Thoughts On Finding Right Partner In Chrime

The NoSQL landscape is a fickle thing, new tools popping up every week, broadening a spectrum that’s already close to being ungraspable, especially when you’re totally new to the whole thing. There’s a couple of common misconceptions and wrong-doings that people who’ve been playing with the tools already tend to tell newbies in the landscape.

When To Redis

A very valid question is: What’s a good use case for Redis? There’s quite a few, as Redis isn’t your every day key-value store, it allows you to keeps lists and sets in your datastore, and to run atomic operations on them, like pushing and popping elements. All that stuff is incredibly fast, as obviously your data is held in memory and only persisted to the hard disk if necessary and to top it off, asynchronously, while not reducing the throughput of the server itself.

There’s Something About Redis

I like to think that there’s never been a more exciting time when it comes to playing with new technologies. Sure, that’s a bit selfish, but that’s just how I feel. Doing Java after I got my diploma was interesting, but it wasn’t exciting. Definitely not compared to the tools that keep popping up everywhere.

The NoSQL Dilemma (with a Happy Ending)

Call it NoSQL, call it post-relational, call it what you like, but it’s hard to ignore that hings are happening in the database world. A paradigm shift is not too far ahead, and it’s a big one, and I for one am welcoming our post-relational overlords. Whatever you call them, CouchDB, MongoDB (although you really shouldn’t call a database MongoDB), Cassandra, Redis, Tokyo Cabinet, etc. I’m well aware that they’re not necessarily all the same, but they do try to fill similar gaps. Making data storage easy as pie, offering data storage fitting with the kind of evolving data we usually find on the web.

Back to Top ↑

smallbiz

Giving Back: Travis CI’s Charitable Giving in 2014

One of my core beliefs is that a business needs to care about more than just their customers and their people. They need to care for the local environment they work in, and they need to care about people (in their local area if possible) less fortunate than them. It’s part of being an ethical business. A healthy business shouldn’t be about hoarding money, it should be about doing good with it.

Start by Building and Selling Small Products

We love grand ideas. As engineers in particular, we like the idea of building something big that solves an idea we’ve had. We love sweating the details, we love refining architecture, we love building the right tools for the job.

Building an Ethical Business

With our own company growing, both in terms of our team size and our customer base, I keep finding myself thinking more about what kind of company we want it to be.

On Working (Too) Hard

There’s a prevailing idea when it comes to startups and building and running your own business.

The Fear of Saying No

For a startup or a small biz in its infancy, every opportunity looks like a pot of gold.

Back to Top ↑

macosx

Vim - My College Sweetheart

It’s true, I did write my diploma thesis using Vim. Old-school with LaTeX and C++. When I came to the Mac five years ago I was still using the now pretty much dead Carbon version of MacVim. And well, it just didn’t feel right. I’m very comfortable on the command line, but on the Mac I wanted something that integrated well with the rest of that system, that behave like a real Mac application.

Megazoomer Full-Screens your Mac Applications

I recently remembered that there used to be a nice plugin for SIMBL that’ll put e.g. TextMate into full screen mode. Something TextMate itself doesn’t support out of the box, but that comes in handy to reduce distractions while working with it.

Stop Using FTP

Steven Frank gives you a whole bunch of reasons not to use FTP anymore. For me, SFTP (the SSH version), together with scp, have replaced FTP long ago. FTP reminds me of the good old PHP days, when your deployment would consist of just copying your files over FTP, without backup of course, and then frantically trying to revert the change that cause your production application to break.

Friday Tab Sweep (21.03.2008)

Lots of open tabs to be swept. Brace yourselves.

Git

Can you tell I’m looking into Git right now?

Ruby

Rails

Mac OS X

  • Secrets. An ever-growing list of hidden preferences. Comes with a handy-dandy preference pane.

CruiseControl in your Menu Bar

Now here’s a little gem I’ve been waiting for a long time, and that I just discovered today. Usually i just implemented custom scripts that would check the build status in CruiseControl and use Growl to notify me of build errors. I don’t like having my email client open all the time just to see if the build failed, so this is a god-given.

CCMenu wants to remedy that, and comes along with support for all the CruiseControls out there, sitting in your menu bar, and checking your dashboards for the build status. It also signalizes, if a build is currently running.

CCMenu

Just as you’d expect it to, in good pragmatic automation fashion, it’ll notify via Growl of the build status.

CCMenu Growl Notification

Apparently the tool has been written by ThoughtWorks people, no surprise here. Well done is all I can say. It still has some rough edges, but it’s open source, so no need to complain, just more reasons to dig in.

Been using it with CruiseControl.rb all day, and it’s working neatly.

MacSanta is Coming to Town

Just like last year, MacSanta opened its doors right on time for the holiday season. They have some pretty good deals on some excellent Mac shareware. I stacked up already during last year’s sale, but their daily deals are well worth keeping an eye on.

MarsEdit 2.0 loves Flickr

MarsEdit 2.0 has been released recently. It’s been my blog editor of choice for more than two years now, and the UI facelift it got was long overdue. No more drawers, just like Apple Mail, and best of all, Flickr integration.

Friday Rails Links

Have a RESTful weekend with some REST-related reading, some of it already a little older, but it’s gotten more important to me recently:

Increase Productivity by Reducing Distractions

I get distracted easily. E-mail, instant messaging, the mighty and fraudulent web, you name it. However, recently I’ve surrounded my workspace with a couple of tools that help me reduce distractions, both explicitly and implicitly.

CSSEdit Keeps Getting Better And Better

MacRabbit today released CSSEdit v2.5, a release sporting some nice new features, amongst them tabs (gotta have those), a shiny inspector for X-ray to get all the details on the styles a particular element has, and last but not least, a selector builder to make the sometimes-hassle of building the right selector a visual pleasure.

CSSEdit is one of my favorite tools on the Mac. It’s a perfect example how design and function can be integrated into a focussed and usable application.

Go grab it while it’s hot.

In other news, the good folks at Panic today released Coda, an integrated web development environment. Mind you, it’s not Dreamweaver, no, it looks better. Though I prefer my stack of tools it definitely looks like a thought-through and well-designed tool. I’ll definitely take it for a spin.

Back to Top ↑

books

Reading List 2015

It’s the end of 2015, and in the tradition of 2013 and 2014, here’s my reading list, clocking in at 36 books I’ve read this year. I’ve been enjoying reading more and more with every year, and I’ll set the bar at reading at least 40 books in 2016.

Reading List 2014

2014 has been a good year of reading for me, and below is the list of books I’ve read and a bit of commentary on each. As you’ll notice, I’ve been focusing on leadership, management and the likes a lot, the area where I still have so much to learn and where I’m thankful for some of the books that shed light on how other companies have handled the hard bits of building and growing a business.

Reading List 2013

I got to read a lot of great books in 2013, shaping a lot of my current thinking both in terms of business and web operations. If you’re looking for something to read, follow along!

September Reading List

Been a while since the last reading list (here’s a handy link, in case you’re looking for more to read). Time to remedy that. Disclaimer: All links below are Amazon affiliate links. You’ll be feeding my reading habit. Thank you in advance!

June Reading List

I’ve been on vacation in France for most of June, and that means lots of time to read. Originally I planned on reading more on distributed systems, but I had a decent backlog of books on my Kindle, so this was just the right time to plow through them. By the way, if you don’t have a Kindle yet, you should get one. It’s a great little device. I’ve been reading so much more since I got it. Anyhoo, here’s the list of books I’ve been reading in June.

An Update On The NoSQL Handbook

A couple of months ago I set out to write a book on NoSQL. It’s about time I give an update on how it’s been going, and when you can expect a book in your hands, or rather, on your screen.

Ruby and Rails Book Updates

There are some interesting books on Ruby and Rails related entering the fierce market, let’s have a quick look.

For The Love Of Light: The Book

Jenifer Altman did it. She finished the book for our Polaroid project. 25 Polaroid photographers from all over the world say farewell to a piece of photographic history. Here’s a sneaky peek at the cover:

Reading List

I bought a nice stack of books recently, and I’m planning on buying some more. There’s a lot of good stuff, not only new books, but also some older books (as in from 2004, I’m not talking about the C++ books on my shelf).

Review: “Continuous Integration: Improving Software Quality and Reducing Risks”

I’ve been a fan and user of continuous integration for quite a while now, yet I’ve been keen to pick up the book “Continuous Integration: Improving Software Quality and Reducing Risk” by Paul M. Duvall et. al. to see, if it can live up to be the first book dealing exclusively with the topic. They don’t have to sell me on the idea anymore, but still, there’s always something to learn.

Rails/Ruby Books Galore

The book market is being swamped with new books. It seems like every day I discover a new announcement for an upcoming book on Ruby or Rails. Let’s see what’s currently in stock, and what’s waiting for us next year.

Back to Top ↑

testing

The Shoulda RSpec Extravaganza

I don’t use RSpec a lot any more these days. I much prefer Shoulda, heck I even started using Rails integration tests again (using Shoulda of course), because sometimes the additional abstraction of Cucumber is just too much. Any way, there’s some things I liked about RSpec, and they were not related to the features of the testing DSL itself, but more to the tool RSpec. It has a neat formatter that’ll output the ten slowest-running tests. I also found the colored list of full test names to be very helpful.

Mocking Is So 2008

Pat Maddox recently published a blog post on mocking called “You Probably Don’t Get Mocks.” I wanted to write something on my experiences with mocks for a while now, so here’s good reason to finally do so. I’m a recovering mock addict, if you will, so this is my retribution of things I learned over the last 18 months, and how my testing workflow changed with them.

New Tools For My Toolbox

For a new project I wanted to try some new things, the moment just seemed right, so let me just give you a quick round-up.

Raising Test-Awareness

It’s test-awareness month over at RailsTips. If you still need reason, motivation or general tips on testing, head over there immediately. If you’re a fan of new year’s resolutions, this is your chance. John Nunemaker is spot-on with this series.

Refactoring Rails Controllers

This post has been lying in my drafts folder for a while now, and since I’m trying out new approaches to shrink oversized controllers, it’s about time to put this out, and get ready for describing alternatives.

Testing Meme

I’m not religious about anything, but if there’s one thing I adopted and applied rigorously over the last years it’s testing. Out of that habit I’ve developed using some principles that drive my writing of tests.

Why Testing Matters

Sometimes it’s easy to forget, just how important testing has become in the development lifecycle. I recently had to remind myself and others that there are no reasonable excuses not to write tests. I would go as far as saying you’re jeopardizing the quality of your software, just because you had no time, were pushed by management, or were just plain lazy.

Mocha and RSpec Don’t Play Nice

Mocking is a great part of RSpec, and from the documentation it looks insanely easy. What had me frustrated on a current project is the fact that the mocks and stubs wouldn’t always do what I’d expect them to do. No errors when methods weren’t invoked, and, the worst part, mocks wouldn’t be cleaned up between examples which resulted in rather weird errors. They only occurred when run as a whole with rake spec but not when I ran the specs through TextMate.

I was going insane, because noone on the mailing list seemed to have any problems, same for friends working with RSpec. Then I had another look at the RSpec configuration.

Turns out, the reason for all of this is that Mocha was used for mocking. Switching the configuration back to use RSpec’s internal mocking implementation, everything worked like a charme from then on.

So what you want to have in your SpecHelper isn’t this:

Spec::Runner.configure do |config|
  config.mock_with :mocha
end

but rather

Spec::Runner.configure do |config|
  config.mock_with :rspec
end

or no mention at all of mock_with which will result in the default implementation being used which is, you guessed it, RSpec’s own.

Testing Active Web Service with RSpec

I recently started picking up RSpec for a current project. Not too far along the way I found myself wanting to test a SOAP web service written with Active Web Service with it.

Write Tests for even the Smallest Projects

For Bratwurst on Rails I implemented a small application to allow for easy signup. We could’ve used something like upcoming or wevent, but first we wanted to give people an opportunity to tell us what they like to eat and second, we needed to have room for our sponsors.

Back to Top ↑

productivity

Workflows That Help Me Stay (and Feel) Productive as a Manager

One of the greatest challenges for a manager is finding ways to channel the constant pulling into different directions. These days, that pull is likely also true, especially in a distributed team where it’s easy to get pulled into Slack discussions and lose track of priorities. At least that’s been my experience in the past and in the present too, amplified further by now having a management role.

Why I Don’t Read Email in the Morning

Early mornings are pristine, they’re my favorite time of the day. As the sun keeps coming up earlier and earlier, I find myself waking up at 6. Rather than do anything else, I either go for a run or skate, or I grab a book and a cup of coffee and read.

Implement Routines to Foster Habits

I’ve been trying to implement daily habits over the past couple of months. Writing, push-ups, taking a walk, writing a diary. Those are my key habits that I want to practice every day.

Three Simple yet Incredibly Hard Productivity Tips

Our working days (even our spare time and holidays) are filled with distractions. Every social network that we used is fighting for our attention. Plus, emails are always waiting to be replied to, archived or deleted. Push notifications are constantly reminding us to reply to a friend, that one

Be Humble, and Get Shit Done!

I had the honor of speaking at JAOO, sorry GOTO, this year. Being part of so many great speakers, like James Gosling, Rich Hickey, Martin Fowler, Tim Bray, Michael Nygard, and Dan Ingalls (maker of several Smalltalk versions), made me feel nothing but humble, but not in a bad way. I talked about CouchDB, and if you care for it, check out my slides. This is my take away from the conference.

Increase Productivity by Reducing Distractions

I get distracted easily. E-mail, instant messaging, the mighty and fraudulent web, you name it. However, recently I’ve surrounded my workspace with a couple of tools that help me reduce distractions, both explicitly and implicitly.

Inbox Zero

A while ago I picked up Merlin Mann’s (of 43 Folders fame) Inbox Zero philosophy and since, have been recommending it to friends. It’s a great way to deal with your daily load of email, still one of the biggest distractions in the digital life.

Learning Ten Finger Typing

For ten years now, I’ve been rather successful with my own typing style, using mostly my index fingers. I am pretty fast this way, but over the last months this lead to more and more pain in my wrists and my knuckles which can be rather unpleasant, especially when you type for a living. Learning to use all ten fingers for typing has been on my list for quite a while now, so now I finally got over myself and started learning it.

A First Look at OmniFocus

I’m a big fan of Kinkless GTD, or better yet, I was a big fan. Recently I got my invitation for the alpha program for the newest kid on the GTD tools block, OmniFocus, and now I don’t look back anymore.

Back to Top ↑

operations

What is Automation?

In our circles, automation is most frequently associated with infrastructure, tools like Puppet and Chef, automating away your server provisioning and deployments.

A Short Story on Human Error

A few weeks back I came across a post that struck home in several ways. “How I Fired myself” (cached version) is a short story of a developer who accidentally deleted the entire users table in production while working on a new feature. You should read the whole thing, go ahead, I’ll wait for you.

Monitoring for Humans

Hi, I’m Mathias, and I’m a developer. Other than a lot of you at this conference, I’m far from being a monitoring expert. If anything, I’m a user, a tinkerer of all the great tools we’re hearing about at this conference.

Failure is Always an Option

Failure is still one of the most undervalued things in our business, in most businesses really. We still tend to point fingers elsewhere, blame the other department, or try anything to cover our asses.

On Pager Duty

Over the last year, as we started turning Travis CI into a hosted product, we added a ton of metrics and monitoring. While we started out slow, we soon figured out which metrics are key and which are necessary to monitor the overall behavior of the system.

Web Operations 101 For Developers

This post is not about devops, it’s not about lean startups, it’s not about web scale, it’s not about the cloud, and it’s not about continuous deployment. This post is about you, the developer who’s main purpose in life has always been to build great web applications. In a pretty traditional world you write code, you write tests for it, you deploy, and you go home. Until now.

Back to Top ↑

java

Using Rails-like Environments with Spring

One thing that’s nice about Rails is the separation of test, development and production environment right from the beginning. I’m currently working on a Java project with Spring and found myself using MySQL for most of the development and testing and Oracle in production. Using Hibernate that’s not a big problem (most of the time that is, unless you’re bitten in the ass by another weird Oracle JDBC driver bug), but I don’t want to change all the properties for every deployment.

Do Java’s Date Classes Make Any Sense?

I just spent the last hour banging my head on my desk trying to get any kind of date type (whether java.util.Date or a simple timestamp) from the current time and a timezone identifier (something along the lines of Etc/GMT+12). You’d think this is an easy task. Obviously the GregorianCalendar takes a timezone as a constructor argument, so it really should be.

The Perils of Using final

I’m currently working with a proprietary framework. Which is not bad per se. Compared to others I’ve worked with it’s a nice framework to work with. It uses Spring heavily which is a plus and makes working with it quite flexible.

IDEA still makes Java Fun

Since I’ve started freelancing I worked less and less in a Java environment. Which is quite a good thing for me, since I get to do what I enjoy. I worked in a J2EE environment for three years. Though I never got to feel the pain of using entity beans, I still started loathing it over time. It just felt too heavy-weight. Testing is a pain, deployment takes ages, and it just can get frustrating what with all the waiting and the complexity involved.

Storing Images with Oracle and Hibernate

All I wanted was to store images in the database through Hibernate. It all look so easy. Add a byte array property, add it as a binary type to the Hibernate mapping and off you go. So far so good. I’m developing with MySQL where everything worked the way it’s supposed to. Image data goes into the database and comes out when required, no problem.

Bootstrapping a Web Project with Java and Rails

For a current gig I had to set up a Java web project from scratch. The set-up isn’t that unusual:

  • Spring 1.2 (yes, it’s rather old, but the project uses a portlet framework which used to work with Spring 1.1, and I don’t want to make the big jump just yet, the upgrade to Spring 1.2 went just fine though)
  • Hibernate 3.2 (hence the upgrade to Spring 1.2)
  • Tomcat 4.1.38 (again, the framework, and it’s a very stable version)
Back to Top ↑

bestpractices

How Not To Design An API

I’ve had the dubious pleasure of working with a certain library. It’s a layer to talk to most of the Amazon Web Services APIs. While working with web services usually is a particular awful experience, this library doesn’t make much of an effort to hide their awkwardness, in fact, in some ways it even makes it worse. It’s pretty old news that I enjoy bitching about code I don’t like, but I also like to keep it positive in at least thinking about how it could be improved.

Refactoring Rails Controllers

This post has been lying in my drafts folder for a while now, and since I’m trying out new approaches to shrink oversized controllers, it’s about time to put this out, and get ready for describing alternatives.

Why Code Metrics Don’t Matter

Code metrics are a nice tool, and they’re starting to become popular in the Ruby community. They statically analyze your code, and tell you with the simple power of numbers what’s wrong with your code. You can spend ages changing your code to make the numbers look good. Still that doesn’t tell your customer anything. He doesn’t care about those numbers, he wants to see a finished product.

Testing Meme

I’m not religious about anything, but if there’s one thing I adopted and applied rigorously over the last years it’s testing. Out of that habit I’ve developed using some principles that drive my writing of tests.

Why Coding Guidelines Don’t Matter

I’ve been on a lot of projects, where people put an awful lot of time into coming up with the right coding style. Everyone of course wants to have his knack for a certain way of doing things included: “I want my opening curly brace at the end of the line.” Or: “A single space between if and the following opening brace.”

Why Refactoring Matters

It’s hard to believe, but for some people it still doesn’t. I’ve heard something along the lines of “The refactoring is done, now we can code again” or “I can’t refactor that code right now, I’ll just add a little code here and be done with it” far too often over the last months and years. The irrational but persistent thought that refactoring is a once-in-a-product-lifecycle activity is an annoyingly sticky idiom. Refactoring is not a one time thing, it is (or at least should be) an important part of your development process, equally important as coding and testing.

Best Practices on Rails

This morning, on day two, Marcel Molina and Michael Koziarski did a little Best Practices session, a welcome change to the keynotes and sessions. It was very code-oriented. I did even take something out of it I didn’t know before. Though I wish it would’ve gone into a little bit more detail (which I actually wish for a lot of the other sessions as well, but more on this in a later post), it was something that you could relate to on a practical level.

Back to Top ↑

railsconf

RailsConf Europe 2008 Recap

RailsConf Europe 2008 is over (and has been for a few days now, I know), so it’s time for a recap. In all it was much better than I expected, last year’s conference was a bit of a disappointment, so my expectations were low enough to be positively surprised.

Best Practices on Rails

This morning, on day two, Marcel Molina and Michael Koziarski did a little Best Practices session, a welcome change to the keynotes and sessions. It was very code-oriented. I did even take something out of it I didn’t know before. Though I wish it would’ve gone into a little bit more detail (which I actually wish for a lot of the other sessions as well, but more on this in a later post), it was something that you could relate to on a practical level.

RailsConf Europe 2007 Day One

Day one of the RailsConf Europe is over (for me anyway), and so here’s my summary of what I’ve seen and heard today.

It all really started yesterday with Dave Thomas’ keynote on “The Art of Rails”. The talk was inspiring. It wasn’t really any new stuff, basically a nice speech with visuals about what the Pragmatic Programmers have already written about. The comparison to art sounds far-stretched for a lot of people, and it might even be. Still, there’s a lot to learn from art that can be applied to software development. Casper Fabricius published a nice summary.

The morning keynote by David Heinemeier Hansson was okay. It wasn’t great. It pretty much summed up all the neat new features of Rails 2.0. There’s another nice summary over at the blog of Casper Fabricius.

My sessions schedule started out with Benjamin Krause’s “Caching in Multi-Language Environments.” He actually patched the REST-routing in Rails to support the content language as a parameter for a resource URI, e.g. /movies/231.html.de. Neat stuff. He also implemented a language-based fragment cache using memcached. Both will be available later this week on his blog.

Next up was Dr. Nic’s talk on meta-programming with Ruby and Rails. My word, I love his Australian accent. His talk was highly entertaining, I was laughing a lot. But it was also inspiring. He’s very encouraging about trying out the meta-programming features of Ruby and doing some weird, funny and useful stuff with it. He already put up his slides for your viewing pleasure.

The afternoon was filled with the wondrous joys of JRuby and Rubinius, held by their respective maintainers Charles Nutter, Thomas E Enebo and Evan Phoenix on both of which I’m hooked now. Especially Rubinius impressed me a lot.

Roy Fielding’s talk on REST was something I was really looking forward too, but it turned out to be more of a summary of his dissertation. The part on REST was good, but he spent an awful lot of time telling history and the theories behind REST.

The smaller diamond-sponsor keynotes by Jonathan Siegel of ELC Tech and Craig McClanahan were short, but pretty good I’d say.

In all, the day was pretty good, and I’m looking forward to tomorrow.

Back to Top ↑

git

Git Commit Messages as a Timeline of Reasoning

We’re now more than two years into building, maintaining and growing the code base for Travis CI. A lot has happened in the code base, especially in the first year of our existing as a company. Lots of code was moved around, refactored, changed, improved, or written from scratch.

Git Bits: Renaming with Lowercase and Uppercase

There’s a small pitfall when using git-svn. I just recently had the problem that someone renamed a file from lowercase to uppercase in our Subversion repository. Why should that bother me, when I’m using Git, you ask? Well, I’m using git-svn, and it didn’t really like that kind of change. The default on Mac OS X file systems is that they are case-insensitive. FFFFFF.gif is the same as ffffff.gif.

Smalltalk on Git

It’s been quite around here. That’s mainly due to the fact that I had visitors from Canada over, and led them and two more visitors from Norway around beautiful Berlin and Potsdam. Being a tour guide sure is a full-time job.

Git Bits: Committing Partial File Changes

As if there weren’t enough reasons to love it, I came across a nice little article by Ryan Tomayko called “The Thing About Git”. He describes how to do partial commits of only some selected changes in specific files instead of having to commit the whole file. git add --patch to the rescue. Neat stuff. I still like git stash, but being able to commit specific changes while leaving others untouched in the local repository can come in handy from time to time.

Back to Top ↑

redis

June - A Month of Conferences

June was an exhausting month for me. I spoke at four different conferences, two of which were not in Berlin. I finished the last talk today, so time to reciprocate on conferences and talks. In all I had good fun. It was a lot of work to get the presentations done (around 400 single slides altogether), but in all I would dare say that it was all more than good practice to work on my presentation skills and to loose a bit of the fear of talking in front of people. But I’ll follow up on that stuff in particular in a later post.

Redis and Rails sitting on the Couch

I’ve been spending some quality time with two of my new favorite tools lately (CouchDB and Redis, duh!), and while integrating them into Scalarium some needs and as a result some smaller hacks emerged. I don’t want to deprive the world of their joy, so here they are.

How To Redis

We’ve covered some good ground already, some blabber about Redis in general, and also some thoughts on when using it could be beneficial. The other big question is: How do I integrate that stuff in my application? How do I get my objects to be stored neatly in Redis?

When To Redis

A very valid question is: What’s a good use case for Redis? There’s quite a few, as Redis isn’t your every day key-value store, it allows you to keeps lists and sets in your datastore, and to run atomic operations on them, like pushing and popping elements. All that stuff is incredibly fast, as obviously your data is held in memory and only persisted to the hard disk if necessary and to top it off, asynchronously, while not reducing the throughput of the server itself.

There’s Something About Redis

I like to think that there’s never been a more exciting time when it comes to playing with new technologies. Sure, that’s a bit selfish, but that’s just how I feel. Doing Java after I got my diploma was interesting, but it wasn’t exciting. Definitely not compared to the tools that keep popping up everywhere.

Back to Top ↑

rspec

The Shoulda RSpec Extravaganza

I don’t use RSpec a lot any more these days. I much prefer Shoulda, heck I even started using Rails integration tests again (using Shoulda of course), because sometimes the additional abstraction of Cucumber is just too much. Any way, there’s some things I liked about RSpec, and they were not related to the features of the testing DSL itself, but more to the tool RSpec. It has a neat formatter that’ll output the ten slowest-running tests. I also found the colored list of full test names to be very helpful.

Mocha and RSpec Don’t Play Nice

Mocking is a great part of RSpec, and from the documentation it looks insanely easy. What had me frustrated on a current project is the fact that the mocks and stubs wouldn’t always do what I’d expect them to do. No errors when methods weren’t invoked, and, the worst part, mocks wouldn’t be cleaned up between examples which resulted in rather weird errors. They only occurred when run as a whole with rake spec but not when I ran the specs through TextMate.

I was going insane, because noone on the mailing list seemed to have any problems, same for friends working with RSpec. Then I had another look at the RSpec configuration.

Turns out, the reason for all of this is that Mocha was used for mocking. Switching the configuration back to use RSpec’s internal mocking implementation, everything worked like a charme from then on.

So what you want to have in your SpecHelper isn’t this:

Spec::Runner.configure do |config|
  config.mock_with :mocha
end

but rather

Spec::Runner.configure do |config|
  config.mock_with :rspec
end

or no mention at all of mock_with which will result in the default implementation being used which is, you guessed it, RSpec’s own.

Testing Active Web Service with RSpec

I recently started picking up RSpec for a current project. Not too far along the way I found myself wanting to test a SOAP web service written with Active Web Service with it.

Back to Top ↑

monitoring

Monitoring for Humans

Hi, I’m Mathias, and I’m a developer. Other than a lot of you at this conference, I’m far from being a monitoring expert. If anything, I’m a user, a tinkerer of all the great tools we’re hearing about at this conference.

A Plea for Client Library Instrumentation

The need to measure everything that moves in a distributed system or even simple web apps is becoming the basis for thorough monitoring of an application.

The Virtues of Monitoring

Over the last year I haven’t only grown very fond of coffee, but also of infrastructure. Working on Scalarium has been a fun ride so far, for all kinds of reasons, one of them is dealing so much with infrastructure. Being an infrastructure platform provider, what can you do, right?

XRay Goggles For Your Ruby Processes

The guys over at Pivotal Labs wrote a small piece on a neat tool called XRay. It hooks into your Ruby code to provide Java-like signal handlers which dump the current stack trace into whatever log file seems fit. Using Passenger that’ll be your Apache’s error log file.

Back to Top ↑

riak

Riak Handbook 1.1 is out!

I’m happy to report that the Riak Handbook has hit a major update, bringing a whopping 43 pages of new content with it. If you already bought the book, this is a free update, and instructions how and where to download it were sent in a separate email.

Storing User Timelines in Riak

The idea of building and storing user timelines (think Twitter) in Riak confused me at first. It sounds like such a spot-on case for time series databases. Yet Yammer managed to make the idea pretty popular. The whole thing lacked implementation though, because they kept their to themselves, which I don’t blame them for at all.

The Simple Magic of Consistent Hashing

The simplicity of consistent hashing is pretty mind-blowing. Here you have a number of nodes in a cluster of databases, or in a cluster of web caches. How do you figure out where the data for a particular key goes in that cluster?

Why Riak Search Matters…

The awesome dudes at Basho released Riak 0.13 and with it their first version of Riak Search yesterday. This is all kinds of exciting, and I’ll tell you why. Riak Search is (way down below) based on Lucene, both the library and the query interface. It mimicks the Solr web API for querying and indexing. Just like you’d expect something coming out of Basho, you can add and remove nodes at any time, scaling up and down as you go. I’ve seen an introduction on the basics back at Berlin Buzzwords, and it was already shaping up to be nothing but impressive. But enough with all the praise, why’s this stuff exciting?

Back to Top ↑

leadership

On Drafting an Engineering Strategy

During the first weeks in a new role, one of the things I’ve most recently focused on is to assess the direction of the engineering department as a whole. At the time I started there was no explicit strategy in place. Which is also not an unusual thing for a young company, just to be clear. So I set out to draft one.

Why is my team not doing what I expect from them?

Leaders who find themselves wondering why their teams aren’t making important decisions on their own tend to be leaders who are constantly pulled into many different discussions. Their calendars are filled to the brim, leaving little time for longer term work. This can seem like you’re contributing as a manager, like you’re doing important work and keeping yourself busy. It also means that you’ll have less time to focus on strategic work.

Workflows That Help Me Stay (and Feel) Productive as a Manager

One of the greatest challenges for a manager is finding ways to channel the constant pulling into different directions. These days, that pull is likely also true, especially in a distributed team where it’s easy to get pulled into Slack discussions and lose track of priorities. At least that’s been my experience in the past and in the present too, amplified further by now having a management role.

The Most Important Thing About 1:1s (and Building Trust)

Slightly more than a year ago, I had no idea what a 1:1 is let alone what purpose it’s serves. The idea of talking to one of our team member seemed so foreign at a time when we structured our team around individual autonomy and the assumption that people will speak up when something’s up.

To Be a Better Listener, Embrace the Awkward Pause

About a year ago I met one of our team members in person for the first time. We hung out for the entire day, talking about all kinds of things, problems we were facing with our company at the time were amongst them.

Five Habits of an Introverted Leader

Being an introverted person in a leadership position is challenging. The one thing that exhaust you the most is now your main focus, interacting with people.

Back to Top ↑

photography

For The Love Of Light: The Book

Jenifer Altman did it. She finished the book for our Polaroid project. 25 Polaroid photographers from all over the world say farewell to a piece of photographic history. Here’s a sneaky peek at the cover:

For The Love of Light

Jenifer Altman, a very talented Polaroid and Hasselblad (did I mention I want one of these?) shooter, is working on a project to celebrate and honour the art of Polaroid photography before it completely dies (I still have high hopes that’s not gonna happen) within the next year. The project’s titled “For The Love of Light”, and I was invited to take part in that project, and I’m rather thrilled about that. Around mid-July the project will eventually be turned into a book which will be available to the public. The artists include awesome photographers from 10 different countries, and the result will, no doubt, be awesome.

The End of an Era

On February 9th 2008 the Polaroid Corporation announced what will most likely be the demise of an era in photography. They’re closing down all their factories, and they will stop producing the famous instant film, after they made enough to last until 2009.

Film is the new Black

Okay, maybe that statement is a slight exaggeration. I started getting into photography about a year ago, and that was mainly thanks to my girlfriends diploma thesis. I started with a simple point & shoot, but it soon gets annoying to be held back by its restrictions, especially when there’s a Nikon D80 in the same household.

Back to Top ↑

management

On Drafting an Engineering Strategy

During the first weeks in a new role, one of the things I’ve most recently focused on is to assess the direction of the engineering department as a whole. At the time I started there was no explicit strategy in place. Which is also not an unusual thing for a young company, just to be clear. So I set out to draft one.

The Feedback Log

One thing I wanted to a better job at as I took on a new role last year is to be more deliberate in giving feedback. As a German, I tend to fall on the side of only focusing on negative, or constructive feedback. I tend to focus on pointing out what I think should be improved, or what isn’t conclusive. This is quite ingrained in the German work culture.

Why is my team not doing what I expect from them?

Leaders who find themselves wondering why their teams aren’t making important decisions on their own tend to be leaders who are constantly pulled into many different discussions. Their calendars are filled to the brim, leaving little time for longer term work. This can seem like you’re contributing as a manager, like you’re doing important work and keeping yourself busy. It also means that you’ll have less time to focus on strategic work.

Workflows That Help Me Stay (and Feel) Productive as a Manager

One of the greatest challenges for a manager is finding ways to channel the constant pulling into different directions. These days, that pull is likely also true, especially in a distributed team where it’s easy to get pulled into Slack discussions and lose track of priorities. At least that’s been my experience in the past and in the present too, amplified further by now having a management role.

Back to Top ↑

continuousintegration

Integrity And Passenger Play Nice

I wanted to play the field of continuous integration tools a little bit more, so I finally gave Integrity a go. Its promise of being lightweight sure was tempting.

Review: “Continuous Integration: Improving Software Quality and Reducing Risks”

I’ve been a fan and user of continuous integration for quite a while now, yet I’ve been keen to pick up the book “Continuous Integration: Improving Software Quality and Reducing Risk” by Paul M. Duvall et. al. to see, if it can live up to be the first book dealing exclusively with the topic. They don’t have to sell me on the idea anymore, but still, there’s always something to learn.

CruiseControl in your Menu Bar

Now here’s a little gem I’ve been waiting for a long time, and that I just discovered today. Usually i just implemented custom scripts that would check the build status in CruiseControl and use Growl to notify me of build errors. I don’t like having my email client open all the time just to see if the build failed, so this is a god-given.

CCMenu wants to remedy that, and comes along with support for all the CruiseControls out there, sitting in your menu bar, and checking your dashboards for the build status. It also signalizes, if a build is currently running.

CCMenu

Just as you’d expect it to, in good pragmatic automation fashion, it’ll notify via Growl of the build status.

CCMenu Growl Notification

Apparently the tool has been written by ThoughtWorks people, no surprise here. Well done is all I can say. It still has some rough edges, but it’s open source, so no need to complain, just more reasons to dig in.

Been using it with CruiseControl.rb all day, and it’s working neatly.

Back to Top ↑

polaroid

For The Love Of Light: The Book

Jenifer Altman did it. She finished the book for our Polaroid project. 25 Polaroid photographers from all over the world say farewell to a piece of photographic history. Here’s a sneaky peek at the cover:

For The Love of Light

Jenifer Altman, a very talented Polaroid and Hasselblad (did I mention I want one of these?) shooter, is working on a project to celebrate and honour the art of Polaroid photography before it completely dies (I still have high hopes that’s not gonna happen) within the next year. The project’s titled “For The Love of Light”, and I was invited to take part in that project, and I’m rather thrilled about that. Around mid-July the project will eventually be turned into a book which will be available to the public. The artists include awesome photographers from 10 different countries, and the result will, no doubt, be awesome.

The End of an Era

On February 9th 2008 the Polaroid Corporation announced what will most likely be the demise of an era in photography. They’re closing down all their factories, and they will stop producing the famous instant film, after they made enough to last until 2009.

Back to Top ↑

databases

MongoDB, Data Durability and Improvements coming in 1.8

Last weekend I tweeted two links to two tweets by a poor guy who apparently got his MongoDB database into an unrecoverable state during shutdown whilst upgrading to a newer version. That tweet quickly made the rounds, and the next morning I saw myself staring at replies stating that it was all his fault, because he 1.) used kill -9 to shut it down because apparently the process hung (my guess is it was in the middle of flushing all data to disk) and 2.) didn’t have a slave, just one database instance.

Why I Love and Hate Distributed Systems

Let me go ahead and say it: I love distributed systems. Why? Simply because they bend my brain. Yesterday I tweeted “Distributed databases are my happy place.” One response I got was along the lines of: “then you’re probably not running a distributed database in production.” Busted! But does it matter? We all love distributed stuff, we love thinking about scaling. They seem like problems everyone wants to have and solve.

The NoSQL Dilemma (with a Happy Ending)

Call it NoSQL, call it post-relational, call it what you like, but it’s hard to ignore that hings are happening in the database world. A paradigm shift is not too far ahead, and it’s a big one, and I for one am welcoming our post-relational overlords. Whatever you call them, CouchDB, MongoDB (although you really shouldn’t call a database MongoDB), Cassandra, Redis, Tokyo Cabinet, etc. I’m well aware that they’re not necessarily all the same, but they do try to fill similar gaps. Making data storage easy as pie, offering data storage fitting with the kind of evolving data we usually find on the web.

Back to Top ↑

mongodb

MongoDB, Data Durability and Improvements coming in 1.8

Last weekend I tweeted two links to two tweets by a poor guy who apparently got his MongoDB database into an unrecoverable state during shutdown whilst upgrading to a newer version. That tweet quickly made the rounds, and the next morning I saw myself staring at replies stating that it was all his fault, because he 1.) used kill -9 to shut it down because apparently the process hung (my guess is it was in the middle of flushing all data to disk) and 2.) didn’t have a slave, just one database instance.

June - A Month of Conferences

June was an exhausting month for me. I spoke at four different conferences, two of which were not in Berlin. I finished the last talk today, so time to reciprocate on conferences and talks. In all I had good fun. It was a lot of work to get the presentations done (around 400 single slides altogether), but in all I would dare say that it was all more than good practice to work on my presentation skills and to loose a bit of the fear of talking in front of people. But I’ll follow up on that stuff in particular in a later post.

Notes on MongoDB

For an article in a German magazine I’ve been researching MongoDB over the last week or so. While I didn’t need a lot of the information I came across I collected some nicely distilled notes on some of its inner workings. You won’t find information on how to get data out of or into MongoDB. The notes deal with the way MongoDB treats and handles your data, a high-low-level view if you will. I tried to keep them as objective as possible, but I added some commentary below.

Back to Top ↑

reading

September Reading List

Been a while since the last reading list (here’s a handy link, in case you’re looking for more to read). Time to remedy that. Disclaimer: All links below are Amazon affiliate links. You’ll be feeding my reading habit. Thank you in advance!

June Reading List

I’ve been on vacation in France for most of June, and that means lots of time to read. Originally I planned on reading more on distributed systems, but I had a decent backlog of books on my Kindle, so this was just the right time to plow through them. By the way, if you don’t have a Kindle yet, you should get one. It’s a great little device. I’ve been reading so much more since I got it. Anyhoo, here’s the list of books I’ve been reading in June.

February Reading List

With February almost over, it’s time to give you news things to read, or at least to make a list of things I’ve been reading lately.

Holiday Reading List

Here’s a list of things I’ve been reading lately or that I’m about to read, and that I found to be worth sharing. If you’re looking for something to read over the holidays, I’m happy to give you some suggestions. Books, papers, articles, and videos, something for everyone.

Back to Top ↑

web

Form Objects with ActiveModel

When I built the billing process for Travis CI’s commercial offering, I decided to try out some new things to avoid callbacks in ActiveRecord models, including validations.

When Will the Web 2.0 Bubble Burst?

Every day a load of new start-ups appears on the scene. Every day is full of announcements of new Web-2.0-like tools, platforms, and whatnot. Every day another start-up gets new funding, sometimes in ridiculous amounts. TechCrunch is full of news like that. And every day I ask myself: Haven’t I seen all this before? Before the new millennium millions, if not billions of investor and stock money went down the drain with the crash of the first wave of web start-ups. Venture capitalists invested without questioning business plans, if such a thing even existed. Personally I crashed rather soft. I was still a student, and I found a new job without any problems. I switched from new economy to old economy for a while.

Back to Top ↑

textmate

Making TextMate And rvm Play Nice

After being annoyed with running multiple versions of Ruby just by using MacPorts I finally gave in and tried out rvm, the Ruby Version Manager. That stuff got even more annoying when I tried to make Bundler behave well with multiple Ruby versions, because it just doesn’t by default. It’s not really a problem with normal gems, but Bundler falls apart with its defaults when you’re trying to run gems with native extensions. Hint: Set bundle_path to include RUBY_VERSION and make some links from one cache directory to another to not have every gem cached for every Ruby version.

Back to Top ↑

mysql

Stalled MySQL Logins

If you ever see a list like this in your MySQL process list, run!

+---------+--------------------------------------------+--------------------------------+------------+-----------------+------------+-------------+------------+
| Id  | User                 | Host           | db   | Command | Time | State | Info |
+---------+--------------------------------------------+--------------------------------+------------+-----------------+------------+-------------+------------+
| 442 | unauthenticated user | 10.1.1.2:55885 | NULL | Killed  | NULL | login | NULL | 
| 443 | unauthenticated user | 10.1.1.1:48009 | NULL | Killed  | NULL | login | NULL | 
.....
| 444 | unauthenticated user | 10.1.1.1:58105 | NULL | Killed  | NULL | login | NULL | 
| 445 | unauthenticated user | 10.1.1.2:60799 | NULL | Killed  | NULL | login | NULL | 
+---------+--------------------------------------------+--------------------------------+------------+-----------------+------------+-------------+------------+

No seriously. Apparently it’s something of a known bug which comes up at unpredictable points in time.

One proposed solution is to add all your internal hosts which can’t be looked up through DNS to your /etc/hosts file:

10.1.1.1    appserver1
10.1.1.2    appserver2

Et voila. The exact same moment, all the users were authenticated. Scary? Yes. Weird? Yes. Problem solved? Yes.

MySQL No-Nos: ORDER BY RAND()

It’s a classic. You want to return random rows from a table, say a collection of random users in your social network. Easy, MySQL’s ORDER BY RAND() to the rescue. After all, everybody’s doing it. At least on my last search on that topic, all the PHP kids did it.

Paul Tuckfield on Scaling MySQL

Paul Tuckfield (YouTube’s MySQL administrator) gave a nice talk on do’s and don’ts when it comes to scaling MySQL. He held it at last year’s MySQL Conference, so it’s not that recent, but it’s still very much worth it.

Back to Top ↑

iphone

Cocoa Lessons Learned #1: Threading is Hard

While working on iMacistrano (or iWebistrano if you fancy, either way my little iPhone toy project) I started moving things into background tasks and to use timers to fire off requests on a regular basis, specifically to create a deployment, and then to monitor its state.

ObjectiveResource: It’s Like ActiveResource For Cocoa

The guys at [Y Factorial](http://www.yfactorial.com) put it in a lot of effort in a new framework for Cocoa which mimics the functionality of ActiveResource. It’s ingeniusly called ObjectiveResource, and acts as (having a worst Rails plugin names flashback while writing this) a bridge between your Cocoa (yes, that includes iPhone) applications and RESTful Rails applications.

Missing iPhone Applications

Instead of disco balls, the 100th todo list application (I’m using OmniFocus, thank you very much) a coin flipper (just use a quarter, will ya?) or a face melter, how about something useful for a change?

Back to Top ↑

conferences

Presentation Fu

I’ve attended my fair share of conferences this month alone, plus a Seedcamp, and I can safely say that in any way, I learned a lot about how to build slides, how to keep the audience engaged and things one just shouldn’t do in a talk or in slides. While I certainly don’t claim to be an expert on the topic now, I just wanted to put all of my impressions and lessons learned into a post.

Upcoming Conference Talks

June is a busy month when it comes to me speaking at conferences, you should drop by at least one of my talks, if you’re in the area.

RailsWayCon: Call For Papers

On the heels of RailsConf Europe’s cancellation comes the call for papers for one of the viable alternatives, the RailsWayCon. It’s happening from May 25th to 27th in Berlin, so other than going to Scotland on Rails like yours truly, this is the conference to go to.

Back to Top ↑

coffee

Only The Simplest Tools

Over the past couple of years, there’s been a curious trend in the world of coffee. While espresso is still a thing of expensive machinery to get the most out of the bean, filter coffee has taken an interesting turn towards simplicity.

The Secret to Latte Art

I’ve been practicing my latte art at home as of late. I have a Rancilio Silvia machine, which packs a decent punch regarding pressure and steam, much better than the Gaggia Classic I had before.

Coffee and the Art of Customer Happiness

This essay is an extended version of a talk I gave at Paperless Post about coffee and customer happiness. While the talk was originally titled “Coffee and the Art of Software Maintenance”, I figured that customer happiness is overall a much more fitting for the topic.

Back to Top ↑

culture

Failure is Always an Option

Failure is still one of the most undervalued things in our business, in most businesses really. We still tend to point fingers elsewhere, blame the other department, or try anything to cover our asses.

Back to Top ↑

ops

Back to Top ↑

freelancing

Abandon Ship!

Well, not quite. It’s been quite around here lately. I’ve been swamped with work over the last two months which is, of course, not a bad thing. The good thing is that I’ve seen several projects going live over the last few weeks.

Back to Top ↑

cruisecontrol

CruiseControl in your Menu Bar

Now here’s a little gem I’ve been waiting for a long time, and that I just discovered today. Usually i just implemented custom scripts that would check the build status in CruiseControl and use Growl to notify me of build errors. I don’t like having my email client open all the time just to see if the build failed, so this is a god-given.

CCMenu wants to remedy that, and comes along with support for all the CruiseControls out there, sitting in your menu bar, and checking your dashboards for the build status. It also signalizes, if a build is currently running.

CCMenu

Just as you’d expect it to, in good pragmatic automation fashion, it’ll notify via Growl of the build status.

CCMenu Growl Notification

Apparently the tool has been written by ThoughtWorks people, no surprise here. Well done is all I can say. It still has some rough edges, but it’s open source, so no need to complain, just more reasons to dig in.

Been using it with CruiseControl.rb all day, and it’s working neatly.

Back to Top ↑

activemessaging

How to Process Multiple ActiveMessaging Queues Concurrently

The title totally overemphasizes the topic, but here we go. By default ActiveMessaging will process all your queues in one thread. All messages from all queues will be processes sequentially. This isn’t always what you want. Especially in scenarios where you have both long-running tasks being kicked off through messages, and rather short-lived tasks that you just fire and forget.

ActiveMessaging has a rather simple and not-so-obvious way of dealing with that: processor groups. There’s some documentation on them, but it doesn’t bring out the real beauty of them.

Basically you split your processors in groups, how finely grained is up to you. A simple way would be to just separate long-running from short-lived tasks. You just have to define these in config/messaging.rb:

ActiveMessaging::Gateway.define do |s|
  s.destination :index_update, '/queue/IndexUpdate'
  s.destination :giant_batch_job, '/queue/GiantBatchJob'
  s.processor_group :short, :index_update_processor
  s.processor_group :long, :giant_batch_job_processor
end

Now that you have these, how do you get them to run in different threads? If you just use script/poller start, it will continue to work through all messages from all queues. You need to start each processor group individually:

$ script/poller start ---- process-group=short
$ script/poller start ---- process-group=long

Keep in mind though that you can’t stop just one poller for one particular processor group. Running script/poller stop will tear them all down. Which comes in handy during deployments. That way you only have to ensure that all your process groups are started during the deployment, but not about stopping every one of them.

ActiveMessaging will run each group in a separate thread which all are monitored by the poller_monitor. The latter will only be started once, courtesy of the daemons package.

Serializing Data with ActiveMessaging and Filters

I’ve been playing around with ActiveMessaging recently. Well, actually more than that. I integrated it into a project for asynchronous processing. It’s a pretty neat plugin. We’re using StompServer as a message broker, and therefore the Stomp protocol to publish and poll the messages.

Now Stomp is a pretty simple protocol and breaks down when you’re trying to deliver “complex” data structures like hashes, arrays or **gasp** objects. That’s not a bad thing per se, since we can serialize them with YAML. Of course you could just always do that by hand before publishing a message, but let’s face it, that’s just tedious.

The author of ActiveMessaging recently added support for filters. They can be run after publishing a message and/or before processing it on the polling side. I hear it clicking on your end, why not use filters to do the serializing work for us? Right on!

Here’s a simple filter to serialize the message when it’s sent:

class SerializeToYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    if message.body.respond_to?(:to_yaml)
      message.body = message.body.to_yaml
    else
      message.body = YAML::dump(message.body)
    end
  end
end

It uses the to_yaml method mixed in by Rails, if it’s available. Otherwise it just dumps the object with the YAML::dump method.

The receiving end is even easier.

class DeserializeYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    message.body = YAML::load(message.body) rescue message.body
  end
end

The filter respects potential deserializing errors and just returns the message body in that case. Otherwise it just loads the objects from the message body. And that’s the whole story.

Now you need to configure it in config/messaging.rb and you’re good to go:

ActiveMessaging::Gateway.define do |s|
  s.filter :deserialize_yaml_filter, :direction => :incoming
  s.filter :serialize_to_yaml_filter, :direction => :outgoing
end

The benefit? This way you can send more complex data structures (as opposed to just strings) through the broker:

publish :my_queue, :action => 'do_stuff', :with => 'User', :id => 1

But remember to keep it simple. Don’t try to stuff large objects through there. Sending over the user itself is very likely not a good idea, even more so when it’s an ActiveRecord object.

More to come on a13g and Stomp.

Back to Top ↑

asynchronous

How to Process Multiple ActiveMessaging Queues Concurrently

The title totally overemphasizes the topic, but here we go. By default ActiveMessaging will process all your queues in one thread. All messages from all queues will be processes sequentially. This isn’t always what you want. Especially in scenarios where you have both long-running tasks being kicked off through messages, and rather short-lived tasks that you just fire and forget.

ActiveMessaging has a rather simple and not-so-obvious way of dealing with that: processor groups. There’s some documentation on them, but it doesn’t bring out the real beauty of them.

Basically you split your processors in groups, how finely grained is up to you. A simple way would be to just separate long-running from short-lived tasks. You just have to define these in config/messaging.rb:

ActiveMessaging::Gateway.define do |s|
  s.destination :index_update, '/queue/IndexUpdate'
  s.destination :giant_batch_job, '/queue/GiantBatchJob'
  s.processor_group :short, :index_update_processor
  s.processor_group :long, :giant_batch_job_processor
end

Now that you have these, how do you get them to run in different threads? If you just use script/poller start, it will continue to work through all messages from all queues. You need to start each processor group individually:

$ script/poller start ---- process-group=short
$ script/poller start ---- process-group=long

Keep in mind though that you can’t stop just one poller for one particular processor group. Running script/poller stop will tear them all down. Which comes in handy during deployments. That way you only have to ensure that all your process groups are started during the deployment, but not about stopping every one of them.

ActiveMessaging will run each group in a separate thread which all are monitored by the poller_monitor. The latter will only be started once, courtesy of the daemons package.

Serializing Data with ActiveMessaging and Filters

I’ve been playing around with ActiveMessaging recently. Well, actually more than that. I integrated it into a project for asynchronous processing. It’s a pretty neat plugin. We’re using StompServer as a message broker, and therefore the Stomp protocol to publish and poll the messages.

Now Stomp is a pretty simple protocol and breaks down when you’re trying to deliver “complex” data structures like hashes, arrays or **gasp** objects. That’s not a bad thing per se, since we can serialize them with YAML. Of course you could just always do that by hand before publishing a message, but let’s face it, that’s just tedious.

The author of ActiveMessaging recently added support for filters. They can be run after publishing a message and/or before processing it on the polling side. I hear it clicking on your end, why not use filters to do the serializing work for us? Right on!

Here’s a simple filter to serialize the message when it’s sent:

class SerializeToYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    if message.body.respond_to?(:to_yaml)
      message.body = message.body.to_yaml
    else
      message.body = YAML::dump(message.body)
    end
  end
end

It uses the to_yaml method mixed in by Rails, if it’s available. Otherwise it just dumps the object with the YAML::dump method.

The receiving end is even easier.

class DeserializeYamlFilter < ActiveMessaging::Filter
  attr_accessor :options
  
  def initialize(options={})
    @options = options
  end

  def process(message, routing)
    message.body = YAML::load(message.body) rescue message.body
  end
end

The filter respects potential deserializing errors and just returns the message body in that case. Otherwise it just loads the objects from the message body. And that’s the whole story.

Now you need to configure it in config/messaging.rb and you’re good to go:

ActiveMessaging::Gateway.define do |s|
  s.filter :deserialize_yaml_filter, :direction => :incoming
  s.filter :serialize_to_yaml_filter, :direction => :outgoing
end

The benefit? This way you can send more complex data structures (as opposed to just strings) through the broker:

publish :my_queue, :action => 'do_stuff', :with => 'User', :id => 1

But remember to keep it simple. Don’t try to stuff large objects through there. Sending over the user itself is very likely not a good idea, even more so when it’s an ActiveRecord object.

More to come on a13g and Stomp.

Back to Top ↑

refactoring

Refactoring Rails Controllers

This post has been lying in my drafts folder for a while now, and since I’m trying out new approaches to shrink oversized controllers, it’s about time to put this out, and get ready for describing alternatives.

Why Refactoring Matters

It’s hard to believe, but for some people it still doesn’t. I’ve heard something along the lines of “The refactoring is done, now we can code again” or “I can’t refactor that code right now, I’ll just add a little code here and be done with it” far too often over the last months and years. The irrational but persistent thought that refactoring is a once-in-a-product-lifecycle activity is an annoyingly sticky idiom. Refactoring is not a one time thing, it is (or at least should be) an important part of your development process, equally important as coding and testing.

Back to Top ↑

objective-c

Cocoa Lessons Learned #1: Threading is Hard

While working on iMacistrano (or iWebistrano if you fancy, either way my little iPhone toy project) I started moving things into background tasks and to use timers to fire off requests on a regular basis, specifically to create a deployment, and then to monitor its state.

ObjectiveResource: It’s Like ActiveResource For Cocoa

The guys at [Y Factorial](http://www.yfactorial.com) put it in a lot of effort in a new framework for Cocoa which mimics the functionality of ActiveResource. It’s ingeniusly called ObjectiveResource, and acts as (having a worst Rails plugin names flashback while writing this) a bridge between your Cocoa (yes, that includes iPhone) applications and RESTful Rails applications.
Back to Top ↑

cocoa

Cocoa Lessons Learned #1: Threading is Hard

While working on iMacistrano (or iWebistrano if you fancy, either way my little iPhone toy project) I started moving things into background tasks and to use timers to fire off requests on a regular basis, specifically to create a deployment, and then to monitor its state.

ObjectiveResource: It’s Like ActiveResource For Cocoa

The guys at [Y Factorial](http://www.yfactorial.com) put it in a lot of effort in a new framework for Cocoa which mimics the functionality of ActiveResource. It’s ingeniusly called ObjectiveResource, and acts as (having a worst Rails plugin names flashback while writing this) a bridge between your Cocoa (yes, that includes iPhone) applications and RESTful Rails applications.
Back to Top ↑

messaging

A Story About Queues in Four Acts

There are queues everywhere. This is the story of a few of them. The names of the queues are made up, but their story is real nonetheless.

Back to Top ↑

development

Git Commit Messages as a Timeline of Reasoning

We’re now more than two years into building, maintaining and growing the code base for Travis CI. A lot has happened in the code base, especially in the first year of our existing as a company. Lots of code was moved around, refactored, changed, improved, or written from scratch.

How Not To Design An API

I’ve had the dubious pleasure of working with a certain library. It’s a layer to talk to most of the Amazon Web Services APIs. While working with web services usually is a particular awful experience, this library doesn’t make much of an effort to hide their awkwardness, in fact, in some ways it even makes it worse. It’s pretty old news that I enjoy bitching about code I don’t like, but I also like to keep it positive in at least thinking about how it could be improved.

Back to Top ↑

couchdb

10 Annoying Things About CouchDB

Hi, I’m Mathias, and I’m a CouchDB user. I’ve been using it for almost a year now, and we have a project using it in production, with a side of Redis. I think it’s an awesome database, some of its features are simply unrivaled. Offline replication, CouchApps, to name a few. CouchDB just hit version 1.0. It’s been a long time coming, with CouchDB having probably one of the longest histories in the non-relational database space. I’ve heard about it first back in September 2008, when Jan Lehnardt talked about it at a local co-working space. I still blame him for getting me all excited about this whole NoSQL thing. Fun fact: I bookmarked the CouchDB website back in February 2008.

Redis and Rails sitting on the Couch

I’ve been spending some quality time with two of my new favorite tools lately (CouchDB and Redis, duh!), and while integrating them into Scalarium some needs and as a result some smaller hacks emerged. I don’t want to deprive the world of their joy, so here they are.

Back to Top ↑

talks

June - A Month of Conferences

June was an exhausting month for me. I spoke at four different conferences, two of which were not in Berlin. I finished the last talk today, so time to reciprocate on conferences and talks. In all I had good fun. It was a lot of work to get the presentations done (around 400 single slides altogether), but in all I would dare say that it was all more than good practice to work on my presentation skills and to loose a bit of the fear of talking in front of people. But I’ll follow up on that stuff in particular in a later post.

Upcoming Conference Talks

June is a busy month when it comes to me speaking at conferences, you should drop by at least one of my talks, if you’re in the area.

Back to Top ↑

writing

Back to Top ↑

failure

On Resilience in Automated Systems, Failures and the Human Factor

Recently I’ve been reading several posts on how humans can be a deadly factor when complex and automated systems fail. Several posts diving into the issue are well worth reading, in particular “Automated to Death”, “Are We Automating Ourselves Into a Corner?” , “Cockpit Crisis”, and “People Make Poor Monitors for Computers”. Hot off the presses is James Hamilton’s analysis on the official report of the Fukushima accident.

Back to Top ↑

travisci

The Smallest Distributed System

Travis CI started out as an idea, an ideal even. Before its inception, there was a distinct lack of continuous integration systems available for the open source community.

Back to Top ↑

remote

Dear Founder: Things To Consider When Building a Remote Team

Every now and then a fellow founder approaches me looking for advice. The topics range from pricing, positioning products, to building and growing teams. Or in this case, they are questions about what to consider when you’re looking to go remote. A founder building a startup in Europe recently asked me for advice on building a remote team. I’ve been working in distributed teams for ten years now. Those teams have spanned from Europe to the US west coast. Sometimes they went beyond that, covering almost 24 hours of timezones.

Back to Top ↑

technology

Back to Top ↑

happiness

Always Improve, Never Stop, Never Pause, Never Appreciate

Building out a company and a business has been my greatest challenge so far. The company’s mission is built around continuous integration and continuous improvement, the constant drive of always getting better at what you do.

Back to Top ↑

vacation

From Open (Unlimited) to Minimum Vacation Policy

When Travis CI turned into a business with employees, one of our ideas was to not constrain people in how much time they take off for vacations. We didn’t track the days people were taking off, and as the people running the company, we didn’t actively encourage people to take times off. In short, we had an open vacation policy.

Back to Top ↑

startups

Dear Founder: Things To Consider When Building a Remote Team

Every now and then a fellow founder approaches me looking for advice. The topics range from pricing, positioning products, to building and growing teams. Or in this case, they are questions about what to consider when you’re looking to go remote. A founder building a startup in Europe recently asked me for advice on building a remote team. I’ve been working in distributed teams for ten years now. Those teams have spanned from Europe to the US west coast. Sometimes they went beyond that, covering almost 24 hours of timezones.

Back to Top ↑

10things

10 Things I’ve been Doing Lately

  1. Integrating Ferret, a very nice search engine for Ruby, in a project with acts_as_ferret.
  2. Learning ten finger typing.
  3. Writing an article about one of my favorite clothing labels, New Zealand based Huffer, for the magazine of two friends.
  4. Been hiking though snowy mountains in Norway on my summer holiday.
  5. Reading “RESTful Web Services” by Leonard Richardson and Sam Ruby. A highly recommended book on REST which I’m starting to like.
  6. Doing my first real-life project with the features of Java 5. That might sound a little ridiculous, but the clients using Java I worked for over the last year all used Java 1.4, mainly for political reasons or restrictions of the application server environment (WebLogic 8.2 is a no-go with Java 5).
  7. Finding more and more joy in photography, and at the same time starting to really like Lightroom.
  8. Playing with AP4R, an asynchronous job processor for Ruby and Rails. It looks like a very nice and more reliable way to do background tasks than BackgrounDRb. The latter now has a new maintainer by the way. Maybe that will bring the mostly stalled development back up to par.
  9. Working in my office. Something I really enjoy. Having a decent and quiet place to work in is important for a freelancer.
  10. Looking for a new mobile. In case you’re wondering the iPhone doesn’t appeal to me.
Back to Top ↑

oracle

Storing Images with Oracle and Hibernate

All I wanted was to store images in the database through Hibernate. It all look so easy. Add a byte array property, add it as a binary type to the Hibernate mapping and off you go. So far so good. I’m developing with MySQL where everything worked the way it’s supposed to. Image data goes into the database and comes out when required, no problem.

Back to Top ↑

paypal

Singing the Paypal Subscription Blues

For a recent project I had the pleasure to work with Paypal, especially with the Instant Payment Notification API. I haven’t heard a lot of things before I tried to marry it with Rails, but what I’d heard made me assume it wouldn’t be a piece of cake. And I was right.

I’d love to share some code with you, but Vasillis Dimos beat me to it. He wrote two posts on Paypal IPN and Rails, one dealing with the basics and the other about mocking IPN, which you really need to do to test your code. Really.

Personally I did the testing a little differently, since all my payment handling logic was in the model. I didn’t use ActiveMerchant either, but just the Paypal gem. But in general things are similar. Outside of the US and the UK you’re pretty much out of choices for payments, since there’s no Web Payments Pro available here, so IPN is (sadly) the way to go. It’s a real PITA and here’s why:

  • Paypal needs to reach your development machine from the outside. For testing this is not an issue of course, but when you need to do testing with the Paypal sandbox (which is painfully slow) and, god forbid, the real Paypal, there’s no way around that.
  • The payment flow is unnatural. You have to handle the payment outside of the user’s page flow. You have to rely solely on the stuff you get from Paypal, no session, no cookie, no user. It takes a lot of care to handle all that and there still might be a hole in your code that could be exploited.
  • IPNs might come in late, sometimes only after the user already got back to your site. Now you want to present him with a nice success message, but that’s not gonna happen then. That’s a rare case though. The IPN come in slower from the sandbox, that’s for sure. It’s up to you how to handle that. You can act in the favor of the user, or you can just make him wait till everything fell into place.
  • In rare cases you won’t get an IPN from Paypal, for whatever reason. I’ve seen this happen. Be prepared to create the successful payment by hand or have something like a small GUI at hand to do it.
  • For subscriptions six different notification types need to be handled. And their even spread out over two different fields in the notification.

Some advice on how to get it right:

  • Log everything. Store the IPNs in the database, in the log files, wherever. Just log them. Their your proof of things that happened. Just storing them with their raw post data should do while leaving the most important fields separately in different columns.
  • Use mocks. It’s not hard. But it’s totally worth it. When you want to test all events that Paypal might send you, which is a lot for subscriptions, it’s a painful development cycle. And some events aren’t even fully testable by hand.
  • Decide on strategy to handle fraud. While your IPN URL is not really public (nothing should link here, and it’s hopefully transmitted to Paypal encrypted) it’s not exactly safe to just accept everything.
  • Don’t return errors in your IPN handler. Paypal will try it again.
  • Store a pending payment and make it a full one when the corresponding IPN arrives.

All that said, it was an experience, and while not always pleasant, at least I learned something. But Paypal is far from being a pleasant way to handle payments, if you want to make it secure and protect your the integrity of your application and prevent fraudulent users from abusing your services, all of which should be your primary interests.

Back to Top ↑

mocks

Mocha and RSpec Don’t Play Nice

Mocking is a great part of RSpec, and from the documentation it looks insanely easy. What had me frustrated on a current project is the fact that the mocks and stubs wouldn’t always do what I’d expect them to do. No errors when methods weren’t invoked, and, the worst part, mocks wouldn’t be cleaned up between examples which resulted in rather weird errors. They only occurred when run as a whole with rake spec but not when I ran the specs through TextMate.

I was going insane, because noone on the mailing list seemed to have any problems, same for friends working with RSpec. Then I had another look at the RSpec configuration.

Turns out, the reason for all of this is that Mocha was used for mocking. Switching the configuration back to use RSpec’s internal mocking implementation, everything worked like a charme from then on.

So what you want to have in your SpecHelper isn’t this:

Spec::Runner.configure do |config|
  config.mock_with :mocha
end

but rather

Spec::Runner.configure do |config|
  config.mock_with :rspec
end

or no mention at all of mock_with which will result in the default implementation being used which is, you guessed it, RSpec’s own.

Back to Top ↑

python

Back to Top ↑

blog

Hello From Jekyll

I got a little sick of having to maintain an unmaintained blog engine (I’m looking at you SimpleLog), so I did what all the cool kids are doing, I switched the blog to using Tom Preston-Werner’s excellent Jekyll. I threw in a few tweaks of my own, and tweaked my Rakefile and Apache to support things that SimpleLog can do, but the static nature of Jekyll can’t. Thankfully, the URL format of both is pretty similar, so it was pretty easy to set up redirects from the old URLs to the new ones.

Back to Top ↑

kiss

Keep It Simple

It seems to be common sense these days to throw a search engine, a database slave or an external cache at your application in even the earliest stages of a project. Let me just give you my two cents on the issue, and why I think that’s a bad idea.

Back to Top ↑

scaling

Keep It Simple

It seems to be common sense these days to throw a search engine, a database slave or an external cache at your application in even the earliest stages of a project. Let me just give you my two cents on the issue, and why I think that’s a bad idea.

Back to Top ↑

performance

Keep It Simple

It seems to be common sense these days to throw a search engine, a database slave or an external cache at your application in even the earliest stages of a project. Let me just give you my two cents on the issue, and why I think that’s a bad idea.

Back to Top ↑

bdd

Mocking Is So 2008

Pat Maddox recently published a blog post on mocking called “You Probably Don’t Get Mocks.” I wanted to write something on my experiences with mocks for a while now, so here’s good reason to finally do so. I’m a recovering mock addict, if you will, so this is my retribution of things I learned over the last 18 months, and how my testing workflow changed with them.

Back to Top ↑

mocking

Mocking Is So 2008

Pat Maddox recently published a blog post on mocking called “You Probably Don’t Get Mocks.” I wanted to write something on my experiences with mocks for a while now, so here’s good reason to finally do so. I’m a recovering mock addict, if you will, so this is my retribution of things I learned over the last 18 months, and how my testing workflow changed with them.

Back to Top ↑

capistrano

Parallelizing Capistrano

On a recent project we ran into a situation where we needed a more advanced way of parallelizing Capistrano tasks than just using the parallel method it already sports. To jog your memory, parallel can run arbitrary shell commands in parallel on different servers. So if you wanted your webserver to already restart the processes while you restart your background processes, you can do it like this:

Back to Top ↑

deployment

Parallelizing Capistrano

On a recent project we ran into a situation where we needed a more advanced way of parallelizing Capistrano tasks than just using the parallel method it already sports. To jog your memory, parallel can run arbitrary shell commands in parallel on different servers. So if you wanted your webserver to already restart the processes while you restart your background processes, you can do it like this:

Back to Top ↑

run_later

run_later Gets Some Rails 2.3 Middleware Love

Apart from the awesome new features for users of the framework, Rails 2.3 got a lot of love on the inside too. It’s no secret it’s running on Rack now, and that switch made some of the internal code a lot easier on the eyes. They also added a Rails-internal middleware stack, on which some of the framework’s functionality builds already.

Back to Top ↑

rack

run_later Gets Some Rails 2.3 Middleware Love

Apart from the awesome new features for users of the framework, Rails 2.3 got a lot of love on the inside too. It’s no secret it’s running on Rack now, and that switch made some of the internal code a lot easier on the eyes. They also added a Rails-internal middleware stack, on which some of the framework’s functionality builds already.

Back to Top ↑

metaprogramming

A Ruby Meta-Programming Riddle

When we were at Scotland on Rails (excellent conference by the way, you should definitely go), and we sat in Dave Thomas’ keynote, where he talked about the “Ruby Object Model”, funnily enough we ran across a meta-programming wonder in that very session. It has been keeping me busy for a couple of hours, and I’d like to share my revelations. With some of them I’m not completely in the clear, but maybe they’ll be a start for discussion. It’s more a tale of one of my adventure through the Ruby object model than a fancy tutorial, so if you’re up for that kind of thing, keep going. If not, just keep on reading.

Back to Top ↑

conference

Back to Top ↑

plugin

Crumble - Breadcrumbs for Rails Applications

I recently had to improve the breadcrumbs situation on one of my projects. Until now, breadcrumb definition were sprinkled across the controllers. While that was okay for a while, the current breadcrumbs have become a bit more complex, and I wanted to get them out of the controllers. One option would’ve been to put them into the model, but seriously, who does that? Plus, I have a lot of breadcrumbs that are not exactly related to a model, and if they are, it’s not always an ActiveRecord model.

Back to Top ↑

rabbitmq

Back to Top ↑

aws

Daily AWS Wtf and German Rails Conference

I’ve started a new blog (don’t worry, I have not abandoned this one), specifically targeting experiences, wtf’s and workarounds for the latter on Amazon’s Web Services. I’ve been working quite a lot with them recently, and there’s heaps of dark corners around, and things you need to be aware of. That’s what that blog is about. Head on over to Daily AWS Wtf and give it a read. It’s powered by the people of Peritor, so there’ll be other people writing too.

Back to Top ↑

legacy

Back to Top ↑

code

Back to Top ↑

api

How Not To Design An API

I’ve had the dubious pleasure of working with a certain library. It’s a layer to talk to most of the Amazon Web Services APIs. While working with web services usually is a particular awful experience, this library doesn’t make much of an effort to hide their awkwardness, in fact, in some ways it even makes it worse. It’s pretty old news that I enjoy bitching about code I don’t like, but I also like to keep it positive in at least thinking about how it could be improved.

Back to Top ↑

shoulda

The Shoulda RSpec Extravaganza

I don’t use RSpec a lot any more these days. I much prefer Shoulda, heck I even started using Rails integration tests again (using Shoulda of course), because sometimes the additional abstraction of Cucumber is just too much. Any way, there’s some things I liked about RSpec, and they were not related to the features of the testing DSL itself, but more to the tool RSpec. It has a neat formatter that’ll output the ten slowest-running tests. I also found the colored list of full test names to be very helpful.

Back to Top ↑

rest

ActiveRecord’s Callbacks Ruined My Life

Recently I’ve been having a foul taste in my mouth, or just a bad feeling, if you will. Whenever I started adding validations and callbacks to a model in a Rails application. It just felt wrong. It felt like I’m adding code that shouldn’t be there, that makes everything a lot more complicated, and turns explicit into implicit code. Code that is only being run depending on the persistence state of an object. Code that is being hard to test, because you need to save an object to test parts of your business logic. Don’t get me started on observers, I never was a fan of them. Putting stuff that should be run when an object was saved elsewhere is the worst kind of hiding business logic.

Back to Top ↑

video

Conference Talks You Should Be Watching

Thanks to the guys from Confreaks, there’s a whole bunch of video material from conferences for the rest of us to enjoy. I’ve been watching quite a few recently, so here’s some recommendations of talks I found interesting.

Back to Top ↑

rubyish

Conference Talks You Should Be Watching

Thanks to the guys from Confreaks, there’s a whole bunch of video material from conferences for the rest of us to enjoy. I’ve been watching quite a few recently, so here’s some recommendations of talks I found interesting.

Back to Top ↑

presentations

Presentation Fu

I’ve attended my fair share of conferences this month alone, plus a Seedcamp, and I can safely say that in any way, I learned a lot about how to build slides, how to keep the audience engaged and things one just shouldn’t do in a talk or in slides. While I certainly don’t claim to be an expert on the topic now, I just wanted to put all of my impressions and lessons learned into a post.

Back to Top ↑

vim

Back to Top ↑

documents

Back to Top ↑

schema

Back to Top ↑

replication

Back to Top ↑

distributed

Why I Love and Hate Distributed Systems

Let me go ahead and say it: I love distributed systems. Why? Simply because they bend my brain. Yesterday I tweeted “Distributed databases are my happy place.” One response I got was along the lines of: “then you’re probably not running a distributed database in production.” Busted! But does it matter? We all love distributed stuff, we love thinking about scaling. They seem like problems everyone wants to have and solve.

Back to Top ↑

algorithms

Why I Love and Hate Distributed Systems

Let me go ahead and say it: I love distributed systems. Why? Simply because they bend my brain. Yesterday I tweeted “Distributed databases are my happy place.” One response I got was along the lines of: “then you’re probably not running a distributed database in production.” Busted! But does it matter? We all love distributed stuff, we love thinking about scaling. They seem like problems everyone wants to have and solve.

Back to Top ↑

humility

Be Humble, and Get Shit Done!

I had the honor of speaking at JAOO, sorry GOTO, this year. Being part of so many great speakers, like James Gosling, Rich Hickey, Martin Fowler, Tim Bray, Michael Nygard, and Dan Ingalls (maker of several Smalltalk versions), made me feel nothing but humble, but not in a bad way. I talked about CouchDB, and if you care for it, check out my slides. This is my take away from the conference.

Back to Top ↑

fulltext

Why Riak Search Matters…

The awesome dudes at Basho released Riak 0.13 and with it their first version of Riak Search yesterday. This is all kinds of exciting, and I’ll tell you why. Riak Search is (way down below) based on Lucene, both the library and the query interface. It mimicks the Solr web API for querying and indexing. Just like you’d expect something coming out of Basho, you can add and remove nodes at any time, scaling up and down as you go. I’ve seen an introduction on the basics back at Berlin Buzzwords, and it was already shaping up to be nothing but impressive. But enough with all the praise, why’s this stuff exciting?

Back to Top ↑

infrastructure

The Virtues of Monitoring

Over the last year I haven’t only grown very fond of coffee, but also of infrastructure. Working on Scalarium has been a fun ride so far, for all kinds of reasons, one of them is dealing so much with infrastructure. Being an infrastructure platform provider, what can you do, right?

Back to Top ↑

durability

MongoDB, Data Durability and Improvements coming in 1.8

Last weekend I tweeted two links to two tweets by a poor guy who apparently got his MongoDB database into an unrecoverable state during shutdown whilst upgrading to a newer version. That tweet quickly made the rounds, and the next morning I saw myself staring at replies stating that it was all his fault, because he 1.) used kill -9 to shut it down because apparently the process hung (my guess is it was in the middle of flushing all data to disk) and 2.) didn’t have a slave, just one database instance.

Back to Top ↑

eventmachine

EventMachine, How Does It Work?

At this year’s Scottish Ruby Conference, I gave a talk about EventMachine, slides are available. Amidst the hype around Node.js it’s too easy to forget that Ruby has had evented I/O libraries for years. EventMachine, libebb, rev, cool.io, to name a few. As a general introduction I recommend reading Dan Kegel’s article on the C10K problem, the problem of handling 10000 server connections on a single machine. It introduces all the evented approaches that have been implemented in the different operating systems over the last some 15 years.

Back to Top ↑

networking

EventMachine, How Does It Work?

At this year’s Scottish Ruby Conference, I gave a talk about EventMachine, slides are available. Amidst the hype around Node.js it’s too easy to forget that Ruby has had evented I/O libraries for years. EventMachine, libebb, rev, cool.io, to name a few. As a general introduction I recommend reading Dan Kegel’s article on the C10K problem, the problem of handling 10000 server connections on a single machine. It introduces all the evented approaches that have been implemented in the different operating systems over the last some 15 years.

Back to Top ↑

nodejs

EventMachine, How Does It Work?

At this year’s Scottish Ruby Conference, I gave a talk about EventMachine, slides are available. Amidst the hype around Node.js it’s too easy to forget that Ruby has had evented I/O libraries for years. EventMachine, libebb, rev, cool.io, to name a few. As a general introduction I recommend reading Dan Kegel’s article on the C10K problem, the problem of handling 10000 server connections on a single machine. It introduces all the evented approaches that have been implemented in the different operating systems over the last some 15 years.

Back to Top ↑

publishing

Back to Top ↑

tools

Back to Top ↑

dynamo

A Tour of Amazon’s DynamoDB

Amazon’s recent release of DynamoDB, a database whose name is inspired by Dynamo, the key-value database the distributed datastore they’ve been running in production for a good five to six years now. I think it’s great they’ve finally done it, though from my obverservations, there’s little resemblance of what the original Dynamo paper describes, but I’m getting ahead of myself. Traditionally Amazon hasn’t been very open about how they implement their services, so some of what I’m stating here may be nothing more than an educated guess. Either way, the result is pretty neat.

Back to Top ↑

amazon

A Tour of Amazon’s DynamoDB

Amazon’s recent release of DynamoDB, a database whose name is inspired by Dynamo, the key-value database the distributed datastore they’ve been running in production for a good five to six years now. I think it’s great they’ve finally done it, though from my obverservations, there’s little resemblance of what the original Dynamo paper describes, but I’m getting ahead of myself. Traditionally Amazon hasn’t been very open about how they implement their services, so some of what I’m stating here may be nothing more than an educated guess. Either way, the result is pretty neat.

Back to Top ↑

blocks

Fun with Ruby Block Parameters

I always forget what kinds of crazy things you can do with Ruby’s blocks and their parameters, so here’s a little write-up on them. I regularly forget things I’ve learned (must be an age thing), and I found that not even books on the Ruby language fully cover all the gory details on block (and method) parameters. So consider this my personal reference of crazy Ruby block syntax features for future use.

Back to Top ↑

logging

Back to Top ↑

handbook

Riak Handbook 1.1 is out!

I’m happy to report that the Riak Handbook has hit a major update, bringing a whopping 43 pages of new content with it. If you already bought the book, this is a free update, and instructions how and where to download it were sent in a separate email.

Back to Top ↑

crdt

Back to Top ↑

resilience

On Resilience in Automated Systems, Failures and the Human Factor

Recently I’ve been reading several posts on how humans can be a deadly factor when complex and automated systems fail. Several posts diving into the issue are well worth reading, in particular “Automated to Death”, “Are We Automating Ourselves Into a Corner?” , “Cockpit Crisis”, and “People Make Poor Monitors for Computers”. Hot off the presses is James Hamilton’s analysis on the official report of the Fukushima accident.

Back to Top ↑

weboperations

On Resilience in Automated Systems, Failures and the Human Factor

Recently I’ve been reading several posts on how humans can be a deadly factor when complex and automated systems fail. Several posts diving into the issue are well worth reading, in particular “Automated to Death”, “Are We Automating Ourselves Into a Corner?” , “Cockpit Crisis”, and “People Make Poor Monitors for Computers”. Hot off the presses is James Hamilton’s analysis on the official report of the Fukushima accident.

Back to Top ↑

humans

Back to Top ↑

queues

A Story About Queues in Four Acts

There are queues everywhere. This is the story of a few of them. The names of the queues are made up, but their story is real nonetheless.

Back to Top ↑

customers

Coffee and the Art of Customer Happiness

This essay is an extended version of a talk I gave at Paperless Post about coffee and customer happiness. While the talk was originally titled “Coffee and the Art of Software Maintenance”, I figured that customer happiness is overall a much more fitting for the topic.

Back to Top ↑

humanerror

A Short Story on Human Error

A few weeks back I came across a post that struck home in several ways. “How I Fired myself” (cached version) is a short story of a developer who accidentally deleted the entire users table in production while working on a new feature. You should read the whole thing, go ahead, I’ll wait for you.

Back to Top ↑

s3

Back to Top ↑

jekyll

Back to Top ↑

continuousdeployment

Back to Top ↑

distributedsystems,

The Smallest Distributed System

Travis CI started out as an idea, an ideal even. Before its inception, there was a distinct lack of continuous integration systems available for the open source community.

Back to Top ↑

office

Back to Top ↑

infrastructure,

Back to Top ↑

work

On Working (Too) Hard

There’s a prevailing idea when it comes to startups and building and running your own business.

Back to Top ↑

risk

Back to Top ↑

safety

Back to Top ↑

learning

Back to Top ↑

devops

The Developer is Dead, Long Live the Developer

I came across an article called “How DevOps is Killing the Developer.” It mourns the rise of DevOps and an ever increasing set of skills a developer has to have to work in the resource-constrained environment of a startup. The assumption is that a developer has to fill all these roles even though his position is at the top of the company’s hierarchy and no one else can do what they can.

Back to Top ↑

humanfactors

Back to Top ↑

creativity

Back to Top ↑

featuritis

Focus Starts With Saying No

Every product out there is riddled by a thousand customers’ requests for a thousand features. Every single one of them has an idea on what would make your product better, what would make it more suitable for their purpose, for their daily work.

Back to Top ↑

simplicity

Only The Simplest Tools

Over the past couple of years, there’s been a curious trend in the world of coffee. While espresso is still a thing of expensive machinery to get the most out of the bean, filter coffee has taken an interesting turn towards simplicity.

Back to Top ↑

habits

Planning Your Week

Our household recently picked up an interesting habit, one where people tell me they couldn’t do it, or they just don’t work that way.

Back to Top ↑

life

Being Busy, Distractions and Just One More Retweet

Thanks to the internet and the wild things our mobile devices can now do, we can connect with people anywhere, heck, even on the toilet, what used to be a sanctuary of quiet contemplation.

Back to Top ↑

justsayno

The Power of Saying No (To Sugar)

Over the last couple of weeks, I’ve been avoiding sugar. Not just avoiding eating spoon-fulls of crystal sugar, but avoiding food and drink that contains sugar.

Back to Top ↑

goals

Back to Top ↑

smallbiz,

From Open (Unlimited) to Minimum Vacation Policy

When Travis CI turned into a business with employees, one of our ideas was to not constrain people in how much time they take off for vacations. We didn’t track the days people were taking off, and as the people running the company, we didn’t actively encourage people to take times off. In short, we had an open vacation policy.

Back to Top ↑

growth,

Always Improve, Never Stop, Never Pause, Never Appreciate

Building out a company and a business has been my greatest challenge so far. The company’s mission is built around continuous integration and continuous improvement, the constant drive of always getting better at what you do.

Back to Top ↑

growth

Five Habits of an Introverted Leader

Being an introverted person in a leadership position is challenging. The one thing that exhaust you the most is now your main focus, interacting with people.

Back to Top ↑

feedback

The Feedback Log

One thing I wanted to a better job at as I took on a new role last year is to be more deliberate in giving feedback. As a German, I tend to fall on the side of only focusing on negative, or constructive feedback. I tend to focus on pointing out what I think should be improved, or what isn’t conclusive. This is quite ingrained in the German work culture.

Back to Top ↑

strategy

On Drafting an Engineering Strategy

During the first weeks in a new role, one of the things I’ve most recently focused on is to assess the direction of the engineering department as a whole. At the time I started there was no explicit strategy in place. Which is also not an unusual thing for a young company, just to be clear. So I set out to draft one.

Back to Top ↑

engineering

On Drafting an Engineering Strategy

During the first weeks in a new role, one of the things I’ve most recently focused on is to assess the direction of the engineering department as a whole. At the time I started there was no explicit strategy in place. Which is also not an unusual thing for a young company, just to be clear. So I set out to draft one.

Back to Top ↑