True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

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

Super-wheels!

March 14th, 2009

Why am I just hearing about these now? the Mecanum wheel, invented in 1973. These wheels can move in any direction. A pair rotates in opposite directions to move sideways.

mecanum wheel

The battle between good and evil (to publish)

March 14th, 2009

Pharyngula has a post tearing apart a creationist who in passing refers to Satan as ‘Satan et al.’

So I wondered, *has* Satan published in the biological journals?

A PubMed search of biological publications finds no papers published by Satan but twenty-three with God as an author. You may draw your own conclusions from this…

March 12th, 2009

Cool, a custom made dodecahedral puzzle like a 5x5x5 version of Rubik’s cube!

The MAKE site has pictures of the build process: MAKE, video

petaminx

Idea: clearing pre-cancerous cells

February 17th, 2009

Cells become cancerous through a multi-step process. The cells pick up several mutations, each clearing a natural limit on cell division and usually increasing the rate at which the cells divide. By the time a person gets old their body has many pre-cancerous clumps of cells, and cancer occurs when one of the cells in one of the clumps picks up a final mutation and becomes fully cancerous.

Cancer has proven very difficult to treat, but perhaps it is easier to treat at the pre-cancerous stage. The idea would be to treat healthy people at middle age or later and kill most of their pre-cancerous cells. This would make the pool of cells that can develop into cancer much smaller and reduce the incidence of cancer.

Chemical chemotherapy drugs would be a poor choice for this–I expect they are not effective on slowly dividing pre-cancerous cells and these drugs are also damaging.

Instead, it may be possible to trigger apoptosis (cell suicide) in pre-cancerous cells. These cells are losing their differentiation and activating abnormal signaling pathways. They are likely stressed and may already be primed to undergo apoptosis. One of the organism’s anti-cancer mechanisms is to trigger apoptosis in pre-cancerous cells. The idea here is to supercharge this mechanism.

So the idea would be to treat the person with a cocktail of drugs that induces apoptosis by activating the apoptotic signaling pathways. The treatment should be strong enough to trigger a wave of apoptosis in the most susceptible cells clearing most pre-cancerous cells from the body. There would be some normal cells killed as well but they will be replaced by normal tissue processes.