without-brains.net

A software developer's blog

Introducing Emphloyer

There comes a time in the life of any web application that asynchronous job processing becomes a requirement (you don’t want to keep your web processes hanging on long running tasks slowing down your users after all). In the years that I worked a lot with Ruby (and Rails) I worked with and on a variety of frameworks that cater for this need such as delayed_job and resque, and at a time I even built one of myself as a side project: Employer.

Nowadays I work mostly with PHP and I wanted something similary flexible to Employer so I decided to redo it in PHP… and thus Emphloyer was born!

Add your own customization to Vagrant boxes

Earlier posts on my blog show that I like to run my development environments on virtual machines rather than directly on my own OS. In the past I did this using VirtualBox, nowadays I prefer using Vagrant (my previous blog post probably gave that away already) which makes managing development VMs a lot easier. If you’re not already using Vagrant I highly recommend you give it a try. There’s an excellent introduction on Railscasts if you like screencasts, otherwise the Vagrant website should most certainly help you get started. I like to do most of my work on shell sessions, and to do this effectively I have the need to customize all of my Vagrant boxes to have my own settings. In this article I’ll show you how you can easily setup Vagrant to customize your Vagrant boxes to your heart’s content.

Capybara and Selenium with Vagrant

Capybara is an easy way to perform integration testing through a browser for your web applications. Capybara has various drivers including one which works with Selenium Webdriver that allows you to run your tests against a number of different browsers including Internet Explorer, Firefox and Chrome. When you develop directly on your own machine then all is good and running your tests through Capybara with Selenium will fire up a browser window to run your tests. I like to develop web applications using Vagrant boxes with Ubuntu server on them and there the same approach won’t work directly, in this article I’ll show what you can do to automate testing using Capybara with Selenium on such an environment.

Globally unique values on embedded Mongoid documents

Mongoid is an excellent ORM for using MongoDB. Its very easy to use as a replacement for ActiveRecord in Rails as it uses ActiveModel inside and offers a lot of the same functionality as ActiveRecord.

MongoDB encourages you to embed documents for contains type of relations rather than creating relations between different collections. If you want to know more about embedding versus linking I encourage you to read the MongoDB documentation on schema design.

When you use Mongoid and add uniqueness validations on an embedded document you’ll soon discover that these validations only apply to the scope of the parent document (as described in the validations documentation). In many cases that’s exactly what you want, however there may be scenarios where you want a field in an embedded document to be unique across the entire collection. In this article I’ll show you how that can be done.

From WordPress to Octopress

After running this blog on WordPress for just over 2 years I’ve decided to finally make the move to Octopress. For me Octopress has a number of advantages:

  • The website itself is now just static HTML, and because of this my server no longer needs to run PHP and MySQL and thus greatly decreasing the footprint of this blog.
  • All of the blog entries and pages can be written in text files, edited with my favorite editor, and kept in version control make the whole lot much more portable.

Goodbye comments

Since I get so many spam comments and so few actual comments I’ve decided to turn off comments on this weblog. If I post something here and you want to reply to it then please go ahead and send a public tweet to my Twitter account: @mkrmr.

Writing a SOAP web service in Ruby

Ruby 1.9 doesn’t come with SOAP support out of the box, in this article I’ll show you a very basic example SOAP service over HTTP that I’ve written in Ruby 1.9 that supports a subset of the SOAP 1.1 standard (enough to make it compliant for what it does) that you can use to get started if you want or need to write a SOAP service in Ruby get started. Additionally I’ll briefly show you how you can poke around it with soapUI and how you can consume (use) it with PHP, Java (using Apache CXF), .NET and of course Ruby (using Savon).

Using RVM global gemsets

If you use RVM with gemsets to manage your Ruby installations (which I do for development) and you find yourself constantly installing certain gems in all of your gemsets (like interactive_editor or pry) then there’s a way to make life easier for yourself.

Customizing the Ubuntu 11.10 login screen

Ubuntu 11.10 uses lightdm as its display manager, configuring how the login screen behaves and what it looks like can be done with the files in /etc/lightdm. To change the background image for the login screen simply edit /etc/lightdm/unity-greeter.conf (as super user, so be sure to use sudo or gksudo to fire up your editor)