Introducing TrueCrypt Mounter for OS X

After playing around with using TrueCrypt and syncing the volume over Dropbox I was disappointed to discover that it doesn't let you mount the volume by double clicking on the file. You have to open TrueCrypt, select the file and then type in your password.

To further expand my knowledge of OS X application bundles I set out to write an application that associated with the .tc file extension and when you opened a .tc file it would prompt your for your password and once you are done and eject the disk, automatically dismount the TrueCrypt volume.

The fruit of my labour is available in this GitHub repository and you can download the application here. Once you have copied the application to your Applications directory, it will associate with any *.tc file. You must add this extension to any of your TrueCrypt volumes because (unfortunately) TrueCrypt does not do this for you automatically.

Speeding up jruby with nailgun

I had always wondered why when I installed jruby using rvm it always built something called Nailgun but I never bothered to search about it.

That was a mistake.

Nailgun is an amazing idea that greatly speeds up the start up time of the JVM and subsequently: jruby.

Without Nailgun

$ time jruby -e ''

real        0m1.336s
user        0m2.608s
sys         0m0.205s

With Nailgun

$ time jruby --ng -e ''

real        0m0.265s
user        0m0.001s
sys         0m0.003s

As you can see, nailgun reduced the start up time for jruby by 500%. Now you may be asking "How do I get started using nailgun?". Well, if you are using rvm then all you need to do is enable the after_use_jruby hook which will start up a nailgun server for you.

    chmod +x "$rvm_hooks_path/after_use" "$rvm_hooks_path/after_use_jruby"

And that's all you need to do. rvm jruby or rvm use jruby will now start up a nailgun server if there isn't one running and it set the --ng switch for all jruby runs.

If you aren't using rvm, you will have to compile nailgun and start up a nailgun server with jruby --ng-server. Now whenever you run jruby you just add the --ng switch and it will use the nailgun server. You may want to export JRUBY_OPTS="--ng" to set the switch for all jruby runs.

Addendum: mysql2 ruby gem and Mac OS X: image not found

Back at the start of April I wrote mysql2 ruby gem and Mac OS X: image not found to deal with the extremely relative path to libmysqlclient.16.dylib. I had said I would prefer not putting libmysqlclient.16.dylib in /usr/lib but I couldn't find a dylib path that ruby uses. That is until today when I decided to try again.

I found libexecdir in RbConfig::CONFIG which is the directory where ruby can load dylib files from.

libexecdir=$(ruby -rrbconfig -e 'puts RbConfig::CONFIG["libexecdir"]')
sudo mkdir -p $libexecdir
sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib $libexecdir

Now ruby can load libmysqlclient.16.dylib without putting it in /usr/lib.

I forgot to mention it in the first post but if your ruby wants libmysqlclient.18.dylib, just replace the 16 with 18. Same with any other number.

mysql2 ruby gem and Mac OS X: image not found

If you are using the mysql2 ruby gem on Mac OS X you may have run into this problem before.

> require 'mysql2'
LoadError: dlopen(mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9):
  Library not loaded: libmysqlclient.16.dylib
  Referenced from: mysql2-0.2.7/lib/mysql2/mysql2.bundle
  Reason: image not found - mysql2-0.2.7/lib/mysql2/mysql2.bundle

So far the only solution I have found online is to use install_name_tool to update the (extremely) relative libmysqlclient.16.dylib reference to be absolute (usually to /usr/local/mysql/lib/libmysqlclient.16.dylib).

While this solves the problem, it only works until you reinstall the mysql2 gem or install a newer version and then you have to do it again. To permanently solve it you need to create a symlink of libmysqlclient.16.dylib to /usr/lib so that it can be found with that default relative path.

Ideally you wouldn't put it in /usr/lib but I haven't be able to find a path inside of ruby that will let you load the dylib.

sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/lib

Enter your password and then you can use the mysql2 gem without needing to edit the compiled bundle afterwards.

Store your git https passwords in your OS X Keychain

Around this time last year git added a "smart" HTTP transport that is faster than the old HTTP transport (and in some cases faster than SSH too). And a few months later GitHub added support for this new HTTP transport and made it the default selected url for repositories (that you aren't a contributor for).

There aren't any major advantages using https over ssh to access your GitHub repositories, it's just more simple to use your username/password instead of adding your ssh key. The only other advantages is that it's easier to set up HTTP proxy for git (git config --global http.proxy proxy:8080 vs ssh config) and being able to use more than one GitHub account (which you shouldn't since anyone can add you as a contributor to a project).

One major disadvantage is that it asks you for your username/password each time you interact with your remote repository (clone, pull, push, etc). To solve this, I decided to write a program that stores your username and/or password in your keychain so git will ask once for you username/password and retrieve it later so you don't have to type it again. If you only want the program, skip to it.

Continue reading "Store your git https passwords in your OS X Keychain"

PhidgetSBC2 Interactive C# Shell

One cool package for playing around with your phidget(s) is mono-csharp-shell which gives you an interactive C# shell (with tab completion).

apt-get install -y mono-csharp-shell

Once the package is installed, you can open it with csharp but just like with gmcs we have to include the reference to the Phidget library.

csharp -r:Phidget21.NET.dll

Continue reading "PhidgetSBC2 Interactive C# Shell"

Missing Namespaces on PhidgetSBC2’s Mono

Since we cannot install mono-complete on the PhidgetSBC2 currently, we are missing some of the C# namespaces. If you are trying to use any of the following namespaces and gmcs cannot find it, you will have to install the respective package.

Namespace Package
Mono.Data libmono-data2.0-cil
System.Data libmono-system-data2.0-cil
System.Data.Linq libmono-system-data-linq2.0-cil
System.DirectoryServices libmono-system-ldap2.0-cil
System.Messaging libmono-system-messaging2.0-cil
System.Runtime libmono-system-runtime2.0-cil
System.Web libmono-system-web2.0-cil
System.Web.Mvc libmono-system-web-mvc2.0-cil