Tuesday, June 28, 2005

compiling hat with ghc 6.4 on debian

$ make
...
MkProg: hmake: the compiler 'ghc' is not known.

Stop - hmake dependency error.
$ locate hmakerc
/var/lib/hmake/debian/hmakerc
$ hmake-config `locate hmakerc` list
Global config file is:
    /var/lib/hmake/debian/hmakerc
Known compilers:
    ghc6        (6.4)
    /usr/bin/haskell-compiler   (6.4)
    /usr/bin/ghc6       (6.4)
Default compiler:
    /usr/bin/haskell-compiler
$ hmake-config new
hmake-config: Starting new personal config file in
.../.hmakerc/debian
$ hmake-config add ghc

GIF with transparancy to white background

giftopnm --alpha=$file.alpha $file > $file.ppm
pnminvert $file.alpha|pnmcomp -alpha=$file.alpha $file.ppm > $file.pnm

compress reorder lines

How well can one compress a file if one is allowed to put the records in any order?

Monday, June 27, 2005

lesskey

echo "\kl prev-file\n\kr next-file" | lesskey -

Wednesday, June 22, 2005

Optimal coinage

What set of 4 coins values optimize the average number of coins needed to make change from zero to 99? 3 coins from 0 to 19? Under the constraint that greedy change-making work?

Sunday, June 19, 2005

Kerberos for Mac OS X

If Kerberos is not configured yet on Mac OS X (osx macos macosx) 10.4 (tiger) you'll get "debug1: Miscellaneous failure Server not found in Kerberos database" from ssh -v. The documentation at MIT Kerberos for Mac is mostly useful, but it neglects to mention that one one needs to touch a zero byte file "edu.mit.Kerberos" in /Library/Preferences in order for the "Edit Realms..." menu option in the Edit Menu to work.

It's a little unnerving that the default settings are for 7-day renewable tickets.

Sunday, June 12, 2005

qsort madness

qsort() (redhat glibc 2.3.2-95.30) attempts to be clever with memory by switching to a different algorithm for large inputs. On my computer, the threshold is at 131459071-131459072 for 4-byte integers. Performance abruptly degrades at the threshold. It also has the unfortunate bug-hiding effect that programs can work properly with the small algorithm and fail when inputs get large enough. Finally, at large inputs, the C++ STL implementation becomes comparable. Here are some counts to the number of calls to the comparison function for an array initialized by a[0]=1 a[n+1]= a[n]*1664525+1013904223

qsort
 131459070 easy  0        hard 3333417997
 131459071 easy  0        hard 3333417454
 131459072 easy  50294519 hard 4063553331
 268435456 easy 102684870 hard 8680917338

C++ STL sort()
 131459070 easy 15139169 hard 4345836000
 131459071 easy 15141479 hard 4316599909
 131459072 easy 15139606 hard 4470743742
 268435456 easy 30917419 hard 9444799480

The columns give the number of "easy" comparisons (pa==pb for qsort; a==b for sort) and "hard". The PRNG has period 2^32 so every number is unique.

Sunday, June 05, 2005

Fastest Orbit

How long does it take for a satellite to orbit the earth just above the surface? The sun? Mumble gravity=centripetal force...

Wednesday, June 01, 2005

Nontranscendentals

Continued fractions can tell if a number is rational or a quadratic surd. Is there analogous for all algebraic?

--

Mobile Email from a Cingular Wireless Customer http://www.cingular.com