Getting to the Bottom of’s Flop

Posted by chetan on October 25, 2013

according to the research firm the Standish Group, 94 percent of large federal information technology projects over the past 10 years were unsuccessful — more than half were delayed, over budget, or didn’t meet user expectations, and 41.4 percent failed completely.

via Getting to the Bottom of’s Flop –

Terrorists win

Posted by chetan on September 10, 2013

Game over.

How to fix wget certificate issues

Posted by chetan on June 12, 2012

If you’ve ever run into this annoying message before:

$ wget
--2012-06-12 14:42:46--
Connecting to||:443... connected.
ERROR: cannot verify's certificate, issued by `/C=US/O=DigiCert Inc/ High Assurance CA-3':
  Unable to locally verify the issuer's authority.
To connect to insecurely, use `--no-check-certificate'.

There’s actually an easy fix!

You may want to run


occasionally to keep things up to date as well.

Profiling Java programs on OS X

Posted by chetan on May 18, 2011

Sounds easy, doesn’t it? Well it actually is quite simple but the error messages along the way can really trip you up!

My first attempt at profiling a bit of code was to use the full-boat Eclipse stack: Eclipse Test & Performance Tools Platform Project! Well, what they don’t tell you anywhere on the project page is that it’s only supported on Windows and Linux. A Mac port was started sometime around 2004 and never completed. Yeah, it’s been that long!

And so this brings us to Apple’s Shark: an extremely barebones, no-frills profiler, but, what the heck, it’s free. For the basics on using this tool with your Java app, this great post has all the details. There’s just one catch: 64-bit support. There is none. If you’re on a 64-bit stack and you try to run it, you’ll see something like the following:

$ java -agentlib:Shark -cp foo.jar
Error occurred during initialization of VM
Could not find agent library: libShark.jnilib (searched /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries:/System/Library/Java/Extensions:/Library/Java/Extensions:.)

Er, what? Now let’s see here…

$ ls -al /System/Library/Java/Extensions/libShark.jnilib 
-rwxr-xr-x 1 root wheel 50352 Oct 24  2010 /System/Library/Java/Extensions/libShark.jnilib

Well, that’s odd. But it said it looked there, right?! Well, as it turns out, the Shark JNI library only supports 32-bit JVMs. So finally, we arrive at the following:

$ java -d32 -agentlib:Shark -cp foo.jar
2011-05-18 23:05:20.756 java[84473:20f] Shark for Java enabled...

Great sucess! And now, back to work, just a little less sane…

Compiling Q4M on OS X

Posted by chetan on May 11, 2011

I recently compiled Q4M on my Mac and I’m documenting it here now because it proved to be somewhat painful so hopefully you’ll avoid a bit of grief by reading this.

First off, you need MySQL Server. I’ve been using MacPorts for some time now, so this is installed via ports. Unfortunately, it seems to be a pretty barebones config so I had to create a custom variant to add the necessary --with-fast-mutexes option. You can grab my modified Portfile from github. Just clone it into some directory and then add that path into /opt/local/etc/macports/sources.conf before the rsync line. Once you have that, go ahead and reinstall MySQL:

$ sudo port install mysql5 +fast_mutexes

Q4M also requires access to the MySQL sources, so let’s get those unpacked:

$ cd /tmp
$ tar -xzf /opt/local/var/macports/distfiles/mysql5/mysql-5.1.57.tar.gz

Once that’s done, follow these steps to get Q4M compiled:

$ cd /opt/local/include
$ sudo ln -s mysql5/mysql 
$ ./configure --with-mysql=/tmp/mysql-5.1.57 \
$ CPATH=/opt/local/include/mysql \
   LIBRARY_PATH=/opt/local/lib/mysql5/mysql \
$ sudo mv /opt/local/lib/libqueue_engine.* \
# Final step, tell mysql to install the engine
$ mysql -uroot < support-files/install.sql

If after all that you’re still having problems, maybe you’ll have better luck with these Japanese instructions.

Stupid Windows Firewall

Posted by chetan on January 30, 2011

So it turns out that Windows Firewall, even in Windows 2008, still can’t accept a range of ports, either in the UI or via command line, most commonly when setting up PASV FTP transfers. The common workaround is to create one entry per port in your range like so:

C:> FOR /L %I IN (60000,1,60200) DO netsh firewall add portopening TCP %I "Passive FTP"%I

While this does work, it’s slightly annoying that you have to create 200 individual entries in your config. My slightly better workaround is to just stick every port into the text entry field using this simple ruby helper:

puts (60000..60200).to_a.join(",")

You can run this either in IRB or directly on the command line using the following command:

$ ruby -e 'puts (60000..60200).to_a.join(",")'

This is great if your workstation has ruby on it, but sucks otherwise. So use this javascript version right here instead!




Running mlocate on Mac OS X

Posted by chetan on June 25, 2010

After suffering through yet another morning of ‘find’ pegging my CPU and grinding my sad little laptop hard drive for a couple of hours, I finally decided to rectify the situation. Most Linux distributions these days ship mlocate by default, and so I decided to give it a go on OS X. Unfortunately, it doesn’t quite support OS X out of the box yet. I’ll spare you all the miserable details (it was an epic struggle getting this compiled), but I finally managed to get it working.

Here’s how:

# first we get the source and patch it
$ hg clone
$ cd mlocate
$ wget '' -O mlocate-mountlist-hg.2.diff
$ hg import mlocate-mountlist-hg.2.diff
# prep
$ cd ..
$ git clone git://
$ cd mlocate
$ ../gnulib/gnulib-tool --import
$ mv gnulib/lib/stat-time.h~ gnulib/lib/stat-time.h
$ cp ../gnulib/lib/canonicalize.h gnulib/lib/
$ autoreconf --install --force
# install
$ ./configure
$ make
$ sudo make install

Ok, now we have the binaries in place; we’re almost there! One last thing to do, and that’s create a new user account and group for mlocate. After running updatedb it will try to chown the locate db as the user ‘mlocate’, so we need to make sure this users exists. Unfortunately, there’s no adduser command in OS X and it’s a little bit of a pain, so I wrote this little script to take care of it for you. Grab it here.

Simply run it like so:

$ adduser 
username: mlocate
home dir [default=/var/empty]: 
group id (default=700):
user id (default=700):
real name (default=daemon): 
shell: (default=/usr/bin/false):

All done! Now let’s try updating the db –

$ sudo /usr/local/bin/updatedb

And that should be it. I still ran into a couple of problems with permissions so your best bet is to fix them every time you run updatedb (just stick it in cron):

$ chmod 664 /usr/local/var/mlocate/mlocate.db

Now wasn’t that easy?

PS. If you don’t have Mercurial (hg) or Git installed, get them here:

Updated (July 23, 2010): You may need newer versions of automake and autoconf as well. I had problems with 1.5 and 2.63 respectively but upgrading to 1.11 and 2.65 (with fink) worked fine.

Upgrading the Mac Pro: Adding a 2nd GPU

Posted by chetan on December 16, 2009

tl;dr- Yes, you can add a 2nd GPU; OS X will ignore it; Windows will use it. Make sure to disable the card in the 1st slot to use it for gaming.

Apple makes great hardware, there’s no doubt about it. However, occasionally they make decisions that not only boggle the mind but are completely infuriating. Like putting non-standard ports on a laptop and charging twenty bucks for the proper adapter cable!

A similar problem I ran into recently is the issue of the graphics card in the Mac Pro: only specially branded “Mac-compatible” GPUs will work in OS X. What’s the problem with that you ask? Availability and pricing.

Continue reading…