Category Archives: Posts - Page 2

Unhide ~/Library in OS X 10.7 Lion

Lion hides the user home directory by default. You can navigate to it with cmd-shift-G easily, but if you happen to want it to be visible all the time just run this command in a Terminal.app window.

chflags nohidden ~/Library

Thanks to Matt Pennig for the command.

How to install qcachegrind (kcachegrind) on Mac OSX Snow Leopard

Guest post by Mike! I had originally posted this as a gist on github, but Paul selflessly insisted that I blog about it, so here you go.

I like to use kcachegrind for doing profiling of my ruby code via ruby-prof. This works fantastically if you’re on a platform that has KDE installed. However, most of my development is done on OSX, and while you can install kcachegrind via macports, it takes hours and hours because it has to build KDE, as well. Much to my surprise, the fine folks who wrote kcachegrind also made a QT version, qcachegrind. I was able to build this on OSX in about 10 minutes without too much effort, only having to install QT and GraphViz. Yippie!

I should note that I’m running OSX 10.6.7, with Xcode 4. My default gcc/g++ version is 4.2. I’m sure it will build just fine on earlier versions of Xcode, but I haven’t tested it.

Step 1: Install QT

You could do this via “brew install qt” if you have homebrew, but this takes a long time, so I downloaded the binary distribution of version 4.7.3 for OSX 10.5/10.6 from this page. Installing is easy: open up the dmg, and install QT via the mpkg file contained within.

Step 2: Install Graphviz

Second, you should install Graphviz so that qcachegrind can generate pretty call graphs for you. Like before, you could install this via “brew install graphviz”, but this also takes a really long time and I’m super impatient, so I just downloaded the latest binary installer from this page.

The only component of Graphviz that qcachegrind uses, to the best of my knowledge, is the dot binary. By default, the Graphviz installer drops dot to /usr/local/bin/dot, which qcachgrind.app might not find since /usr/local/bin isn’t in PATH by default (at least, not on my system). In order
# to ensure that qcachegrind can find dot, I created a symlink from /usr/bin/dot to /usr/local/bin/dot:
sudo ln -s /usr/local/bin/dot /usr/bin/dot

Step 3: Building qcachegrind

This is actually simple. Check out the source code for kcachegrind and switch to the qcachegrind directory:

svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/kcachegrind kcachegrind
cd kcachegrind/qcachegrind

You build the application by running ‘qmake’, a QT utility that can generate a boring-old Makefile, if we ask it nicely enough. By default, qmake wanted to build an xcode project on my box. I pointed it at spec profile that generates a Makefile that will build using g++, and things seemed to work fine. You can see all the profiles available in this directory: /usr/local/Qt4.7/mkspecs. This command also managed to spit out a whole bunch of errors and warnings, yet everything seemed to build properly.

qmake -spec 'macx-g++'
make

Step 4: Enjoy!

You should now have a beautiful little “qcachegrind.app” sitting in your build directory. You can run this directly via “open qcachegrind.app”, or you can drop it in your /Applications directory for easy access.

Update (Aug 30, 2011):

  • I removed the step where I would apply a patch that added the ability to open any file name. The qcachegrind source has since been updated to include a functionally identical change.
  • There are several comments about installing Qt via brew, and trying to build qcachegrind using that, yet failing. John Rood, looking to enable other gluttons for punishment, suggested installing Qt like so will get you on your way
    brew install qt --with-qt3support

    (I haven’t tested this out, myself).

  • For those who have installed Qt via brew and are having problems: try uninstalling it if you’re not using it for anything else (‘brew uninstall qt’). You may or may not have to reinstall the binary version, afterward; I’m not sure.

Mongo Monitoring Via Mongo Live In Safari 5

We’ve recently started integrating MongoDB more extensively into our systems at work and found ourselves wanting some basic monitoring during dev to see what the DB was doing. A friend suggested Mongo Live, which fit the bill but was only compatible with Chrome. Since I switch frequently between Safari and Chrome I decided to port it.

Fortunately the extension for Chrome required only minimal changes to get it working in Safari. The most significant change is that the Safari extension uses a toolbar button to activate. The fork is available on Github and supports Chrome and Safari. Hopefully someone finds it helpful!

Revocation Article

I’ve posted an article about the current state of X.509 revocation on the internet over at the Spiderlabs blog. Check out Defective By Design? – Certificate Revocation Behavior In Modern Browsers!

Using dd in OS X

Doing device level copies with dd is a reasonably common Linux task, but not something OS X users typically do. However, if you find yourself needing to write an image file1 to a microSD card or some other media then here’s a simple guide to using it.

First, you’ll want to see the device labels.

diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *250.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            249.7 GB   disk0s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *2.0 GB     disk2
   1:                 DOS_FAT_32 THUMB_DRIVE             2.0 GB     disk2s1

The output from above shows that we have a mounted 2GB USB flash drive named “THUMB_DRIVE” that has been given the identifier /dev/disk2. To write to it we need to unmount it, but ejecting it in the normal Mac way won’t work here.

diskutil unmountDisk /dev/disk2

There we go! Now we just need to write our image file.

dd if=inputfile.img of=/dev/disk2

The shell will appear to hang, but you can check disk activity to see that it’s writing. Once the command returns you’re done!

  1. Frequently these guides will talk about using Win32DiskImager on Windows

r509, Ruby CA

I’ve put a new project up on Github. r509 is a CA written in Ruby which aims to do friendly wrapping around Ruby’s baroque OpenSSL bindings. It’s still in the early stages, but check it out if you’re interested and fork if you want to help it improve!