True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Archive for the ‘Computers’ Category

Scanners for macro photography

Thursday, July 9th, 2009

Scanners can be used for macro photography, at least the ones with a great depth of focus. The scanners with CCD sensors tend to have a good depth of focus while the thin scanners with a CIS sensor can only focus on objects a mm or two from the glass.

I collected a list of scanners recommended for macro photography.

from here:
EPSON Perfection 3170
from here.
Microtek ScanMaker X6 EPP
Artec AM12S, AM 2400-U Pro
Epson Expression 836XL
3D Pro Scanner
Memtek Memorex SCF 9360P 3D
from here:
Epson Perfection 1240U Scanner
Epson Perfection 1200U

Checking specs, these also look well suited:
Epson Perfection 2480
Epson Perfection V300
Epson Perfection 2450
Epson Perfection 3490

256 colors in vim on OS X

Saturday, 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

Wednesday, 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!

Dawkins ‘Weasel’ program as a Perl one-liner

Saturday, 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";

The shape of programmer’s brains

Saturday, October 11th, 2008

I ran across a remarkable paper, “The Camel has two Humps”. Incoming Introduction to Programming students all *want* to learn to program, but about half the class never gets the hang of it and never will. The authors found a test that identifies the students that can learn to program.

The authors’ pretest asks questions about variable assignment: a=10, b=20, a=b. There is a typical meaning for these assignments in programming languages but the incoming students may not know them. So the authors classify the type of logic required to reach different answers and whether the students use the same logic for each question or switch around on different questions. Students who come up with consistent answers for different questions are the students who can learn to program.

Here’s a key figure:
consistent and inconsistent answers corellated with grades

This is remarkable, a way to candle incoming CS students and figure out (mostly) which ones can learn to program.

One notable thing that further research can answer is about the oddballs. The 2-3% of initially inconsistent testers that *do* learn to program–what sort of programmers are they? Do they end up writing different programs than the typical programmer?

Better reading tech

Friday, May 11th, 2007

A company has developed a new reading technology called Live Ink (paper here). The idea is to improve the way text is displayed to improve reading comprehension. The way the brain perceives a page of text is as small region at a time. Words from several lines get picked up at the same time. This confuses the parts of the brain that comprehend words and sentences. Live Ink proposed to spread text out to avoid this mental confusion to improve reading comprehension.

There’s a kernal of a good idea there–electronic text allows reformatting to increase comprehension. But their solution sucks. It takes up too much space and it only partially helps with the problem of line confusion. The syntactic breakup may be helpful. Here’s an image of it:
Live Ink example

Computer formatting is a good idea. Here is my idea of how to do it. Fuzz out the lines before and after the current line. This could be done one of two ways. If eye movement tracking is available, follow the eye and only make the line being looked at visible with the others fuzzed out. Without eye tracking make this a timed system (like traditional light bar reading trainers). Start it on a section of text and make one line at a time is visible moving through the text. Controls would be needed to pause and go back a few lines, and flip it off.

By fuzz out the rest of the page I mean alter it so the brain doesn’t think it is text and try to decode it. Whether making it out of focus is enough or if another kind of noise needs to be added would need to be determined by trials. It would be important to leave enough information that the presence of text blocks and formatting is visible. These provide visual landmarks needed for good reading.

Technically, this could be easy–a web browser extension or perhaps as simple as some Javascript added to a page with overlay images fuzzing the text and moving as needed.

Graphviz on OS X

Sunday, May 8th, 2005

tried running the Graphviz programs on OS X (sudo fink install graphviz) and got a font error message, ‘Could not find/open font : Times in…’

To use the Graphviz programs with OS X, need to specify

-Nfontname=luxisr

The program can use fonts in /usr/X11R6/lib/X11/fonts/TTF. This is part of
the Apple supplied X11 (part of the optional/developer OS install disk? I don’t recall when/how I installed it.).
Found this info at: link