Home / Blog Menu ↓

Blog: #coding

91 posts / tag feed / about the blog / archive / tags

Installing PIL on Lion

Getting PIL working on Lion was a little more difficult than I thought it’d be. (I use PIL in Ink to resize images.) It appeared to install correctly, but when I tried to post something with an image, I got this:

ImportError: The _imaging C module is not installed

I followed the instructions at appelfreelance.com, but libjpeg wouldn’t compile, giving me this error:

checking build system type... mkdir: /private/tmp/PKInstallSandbox.vMj5ds/tmp: No such file or directory
mkdir: /private/tmp/PKInstallSandbox.vMj5ds/tmp: No such file or directory
config.guess: cannot create a temporary directory in /private/tmp/PKInstallSandbox.vMj5ds/tmp
configure: error: cannot guess build type; you must specify one

Turns out TotalTerminal had oddly set $TMPDIR to /private/tmp/PKInstallSandbox.vMj5ds/tmp, which obviously broke other things. I cleared it out (export TMPDIR=) and got libjpeg to compile.

But PIL still gave me this error when I tried to import _imaging in Python to test it:

ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
  Expected in: flat namespace

Oh joy. When I ran otool -L /Library/Python/2.7/site-packages/PIL/_imaging.so, libjpeg didn’t show up in the list, either. I recompiled and reinstalled libjpeg and PIL a few more times. No luck.

The final solution: I installed libjpeg via Homebrew (brew install libjpeg), then compiled and installed PIL (Imaging 1.1.7). That fixed the _imaging.so problem and PIL now works like a charm.


Reply via email

Vim search and replace on funky characters

Occasionally I run across weird characters in Vim that show up as numbers in angle brackets — <95> or <97>, for example. They’re just curly quotes and em-dashes and such, but they’re encoded oddly, and there’s no way easy to do a search and replace on them.

Except that there is.

  1. Yank the character. (That’s Vim talk for copying to the clipboard.)
  2. Start typing your search-and-replace command — :%s/
  3. Hit Ctrl-R followed by " (double quotes) to paste the character.
  4. Finish out the rest of the search-and-replace and hit Enter — :%s/<97>/--/g

Voila. (There might be a way to fix these characters with iconv or some other encoding app, but I haven’t been able to get it to work other than this way.)


Reply via email

Crosswrite (the real thing)

Remember Crosswrite, that proof-of-concept I did for web-based audio transcription? Well, I’ve fleshed it out a bit.

You can now upload files (either through the buttons on the left or via FTP) and it automatically saves your transcripts to text files (no database required) every second.

I don’t have a live demo of the app (since I don’t really want people uploading their MP3s to my server), but the code is on Github as usual. If you run into problems with it or have feature requests, either add an issue on Github or email me.


Reply via email

Erasure

When I was a kid, my mom used to have us memorize poems. She’d write the poem out on a whiteboard and we’d recite it a few times, then she’d start erasing a few words, have us recite it again, erase a few more, and so on. And it worked.

Turns out it’s super easy to do the same kind of thing in a web app. Here’s Erasure:

If you click on an erased word, it’ll briefly become visible again. (But of course you only want to do that if you’re really stuck.)

As usual, the code is on Github.


Reply via email

Old DOS games

I’ve been thinking about some of the old DOS games I used to play as a kid, as part of a goal this year to collect family stories — more on that in an upcoming post. In trying to find one of the games I remembered playing, I discovered that people have posted gameplay videos to YouTube for most if not all of these. Enter a bucketload of nostalgia.

My childhood was spent playing games like Command Keen:

And Joust:

And SkyRoads:

Here, then, are most of the DOS games I remember with fondness (or at least remember playing more than once), with links to videos:

Going through these is making me feel ten years old all over again. Ah, childhood. (You can play pretty much all of these through DOSBox, by the way. Most are still shareware, and a lot have been released as freeware.)


Reply via email

More on Unbindery

For the first year doing the Mormon Texts Project, our process went like this: Volunteers would tell me they were ready for a batch. I would send them a range of five page numbers (145-149, for example) and a text file containing the unproofed text for those pages. (I would also track this in a Google spreadsheet.) The volunteer would then go to the book in Google Books, open the text file in a text editor, and proof the text. After they finished, they would email the text file back to me and I would assign them a new batch. Rinse and repeat.

Too much overhead. So I started working on Unbindery, a web app to automate almost all of this. This is what it looked like a couple weeks ago (a functional but completely unpolished bare-bones app):

I was kind of disappointed about the project — it was moving incredibly slowly, I didn’t really care about it anymore, etc. — and I had made up my mind to let it quietly fall by the wayside.

Then I was at the temple two weeks ago and got a clear impression that I wasn’t going to get off the hook that easily, and that I needed to keep going with MTP and finish Unbindery. With that impression came some inspiration on how to polish the app, and I’ve been working on it since then. Here’s what it looks like now:

For the past week we’ve been using it for MTP work, and since then our productivity has totally skyrocketed. Here are my educated guesses on why:

  1. Smaller chunks. Volunteers proof one page at a time instead of five. It’s easier and, because it’s easier, volunteers proof more than before.

  2. Progress bars. Since volunteers can see their progress visually, there’s more of a drive to keep proofing so they can make the black bar go all the way to the end.

  3. Scoreboard and leaderboard. Volunteers get points every time they finish proofing a page. With the leaderboard, there’s competition, and already I’ve seen an increase in productivity because of this (at least subconsciously).

  4. Convenience. Since Unbindery is a web app, volunteers can proof pages anywhere, instead of having to download/upload text files and all that.

There’s also a new feature I added today, where volunteers can see how much of a given project they proofed:

This way there’s more of a sense of ownership to the work. We’ll see how it goes.

Like I said a few days ago, we went from taking eight months per book to a few days per book. My volunteers have proofed 373 pages in the last week, and I’m now scrambling to get enough books into Unbindery so we don’t run out. That’s a very different problem from the stagnation I had a month or two ago. (Yes, it’s a good problem to have.)


Reply via email

Botswana

As previewed a little while ago, I’d like to introduce Botswana:

A couple weeks ago at work I was talking with two of my coworkers and Core War came up somehow. I got excited about the idea of writing AI bots to compete with each other. Conferring with my friend Chad, we decided to make it web-based and use Javascript as the scripting language for both the bots and the game engine. A couple days later, we had a working engine, and we’ve been fine-tuning it since then.

Each turn, the engine sends the current state of the world to each bot. The bot can then give the engine its command — to move forward, move backward, turn left, turn right, or fire. Last bot standing wins. We’ve gone with an intentionally simple rule system for now, but we’ve got some fun plans for future improvements.

The code’s open source and is on Github.


Reply via email

Botswana sneak preview

Here’s a quick sneak preview of my current project:


Reply via email

In-progress: Unbindery

I’ve been spending more time on the Mormon Texts Project (we’re almost done with The Life of Heber C. Kimball, by the way), and I’ve realized that having a nice integrated system for assigning and editing pages would make things much easier. Enter Unbindery:

My friend Rikker and I started Unbindery a few years ago, but it petered out before it got off the ground, and there it languished until a month or two ago. Since then, I’ve gotten the core up and running and it’s now usable enough to start doing actual MTP work with it. (Taking OCRed text and cleaning it up, that is.) I still have a lot of polish left to do, though.

It’s written in PHP and Javascript and I’ll be releasing it on GitHub in the near future, once I clean up the source a bit.


Reply via email

Crosswrite

I’ve spent some time transcribing audio in the past (both Mormon Artist interviews and family history recordings) and it’s nice having keyboard shortcuts to control audio playback. There are some nice desktop apps that do this for you, but last night I realized that with the HTML5 audio element and some Javascript magic, it’d be super easy to code up a web app to do it instead. And it was. It’s called Crosswrite, and you can try it out on the demo page.

Notes

It works pretty well in Chrome and Safari, but it doesn’t work in Firefox. This is just a demo, not a full-blown app. All things considered, however, it only took ten or fifteen minutes to write, and the hardest part by far was deciding what keyboard shortcuts should do what. (I’m still not entirely happy with my choices.)


Reply via email