without-brains.net

A software developer's blog

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)

Using Foreman to run JRuby with RVM and MRI

Foreman is a utility written in Ruby that makes it easy to launch multiple processes with a single command and watch the output (which is color coded per process) on a single screen. If your application has multiple processes to start then Foreman might be a good solution for you (take a look at the Railscast on Foreman for a good introduction if you’re not familiar with it).

Inside Foreman makes use of Process#fork to launch its processes and unfortunately that isn’t supported by JRuby. If you’re using RVM to manage your Ruby installations you can use its wrapper functionality to create a wrapper for Foreman to run it using MRI (or another Ruby implementation that supports Process#fork). Here’s how you do it:

Useful *nix tools: ack-grep

ack (on Ubuntu named ack-grep, so if you’re using Ubuntu then replace ack in the example commands in this article with ack-grep) is a friendlier alternative to grep for most uses. One of the features I really like is that ack distinguishes files by type and that you can tell ack to explicitly look at certain file types, or to exclude certain file types from your searches.

Using dnsmasq to run your own TLD

So you’re developing networked applications on your own computer and now you want to test using different host names or URLs that route to localhost (because obviously that’s where your running everything). Surely you could go on and edit your hosts file every time you need a new host name, but that becomes tedious and annoying quickly. This article will describe how to use Dnsmasq on Ubuntu 11.04 to setup a (top level) domain for which all host names will route to localhost (your mileage will vary on other distros).

Useful *nix tools: sed

If you work on *nix systems (UNIX, Linux, Mac OS X, BSD, etc.) and you want to extract information from text files such as log files of different kinds and/or lengthy output from other command line tools you’ll want to learn about sed. Sed stands for stream editor, it is an incredibly powerful non-interactive text editor/processor/filter that takes input via a *nix pipe and transforms it based on command line parameters and then outputs the result.