3e8.org

In EBCDIC we trust.

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.