3e8.org

In EBCDIC we trust.

July 24, 2009

Lilliput

Until recently I used rsync+hfsmode to back up my Mac to a Linux box. I stopped only because I needed the features of rsync 3, but that lost me the ability to back up extended attributes in AppleDouble format, which can reside on a plain, non-HFS+ filesystem. Anyway, it turns out rsync+hfsmode had been creating corrupt AppleDouble files for three years—ever since I moved from PPC to Intel. So much for testing your backups.

Briefly, it's an endian issue. Use htonl(), guys! So, I wrote a simple script, adouble-fix.pl to detect and repair broken AppleDouble files created by rsync+hfsmode. It's limited to files which contain only Finder Info and resource forks, but this is exactly what the --hfs-mode=appledouble option produces.

$ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -n -q
Dry-run finished.  1878 files seen, 1852 fixed, 26 skipped, 0 errors.
Dry-run finished.  1895 files seen, 1641 fixed, 254 skipped, 0 errors.
Dry-run finished.  1511 files seen, 1301 fixed, 210 skipped, 0 errors.
real 0m23.586s  user 0m1.460s  sys 0m1.450s

$ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -q
Finished.  1878 files seen, 1852 fixed, 26 skipped, 0 errors.
Finished.  1895 files seen, 1641 fixed, 254 skipped, 0 errors.
Finished.  1511 files seen, 1301 fixed, 210 skipped, 0 errors.
real 0m3.555s  user 0m2.240s  sys 0m0.980s

$ time find 4 -name "._*" -type f -print0 | xargs -0 adouble-fix.pl -q
Finished.  1878 files seen, 0 fixed, 1878 skipped, 0 errors.
Finished.  1895 files seen, 0 fixed, 1895 skipped, 0 errors.
Finished.  1511 files seen, 0 fixed, 1511 skipped, 0 errors.
real 0m1.069s  user 0m0.820s  sys 0m0.400s

July 17, 2009

Zeos, RIP

Computers are fast these days—real fast. One might venture to say too fast, two times fast. Back in my day, you could `type a:autoexec.bat`, drink a sip of coffee, change your mind and Ctrl-C it before you cluttered up your screen with unwanted output. I got nostalgic for those halcyon days of clean screens, and that's why I bought the 640GB Western Digital Caviar Green.

The WD6400AACS is an adequate performer, and runs nice and cool; exactly what I want in a RAID 1. But it was this stellar feature which really caught my eye: after 8 seconds of inactivity, the drive parks its heads. The first subsequent access incurs a half-second pause, which I like to call my "me time".

Eight. Unconfigurable. Seconds. Configuration? No thank you! You'd lose the primary nostalgic benefit: frequent, jarring pauses during interactive use, which is why I bought the thing in the first place!

Let's have a look at an example session with the Caviar Green.

$ ls /usr/share/doc       # what the heck was I looking for?
  [dramatic half-second pause before results appear]
  [you peruse the directory list for 10 seconds; clunk, heads park]
$ cd mutt-1.5; ls         # found it!
  [dramatic half-second pause; exeunt results]
  [you get distracted by an errant cat for a moment; parks heads, clunk]
$ cat README.Debian       # there's my bedtime story
  [dramatic-half-second pause music]
  [you skim the readme for 10 seconds; clunks park, head]
$ date                    # it feels like aeons have passed
  [ironically dramatic half-second pause]
  2300 AD                 # gato, is that you?

Meanwhile, while I pause to gather my thoughts, the drive is continuously falling asleep and being woken up again every 15 seconds anyway as Linux periodically squirts a bit of data at it, causing an absolutely adorable constant clacking sound.

Now, in an alternate universe where I don't actually enjoy using my command-line like it was the gas pedal on an old man's Cadillac, I might scour the internet for hours and come up empty except for an unsupported, DOS-based, placebo utility which only pretended to fix the problem, and eventually resort to a backgrounded while loop touching a file every 7 seconds.

But in this universe, I and Ferris Bueller rate the WD6400AACS a Strong Buy.

February 14, 2009

Walentyn

Welcome back to 1993.

January 22, 2009

Heiraten

Thousands of days ago, during my OS/2 phase, I used the mail client PMMail. Recently, I discovered a long-forgotten cache of 1996-era PMMail-format messages, hidden amongst a surplus of hyphens. I thought there perhaps might be something worth reading in there—a poignant reminder of the human mind's infinite capacity for self-delusion—and in an effort to recover these messages, I wrote a trivial converter from PMMail to Maildir format.

Now, one may explore the dark days of college to one's heart's content. Chiefly, one finds that one was once able to write real good English, which that I can't do anymore.

June 4, 2008

Shift-Command-Z

I redid the site in Scheme. You won't notice any difference.

May 24, 2008

The AA vote

JEdict (4.5.3) does not let you change the font used in its WebKit web browser, nor does it let you specify a custom user stylesheet. Kill two birds with ... well, two stones:

  • defaults write -app JEDict WebKitUserStyleSheetLocationPreferenceKey -string "~/css/jedict.css"
  • defaults write -app JEDict WebKitUserStyleSheetEnabledPreferenceKey -boolean true

A minimal stylesheet for viewing something like 2ch ascii art on OS X might be:

body { font: 14pt MS-PGothic !important; }  /* 16.5pt works too -- but not 16 */
table { font-size: 100%; }

March 28, 2008

Jonesing

I made the following changes to Jonesforth, which are available here:

Tail-call optimization; DOVAR/DOCON -> simplified CONSTANT, VARIABLE, and VALUE; FIG-FORTH-style CREATE ... DOES> support; case-insensitive FIND; Pentium optimizations; SEE aborts on word not found; constant, variable and DOES> decompilation (and indicate primitives). Also added optional space-saving DOES> support, which cannot be decompiled and is probably slower.

February 29, 2008

Schaltjahr

I use SQLite3 for my searches database and I was looking for a way to create a frequency table of search terms--either updating the term count or inserting new termsas needed. Evidently, according to this blog post, MySQL has an extension INSERT ... ON DUPLICATE KEY UPDATE which lets you insert or update as needed. The solution in that post for SQLite3 is programmatic: check if an INSERT fails, and do an UPDATE if so.

However, I thought this was not particularly elegant and it also would not work from a trigger. Here is the autovivification solution I came up with:

CREATE TABLE terms(count INTEGER, term TEXT PRIMARY KEY);
...
INSERT OR IGNORE INTO terms(count, term) VALUES (0, 'my term');
UPDATE terms SET count = count + 1 WHERE term = 'my term';

Execute these two statements whenever you want to bump a term's frequency. The ON CONFLICT IGNORE (aka OR IGNORE) causes the INSERT to silently fail on constraint violation; specifically, the uniqueness of the primary key. The base value of 0 ensures the count starts at 1.

February 25, 2008

And your little spiffy, too

Persistent connections exhibited the same issue on spiffy, so I wrote a socket egg which allows you to disable Nagle's algorithm (among other socket options) on Chicken TCP connections:

(http:listen-procedure 
 (lambda (port backlog host)
  (let ((L (tcp-listen port backlog host)))
    (set! (tcp-no-delay (tcp-listener-fileno L)) #t)    L)))

February 18, 2008

lighttpd's naggling issue

Benchmarking lighttpd on OS X with httperf, I found that persistent connections that were fetching files of certain sizes (some big, some small) had their first request satisfied in under 1ms, but experienced a 40ms delay on subsequent requests. Apache did not have this problem. Only one guy on the entire Internet reported seeing something like this, and he got (surprise) no response.

Studying ktrace/strace and tcpdumps from both sides indicated it might be a Nagle problem, and since httperf does disable Nagling, that left lighttpd. Indeed, I found that lighttpd does not (as of 1.4.18) set the TCP_NODELAY flag on its sockets. I guess it assumes the OS disables the Nagle optimization globally, which is generally true on Linux, but not OS X. Or evidently Solaris, since Sun said they patched lighttpd themselves.

I rebuilt the lighttpd from MacPorts and added a small patch:

port uninstall lighttpd
port -d extract lighttpd    # -d to see extract path
(patch network.c with TCP_NODELAY option)
port install lighttpd 

and it solved the issue.

February 18, 2004

Dreamcast hacking.

I've started coding for the Dreamcast again recently, and posted a few things in the Dreamcast section. First, serpent, a version of the KOS bubbles demo that runs about five times faster, due to an optimized assembly loop that transforms and sends vertices to the PVR via the store queues. This sparked a discussion on DMA, and a DMA-based variant coded by Dan Potter was added to the examples tree. Second, oceano, which uses the specular highlight feature of the PVR to simulate sparkles on water. It doesn't try to be mathematically correct--rather it's meant as a jumping off point for others. Third, punch, a test harness for benchmarking large polygon performance, originally written to test punch-through polygons. There are also a few patches I wrote along the way, some of which are in the main KOS tree now.

April 30, 2003

Summary of additions.

Over the past year I've added several items: brkout, a breakout clone for the Dreamcast; u6edit, my first world editor for Ultima 6; and several musical pieces. Today I added pu6e, which supersedes u6edit and offers many more features.