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.

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

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.

Continue reading Command-line snippets for processing scans

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.

Continue reading Scheme in Javascript

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 include('../header.inc'); ?>
... page contents ...
<?php include('../footer.inc'); ?>

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:

Continue reading Convert PHP to static pages with GNU Make

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.

“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

Petite Chez Scheme for Ubuntu

An Ubuntu package of Petite Chez Scheme seems to be a common request among students, given the popularity of Ubuntu among the techno-capable. ¬†Currently, only RPM packages are provided on the Chez Scheme site, and the traditional recommendation was to use alien to convert the RPM into a .deb. There’s no reason to have everybody do this though.

I’ve built a .deb package of Petite Chez Scheme for amd64 (64-bit) Ubuntu 10.10. You should be able to install it by simply double-clicking the package and following the on-screen prompts. Petite can then be run using the terminal command `petite`.

Known issues: No package docs.

Reading a USB Stamps.com scale

Update: I now have an improved C version of this program: usbscale.

I got suckered into one of those hard-to-cancel Stamps.com trials. The upside is that they give you a $10 USB 5 lb. scale to use with their software. The downside is that they want you to only use it with their software, and the company that makes the scale has since taken down their free USB-scale program.

The good news, as Nicholas Piasecki and some Linux users figured out, is that the USB scale conforms to the USB HID specifications, which helpfully standardize how USB scales should work (no joke).

So, this little Perl hack reads from the Stamps.com scale by accessing the hidraw# interface that Linux provides. In my case, I have hidraw4 hard-coded into the script itself. Basically, it loops until it reads a good value from the scale, at which point it prints out the weight and exits.

Edit: This code is now a Gist on GitHub.

Continue reading Reading a USB Stamps.com scale

GParted stuck on "Scanning all devices"

Ubuntu’s partition editor, GParted, usually scans all the hard drives when it starts. However, in some cases, it will get stuck on this “Scanning all devices” step indefinitely. By knowing what hard drive you want to edit, you can launch GParted specifically for that hard drive. Either go into run or a terminal, and run “gparted /dev/sda”, where “sda”, “sdb”, “sdc”, etc., is the identifier of your hard drive, and GParted will launch and immediately open that particular disk.