Browsing the blog archives for January, 2009

Compiling Django with Twitter support as a Mac OS X Universal Binary

How-Tos

Introduction

This post is a guide for building your own version of Apache’s mod_python as a Universal Binary in order to support a custom Django install containing the Twitter libraries. As you can probably gather, this information is likely only useful to advanced Mac users who are comfortable in Terminal with compiling and installing software from source. If you’re still interested, gird your loins, crack your knuckles, grab some Mountain Dew, and read on.

Mac OS X 10.5 “Leopard” is yet another step forward into the world of 64-bit. At the same time, Apple has to support both PowerPC and Intel architectures. This is no mean feat, and this is where “fat” or Universal binaries come in.  Apple also has an explanation of Universal binaries, although it’s heavy on PR. This is all well and good, but there is one problem: once you make this leap, all of your library dependencies must contain the architecture you’re running as. Much software is still built as 32-bit only; while it may be a “fat” binary, containing both Intel and PowerPC machine code, it only has the 32-bit versions thereof. For reference, the names of the various architecture flags:

  32-bit 64-bit
Intel i386 x86_64
PowerPC ppc7400 ppc64

Huzzah naming conventions! There’s a lot of history in those names. I’ve linked to the relevant Wikipedia articles if you’re curious; these flags will be coming up again later when configuring various builds. The main thing to note is that most build configurations default to i386 on Intel Macs (even though Core 2 and Xeon processors are natively 64-bit), probably because most software is developed for 32-bit versions of Windows and Linux. As you’ll see, we’ll be overriding that default in several places to get this whole mess working.

Unfortunately, Universality is a cancer, which in my case starts with the Apple-shipped version of the Apache web server in 10.5, a universal binary. Everything it touches needs to be Universal as well, so that Apache can run as a 64-bit process by default. I wanted to add Django support on my web server via mod_python, specifically to play with the Twitter API, which meant I also needed to build python-twitter and its dependencies, as well as a MySQL python module to allow Django to talk to my database. None of these are included in the default Leopard version of Python 2.5.1.

After getting all of this set up, and trying to start my test Django app, mod_python was giving me errors about architecture. As it turns out, the included version of Python is only a “fat” 32-bit binary, not a Universal binary… which means all of the new Python modules I just compiled to support Twitter and Django were only 32-bit, which in turn means that the included Universal version of Apache and mod_python couldn’t use them. Yay.

Below the cut you’ll find my complete instructions for compiling all of the relevant components and their dependencies. I also took the opportunity to update to the latest release version of Python 2.6 and MySQL 5.1, and as a side effect my database server is now running as a 64-bit process. Progress has been made here. Feel free to comment or contact me if you have questions.

Continue Reading »

No Comments

Chrome DNS Caching

Stupid Tricks

The Problem

Google Chrome has an interesting feature: it maintains its own DNS cache “to improve page load performance”. Whether or not this is a good feature is a debate I’m not terribly interested in, but I have found that it can cause problems if a web site’s DNS changes for whatever reason, so I’ve decided to disable it. It’s a pretty easy change.

I noticed the problem because Radio Paradise upgraded its web servers, in the process changing IP addresses. Chrome has been giving me weird errors on that site recently, and this change only compounded them because I was being oddly redirected. Bill Goldsmith (DJ of said internet radio station) pointed out that it was a problem with Chrome’s DNS caching, a feature I was until that point unaware of. I have been using Chrome since it was made available for public beta, but perhaps Bill’s point that it “may not be ready for prime time” has some truth in it. I do not know if this DNS cache is stored locally, or if Chrome asks Google for cached information.

The Solution

Extremely easy: turn the setting off, and restart Chrome.

  1. In the Tools menu, open Options and go to the Under the Hood tab
  2. Uncheck the option “Use DNS pre-fetching to improve page load performance”, as shown here:  

    Google Chrome Under The Hood Options Tab

    Google Chrome Under The Hood Options Tab

  3. Restart Chrome. Note that you have to close all Chrome tabs, even though they are separate processes, for this setting change to take effect.
2 Comments

Local Version Control With Git

How-Tos

Introduction

I’ve recently become obsessed with git for version control. I know that there are many git tutorials out there; this is probably redundant, but it focuses on only the simplest operations for my own reference. The git man pages themselves are extremely well written. This post is an adaptation of an article I wrote for our department wiki, targeted at some of my fellow researchers who have probably never heard of git. I removed all of the references to our internal projects.

Unfortunately, one of our major codebases at work is stored in a Microsoft Visual SourceSafe repository; it has been for years, and there’s enough momentum that we likely won’t move to a better version control system any time soon. If the motivation sounds odd, I mostly write research code, so we are regularly creating totally new code that may be used once or twice and then never again.

Visual SourceSafe has limited branching capabilities, so many users keep large subsets of the codebase checked out onto their development machine. When a major experimental change is feature-complete, dealing with merges in VSS is a pain that typically involves face-to-face negotiations of who checks in what when, or one person spending a day or two fixing conflicts in WinMerge or a similar tool. This article demonstrates how to use git, a modern distributed version control system used by the Linux kernel (among others), to manage smaller-scale changes to VSS code trees on Windows without having to risk checking in files that “break” functionality for other users.

The main point of using a local version control repository inside of a VSS checkout is three-fold:

  1. Commit more often
  2. Easy branching for experimental code (whether or not it pans out)
  3. More detailed history/self-documentation of recent changes

I’ve found that my development habits have gotten much better using git; in particular, I commit just about every successful compile-and-test, and I try to isolate commits by functionality as much as possible, so that it’s trivial to cherry pick experimental changes that should be kept or not.

Continue Reading »

6 Comments

FeedBurner

meta

I’ve set up FeedBurner for my blog, in part because I’m obsessed with statistics, and in part because I like that nice Google Reader autoprompt when it’s used on other blogs.

UltraNurdage FeedBurner Feed

UltraNurdage Comments FeedBurner Feed

If you’ve already subscribed via RSS, my bandwidth would appreciate you switching to the FeedBurner feeds, as would my stats obsession :o). If you’re reading through the automatic LiveJournal cross-posts, this doesn’t affect you, although if you ever stop using LJ as your feed reader, you’ll find the FeedBurner subscribe link at the top of my blog.

2 Comments

Vortex Cannon

How-Tos

Introduction

I generally do Big Brother on Saturday afternoons from about 2 to 6 at Patrick’s house near Central Square. Sometimes we go out for a museum (a trip to the Museum of Science is likely next week), or a movie, but this week I didn’t have any ideas. Patrick had previously showed me some YouTube videos of  water balls, and we’ve done “kitchen science” before, so I was looking into that this morning… but it looked like the listed materials would be hard to obtain, and a number of comments claimed that the video was fake. However, in the related videos, I stumbled across this page on vortex cannons, and decided that would make a fun quick activity. Unfortunately, because I’m an idiot, I didn’t take any pictures >.<.

Materials

Due to the supplies at hand, we had to use a slightly different procedure, but the visual effect was pretty impressive.

  • One (1) 1-liter plastic bottle, empty and dry
  • One (1) tea candle target
  • One (1) fog machine
  • Matches (or some other candle-lighting device)
  • A room with still air

Procedure

We found two techniques worked pretty well, but produced very different results. One, when combined with the fog machine, allowed us to really visualize what was happen, and gave me the opportunity to explain some of the science to Patrick; the other actually put the candle out.

We first tried it without the fog machine, but couldn’t get the candle to blow out; it turned out that our aim was a bit off. The chemical fog stuff (part of an old Halloween setup) allowed us to actually see and aim the smoke rings, and see the vortices forming.

Grabbing the bottle with both hands and squeezing in a quick pulse produces a large, slow-moving smoke ring, with a long-lasting vortex that you can watch stretch as the ring expands. If you squeeze too hard, you just get a turbulent puff; too soft and you get nothing. It takes some trial and error. While these were nifty to look at, they couldn’t put out the candle, even from only a few centimeters away.

I found tapping one side of the bottle with just two fingertips, very firmly, produced a small but fast burst that formed a very fast-moving smoke ring. You could barely tell it was a ring at that speed. They moved fairly straight (as opposed to the slower-moving rings that tended to drift a bit), but were a bit touchy to aim. Once you connected with the candle flame, it went right out, without any guttering as you would see when trying to blow it out manually. We were able to successfully put the candle out at about a meter.

 Conclusion

This was a very fun demonstration, and only took a few minutes to set up. It also requires no cleanup, and you can hypothetically sneak up on your little sister and blow smoke rings at her. Not that I would encourage that sort of sibling mischief…

One thing I needed was a concrete example of why this is important science, and not just a toy demonstration. It’s hard to explain fluid dynamics to a ten year old. Patrick enjoyed it as a project, though.

2 Comments

I Cast Resurrect Blog

meta

Who am I?

My name is Nicolas Ward, generally known as UltraNurd on the intertrons. I am a software engineer working in Natural Language Processing for BBN Technologies in Cambridge, MA. I am a part-time masters student in computer science in the Harvard University EECS department. I am the guildmaster of Mellonea in World of Warcraft. I am a huge geek.

What is this blog?

To be honest, I don’t really know yet. I have recently gotten interested in social media, mostly as a Twitter user. I used to blog on LiveJournal (you’ll note the complete archive of that is available here), but once I got into a work routine, I didn’t have much to post about, or rather never took the time to post. I am now trying to get back into regular long-form blogging, since basic life updates and short comments to the void are fulfilled by microblogging on Twitter.

I am naturally interested in all things computer-related, but I have a wide variety of interests. I like to think of myself as a maven (as per Malcolm Gladwell’s The Tipping Point). I expect my posts will fit into several potential categories:

  • Computer howtos
  • Book and video game reviews/discussions
  • Political and religious commentary
  • Software ideas (probably focused on NLP)
  • Current school projects
  • My experiences with social media
  • Responses to friends’ blog posts
  • LiveJournal archive

If any of that is interesting to you, I hope you’ll enjoy reading at least some of what I blather on about.

I license everything I write, as well as all of my pictures, using a Creative Commons Attribution 3.0-US (“CC-BY”) license. In general, that probably means you can quote or copy anything I post, as long as you say it’s from me, except where otherwise noted. For a number of reasons, including licensing issues, I won’t be blogging with any specifics about what I do at work. They own my brain when I’m on the clock.

What do I read?

You can check out my blogroll on the left, but I’ll highlight some of the blogs that aren’t written by famous people, and explain why I follow them.

  • An Bui – An is a friend of mine from college, and she is directly responsible for getting me on Twitter. She writes about social media marketing.
  • The Camel’s Knees – My sister Joanna is currently serving with the Peace Corps in Gao, Mali, West Africa. Her ability to post is intermittent, but she writes about development and nutrition issues, as well as describing elements of Sonrai culture.
  • Tweetworks Blog – Tweetworks is a Twitter threading tool developed by Boston local Mike Langford. He writes about the Tweetworks tool, as well as general Twitter issues.
  • Brett Nordquist – Brett is one of the first people I started following on Twitter randomly; he writes about tech issues, and raising his kids.
  • Ku Photos Blog – Emery was my college roommate for three years, and is an awesome photographer. Check out his work!
5 Comments