without-brains.net

A software developer's blog

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.

Ubuntu 11.04

Ubuntu 11.04 has been released recently, so I decided to give it a spin on my own machine. Unfortunately getting it to work was not without problems, this article describes what I’ve run into so far and how I fixed it.

Vim 7 in your Solaris home directory with colours

I am currently employed by a company that runs it’s development environments on a Solaris 10 server, and I often work on that machine’s shell over SSH. Often I want to use an editor directly on that machine (because that’s convenient), and my preferred editor is Vim. In my case the server had Vim 6 installed and I wanted to use Vim 7.3 (the latest version at the time of this writing), because some of my favorite Vim extensions require Vim 7.

Assuming that you have access to gcc and gmake it’s easy to install Vim in your home directory. For this article I’ll provide examples using bash, if you’re using another shell your command syntax and the preference files you need to edit will likely be a little different.

Ruby on Rails 3 and UJS

On August the 29th Ruby on Rails 3 was been released, the Rails team has made a series of screencasts available about the changes in Rails 3 here. Ryan Bates also made a series of screencasts about Rails 3 on Railscasts.com here. Let me start this article by thanking everyone for their hard work on Ruby on Rails 3, it’s a fantastic release!

Now to dive into the subject of this article, one of the new features in Rails 3 that I really like is the use of UJS (Unobtrusive JavaScript) taking away all the inline Javascript that was generated by Rails inline within your HTML. UJS has many advantages over inline Javascript, the main advantages in my opinion being that Javascript is now no longer treated as a second class citizen, more easily managed (because it isn’t all over the place anymore) and that it makes it easier to build pages that work with and without Javascript.

Vim tip: Platform specific settings in your vimrc

If you use Vim on multiple platforms like I do, you may find it convenient to know that you can detect the platform your installation Vim was compiled for in Vimscript. With this functionality you can put all your settings for all your systems in a single vimrc file.

Vim tip: Visual block editing

One of the features I find very convenient in Vim editing in visual blocks.

With CTRL+V (while in normal mode) you can activate the visual block mode, by using the standard movement keys (h, j, k, l or the arrow keys). You can perform various operations on visual blocks (check the help with :help v), in this article I will describe how you can prepend or append text to a block.

Installing Windows Vista using a USB flash drive

It’s fairly simple to create a USB flash drive that can be used to boot a computer and install Windows Vista (assuming that the computer that you want to install on can boot from a USB flash drive). To get your USB flash drive ready you need the following:

  • USB flash drive of the appropriate size (I used a 6GB drive)
  • Windows Vista install DVD
  • Computer that has Windows Vista installed, a DVD drive and has a free USB slot (for use with the USB flash drive)