davidb dives in

various musings and babblings.

Migration to Octopress

| Comments

I’ll admit it. I’ve been ignoring this blog for a while. Recently, over lunch, my friends started talked about their moribund blogs and the basic security threat they implied. My friend Sean said that he’d migrated to octopress based on a blog post. Given that we had all been running various versions of wordpress, it seemed like a good idea to investigate some other, less risky solution. I had sort of kept up with wordpress upgrades, but didn’t make the leap to the 3.x series. I actually tried it recently, and discovered that my PHP version on the host wasn’t up to snuff.

So, I’ve decided to take the plunge as well. I haven’t yet decided to move my blog to github pages, but I have done some work to get octopress working on my existing host. This is the default octopress theme. I’m going to leave it like that for a while, because a) it works and looks fine, and b) I’m not entirely sure how to change it. As part of the migration, all of my posts were transcoded into Markdown (in some cases, back into Markdown, but the majority were straight html.) As such, some of the formatting is broken. I plan to fix them as time goes on.

Octopress has the advantage of just generating static HTML sites (which you then move to the host via rsync or git.) This makes me much happier from a security standpoint. On the other hand, I now have to have Octopress installed on any machine that I want to be able to post from.

Since comments were actually useful on my site (although I was very remiss in moderating them), I’ve moved them to disqus, as octopress can’t handle them in line.

Hosting Your Own Git Repositories

| Comments

Github is all the rage, but what if you don’t want to store your code up in the sky? No, you want to host it yourself. Or, more likely, you have to host it yourself, because you work for some giant corporation who doesn’t believe in letting their coders store their stuff in the unclean world.

So. What are your options?

Let’s back up a little. Why do you need to host git repositories at all? What sorts of things should a hosting solution give you? First of all, if you want to actually work with other people, and those other people use, um, different computers, it is quite convenient to have a central repository around to use as a conduit. Also, if you want to be able to push changes anywhere, a central hosted git repository is a not-very-confusing place to do so.

Generally hosting solutions range from just providing push and clone access to a bare git repository somewhere, to bundling repository browsers, bug trackers, wikis, graphs, ugh. The top end of the hosting solutions integrates everything you need to run a successful software project, the bottom end solutions do the bare minimum, letting other apps handle the metaphorical heavy lifting. Unless you are the only one going to use the hosted repositories, your hosting solution likely has to deal with account management (i.e., letting other folks get accounts, upload keys, etc.), and likely it will have to make trivial the task of adding new repositories to the service. Some other things that it is useful to know:

  • ssh is the gold standard for pushing changes. It can be done other ways, but why waste your time with anything else?
  • The git protocol and http (or https) are pretty common for pull protocols, although, you can use ssh too, of course. The nice thing about using http is that is almost always works (unless you don’t add the right post-commit hook). The git protocol is nice when it isn’t blocked by an annoying firewall.

And back to the main business at hand: your hosting options. This list is non-exhaustive, but it should get you headed in the right direction.

The high end:

  • github:fi. This is the commercially available version of github that you can install yourself. It costs money, so it makes it hard to install as part of a stealth project. Count on paying at least $8k-ish. However, it does everything that github.com does, and looks to be quite easy to install.

  • gitorious. (This project always makes me think of Duran Duran.) As an open source project, gitorious can be downloaded and installed on your own system. I haven’t tried this yet, but it looks like it has a fair number of dependencies, and no one has wrapped this thing up in a nice bow for you, so installation may be non-trivial.

  • girocco. This is basically gitweb on steroids. That is, it looks mostly like gitweb, but also provides mechanisms to allow users to set up repositories, handles “forks” of projects, and can “mirror” an external git repository (that is, use a pull model rather than a push model). It is a bit non-trivial to set up, but has fewer dependcies than gitorious. You will likely have the easiest time of it if you are installing onto Debian “Lenny” (so I gather from the documentation). If you aren’t prepare to edit some of the scripts.

The low end:

  • gitolite/gitosis. Both of these packages do roughly the same thing: manage user access. Project browsing, repository creation, etc. are not included. The basic technique with either tool is to create a single account (probably called ‘git’) on your host, then uses the package to add other user’s ssh keys to that account while still maintaining the idea that different users are committing to the repositories. Of the two packages, gitolite is still active and has more features, while gitosis hasn’t been updated in 3 years. gitolite is implemented in Perl, gitosis in Python.

Or, just give everyone an account on a machine and tell them the path to the bare git repositories. Or you could use a combination of straight ssh and gitosis/gitolite. With the “low end” solutions, you’d typically want to set up repository browsing (at least). Fortunately, git comes with a reasonable one, gitweb. However, there are others: cgit, Trac, and FishEye, to name a few.

Switching to Cocoa Emacs

| Comments

… from Carbon Emacs, That is. I pretty much assume that if you aren’t already a dedicated Emacs user you will just stick with TextMate Or TextWrangler, or whatever.

Anyway, did you even know that Cocoa Emacs existed? You may have heard Of Carbon Emacs or Aquamacs, but WTH is Cocoa Emacs? It turns out that with the final stable release of Emacs 23.1, it came with a Cocoa native build option. Thus, Cocoa Emacs is Now the standard, no-nonsense build of Emacs for OS X. So, how does Cocoa Emacs compare to Carbon Emacs? It acts and feels mostly the Same, although I think it looks a bit crisper and feels a bit faster (which is probably an illusion). It is smaller on disk (95 MB vs 157 MB), and, of course, it is based on a newer version of Emacs Itself. It is The Future!

There are two things that irritated me with Cocoa Emacs when I Switched:

  1. Meta is, by default, mapped to the option key. However, this is easily fixed.
  2. Carbon Emacs came with a built-in version of aspell. With Cocoa Emacs you need to get aspell separately. This is less easily fixed, but it isn’t too bad.

You can get a pre-built stable version of Cocoa Emacs from Here, or nightly builds from here.

Step 1: Switch the meta key back to the command key, where it is meant to be. This can either be done via Customize, or you can do it manually with elisp. Manually, add: (setq ns-command-modifier 'meta) to .Emacs. This same thing can be done simply via Customize:

  1. M-x customize,
  2. go to Environment->NS,
  3. and change the “Ns Command Modifier” option to “meta”.

You can map option to something else, keep it is “meta”, or unset it altogether (which is how it behaves in Carbon Emacs, and probably what You want).

Step 2: Getting aspell. If you never ask Emacs to spell check anything, you can ignore this. There are three Ways that I’ve thought of to get aspell:

  1. Copy it from Carbon Emacs. I haven’t actually tried this, but it should be possible to copy it from the Carbon Emacs bundle into the Cocoa Emacs bundle. You will probably need Contents/Mac OS/bin/aspell and aspell-import, and Contents/Resources/lib, and Contents/Resources/site-lisp/site-start.d/builtin-aspell.el. Good Luck.
  2. Install aspell via macports. If you already have macports, this is probably the way to go. To do it this way:
    • % sudo port install aspell
    • % sudo port install apsell-dict-en (or some other language dictionaries)
    • In Emacs: M-x customize-option, ispell-program-name, and set the value to /opt/local/bin/aspell.
  3. Get it by installing cocoaAspell. This is what I’ve done currently.

CocoaAspell both delivers a version of aspell (to /usr/local/bin) and also delivers a preference pane for getting it configured. Nifty, but I had to manually fix the aspell configuration to point it to the dictionaries, and you also need to modify the ispell-program-name variable (which can be done via Configure, as well). To fix the aspell configuration, I edited /usr/local/etc/aspell.conf, changing: dict-dir /usr/local/lib/aspell-0.60 to dict-dir /Library/Application\ Support/cocoAspell/aspell6-en-6.0-0 Or, I suppose, you could copy the dictionaries back to /usr/local/lib/aspell-0.6.0.

Installing DBD::Oracle on Mac OS X, Redux

| Comments

After upgrading to Snow Leopard, I had to redo the installation of DBD::Oracle. This time I used DBD::Oracle 1.23. The good news is that the majority of my previous instructions no longer appear to be necessary: a normal build of DBD::Oracle looks ugly, but completes.

However, I did discover that if you are running a 64-bit perl, which you probably are, you need to get the 64-bit Oracle instantclient release. If you build DBD::Oracle and then cannot load the module because of missing symbols (e.g., _OCIAttrGet), then what is happening is that you linked against 32-bit libraries which cannot load from the 64-bit perl instance.

Wordpress Upgrade (2.7)

| Comments

Posting about upgrading your incredibly common blogging software isn’t very interesting. But I’m going to take this opportunity to suggest that this time, if you are able, switch to using subversion for wordpress. Installing wordpress is pretty easy. Upgrading it is also easy, but you still have to move your plugins, themes, and wp-config.php around, or delete stuff that gets in the way. Using subversion makes all of that that go away. Yay!

Update: Sadly, since I have been such a blog slacker, I was able to upgrade to wordpress 2.7.1 while this post was still the top post. Using svn did, in fact, make this the easiest wordpress upgrade I’ve done.

Update 2: Even more sadly, I just upgraded to 2.8.1.

How to Install DBD::Oracle on Mac OS X

| Comments

Today, I figured out how to get DBD::Oracle to work on Mac OS X Leopard (intel). Since it isn’t (yet) entirely straightforward, I thought I’d describe the process here:

  1. Install instantclient. You will need the basic and sdk modules. I suggest also getting the sqlplus module while you are at it. I put this in /usr/local/instantclient_10_2.
  2. Modify your .bashrc (or whatever) to set ORACLE_HOME and DYLIB_LIBRARY_PATH to /usr/local/instanclient_10_2.
  3. Get DBD::Oracle from CPAN. (I got 1.22). Here is where it gets tricky: In Terminal:

    % perl Makefile.PL

    This generates Makefile.

  4. Edit Makefile, changing: NMEDIT=nmedit to NMEDIT=echo
  5. Edit dbimp.c, removing all code that references dump_env_to_trace(). I found a patch at macosxhints.com, but this is tied to a particular release of DBD::Oracle. I decided to use my mad programming skillz to logically do what was needed. Hopefully this will be fixed in some future version of DBD::Oracle.
  6. Again, in Terminal:

    % make && sudo make install

And that should do it.

I Has iPhone

| Comments

After a mere 2.5 hour wait in line, assisted by jet-lag, I have acquired the 3G iPhone. More later.

Python-rwhoisd

| Comments

Back in 2003, as an exercise to help me learn Python, I wrote python-rwhoisd. Why an RWhois server? I had been the main developer and sole maintainer of the C reference version since 1996, and I had been thinking about writing a replacement in a nicer language ever since. So I pretty familiar with the protocol and problem space, and it was complicated enough to be able to sink your teeth into it, yet not so hard that you couldn’t do it fairly quickly. Basically, a great learning project.

Back then, I wanted this project to be unquestionably mine. I was paranoid enough to believe that if I used any of my employer’s equipment, network access, or time that my employer might claim ownership. Why they would want to is anyone’s guess.

So I was very careful to only work on python-rwhoisd at home, on my own time, on my own equipment. The initial version took me two weeks of nights and weekends. Hm. That makes it sound like I was furiously coding into the wee hours. I was actually only spending a few hours each day on it.

Python was a joy to use. My day job was in Java (and Perl) and it felt extremely liberating to be able to write so much code with so little typing. My favorite part was discovering that as I learned more about Python, my code kept getting smaller without getting less readable. Amazing!

Even though I had basically just written python-rwhoisd to learn a new programming language, I was planning on releasing it. I didn’t think that many folks would want it. RWhois wasn’t (and still isn’t) a popular protocol. But some of my colleagues were evangelizing IRIS at the time, and urged me to not release. They thought that it would muddy the waters, so to speak. So I didn’t release it, and then I basically forgot about it.

Fast forward five years. Just two weeks ago I suddenly wanted to learn how to use Git. I played around with tutorial-like git repositories, but it wasn’t enough. I needed something real to work on. I was casting about for a project that I could use, and I ran across python-rwhoisd, mouldering in a local CVS repository.

I had things that I thought should be improved about python-rwhoisd before attempting to release it again. The main thing was to add IPv6 indexing support, which I had done for the C version several years before. While this wasn’t a perfect project for learning Git in all of its glory (for that, I would need collaborators to merge with), it was good enough. Several days later, I’d added the IPv6 indexing and search support, and it was time to release it.

While I don’t expect there to be any major outpouring of interest over python-rwhoisd, it still should be easier to run than the C version (at least, for small datasets), and it should be possible to get it working on Windows without too much effort.

Get it here.

Running UNBOUND at Home.

| Comments

I finally got around the setting up unbound as my home resolver. I should have done this months ago, when it was in beta or before, since I had access to it. I kick myself. I feel bad. Oh well, let’s get on with it. My initial impressions:

  1. It will be nice once there are distribution packages for unbound. I spent more time that I would like (which is zero) figuring out where to put the log file, pid file, etc. Of course, I was installing it on a machine running Fedora Core 5…
  2. I was forwarding a zone to a nameserver running on localhost:20053. There is a gotcha to doing this, as, by default unbound won’t send any queries to localhost. You have to add a ‘do-not-query-localhost: no’ config line to fix it. Maybe this is something unbound-checkconf could detect?
  3. unbound’s configuration defaults leave it locked down fairly tightly. I had it running, but on my other machines, it seemed so slow – turns out, my queries were timing out and I was hitting my ISP nameserver. Make sure you add your networks to the ‘access-control:’ config parameters.
  4. I turned up the logging to debug some of my issues. Looking at the log was uncanny.

Anyway, it didn’t take all that long to set up. Hopefully relatively soon I (or someone else) will write up how to configure unbound to run in a few different scenarios.

Wordpress Upgrade (2.5)

| Comments

I realized that I was running a now-ancient version of wordpress, so I upgraded. It was easy. Yay wordpress 2.5!