vcachefs – a compelling solution to a remote iTunes library
Per my idea in my previous post, I decided to write my own FUSE filesystem; following the tradition of obscure names that end in ‘fs’ for filesystems, I am calling it vcachefs. Here’s the git repository at Github. I mention more in the README, but the goal is to be able to add network files to iTunes and other media apps’ libraries without the poor performance and random lockups that usually happen when you try to do this directly.
I’m still at the proof-of-concept stage right now, but you can see my plan in the TODO file. As of today, you can create a mirror of ‘/etc’ in some other folder – not too exciting, but now that I’ve got the base stuff working, I can put the caching stuff on top of it.
After I get the app working correctly at the command-line, I may consider making it a full “Mac-like” application (with a pretty icon and everything!) – I think a lot of people want to do this kind of thing, because requiring all of your library to be on the local computer is asinine.
For those who aren’t familiar, FUSE is a kernel interface that lets you quickly write your own virtual filesystems with a minimum amount of work, and without writing kernel code. While this approach isn’t very fast, it’s super-easy to get working, and there’s almost no bookkeeping stuff necessary. This has led people to write very strange yet useful “filesystems”, such as FlickrFS or WikipediaFS (which show Flickr collections / Wikipedia articles in your filesystem).
It’s pretty nice to come back to some old-school C hacking, while cool languages like Ruby and C# have a lot of fancy features, there’s nothing like busting out a copy of Vim and going to town.
Moving git repositories to SVN/TFS
Git is great!
At my job, I’ve been working on a project for several months now. Since I needed a cheap, easy VCS, and I wanted to learn the next cool thing, I decided to use Git, to shuffle files between computers and keep a history of commits. It turns out, Git is really, really awesome – beats the pants off of the customized Perforce we use at work. The individual pieces of our project are starting to come together, so one of my coworkers started the arduous project of setting up Team Foundation Server. I was interested because its integration with VS (especially being able to see the changes annotated in the code in the gutter – very cool), as well as the “Trac-like” stuff that I’ve never bothered with in my personal projects.
The plan from 10,000 feet
Unfortunately, getting my Git history into TFS hasn’t been the easiest thing, but it can be done. If you’re not familiar with TFS as a VCS, it’s pretty similar to Perforce (surprise!), but without a solid command-line client. Fortunately, via Scott Hanselman’s Blog, I found SVNBridge. Basically, you give it a TFS server, and it’ll pretend to be a local SVN server. This program is under really heavy development (aka “isn’t finished yet”), so you’re gonna run into some problems; run it under VS 2005/2008 debugger to see what goes wrong, it’s usually some dumb TFS rule.
Since Git has a really great tool called git-svn which allows us to pull and push to Subversion repositories, we’ll use this hacky structure to push our Git repository to a new blank TFS repository. Note that this method works for a regular Subversion repository too, just use your SVN URL instead of SVNBridge’s fake URL. We do some trickiness later because git-svn dcommit doesn’t seem to work as advertised, so we have to specifically commit each revision using git-svn set-tree (not manually, but it’s still hacky).
The guts – copying an example repo from Git to Subversion
Start up SVNBridge (under the debugger!), and point it to your TFS repository. Make sure this repository is blank (or at least doesn’t have any of your project files in it), or else TFS will have a fit. However, if the repo is completely empty, git-svn will have a fit, so make sure to commit some blank file to the TFS/SVN repository first. git-svn needs this to base its merge on.
In this case, our Subversion “repository” is mapped using SVNBridge to http://localhost:8081, and our git repo is at http://git.example.com. Now here’s the commandline magic – make sure to run this in a Bash(or zsh/ksh/whatever) shell, not under cmd – git doesn’t like non-sh shells.
mkdir tmpwc && cd tmpwc
git-svn clone http://localhost:8081/SomeProject .
# Merge in our source Git repo
git pull http://git.example.com
# Grab all of the commits and write them to a file, from first to last
# If you want to, you can manually edit this file first
git log –pretty=oneline –reverse > commits
# Commit them all, one by one
cat commits | cut -d ‘ ‘ -f 1 | xargs -l1 git-svn set-tree
If you’re lucky, that worked. If not, keep hacking at it and you’ll eventually get it to do your bidding.
Ubuntu mounting /var/run in RAM causes MySQL death
Warning: apparently, Ubuntu decided to mount /var/run as a ramdisk, so if you run MySQL on it, eventually your transaction log (or something stored in /var/run/mysql) will grow so big that it will exhaust /var/run. The result of this is, your MySQL will seize up and die and your website will be unavailable.
However, now that I’ve rigged /var/run to be on disk, I don’t know what the result of holding around all these files will be either, so I may be hosed either way. Thoughts? Comments?
A powerful UI programming metaphor from Aaron Hillegass
Once upon a time (before Baywatch), there was a man with no name. Knight Industries decided that if this man were given guns and wheels and booster rockets, he would be the perfect crime-fighting tool. First they thought, “Let’s subclass him and override everything we need to add the guns and wheels and booster rockets.” The problem was that to subclass Michael Knight, you would need to know an awful lot about his guts so that you could wire them to guns and booster rockets. So instead, they created a helper object, the Knight Industries 2000 Super Car, or “Kitt”.
Notice how this is different from the RoboCop approach. RoboCop was a man subclassed and extended. The whole RoboCop project involved dozens of surgeons who extended the man’s brain into a fighting machine. This is the approach taken with many object-oriented frameworks.
While approaching the perimeter of an arms dealer compound, Michael Knight would speak to Kitt over his watch-radio. “Kitt”, he would say, “I need to get to the other side of that wall.” Kitt would then blast a big hole in the wall with a rocket. After destroying the wall, Kitt would return control to Michael, who would stroll through the rubble.
– from Cocoa Programming for Mac OS X, by Aaron Hillegass
Even if you don’t care about programming on the Mac, you should take a look because the developers at NeXT were really ahead of their time when they created the Cocoa framework. Objective C is like the “metal” version of Ruby, especially when you look at features in Obj-C like how their vtables are structured and their emphasis on introspection and mixins (called “categories” in Obj-C), and Cocoa takes full advantage of these features to make a really elegant, reusable UI framework.
pathedit 0.1 – Change your filesystem using your favorite editor
I read on one of the Planets about this idea, but I could never find the post so I reimplemented the idea in Ruby. The idea is, you can use a text editor to do mass file moves/renames/copies/etc. I wrote it to organize my downloaded TV shows, and it works pretty well and hasn’t eaten any of my data yet. Of course, the standard caveats apply.
The utility reads paths from either standard input or passed as parameters. Here’s the output from --help
If no files are given, the paths will be read from standard input
Specific options:
-a, –action type Action to perform (one of ‘copy’, ‘move’, ‘symlink’)
Common options:
-d, –debug Run in debug mode (Extra messages)
-v, –verbose Run verbosely
-h, –help Show this message
–version Show version
Caveats for this version
- Might give you problems on Windows unless you pass paths as parameters – soon to be fixed
- Can only use GUI editors in Linux, cause that’s the only operating system that handles GUI apps correctly – hopefully I can fix this too
Download it!
Every CS undergrad must read this by the day they leave
This presentation done by Wil Shipley given to the WWDC Student developers is fucking awesome. Read it, be inspired. Even if you don’t care about Apple at all, his advise applies to anyone who’s a developer (or really, even anyone who wants to start a business)

Even if you don’t make the zillion dollars, you’ll be rich in awesome.
Cross-platform UI with Qt4 and Ruby – Mac/Linux HOWTO
Today I’ve spent the day working on figuring out how to make UIs using Ruby and Qt4. If you haven’t heard of it, Qt4 is an awesome UI framework written in C++. Since C++ is way too much work, some great KDE devs wrote a bindings generator for Qt4 called qt4-qtruby. While this package is fairly “linuxy”, it’s pretty easy to build it on Mac OS X too, making it possible to write GUI programs for OS X without having to delve into RubyCocoa which has too much hackiness (in my opinion), or even worse, Objective C. Furthermore, your code that you write on OS X will look great on Windows and Linux too!
Starting from scratch
First, install Ruby. If you’re using Linux, you’ll probably use the package manager to install Ruby and the Ruby development libraries! (Ubuntu will run sudo apt-get install ruby irb ruby-dev) OS X Tiger ships with Ruby by default, but you’ll want to install an updated version, via the Ruby one-click installer, then disable the old Ruby by using the following command:
touch ~/.bashrc && echo ‘export PATH="/usr/local/bin:$PATH"’ >> ~/.bashrc
sudo mv /usr/lib/libruby.1.dylib /usr/lib/_libruby.1.dylib
Installing Qt4 and QtRuby
First, install Qt4 by using your package manager on Linux (in Ubuntu, use the -kdecopy packages, they are more up to date), or by downloading the DMG from the Qt/Mac Open Source Edition Download page. You’ll also need MacPorts (and by proxy, the XCode tools). Also, download the Qt4 Ruby bindings source code from Rubyforge and save it to the Desktop.
Here’s the cool thing about QtRuby, and the advantage of building it from source: the build framework for QtRuby scans through whatever version of Qt you have installed, and dynamically builds the bindings. This means, there’s no waiting for new Qt features to be available in Ruby, it’s always up-to-date! Which is quite handy, because it seems like every minor version of Qt has new cool stuff.
Next, we have to do a bit of hackery – unfortunately, there’s no easy way to install QtRuby but it’s not so hard. Here’s what you’ll run:
sudo port install cmake ## CMake is a cool build system
tar -xzvf qt4-qtruby-1.4.9.tgz && cd ./qt4-qtruby-1.4.9
cmake .
make && sudo make install
Try it out!
Once you’ve got it built, try this sample code to see some of the new features in Qt 4.3 – this code will run a natively-styled wizard in Windows, Mac, and Linux without any changes! Unfortunately, this code isn’t very elegant or Ruby-like, but it’s a base that someone could write a really elegant UI framework over like RoR.
a = Qt::Application.new(ARGV)
def create_intro_page
page = Qt::WizardPage.new do |p|
p.title = "Introduction"
end
label = Qt::Label.new("This is a wizard!")
label.word_wrap = true
layout = Qt::VBoxLayout.new do |v|
v.add_widget(label)
end
page.layout = layout
page
end
wiz = Qt::Wizard.new do |x|
x.add_page(create_intro_page())
x.set_window_title("Test Wizard")
x.show
end
a.exec
![]() On Mac OS X |
![]() On Linux |
In summary:
- Install a Ruby that doesn’t suck, and hack your environment so it works right
- Install Qt and MacPorts
- Build QtRuby and install it
- Make UIs for all 3 platforms without hating your life
Connection errors in Pidgin with GTalk?
In several places that I’ve tried (most notably at work), Pidgin would fail connecting to GTalk, probably because it goes through a proxy server. However, I found a fix online today via manast.com. Basically, go to the advanced tab and set:
- Force old (port 5223) SSL
- Allow plaintext auth unchecked
- Connect port: 443
- Connect server: talk.google.com
- Use global proxy
Sharing your home directory with a VMware Machine
For the last week or so, my experiences with Mac OS X have been mixed – I’ve tried to get it working the way I want it to, but for some things Ubuntu is just better. Unfortunately, Ubuntu on the Mac hardware is pretty messed up right now (and by “pretty messed up” I mean “get ready to compile and edit kernel drivers by hand” messed up). VMware Fusion to the rescue! With the VMware tools installed, it’s mostly usable. However, it’d be awesome if I could share my /home for both Mac OS X and Ubuntu. You could do this trick with any POSIX OS though, I’m gonna try to do it for Windows next.
Disclaimer!
I haven’t tested this that much – just enough to get it to work (I still haven’t restored my data, so I can’t really use it for anything). However, VMware’s Shared Folders feature doesn’t handle locking between host and guest. So if you open a file on both OS X and Ubuntu at the same time, expect fiery death
How to set it up
First, set up your home directory to be shared in VMware – I use the appropriate name “home” here. Then in the guest OS, run these commands (replace ‘paul’ with your username, hint):
sudo groupmod -u `ls -l /mnt/hgfs/home/paul | cut -d ‘ ‘ -f 4 | tail -n 1` paul
# If you use Macports, do this and your .bashrc won’t go crazy
ln -s /usr /opt/local
This is necessary because the number that Mac OS X picked for your username (the UID) is different than the one Ubuntu picked – we set the Ubuntu one to match the Mac. Now, reboot (or do this stuff logged in as root), then open up /etc/rc.local and add the following line:
Some hacks
Because of the locking issue, we have to do one more hack to make GNOME work – KDE users probably don’t need this hack. Open up /etc/gdm/Xsession and add the following section to the top, after the comments:
That’s everything – like I said, I’m gonna work on trying this same trick for C:\Users in Vista using mapped drives and seeing if I can get the same success. It might involve some hackery though.
Santa Rosa Macbook Pro hardware info
In the interest of getting this machine compatible with non-Mac OS’s, here’s some relevant information on the new Macbook Pros with the Santa Rosa chipset:
Output of:


