Technology

Nena vs Eminem

Is it possible to take the instrumentals from one track, the vocals from another, and come up with something that you'd actually want to listen to? Turns out yes:

Amazing what computers can do these days. (via Holger Levsen)

Original 1, Original 2.

Introducing UIH: Math + Unicode, Happy Together

As a math person, you're often faced with the task of communicating about math. Unfortunately, most modern means of communication, be it email, the web or instant messages, aren't really suited to typing math. Fortunately, however, many of these means do allow the use of Unicode, and Unicode allows for certain limited forms of mathematical typography.

Putting Unicode formulas together usually requires a fair amount of patience and some quality time with your favorite character map application. But now there's an easier way: The Unicode Input Helper--or "UIH". Here's an image of it in action:

uih-screenshot.png
uih-screenshot.png

Using it, you may use HTML entity names with backslashes (such as \int for an integral) to put together the basics of a formula, and then use a searchable list of all known Unicode characters to add the finishing touches. The screenshot gives you an idea. Once you've finished your masterpiece, simply use your computer's copy-and-paste function to get it to where it needs to be.

Download the most recent version of UIH

(Like PuDB, uih requires Ian Ward's urwid library.)

As a side benefit, I think uih makes for a nice replacement for pretty much every character map program--but its original purpose was easy typing of math.

Debug Python in Style

I'm happy to introduce PuDB, a full-screen, console-based visual debugger for Python that I recently cooked up.

Download it here

Or install it simply by typing

easy_install pudb

into your Unix shell. Here's a screenshot of it in action:

PuDB screenshot

Python has had decent debugging support for a while now, in the form of

  • Pdb, the command-line debugger that comes with the interpreter
  • Winpdb, a very nice GUI debugger
  • IDEs such as Eric

But I felt that there was a gap between these offerings--Pdb being very austere, and Winpdb and the IDEs being rather heavyweight. I wanted a comfortable debugger that's easily usable in a shell and doesn't require me to touch my mouse. PuDB uses Ian Ward's excellent Urwid library for its interaction with the console.

Update: Looks like PuDB is slowly growing a community. There's now a mailing list to host discussions.

What they don't tell you about VTK XML binary formats

You might have been trying to implement the new-style VTK XML file formats. And you might have realized that what they tell you in the file format "specification" is just incomplete. Well, here are a few bits of information missing from there:

Binary Blob Header: In front of every binary blob, base64 or raw-binary, appended or not, there is an UInt32 length indicator. If you do not have this length indicator, you might get error messages like

Cannot read cell offsets from XXXX in piece 0 because the "offsets" array is not long enough.

Note that if you are encoding in base64, that length header must be encoded separately, so that the end result looks like XXXXXX==XXXX... (note the two equals signs indicating the early end of the length header block).

Compression Header: If you use compression, the following header applies instead:

struct {
  uint32 blocks; 
  uint32 blocksize; 
  uint32 last_blocksize; 
  uint32 compressed_blocksizes[];
};

Again, this header is encoded separately from the data. This was figured out by Thomas Svedberg. Thomas adds that the following works for him:

struct {
  uint32 blocks = 1
  uint32 blocksize = total data size
  uint32 last_blocksize = total data size
  uint32 compressed_blocksizes[] = compressed data size
};

Offset Field Meaning for base64: The "offset" field on DataArrays with format="appended" is not a binary offset, it is the base64 character count from the underscore that starts the AppendedData section.

Vector Element Order: If you are encoding vectors (i.e. anything with NumberOfComponents="3"), and suppose your vectors are X,Y,Z,..., then the encoded data stream has the ordering X[0], X[1], X[2], Y[0], Y[1], Y[2], Z[0]...

Singing the praises of <link rel="next">

Here's a chicken-and-egg problem for you. And you can be part of the egg. I'll show you how in a minute.

I bet you've noticed that bajillions of websites have little links that say "next" and "previous", right? Like previous page, previous item, previous whatever. And sometimes there's "up", too. As in "up" to the parent directory, "up" to the category containing this item, and so on. And every time you come upon a web page like that, you ask yourself, "so where is the link that takes me to the 'next' page?" Wouldn't it be nice if that button was always in the same spot, preferably on your browser user interface?

You might be surprised to learn that a solution to this already exists. The HTML standard specifies the <link rel="next"> and <link rel="prev"> header tags. But how can you make them show up in your browser? Easy: Use the Link Widgets Firefox extension. By installing and using that, you've become part of the egg. Now the chicken is that more sites need to start using the <link rel="..."> tags. There are already enough of them to make the extension worthwhile, for example Google, or any Drupal site (such as this one :) ), or anything generated by latex2html, which includes surprisingly large swaths of web documentation. But the more people have the UI to use these links, the more sites will include the markup, making the whole thing more and more useful over time.

And making the web more useful is not a bad thing, is it? ;)

Trust

Watch this:

You won't regret it. :) (PS: Yes, I know it was made by a bunch of Germans, and yes, they misspelled "belief", but that doesn't kill it, in my opinion.)

Embarassing Update: I figured out how to embed youtube videos. :)

Comcast, DHCP and MTU

If you are a Comcast customer (particularly in Illinois) and your Voice-over-IP (or other large-UDP-packet-using) application does not work as it should, don't worry, it's their fault. :P

For some reason, they include

...
OPTION:  26 (  2) Interface MTU             576
...

in the replies from their DHCP servers, which leads your computer to throw away large UDP packets (such as SIP INVITE replies). I don't know why they'd do this since a) it breaks their customers' applications (on purpose?!) and b) it puts more load on their network.

In any case, here's the antidote: In dhclient.conf, say

# F!$#$ stupid comcast.
supersede interface-mtu 1500;

After that, everything should be working fine. If you're violating their terms of service in doing so, it's your own fault. I didn't tell you. 8)

It only cost me like two hours of my life to find and fix this. Quote from the reply from the customer service rep:

I'm sorry, but we do not have any information as to why the MTU is configured for the level that it is. That decision is likely made by the Network Department and something we would not be able to obtain or discuss.

I love you, too.

Rattle back, Rattleback!

As part of the course requirements for the mechanics class I took, a team of which I was a part designed a Rattleback. A rattleback is a top that appears to have a preferred direction of rotation, i.e. if you start spinning it the wrong way, it (unintuitively) will turn around and spin "the right way". There's quite a bunch more to know about the physics [1] of it, if you care. It might also be an interesting dynamical system to study, as little is known about it past what can be found by numerical simulations. Speaking of numerical simulations, if you are a student of EN137 after me and would like to take a peek at our simulation code (which was written in Octave, with a bit of PyLinear sprinkled in), be my guest.

In any case, you may view the NOT FOUND: rattleback.avi=video of our rattleback to see for yourself!

PS: I blatantly stole the title of this entry from one of the other teams. :)

[1] A. Garcia, M. Hubbard Spin Reversal of the Rattleback: Theory and Experiment Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences, Vol. 418, No. 1854 (Jul. 8, 1988) , pp. 165-197

Rain Damage, Rain Damage, Go Away

As I previously reported, my old laptop, aramis, got rained on and sustained water damage resulting in--lo and behold--not a dead computer. In fact, most of it was fine, it even booted into X, and all of its components were usable, it would just always crash after around 15 minutes. That led me to believe that maybe, by switching out the mainboard, I might obtain a usable machine again.

Putting that plan into practice, I downloaded IBM's maintenance manual for the laptop, which, for the record, was an IBM Thinkpad A-Series A21m, and looked up the "FRU" (Factory Replacible Unit) number of the mainboard, which, in my case, was supposed to be 08K3264. These boards were hardly to be found on ebay and were hideously expensive, whereas a good bunch of cheaper boards labeled with FRU 12P3156, which suppposedly are compatible with ThinkPad A20 and A21 models, were readily available. I was unsure, but decided to take the risk--given that the 12P3156 board cost only $44.

After two nights of rather nerve-wrecking work on the laptop, I can announce that it is functioning again. :D The difference between the two boards types seems to be only that the one I had (which turned out to be FRU 12P3288) had a header for TV-Out, whereas the new one didn't. Big deal. I can use my 800 MHz CPU on it, and as far as I can tell, it is being run at full speed.

It turns out that my old board had some visible corrosion damage that probably caused the trouble I described above. If I had taken my laptop apart right after the water came in, it might have dried and thus been rescued right away. May this be a lesson to whoever has to do this next. :)

Summary: When buying laptops, buy IBM! Why?

  • Sturdily built
  • Maintenance information available
  • Existence of a sizable components aftermarket.

That said, I'm not sure Lenovo is going to do as well, but I hope so.

Taking notes like Germans do

Since the semester at Brown starts back tomorrow, I was a little concerned about my total lack of writing material. I still have my non-standard ruled paper from last year, but since a) it's not a standard size, not even US-Letter, much less A4 and b) I don't like ruled paper, I figured, hey, I'm going to take notes in style like I used to.

Tadaa: Good old German NOT FOUND: 1=graph paper, letter size, 5mm squares on it.

Courtesy of Incompetech. :)