Christopher's posterous http://twopoint718.posterous.com Mostly programming things posterous.com Wed, 19 Aug 2009 14:44:00 -0700 Kaprekar's Number http://twopoint718.posterous.com/kaprekars-number http://twopoint718.posterous.com/kaprekars-number

I wrote some code in clojure to play around Kaprekar's Operation:
 
(defn fix  "Finds a fixed point of a function."  [f init-val]  (loop [last-val init-val   curr-val (f last-val)]   (if (= curr-val last-val)   curr-val   (recur curr-val (f curr-val)))))   (defn sort-digits  "Sorts the digits in a number, default is ascending."  ([n] (sort-digits n true))  ([n ascending?]   (let [cmp (if ascending?   #(.compareTo %1 %2)   #(.compareTo %2 %1))]   (Integer/parseInt (apply str (sort cmp (str n)))))))   (defn kaprekar-operation  "Run one iteration of the kaprekar operation (e.g. 4321 - 1234)"  [n]  (- (sort-digits n false) (sort-digits n))) (defn kaprekar-fix  "Report on the fixed point of the Kaprekar operation starting  from the INITIAL value (should be 6174 for 4-digit nums)"  [initial]  (fix kaprekar-operation initial))
 
If you call this like (kaprekar-fix 2315) you should get 6174.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Mon, 17 Aug 2009 14:49:15 -0700 Vortex Smoke Ring Collision is Today's BIG Thing in Technology - AUG 04, 2009 http://twopoint718.posterous.com/vortex-smoke-ring-collision-is-todays-big-thi-0 http://twopoint718.posterous.com/vortex-smoke-ring-collision-is-todays-big-thi-0

This is just an amazing video.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Tue, 28 Jul 2009 14:58:02 -0700 MIT TechTV – Bokode: Imperceptible Visual Tags for Camera Based Interaction from a Distance http://twopoint718.posterous.com/mit-techtv-bokode-imperceptible-visual-tags-f http://twopoint718.posterous.com/mit-techtv-bokode-imperceptible-visual-tags-f

Very cool new way to encode machine-readable data.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sun, 26 Jul 2009 11:53:24 -0700 Ion engine could one day power 39-day trips to Mars - space - 22 July 2009 - New Scientist http://twopoint718.posterous.com/ion-engine-could-one-day-power-39-day-trips-t-0 http://twopoint718.posterous.com/ion-engine-could-one-day-power-39-day-trips-t-0

Very cool video from here http://www.newscientist.com/article/dn17476-ion-engine-could-one-day-power-39day-trips-to-mars.html?full=true about a new type of ion engine that uses SCRF to pump up the energy in the plasma before ejecting it from the engine. Very cool.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Mon, 20 Jul 2009 22:05:45 -0700 HexClock (Part 2) http://twopoint718.posterous.com/hexclock-part-2 http://twopoint718.posterous.com/hexclock-part-2
Click here to download:
hexclock_visual.jar (592 KB)

This is the second installment of my Clojure ( http://clojure.org )
hex clock postings. I think I covered most of the discussion in the
last one. This post is just for my other design. This version
represents the time visually, as a series of colored squares. The MSB
is in the upper left and represents a half day. Read it just like the
(English) newspaper, left to right top to bottom. The LSB is in the
lower right and changes every 1.3 seconds. This makes it easy to
orient the clock.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sat, 11 Jul 2009 20:42:02 -0700 Gists http://twopoint718.posterous.com/gists http://twopoint718.posterous.com/gists Nice:
 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Tue, 23 Jun 2009 11:47:22 -0700 Alan Turing - Wikipedia, the free encyclopedia http://twopoint718.posterous.com/alan-turing-wikipedia-the-free-encyclopedia http://twopoint718.posterous.com/alan-turing-wikipedia-the-free-encyclopedia

Happy Alan Turing day. Hug a computer.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sun, 21 Jun 2009 08:45:33 -0700 HexClock (Java Edition) http://twopoint718.posterous.com/hexclock-java-edition-0 http://twopoint718.posterous.com/hexclock-java-edition-0
Click here to download:
hexclock.jar (553 KB)

I've been meaning to "release" a clojure program into the wild. Partly,
I want to take advantage of how nice it is to be able to deploy via jar
file, and partly because I've been wanting this application.
 
So, without further ado, here's my hexclock (as an executable jar file).
Source is included and is covered by the GPL
http://www.gnu.org/copyleft/gpl.html
 
Just FYI
sha1sum: ac0b67fa8252bf06f00d627dfc3f2975b1c45a30 hexclock.jar
 
Here's some explanation if you're confused. The basic idea is to divide
a day into half, so now we can say if it is AM or PM; easy but, I would
say, a little too coarse of a measurement. With the AM/PM clock, you'd
only need one bit ("is it morning?"). Continuing, next we can divide our day
into 4 equal parts, now we could (using two bits) say whether it was the
first part of the morning "early morning" or the second part of the
morning "late morning." Likewise we could talk about whether it were
late or early PM. These chunks would be 6 hours long. You can see that
we can keep dividing our day like this as much as we want, with each
division we need one more bit to talk about the time and we get twice as
many (and twice as short) chunks. In fact, if you wanted to keep going
until you got something like a second, it just so happens that you'd be
using 16 bits (though, it is a pretty close call (about 32% error versus
34%)). Which just happens to work really nicely for binary arithmetic as
we'll see.
 
Make sense doesn't it? While I have you agreeing with me (if you are),
stop and think about this for a bit, the steps to divide up time into
hours, minutes, and seconds are not at all constant. You must divide a
day into 24 hours, then an hour into 60 minutes and then again a minute
into 60 seconds. Quick, how many seconds in a day? The answer isn't
anything in particular, 86,400 (24*60*60). A fun number for us physics
nerds to memorize as an undergrad, but just that, an arbitrary constant.
 
The way that the clock works is just to represent the day as a 16 bit
number (0 through 65535), if you are accustomed to hexadecimal, this is
0x0000 through 0xFFFF. Hex has the nice property that each digit is four
bits (sometimes called a nybble, half a byte, get it? Well, I like it).
Numbers go 0-9 like usual but then we use A, B, C, D, E, and F for 10
through 15. I somewhat arbitrarily (and somewhat not) divide this number
into two parts the "high" byte (two hex digits) and the "low" byte (the
last two hex digits). I separate the time with a vertical bar like this:
"AB|CD", if you are a programmer this is meant to evoke logical OR. You
can imagine that the time is 0xAB00 | 0x00CD and they get smushed
together with the or operator.
 
When I implemented this in Python:
http://twopoint718.blogspot.com/2008/08/hex-clock.html I talked a bit
about the scale of the digits on the clock. The last digit changes every
1.318 seconds, the next most stable digit changes just about every 21
seconds. The next (the "B" in my example above) switches once every 337
seconds or about 5 and a half minutes. The most stable digit changes
only 16 times a day, since both 24 and 16 are divisible by 4 this makes
that digit equal to 90 minutes (1.5 hour). My proposal is to talk about
the first, most stable digit as hex hours, the second as hex minutes,
and the last two digits are hex seconds. My coined terms for these are
"hexours" (HEX-zours), "hexinutes" (HEX-inuts), and "hexeconds"
(HEX-econds). There are 256 hexeconds in a hexinute and 16 hexinutes an
an hexour. Alternatively, you could just say there it is AB "in the big
byte" and CD "in the little byte". I imagine people would just call out
the time "it is ABCD." To avoid confusion, I think all digits should
always be pronounced "zero, zero, zero, one," though maybe we could all
use the English "z" sound of "zed-zed-zed-one" because it cuts down on
the syllables. But when in doubt, if fewer than four digits are
announced, we should assume that they are talking about the most
siginificant digits first (much in the way that we say "it is 3
o'clock").
 
You can read the post that inspired this idea here:
http://halcanary.org/vv/2007/10/31/706/
 
You can read more about hex time here:
http://www.intuitor.com/hex/hexclock.html (this clock is really similar
to mine, we just group the digits differently, either one is fine).
Wikipedia has an entry about it here:
http://en.wikipedia.org/wiki/Hexadecimal_time (maybe I should change my
digit grouping?)
 
Don't confuse this method of marking time with other binary clocks.
Often they are using binary coded decimal:
http://en.wikipedia.org/wiki/Binary-coded_decimal
Until recently this clock was an example (they added a "true binary"
switch):
http://www.thinkgeek.com/homeoffice/lights/59e0/

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Fri, 19 Jun 2009 07:36:00 -0700 Intellectual Ventures Lab » Quarter Shrinker http://twopoint718.posterous.com/intellectual-ventures-lab-quarter-shrinker http://twopoint718.posterous.com/intellectual-ventures-lab-quarter-shrinker

Video of the quarter shrinker in action (this is what happens when you magnetically pump 15 KJ into a quarter).

I had heard about such a device while at Fermilab, but it is cool too see one.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Mon, 15 Jun 2009 21:11:26 -0700 EmacsWiki: Paredit Cheatsheet http://twopoint718.posterous.com/emacswiki-paredit-cheatsheet http://twopoint718.posterous.com/emacswiki-paredit-cheatsheet

Wow! Paredit, where have you been all my life? http://mumble.net/~campbell/emacs/paredit.el

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sun, 14 Jun 2009 21:02:43 -0700 Good Lisp Commenting Style http://twopoint718.posterous.com/good-lisp-commenting-style http://twopoint718.posterous.com/good-lisp-commenting-style
Check out this website I found at cc.gatech.edu

Tips on commenting lisp code. I fall into Camp 2, well I try to anyway, my code usually isn't that clear and so I shade into Camp 3.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Thu, 11 Jun 2009 13:24:25 -0700 Morse Code-Leno - Video http://twopoint718.posterous.com/morse-code-leno-video http://twopoint718.posterous.com/morse-code-leno-video

This is an excellent video of a Morse code operator up against a text message sender (do we have a term for this? "emitter?," "textor?"). I won't spoil it, but I now understand how Morse code is a kind of Huffman coding http://en.wikipedia.org/wiki/Huffman_coding (though I don't know if Morse is a prefix code)

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sat, 30 May 2009 17:00:00 -0700 XTerm Colors http://twopoint718.posterous.com/xterm-colors http://twopoint718.posterous.com/xterm-colors

I usually like to use xterm (fast, always available, etc.) but one
issue that's pretty persistent is that the colors, with blue in
particular, are too dark. When I google on this, I'm able to find
instructions on how to change *what* color is being used but not how
to modify what that color is. As an example of what's easy to find:
XTerm*Background: green
This will do as expected and set the background of the XTerm to green,
but it won't help you at all to define what shade that green is. The
setting that I really want is this:
XTerm*color4: blue
Any of the 8 colors (color0 through color7) can be changed like this,
but usually the offender is the above. I think the following looks
pretty good:
XTerm*color4: CornflowerBlue
Here's a great listing of the available colors:
http://mkaz.com/ref/xterm_colors.html

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Sun, 24 May 2009 11:34:00 -0700 Sounds at Cafe Montmartre http://twopoint718.posterous.com/sounds-at-cafe-montmartre http://twopoint718.posterous.com/sounds-at-cafe-montmartre

We went out last night to catch Pezzettino
(http://www.themomo.com/cal/090523.htm and
http://www.myspace.com/pezzettino). You can (sorta) see everyone in
their Lion masks.

See and download the full gallery on posterous

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Fri, 22 May 2009 09:11:00 -0700 dd usage http://twopoint718.posterous.com/dd-usage http://twopoint718.posterous.com/dd-usage

This makes sense now that I think of it, but I had to look around for this:
 
# image a floppy dd if=/dev/fd0 of=floppy.img   # write the image dd of=/dev/fd0 if=floppy.img

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Thu, 21 May 2009 15:19:19 -0700 Slashdot | Sys Admin Magazine Ceases Publication http://twopoint718.posterous.com/slashdot-sys-admin-magazine-ceases-publicatio http://twopoint718.posterous.com/slashdot-sys-admin-magazine-ceases-publicatio

Sys Admin Magazine Ceases Publication

Posted by kdawson on Friday August 24 2007, @06:08PM
from the paper-is-obsolete-anyway dept.
keithl writes "I received a postcard in the mail today informing me that Sys Admin magazine has ceased publication. 'We regret to inform you that the magazine has ceased publication effective with the August 2007 issue.' Only paid subscribers with remaining issues receive this mailing. If you do nothing, they will send you a copy of the Sys Admin archive CD (1992 – August 2007), or you can return the card for a full refund of all unsent issues. The deadline to return the postcard for a refund is October 1, 2007." The magazine's Web site has no word that I could find on the closing down of print publication.

I found an old issue of this today and it was pretty interesting; I just missed it.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Thu, 21 May 2009 08:48:18 -0700 Archive http://twopoint718.posterous.com/archive-26 http://twopoint718.posterous.com/archive-26
Click here to download:
chrisblog.zip (150 KB)

Here's an archive of my previous blog (in case I decide to use this one).

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Wed, 20 May 2009 20:06:21 -0700 Benford's law - Wikipedia, the free encyclopedia http://twopoint718.posterous.com/benfords-law-wikipedia-the-free-encyclopedia http://twopoint718.posterous.com/benfords-law-wikipedia-the-free-encyclopedia

Are all the first digits in numbers that are found in nature equally likely? Nope.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Tue, 19 May 2009 20:49:00 -0700 Clojure Translations (part one?) http://twopoint718.posterous.com/clojure-translations-part-one http://twopoint718.posterous.com/clojure-translations-part-one

This is a simple translation of some Java code into Clojure
(http://clojure.org/). I've tried to make the code idiomatic Clojure
(as far as I know it). I'm looking at the NIO libraries and the
SocketChannel in particular for doing some more intelligent two-way
network code.
 
; translation of the java code at:                                              ; http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/TimeServer.java         ; (original copyright can be found there)                                       (ns com.sencjw.time-server   (:import (java.net Socket ServerSocket InetSocketAddress InetAddress)            (java.nio ByteBuffer CharBuffer)            (java.nio.channels ServerSocketChannel)            (java.nio.charset Charset CharsetEncoder)            (java.util Date))) (set! *warn-on-reflection* true) (defn serv   "Starts a time server on a high (8013 default) port"   ([] (serv 8013))   ([port]      (let [charset (.. Charset (forName "US-ASCII"))            encoder (.newEncoder charset)            buff (.. ByteBuffer (allocateDirect 1024))            ssc (ServerSocketChannel/open)               ; create ServSockChan              addr (InetSocketAddress. port)            _ (.bind (.socket ssc) addr)            sc (.accept ssc)                             ; accept the connection            now (str (Date.))]        (try         (.write sc (.encode encoder (CharBuffer/wrap (str now "\r\n"))))         (println (str (.. sc (socket) (getInetAddress)) ": " now))         (.close sc)         (finally (.close sc)))))) (serv)

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson
Wed, 13 May 2009 14:51:00 -0700 Up All Night http://twopoint718.posterous.com/up-all-night http://twopoint718.posterous.com/up-all-night

I stayed up all night today writing Lisp code. This song was stuck in my head, natch

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/60149/vectorme.jpg http://posterous.com/people/15X0eVLAWyZ Christopher Wilson Christopher Christopher Wilson