Convert video with subtitles to MP4 for iPhone/iPad (preliminary notes)

By now, we know of a few requirements for viewing video on iOS (iPhone/iPad et al.). The video codec should be H.264 or another “standard” MPEG codec, and the audio should be AAC. AC3, as far as I know, is not supported. That’s all fine and dandy, but subtitles have been one of the trickiest things to get working on iOS.

(more…)

Command-line snippets for processing scans

I originally wrote this in 2009 as a cheatsheet for processing black and white scanned sheet music. It’s a collection of tips for converting and processing scanned images to ultimately get a nice, high-quality PDF that you could archive.

The programs convert and mogrify are part of the ImageMagick suite and the program pdfimages is part of the Xpdf suite.

(more…)

I just installed Ubuntu 10.04

I just installed Ubuntu 10.04 minimal on a server and it’s great.

$ less
-bash: less: command not found
$ man bash
-bash: man: command not found
$ tree ./
-bash: tree: command not found
$ whois google.com
-bash: whois: command not found
$ curl --help
-bash: curl: command not found

Scheme in Javascript

Scheme’s power to simplicity ratio makes it a fun target for implementation. Today, I introduce a couple new ways of running Scheme powered by Javascript.

The first is an online Scheme interface that I’ve been working on sporadically for the last few months. Inspired by TryHaskell, it began as a series of patches to jquery-console, a jQuery terminal-ish plug-in. While my own Scheme-in-Javascript interpreter FoxScheme hasn’t yet reached a very featureful stage yet (macros are the next step), somebody else had created a similar system before me. It was a simple matter to replace FoxScheme with a different back-end system, in this case, Jason Orendorff’s Try Scheme.

(more…)

Convert PHP to static pages with GNU Make

I recently moved an old website to a new server. For performance reasons, the new server is running nginx instead of Apache, and didn’t have nginx set up to use PHP. (The optimal way, apparently, is to use PHP-FGM, which currently requires you to patch and build PHP yourself, at least until PHP 5.4).

That was fine, though, because this old site only really needed PHP for one little thing that we could do without. In fact, the primary reason for using PHP here was to essentially append the header and footer sections to each unique page. Basically, we had stuff like:

[php]
<?php include(‘../header.inc’); ?>
… page contents …
<?php include(‘../footer.inc’); ?>
[/php]

on every page. What I needed was an automated process to convert all of these PHP pages into static pages. GNU Make, of course, is the de facto standard for automating something like this. Let’s give it a go:

(more…)

Android emulator temp directories

If you are using the Android SDK on a shared computer, you might run into the awesome “NAND: could not create temp file for system NAND” error. This is because “/tmp/android” is hardcoded into the emulator as the directory to start temporary files during emulation, and somebody else has likely claimed it first.

The easiest workaround is, if it won’t cause any problems, to delete or chown the /tmp/android directory, preventing anybody else from using it. If you must share, then you can set up the group so that multiple devs can access it.

But the best way, if you’re not the sysadmin, is to change the temp directory for yourself. You can modify the emulator and change the hardcoded values.

Run “vim -b tools/emulator” and search for “tmp/android” (which would be “/tmp\/android” in vim-speak). Overwrite the name android to something that doesn’t already exist, like “/tmp/anderic”, being careful not to change the length of the file.

Restart your emulator.

Our friend Scope

Scope is one of those things that is absolutely essential to understand as a programmer. If you don’t understand how a language handles scope, you are doomed to continue making difficult-to-understand mistakes and poor code design.

Scheme is a good platform for exploring how scope works for beginners, and the language features that it has distilled to the minimum form the basis of 99% of the cases you encounter from day to day.

Let’s look at one pattern that you’ll find in every jQuery plugin:

(more…)

“usbscale”: read USB scales

I’ve just finished writing the big parts of usbscale, a command-line program written in C that reads and interprets data from USB scales. It was meant as a little hack for the Stamps.com scale, so currently it’s only set up to recognize the Stamps.com 10-lb scale (manufactured by Elane). It should be trivial to add support for more scales, though.

If you have a USB scale, please let me know!

You can find the software at usbscale on Github: https://github.com/erjiang/usbscale

Chicken-NBT: A Minecraft NBT reader for Chicken Scheme

I didn’t see any Scheme code to read Minecraft NBT data files, so I made one. And in doing so, I see why there weren’t any NBT readers in Scheme. (Haskell programmers can use Adam Foltzer’s much cleaner Haskell version.)

When I found out that there was a gzip egg called z3, I thought my troubles were over. Not quite, because although z3 made it ridiculously easy to read compressed data, the only real procedure I had to read data from the gzip stream was read-byte. And not only did I have to read only one byte at a time, but they were all promoted to ints anyways, since there is no notion of different-width integers in Chicken (only fixnums).

(more…)

Blast from the past: The “cloud” five years ago

I was cleaning out some miscellaneous files from my computer today when I found a folder called “eyeos”. EyeOS. My friend and I thought we were uber-cool when we set up eyeOS on our shared hosting accounts and looking back, yeah, well, we were.

A screenshot of the eyeOS.org website from November, 2005.

eyeOS.org, ca. November, 2005. Very Web 1.9.

EyeOS was an ambitious open-source project to give you a desktop in your browser. You could have files, record appointments, and write documents from anywhere, as long as you had an Internet-connected computer. Nothing was stored on your local hard drive, it was all up on the … Internet.

This was November, 2005. This was back when clouds meant fewer UV rays.

(more…)