True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Great web comic

April 16th, 2009

Breakfast of the Gods

Breakfast cereal characters inhabit the world of Cerealia. I didn’t know there were so many of them! Full of sugary goodness.

BOTG

Pyrete boats

April 16th, 2009

I saw the MythBusters segment on making a boat out of frozen water and wood pulp, called Pyrete. It is essentially a composite material. Pyrete worked pretty good, except for it melting quickly. A boat might last in the Arctic winter for a while if the boat was made from pure water as the salt water there is a few degrees below 0°C. Even at best it would melt over the summer.

This material could be useful if the freezing point could be raised. Unfortunately, most things added to water lower the freezing point. NaCl, table salt, is the best known example. There are ways to raise the freezing point of water–certain organic acids, salts, sugar alcohols. But they require large quantities of additives, so they are either expensive or toxic or both. Too bad.

Examining the giant marijuana cash crop urban legend.

April 9th, 2009

I’d heard before that marijuana is the biggest cash crop in California …in Kentucky …in the US. Online you can see a 2006 estimate that puts marijuana on top by Jon Gettman. It always sounded patchy, and here Kevin Drum links to a critical site that estimates the retail value of the cannabis sales at $10 billion.

Even this seems high according to my estimate. I recently (can’t lay my hands on the figure) saw a graph of pot smoking by age in the US within the past month. Highest for people in their 20’s, then about 10% until people hit 60. Older folks smoke very little. So let’s say 10% of people from 15-60 (roughly 24 million people) smoke twice a month:

24 million people x 24 joints/year / 40 joints/ounce x $100/ounce = $1.5 billion retail per year.

By comparison, the US corn crop is $24 billion/year. $1.5 billion/year is about the size of the US tobacco or orange crop. But then we are comparing retail prices to farm prices. So figure growers are getting at best 1/5 or 1/10 or the retail price, and now the marijuana crop is tiny, smaller than the peach crop. Also, considerable marijuana in the US is imported, so the US crop is even smaller.

Running the estimates in the other direction, the $10 billion estimate of spending on marijuana has the monthly US smokers lighting up every other day. This sounds too high, most smokers are occasional smokers. Estimating pot spending at $35 billion as Jon Gettman does has monthly pot smokers averaging eleven joints a week, or every man, woman, and child in the country lighting up once a week. Way high.

Are people on the Nicoya peninsula, Costa Rica long lived?

April 7th, 2009

Caught a story on the Oprah TV show talking about why the people living on the Nicoya peninsula on the Pacific coast of Costa Rica are long lived. And I asked myself, are these people long-lived? I haven’t heard that before and I should know.

So I went looking, and the special on Oprah was touting a book, The Blue Zones: Lessons for Living Longer From the People Who’ve Lived the Longest by Dan Buettner. Buettner first reported the story for National Geographic. So why does Buettner think Nicoyaians are long lived?

Some populations have been studied and found to be long lived–for example, there are four times as many centenarians in Okinawa, Japan compared to Japan as a whole.

Buettner’s source is Dr. Luis Rosero-Bixby, a Costa Rican demographer. The sole published source I can find is The exceptionally high life expectancy of Costa Rican nonagenarians. I haven’t read the paper, but from the abstract national birth registry data was used to establish date of birth and census data was used to monitor survival, and life expectancy of 90-year olds was found to be half a year longer than anywhere else in the world, for males only.

This seems very thin evidence, I can’t find other studies by Rosero-Bixby or evidence that these people were studied by any other groups. It is especially odd that the effect is seen in males but not females–this was the pattern in other areas where long survival was reported but didn’t pan out-the Caucus region of Georgia, northern Pakistan, and the Andean village of Vilcabamba in southern Ecuador. Usually remote areas with poor record keeping.

Harnessing static cling

April 7th, 2009

It would be useful to attach a static electricity generator on the end of a long thin rod to pick up small non-metallic things dropped behind bookcases or otherwise out of reach. Could run a band through the center of a thin rod, or easier yet just package a thin PVC rod with a piece of rabbit fur or nylon.

256 colors in vim on OS X

April 4th, 2009

Terminal colors are broken out of the box in OS X terminals. In part due to a poor OS X terminal implementation, part due to problems with vim. I try new colorschemes and get strange, random looking results.

After many fruitless searches I finally got 256 colors working in vim in a terminal. This post and the GVim site were very helpful. It turns out that the included Terminal app in OS X only supports 16 colors. The terminal background can be set to any color which confuses the issue. The colortest Perl script available on the Gvim site makes this clear.
OS X Terminal colortest:
colortest run in Terminal

The free GNU licensed iTerm terminal does support 256 colors.
iTerm colortest:
colortest run in Terminal

OK, now the terminal supports 256 colors. There are still some hoops to jump through to get vi to show colors though. Most colorschemes are built for gui (using 24-bit RGB colors), so vim needs to be built with gui support. This can be checked with :echo has(‘gui’). It reports 1 for yes, 0 for no. The vim I had (default or Fink installed) didn’t have gui support, so I downloaded GVim and copied it over the old vim:

cp /Volumes/Vim-7.2.148/Vim.app/Contents/MacOS/Vim /usr/bin/vim

and now vim has gui support.

I copied /usr/share/vimrc to /usr/bin because the downloaded vim didn’t know to look in /usr/share and added a few configuration lines:

” Doesn’t get set right.
set t_Co=256

” Needed because the new vim doesn’t know to look in /usr/share
set runtimepath=~/.vim,/usr/share/vim/vim72_2,/usr/bin/vimfiles,/usr/bin,/usr/bin/vimfiles/after,~/.vim/after
let $VIMRUNTIME=’/usr/share/vim/vim72_2′

syntax on
colorscheme LightTan

OK, so now 256-color support works and I can set colorschemes. They still don’t look right because colorschemes made for the gui don’t look right on a 256-color terminal. There’s a great vim script called CSApprox that converts gui colors to the closest of the 256 colors and makes gui colors look pretty good in a terminal. Download it, unzip it, and copy files to the vim directory:
sudo cp plugin/CSApprox.vim /usr/share/vim/vim72_2/plugin
sudo cp autoload/csapprox.vim /usr/share/vim/vim72_2/autoload

and now when I load colorschemes they look pretty close to what the Vim colorscheme test site shows, with the only difference due to font differences.

To get full color support when I log into a linux machine I need to do some more setup. To get gui support in terminal:
yum install vim-X11
and then add to /etc/profile:
alias vi=’gvim -v’
and “source /etc/profile” to enable it.
and add:

set t_Co=256

if &t_Co == 256
colorscheme LightTan
endif

to /etc/vimrc to force 256-color mode and pick a colorscheme.

I also copied the CSApprox files to /usr/share/vim/vim70 and now it works when I ssh to this machine as well!

Indie games

April 1st, 2009

I ran across the independently produced game World of Goo. Fun game, the stylish graphics caught my eye.

So I wondered what was involved in creating a modern game. What’s done? Tech wise, graphics engine, physics engine, AI, etc. Art and sound. Looked around, found these two sites:

Indie Game Developer Links
Gamedev.net

Never found the a straightforward answer to my question though.

Addendum:

Reading the ‘how we made it’ articles on their site, it looks like World of Goo was made using the open source PopCap framework. PopCap includes two physics engines, the 2D Chipmonk Physics library and the 3D ODE physics library!

The eigenspace of fraud

March 30th, 2009

Interesting discussion of the basic types of fraud at Making Light: here, and a followon here.

1. Simple misrepresentation.
2. Using high-pressure tactics to confuse or intimidate the victim.
3. Shell games, sleights of hand, and switch-and-retraction cons: the pigeon drop, the Jamaican switch, Three-Card Monte, etc.
4. The Spanish Prisoner
5. Ponzi Schemes
6. Pyramid schemes
7. Selling information about, or access to, uncommon opportunities

I would add selling a dream. The con man sells people on an appealing dream and convinces them to spend time and money on it. The details determine whether this is a con, a religion, a self-deception, or an honest endeavor. For honest endeavor, consider someone who convinces a town to set up a community garden. For con, think of someone who convinces people to pool money to buy a farm and start a co-op and ends up owning the farm. For religion, think the televangelists that live in mansions built with their followers dough.

Dawkins ‘Weasel’ program as a Perl one-liner

March 28th, 2009

Explained at Panda’s Thumb:

Over at uncommon descent William Dembski is musing over Richard Dawkins Weasel program. Why you may ask? Way back in prehistory (the 1980’s) Dawkins wrote a little BASIC program (in Apple BASIC of all things) to demonstrate the difference between random mutation and random mutation with selection, which many people were having trouble grasping. Now, this wasn’t a simulation of natural selection, and Dawkins was very careful to point this out.

But as a demonstration of selection versus simple random mutation, with the string “methinks it is a weasel” being selected in a matter of minutes, when simple random mutation would take longer than the age of the Universe, it was pretty stunning. As a result, creationists have been having conniption fits over this little program for decades. Such is its power, the Issac Newton of Information Theory, William Dembski, spent a not inconsiderable portion of his time attacking this toy program. In particular, he claimed that after every successful mutation, the successful mutation was locked into place, and couldn’t be reversed. But he was wrong, and it seems he just can’t admit it.

The Weasel program starts with a random string. Then each generation ‘offspring’ strings are generated, each with one letter randomly changed. From among the offspring, the string closest to the target string is chosen each generation. Rather quickly this process of mutation and selection will change any string into the target string. I start with “Creationism is nonsense” and my target is “methinks it is a weasle”, the target Dawkins uses.

Since the creationists are having trouble making such a program, I wondered *just how short* a program could be written to do this. Here’s a first attempt as a eight line Perl one-liner. It can be cut & pasted into a Unix terminal:

perl -e '$|=1;$s="Creationism is nonsense";$e="methinks it is a weasle";$try=11;$let=length($s);@e=split(//,$e);while($s ne $e){$i=-1;while($i++< $try){$new_s[$i]=$s;$chr=int(rand(27))||-64;substr($new_s[$i],int(rand($let)),1,chr(96+$chr));@spl=split(//,$new_s[$i]);$j=0;$new_sc[$i]=0;while($j<@e){$new_sc[$i]++if$e[$j]eq$spl[$j++]}}@sc=sort{$new_sc[$b]<=>$new_sc[$a]}(0..$#new_sc);@new=(shift@sc);while(@sc&&$new_sc[$sc[0]]==$new_sc[$new[0]]){push@new,shift@sc}$s=$new_s[$new[int(rand(@new))]];printf("Generation %5d, %-2dmismatches:  $sr",++$n,$let-$new_sc[$new[0]]);}print"n";'

(When I cut & paste the one liner on my Mac it changes the final single quote to an end quote and the last two pairs of double quotes to funny double quotes, so keep an eye out and change them back if you need to).

And the normal length 35 line program with comments:

#!/usr/bin/perl

$|=1;
$s="Creationism is nonsense";
$e="methinks it is a weasle";
$try=11; #New offspring per generation.

$let=length($s);
@e=split(//,$e);

while($s ne $e) {
  $i=-1;
  #Make $try new strings.
  while($i++< $try){
    $new_s[$i]=$s;

    #Mutate one char of the new string.
    $chr = int(rand(27)) || -64;
    substr($new_s[$i],int(rand($let)),1,chr(96+$chr));

    #Count the characters in the new string that match the target string.
    @spl=split(//,$new_s[$i]);
    $j=0;
    $new_sc[$i]=0;
    while($j<@e){$new_sc[$i]++ if $e[$j] eq $spl[$j++]}
  }

  #Find high scoring offspring strings.
  @sc = sort {$new_sc[$b]<=>$new_sc[$a]}(0..$#new_sc);

  @new=(shift @sc);
  while(@sc && $new_sc[$sc[0]] == $new_sc[$new[0]]){push @new,shift @sc}

  #Set new string to a random offspring strings from among the high scoring offspring.
  $s = $new_s[$new[int(rand(@new))]];

  printf("Generation %5d, %-2dmismatches:  $sr",++$n,$let-$new_sc[$new[0]]);
}
print"n";

Regarding LotR

March 25th, 2009

From a thread discussing Kate Nepveu’s chapter by chapter review of LotR:

Though as Bilbo is the sort of house-guest who shows up out of the blue and stays for seventeen years, eating six meals a day throughout, perhaps the Rivendell Elves have given up expecting him to have finer feelings