Getting the current song in iTunes from the command line

Wondering which Python your Apache with modwsgi is using?

This let me figure out that my modwsgi wasn’t using the Python that I thought it was.

sudo lsof -c httpd | grep python

Fix for oh-my-zsh git-svn prompt slowness

I was dying a slow death from the slowness of my zsh prompt when using oh-my-zsh‘s git plugin and a repository managed by git-svn. I finally decided to do something about it today.

I tracked the slowness down to the parse_git_dirty function in oh-my-zsh/lib/git.zsh. This function calls git status which seems to be quite slow in my environment. My fix was to replace the oh-my-zsh version of the git_prompt_info function with a version that doesn’t call parse_git_dirty. This means that I can’t get the little checkmark (“✔”) or “X” (well actually “✗”) that shows whether my working copy is dirty or not, but it’s worth it to me to not have my prompt lag like crazy.

To fix this, I pasted the following into my ~/.zshrc:

https://gist.github.com/2355834

DTrace for Linux

I wanted to draw attention to the excellent work that Paul Fox has been doing in porting DTrace to Linux. And he recently created a GitHub repo for it, so it’s that much easier to contribute now.

If you have Linux kernel knowledge, I’d encourage you to get involved!

TarColor: color the output of tar tvf similarly to the way GNU ls would

One day I was looking through a tar file and looking for an executable. When I use ls, I can do this at a glance by just looking for green filenames, as I always have my ls configured to show executable files in green. It occurred to me that it would be nice to see the same kind of coloring when looking at the contents of tar files with tar tvf. Thus, TarColor was born. It was a quick Perl script to scratch my own itch. I thought others might find it useful, so I put it on GitHub and CPAN.

Usage

You can use tarcolor manually like this:

$ tar tvf some_tarball.tgz | tarcolor
... colored output ...

There is also a bundled shell script (for bash and zsh) that makes tar automatically pipe its output through tarcolor:

$ source /usr/local/etc/tarcolor/tarcolorauto.sh
$ tarcolorauto on
$ tar tvf some_tarball.tgz
... colored output ...
$ tarcolorauto off
$ tar tvf some_tarball.tgz
... normal uncolored output ...

Customization

Colors can be customized using the LS_COLORS or TAR_COLORS environment variables:

$ export LS_COLORS='di=01;34:ln=01;36:ex=01;32:so=01;40:pi=01;40:bd=40;33
:cd=40;33:su=0;41:sg=0;46'

The format for LS_COLORS and TAR_COLORS is the same format used by LS_COLORS (used by GNU ls). So if you use GNU ls and have your LS_COLORS set, then tarcolor will use similar colors as ls. If you want to tweak your colors and don’t want to edit LS_COLORS manually, you might try this online LS_COLORS generator.

Links

Installing GNOME in FreeBSD 9

I pretty much followed these instructions, but one extra step was required.

The problem that I was having was that the system kept running out of file descriptors and becoming unusable. After a little digging around with fstat and such, it was apparent that gam_server from Gamin was the culprit, using some 3700 file descriptors. From a bit of web browsing, I saw that this is somewhat common on BSD, because BSDs don’t have inotify like Linux, so Gamin uses kqueue but this requires opening files and using file descriptors. This is described in the Gamin Wikipedia page.

My solution was to increase the number of file descriptors by adding to /boot/loader.conf:

kern.maxfiles="25000"

This was enough file descriptors to placate gam_server:

[marca@freebsd9-0 ~/src]$ fstat | grep gam_server | wc -l
    6435

Why you don’t get mock objects

Why you don’t get mock objects

Fascinating talk by Gregory Moeck from RubyCon 2011

While this deals quite a bit with TDD and mock objects, it’s also largely about a particular style of OO design, one that reminds me a lot of some of Allen Holub’s writings. It’s not very specific to Ruby (it has some examples in RSpec – that’s about the extent of the Rubyness).

Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.