Monthly Archives: October 2006

Happy Halloween!

Well, it’s Halloween again, and that means it’s the anniversary of the 1938 broadcast of Orson Wells production of The War of the World. It’s become a bit of a tradition for me to provide an mp3 for download with all my best wishes for a spooky holiday. When I get time throughout the day, I’ll post some more links to other Halloween audio (or maybe even video!) for download. Feel free to add any links of your own in comments (relevant ones, please, I’m not going to approve prescription drugs!) Hope you have a spooktacular time!

Addendum: oddiooverplay has some great halloween mashups. Even more here.

Addendum2: What to Do in a Zombie Attack, courtesy of archive.org.

Prime Number Pathology Courtesy of Good Math, Bad Math

I look forward to reading the Good Math, Bad Math blog, especially on Fridays. Often there is a pointer to an interesting computer language that somehow stretches your understanding of programming languages and computer science. Today was no exception, as he introduced Fractran, and interesting “language” that does computation by multiplying fractions.

It turns out that it isn’t the first time I’d seen this: Conway mentioned it in his Book of Numbers, a terrific little book full of gems of knowledge like this. He presents it just as an aside, by giving you the following list of fractions, labelled A-N,

17/91, 78/85, 19/51, 23/38, 29/33, 77/29, 95/23, 
77/19, 1/17, 11/13, 13/11, 15/14, 15/2, 55/1

You begin by initializing an accumulator to 2. You then proceed by trying to multiply your accumulator by each number. If it results in a whole number, you
update your accumulator, and start again. Every once in a while, this computation generates a result which is an exact power of two. The sequence of
these numbers forms a monotonically increasing series, with only the prime powers of two. I wrote a little Python program to demonstrate this.

#!/usr/bin/python

program = [(17,91), (78,85), (19,51), (23,38), (29,33), (77,29),
           (95,23), (77,19), (1,17), (11,13), (13,11), (15,14),
           (15,2), (55,1) ]

acc = 2

def poweroftwo(acc):
        while acc > 1 and acc % 2 == 0:
                acc = acc // 2
        return acc == 1

def log2(acc):
        cnt = 0
        while acc>1:
                acc = acc // 2
                cnt = cnt + 1
        return cnt

while True:
        for n, d in program:
                if acc % d == 0:
                        break
        acc = n * acc / d
        if poweroftwo(acc):
                print "2^%d = %d" % (log2(acc), acc)

When you run this, you get output like….

2^2 = 4
2^3 = 8
2^5 = 32
2^7 = 128
2^11 = 2048
2^13 = 8192
2^17 = 131072
2^19 = 524288
2^23 = 8388608
2^29 = 536870912
2^31 = 2147483648
2^37 = 137438953472
2^41 = 2199023255552
2^43 = 8796093022208
...

When I first saw this, I must admit that I was mystified, but it’s really not that hard (although far from obvious) to figure out what is going on. Your accumulator is literally encoding the state of a computer. In the case of the calculation above, the “machine” has 10 registers, each one labelled with a prime (basically the
primes less than thirty). If you wish to increment the value in a particular register, you multiply the accumulator by the corresponding prime. If you wish to decrement a counter, you divide. You aren’t allowed to divide if the results aren’t integers, which basically means that each register contains a positive non-negative value. The state of the machine is just the product of all the machine values. Pretty neat!

Using this idea, you can convert the list of fractions given by Conway into a pretty neat little .signature program to compute primes (and runs a lot faster):

int j=1,h,c,o,n,w,a,y,m,v;main(){for(;;)o&&w?a++,o--,w--:(c&&a?j++,h++,w++,c--,
a--:(h&&a?y++,h--,a--:(j&&y?m++,j--,y--:(h&&n?v++,h--,n--:(v?o++,n++,v--:(m?c++
,y++,m--:(y?o++,n++,y--:(a?a--:(w?n++,w--:(n?w++,n--:(j&&o?h++,c++,j--,o--:(j?h
++,c++,j--:(c++,n++))))))))))))),h+c+o+n+w+a+y+m+v||printf("%d\\n",j);}

Not sure about the character mangling, if you have difficulty cutting and pasting this, try clicking this link to get the text.

How’s that for obfuscation? Thanks to Tom for helping me compress this so it will fit down into 4 lines.

Addendum: Here’s an even shorter version. Tom wrote a slightly shorter one by using recursion and avoiding the main loop, but I think that’s vaguely cheating, as C compilers don’t necessarily implement tail recursion as simple loops.

[tags]Programming,Good Math Bad Math,John Horton Conway[/tags]

Good News For Scott Adams

Scott Adams, creator of the amusing Dilbert comic strip, has suffered from a condition known as Spasmodic Disphonia, a normally incurable and largely untreatable disorder which is, at best poorly understood. The strange thing is, he seems to have hacked his own brain into figuring out how to speak normally again. It’s really quite interesting intellectually, and obviously quite uplifting emotionally.

Check out his blog entry.

The Dilbert Blog: Good News Day

[tags]Scott Adams,Spasmodic dysphonia[/tags]

Kenny Rogers Cheating?

Ah, controversy!

Kenny's Dirthy Thumb

During Game 2 of the World Series last night, Fox showed closeup video stills of Detroit pitcher Kenny Rogers’ hand that seemed to show that he had a dark, slick looking substance on the base of his left thumb. According to the official rules of baseball, section 8.02, a pticher shall not “apply a foreign substance of any kind to the ball”. The penalty for violating that rule is immediate ejection and a 10 game suspension.

Interestingly, now their are pictures coming out which show a similar smudge on Rogers hand in the ALCS against the A’s.

After the first inning, Rogers washed his hands and then continued his postgame scoreless streak, extending it to 23 innings pitched without a run scored.

It’s easy to cry conspiracy (particularly if you’re a Yankee fan). Frankly, I am pretty convinced that he was doctoring the ball, and should have been ejected, but it seems pointless to whine on about it if you are a Yankee or an A’s fan. Your team did, after all, lose all the other games in that series as well. And, as was pointed out below, the law of averages might have suggested that if you give Kenny Rogers a few more starts, he might have evened out his post season record.

Double Play Depth: Kenny Rogers’ Thumb Not the Reason for Scoreless Streak Archives

[tags]Baseball,Detroit,Kenny Rogers,Cheating[/tags]

ICFP programming contest 2006 results

Some time ago, I spent an afternoon or two working on the ICFP programming contest for 2006, not as a competitor, but just because I thought it was amusing. (I wrote it up on this blog here. Tom pointed out that there was Google Video of the final presentation on the contest, which is fairly amusing to watch.

ICFP programming contest 2006 results – Google Video

[tags]ICFP Programming Contest,computational archaeolinguistics[/tags]

Addendum: You can get the final report on the contest as a PDF tech report, which includes all sorts of information that was repeated in the video linked above.

Cult of the Bound Variable

Addendum2: When I was mucking around with this stuff, there was quite a bit that I missed, including the presence of an icon embedded in the codex.umz file. Strangely, I couldn’t find any mention of it in the discussion lists or anywhere else, but a few minutes of spelunking in the hex dump of the codex file made it fairly obvious where to look, although I spent a bit more time on it than I needed because I can’t do simple math. Anyway, there it is, archived for all eternity.

Addendum3: Oh, the contest has its own website where you can download the challenge and goof around with it yourself, just for fun.

Forbidding Vistas: Windows licensing disserves the user

Here’s a really cool article detailing some of the nonsense in the new Windows Vista licensing.

Wendys Blog: Legal Tags: Forbidding Vistas: Windows licensing disserves the user

Is there someone out there who thinks that these restrictions are in the least degree reasonable? Do you feel like paying for such an absurdly anti-consumer product is a reasonable use of your hard earned money?

[tags]Rants and Raves,Microsoft Windows,Microsoft Vista[/tags]

The Complete Work of Charles Darwin

Wow, this site contains a huge number of works by Charles Darwin. 50,000 pages of searchable text. 40,000 pages of images. Lots more to come. A fantastic resource in the history of science.

The complete work of Charles Darwin

[tags]Charles Darwin,Evolution[/tags]

Two sad things somewhat spoil this collection for me:

  • There is a dubious assertion of copyright over most of the materials in this collection along with restrictions for their use. Such an assertion of copyright is almost certainly meaningless, since the works are themselves in the public domain, and the courts have held that the mere transcription of public domain works by scanning or copying does not represent a significant creative work that is worthy of copyright. They can, of course, assert a “collection” copyright on the set of work as a whole, but the fact that they would try this subterfuge to restrict access to public domain materials is annoying.
  • All the links to the audio files seem broken. (Incidently, these likely do qualify as creative works, as they are read and performed by humans, which can arguably be called a creative act.)< /s> Well, the audio is back. It’s computer generated audio, which I find enormously tiresome to listen to. Ignore what I said about it being copyrightable.

Watch for Nukes!

The first indication that the North Koreans may have tested a nuclear device came from the the seismic data coming from the USGS. I thought that was kind of cool, and I had learned a few things about parsing XML feeds and the like, so I decided to try to make a little gadget which presented the latest earthquake information from the USGS plotted over a Yahoo! Map of North Korea.

Check it out.

Because there is little seismic activity in North Korea, and I needed some test data, I presented a similar feed for California. Try clicking on some of the markers to see information about seismic events (presumably non nuclear).

[tags]Yahoo! Maps,North Korea,Nuclear Weapons,USGS[/tags]

Ralph Griswold died

Courtesy of Lambda the Ultimate came the report that Ralph Griswold, creator of the computer languages Snobol and Icon, passed away about two weeks ago. Condolences to his family and friends.

On my shelf I have a copy of his book on the Icon programming language. While it never became widely popular, it had a number of relatively innovative features that influenced later programming languages like Perl and Python. It remains a language worthy of study and consideration. I never learned much about Snobol, I should rectify that.

[tags]Ralph Griswold,Icon Programming Language,Programming Languages,Snobol[/tags]

Random disconnects with Airport on a MacBook Pro

Hmmm. This thread had some ideas on my MacBook disconnect problems.
I’ll try them out later and let you know what the deal is.

DD-WRT Forum :: View topic – Random disconnects with Airport on a MacBook Pro

[tags]DD-WRT,Macbook,Wireless[/tags]

Addendum: I changed some settings that was suggested in the thread above, namely setting the wireless preamble to auto and enabling frame burst, and I’m tentatively optimistic. I’ll post another update after a few more hours of use.

Meshing around with Wireless Networks and WDS

I’ve still been having some difficulties with my MacBook and my home wireless networks. When running on battery power, as well as more infrequently when on regular power, my MacBook seems to lose its wireless connection, and will not automatically reconnect: I have to do do so manually, which is a bit of a chore.
I wrote about this before, and as yet have found no resolution.

But the other day when using the network from my bedroom, I noticed that my wireless signal was quite weak, often dipping into the teens as far as quality. I thought that was pretty bad, and indeed, the wireless access point is on the opposite side of my house, through about six walls and one floor, so I thought that it might be time to consider adding a second access point on the second floor.

My current router is a Linksys WRT54GS (version 2) which I upgraded to run the third-party firmware DD-WRT. It has many improvements in QoS and other goodies compared to the official firmware, and was remarkably stable. Despite the fact that have heard that this firmware might be the source of my difficulties with the MacBook, I decided to pick up a new Linksys router as my second access point, and also install and run the new DD-WRT on that box as well. Why? I’ll get to that in a bit…

One of the reasons that the Linksys hardware is so popular is that it was based upon the Linux operating system, and the sources were made available under the GPL. This spawned a huge amount of development, including DD-WRT, which I really like. Unfortunately, the WRT54G underwent a metamorphosis, and they shifted to firmware based upon VxWorks and cut the amount of memory in each box in half. Early on, these boxes were incompatible with third party software, which made them less desireable. However, the “micro” version of DD-WRT (which doesn’t include things like VOIP) will fit in these machines, and bitsum worked out a way of updating the flash appropriately. So, with this handy table in hand, I set off to CompUSA.

Why did I need this printout? Because I wanted to be able to tell which model router they had in stock. It turns out that you can look at the serial number on the outside of the box, and using this table, figure out what version of the hardware is inside. Surprisingly, CompUSA had both v5 and v6 models on the shelf, either of which should work with DD-WRT micro, and for only $49. I hemmed and hawed, and finally decided to get the v5 hardware, mostly with the idea that since it had been out longer, DD-WRT would have had the most chance to be debugged on that hardware. I have no idea whether that was a logical choice, but that is the choice I made.

Okay, I brought it home, plugged it in, it seemed to work. I then went and did some more reading.

I knew that I could string an Ethernet cable to the new box (wherever I put it) and could configure a different local network on it, effectively cascading the routers. But I really wanted the new box to be mounted a significant distance from the old one, and I didnt really want to pull any new cable. I had vaguely heard of something called “WDS”, and looked into it a bit more. It basically allows you to mesh wireless access points together. Each node repeats or bridges traffic going to it to all the other access points in the mesh. The cool thing is that only one machine then needs to be able to access the internet, and then all the rest can. This means that I just have to plug the new access point in somewhere where it can still get a signal from my original one, and it will extend the range.

You can find instructions on how to do this here:

WDS Linked router network – WRT Wiki

The long and the short of it: it works! I now have two APs “brainwagon” and “brainwagon-upstairs” and can use either one interchangeably to access my network. my signal is around 55 now in my bedroom, which is much better and I should be able to improve it a bit more with some moving around of the APs.

The bummer is that I’m still getting disconnects occasionally from my MacBook. The search continues for a resolution to that problem.

[tags]Linksys WRT54G,DD-WRT,Wireless,Macbook,Meshing,WDS,Wireless Distribution System[/tags]