Home

Advertisement

Customize
The Geek Parade Below are the 20 most recent journal entries recorded in the "uncle_toby" journal:

[<< Previous 20 entries]

November 4th, 2008
09:57 am

[Link]

On today, the high holy day of, err, democracy

not me: I voted absentee. And you?

Current Location: home with the kit-kits

(1 comment | Leave a comment)

September 13th, 2008
10:49 pm

[Link]

David Foster Wallace is dead at 46
Wallace apparently committed suicide, sez the Times. Man, he's basically my age, though, ah, spectacularly more productive. Infinite Jest isn't one of my favorite novels, but it's certainly one of the books that's shaped how I understand wit. Someone who wrote novels as dark as Wallace's could have had a pretty dark vision of his own.

Anyone for a quick game of Eschaton?

Resquiat in pace, David. I'll read your books again and with a new eye.

Current Location: home with the kit-kits
Current Mood: grieving
Current Music: Simon and Garfunkle, "Kodachrome"

(1 comment | Leave a comment)

September 1st, 2008
12:00 pm

[Link]

so true
cat


Am I part of an excluded segment of society?

Current Location: home with the kit-kits
Current Mood: excluded
Current Music: "Cowboys," Portishead

(1 comment | Leave a comment)

August 26th, 2008
03:56 pm

[Link]

savagery


If your life feels like this, I understand. This is the refugee camp where stuffed mice are protected from the grasping razor-sharp kitteh claws by a few inches. But the kittehs are growing as fast as their stomachs can turn $4/lb cat food into kitteh poo. Growth is not good for refugee stuffed mice.

Current Location: heading back to work
Current Mood: tired
Current Music: "E-boy the letter," REM

(Leave a comment)

August 24th, 2008
03:15 pm

[Link]

goatse, disney, and Rick.
I think it's very funny that in a Digg post showing Disney pix that imply the goatse horror is commented upon by a RickRolling. As a meta-commenter said, "goatse was the original, slightly more vicious Rick Roll." Each generation has to re-invent sex, drugs, and apparently goatse.

Current Location: home with the kit-kits
Current Mood: amused
Current Music: "Buckets of Rain," Bob Dylan

(Leave a comment)

August 21st, 2008
10:57 pm

[Link]

paper clips and duck (sic) tape
This is relevant to TextMate users, not so much to others. Let's say you're writing some code, and it ends up looking like this:

# $Id:$
# this is the first line. this should be wrapped to the line above.
#
# This is a second paragraph that should be wrapped into some number
# of additional, I mean to say, extra lines.
#
# 1. First, we should wrap this line to somplace under the 'F' in First.
# 2. But this line is separate, and should begin a new odyssey of wrapping, wrappage?
# Either way, here in number two there's a lot to be said, and a lot to wrap.
# Really.
# 3. And one more.
# 3a. this is a long subpoint. These may not happen very often, but when they do, they can be very important.
# 3b. Other subpoints are short.
# 4. and so it goes.
#
# - First, we should wrap this line to somplace under the 'F' in First.
# - But this line is separate, and should begin a new odyssey of wrapping, wrappage?
# Either way, here in number two there's a lot to be said, and a lot to wrap.
# Really.
# - And one more.
# -- this is a long subpoint. These may not happen very often, but when they do, they can be very important.
# -- Other subpoints are short.
# - and so it goes.

very_important_function_immediately_below_comment()
self_version = "$Rev$"

# important whitespace above and below!

my_func <- function(x) {
# Here is an indented comment. Like its friends, it goes on for a long
# time, and it
# has some wrapping issues.
1 == 1
}


What a mess -- very hard to read. TextMate's reformat command (^Q) will make it worse because it's not very smart about what a comment looks like. In emacs, you can load filladapt.el (see below) and with a quick M-q, get this:

#!/usr/bin/env R
# $Id:$
# this is the first line. this should be wrapped to the line above.
#
# This is a second paragraph that should be wrapped into some number
# of additional, I mean to say, extra lines.
#
# 1. First, we should wrap this line to somplace under the 'F' in
# First.
# 2. But this line is separate, and should begin a new odyssey of
# wrapping, wrappage? Either way, here in number two there's a
# lot to be said, and a lot to wrap. Really.
# 3. And one more.
# 3a. this is a long subpoint. These may not happen very often,
# but when they do, they can be very important.
# 3b. Other subpoints are short.
# 4. and so it goes.
#
# - First, we should wrap this line to somplace under the 'F' in
# First.
# - But this line is separate, and should begin a new odyssey of
# wrapping, wrappage? Either way, here in number two there's a lot
# to be said, and a lot to wrap. Really.
# - And one more.
# -- this is a long subpoint. These may not happen very often,
# but when they do, they can be very important.
# -- Other subpoints are short.
# - and so it goes.
very_important_function_immediately_below_comment()
self_version = "$Rev$"

# important whitespace above and below!

def my_func(x):
# Here is an indented comment. Like its friends, it goes on for a
# long time, and it has some wrapping issues.
1 == 1
}

This functionality was really important for me in emacs, and TextMate has nothing like it (as far as I can tell). There's a solution, though: use emacs, as <http://gragusa.wordpress.com/2007/11/11/textmate-emacs-like-indentation-for-r-files/>this guy</a> demonstrated. (this might be obvious to someone deep in unix think: if you like what a tool does, can you coerce the tool to do that thing in your context?) The code below works with a easily configured TextMate bundle to push a comment in a file you're editing with TextMate out to emacs as a filter to reformat the comment, then paste it back into the document.

Go to Bundles -> Bundle Editor, create a new bundle, then create a command in that bundle. Paste the code below into the text box. This code is a simple python program that gets the comment in and out of TM and emacs. Then set the drop downs as shown in the screenshot.




For this to work, you need to have emacs available (the default version in OSX is good), and you need filladapt.el on your emacs search path; get it from the emacs wiki. If you have a directory at $HOME/emacs, put filladapt.el in it.

The python code below is pretty hacky, but there are reasons for some of it. The first is that I wrote this in about an hour and a half, and I haven't cleaned it up much. Furthermore, R's language definition isn't smart enough to recognize multi-line comments, so you can't use the Bundle's tool to export the scope to stdin. The only way to grab the comment is to dig it out of the file. Bug & style fixes most welcome.

#!/usr/bin/env python
import sys, os, collections, copy
from tempfile import mkstemp
from commands import getstatusoutput

elisp_snippet = """
(find-file "%s")
(push (expand-file-name "~/emacs") load-path)
(require 'filladapt)
(filladapt-mode)
(fill-region (point-min) (point-max))
(save-buffer)

"""

def get_data():
# yick. this could be a regexp (\n[^#])*(\n\s*#)+(\n[^#])*
fulltxt = [line.rstrip() for line in sys.stdin.readlines()]
line_ptr = int(os.environ['TM_LINE_NUMBER'])-1
comment = collections.deque()
comment.append(fulltxt[line_ptr])
start = sys.maxint
stop = sys.maxint
# migrate up, then down to get the rest of the comment.
for i in range(line_ptr-1, -1, -1):
line = fulltxt[i].strip()
if not line.startswith('#') or i==0:
start = i
break
comment.appendleft(fulltxt[i].rstrip())
for i in range(line_ptr+1, len(fulltxt)):
line = fulltxt[i].strip()
if not line.startswith('#'):
stop = i
break
comment.append(fulltxt[i].rstrip())
return fulltxt, comment, start, stop

def dump_lines(file_h, contents):
file_h.write('\n'.join(line.rstrip() for line in contents))
file_h.write('\n')
file_h.close()

file_contents, comment, start, stop = get_data()
file_contents = list(file_contents)

data, data_name = mkstemp()
data = file(data_name, 'w')
last_lineno = stop+1
comment_lines = copy.deepcopy(file_contents[start:stop])
dump_lines(file(data_name, 'w'), comment_lines)

# yick! this should be piped via stdin
elisp, elisp_name = mkstemp('.el')
elisp_lines = [";; comment in file lines %i - %i" % (start, stop)] \
+ (elisp_snippet % data_name).splitlines()
dump_lines(file(elisp_name, 'w'), elisp_lines)


# execute emacs: here's where the work is done. note ONE hyphen in option.
# this runs ok from the cmd line but not from here. Interesting.
#status, output = getstatusoutput(
# 'echo "%s" | emacs -Q -script - ' % elisp_snippet)
status, output = getstatusoutput('emacs -Q -script %s ' % elisp_name)
if status !=0:
print "emacs crashed: return code=%s, dying. cmd-Z to get back." % status
raise AssertionError

reformatted_comment = [line.rstrip() for line in file(data_name, 'r').readlines()]
file_contents = file_contents[:start] + reformatted_comment + file_contents[stop:]
print '\n'.join(file_contents)
os.remove(elisp_name)
os.remove(data_name)

There are a lot of things emacs can do to source that we might want to call from TextMate.

I've put reformat on ^Z (don't forget the ^ key under your right hand), but you can put it on any keystroke TextMate can capture. Onward into history with more succinct, better formatted, and more informative comments!

(ok, what's the html for "don't collapse the whitespace" for my code example above? And livejournal ate my my screenshot, which it's never done before. Thanks)

Current Location: home with the kit-kits
Current Mood: pleased
Current Music: "Outlands," The Orb

(Leave a comment)

August 19th, 2008
12:09 am

[Link]

I think reality is slipping away

Using Photographs to Enhance Videos of a Static Scene from pro on Vimeo.

You take crappy video and a few high-res digital pix. This software mixes the photo detail & exposure into the video, creating scarily great video. Whoa.

Current Location: home with the kit-kits
Current Mood: busy
Current Music: "Ten Men," Morcheeba

(Leave a comment)

August 18th, 2008
10:12 pm

[Link]

noisy little kittehs
The very nice downstairs neighbor knocked on my door this evening: the building doesn't allow you to keep wildebeest in your apartment, he told me. They're little and their paws are soft, but the kittehs are very noise-creating when they've got the friskies.

But then they look like this:

Which is good, because otherwise shit like this would make me insane: At JFK Airport, Denying Basic Rights Is Just Another Day at the Office. The other day I was talking to an otherwise sane Truther. He told me that there's going to be some sort of Reichstag-fire incident in October, which the Bushies will use to keep themselves in power. Nah, I replied, there aren't enough National Guardsmen and cops who would enforce a coup attempt. Then I read this story about the Homeland "Security" people, and it just gets a little easier to buy into the paranoid delusion.

(btw, I call a Godwin point on myself)

Current Location: home with the kit-kits
Current Mood: busy
Current Music: "Feast of the Passover," The Congos

(Leave a comment)

August 5th, 2008
01:23 am

[Link]

pix of piglandia & kittehs
Here's where I spend most of my waking hours:


The battle for alfa-kitteh shakes the heavens, or at least annoys the downstairs neighbors:


They keep Stanyan Street under close patrol:

Current Location: home with the kit-kits
Current Mood: mellow
Current Music: "Haze," Aes Dana

(Leave a comment)

August 2nd, 2008
03:28 pm

[Link]

baby's got game
As humans, we have many reasons to be glad we're not field mice. Wunnie and Zirrz provide me with daily reminders.



Current Location: home with the kit-kits
Current Mood: okay
Current Music: "Workingman's Blues #2," Bob Dylan

(Leave a comment)

August 1st, 2008
08:00 pm

[Link]

US Customs and ICE can search your laptop
Unbelievable:

"Federal agents may take a traveler's laptop or other electronic device to an off-site location for an unspecified period of time without any suspicion of wrongdoing, as part of border search policies the Department of Homeland Security recently disclosed."

You're kidding, right? Nope, no suspicion of wrongdoing is needed. Not reasonable doubt, not probable cause, not even reasonable suspicion. Nothing except the vague whims of the barely-literate apes who staff our borders. I entered the US eleven times in 2007, and I went into secondary zero times. Lessee, I'm a middle-aged, middle-class white guy with a thick passport -- I wonder who they're so eager to grab:

Here's Michael Chertoff, Homeland Security Secretary for 171 more days: "the most dangerous contraband is often contained in laptop computers or other electronic devices." (in the same WaPo story linked above)

Scary talk and kiddie porn, that's what he means. How can these people possibly believe this makes sense under what's left of the Fourth Amendment?

Current Location: home with the kit-kits
Current Mood: frustrated
Current Music: "The Guns of Brixton," The Clash

(Leave a comment)

06:00 pm

[Link]

nothin' like Stoopid with a badge and a gun
Wow, ABC News actually got this one pretty close to right: Pot dealer's tragic choice ends in death. A more accurate title would be "Incompetent cops manipulate girl into situation where she's murdered." But be that as it may, the story doesn't really pull punches. The asshole apologizing for the cops is Dennis Jones, Tallahassee Chief of Police, (850)891-4341, should you wish to express your opinion.

Today a grand jury indicted the two guys who probably killed her. "The Grand Jury also said that 'negligent conduct' by the Tallahassee Police Department and the Drug Enforcement Agency contributed to the death of Rachel Hoffman."

There were many, many things wrong with how the Tallahassee cops handled this situation. However, the most obvious and fundamental error was in persecuting someone whose "crime" was selling small amounts of cannabis to her friends. Interesting choice of "crime fighting" priorities for a city that has a rate of forcible rape 2.5x the national level. And persecuting marijuana users is perhaps not in Chief Jones' best interest, if he ever gets colon cancer.

Assholes.

Current Location: home with the kit-kits
Current Mood: enraged

(Leave a comment)

July 30th, 2008
12:43 am

[Link]

ready for vogue?
haz to ware collar for 3 moar dayz.

Current Location: home with the kit-kits
Current Mood: nurturing
Current Music: "I am Thou, I am Peace," Snatam Kaur

(Leave a comment)

July 29th, 2008
09:36 pm

[Link]

mass murderer is a right-wing nut? really?
"Jim Adkisson, the 58 year old man being held in a Knoxville, Tennessee jail on murder charges stemming from a shooting during a children's musical at the Tennessee Valley Unitarian Universalist Church on Sunday, is said to have had a array of right-wing political books in his home, along with brass knuckles, empty shotgun shell boxes, and a handgun discovered by police who searched his home."

This we learn at Raw Story. I'm sure we'll hear howls of denial from Bill O'Reilly, Michael Savage, and Sean Hannity -- whose books were found, copiously annotated, in Adkisson's house -- about how their hate speech is unrelated to this killing. Um, no. Why did this pathetic, bitter, unemployed man turn his anger on liberals? Because that's what the Right does: blame liberals for the terrible but predictable outcomes of their harebrained and hateful political schemes.

Let me be clear -- assholes like these guys should have the right to say anything they want, however revolting it is. However, it seems to me that they should be morally compelled to take responsibility for what this man has done essentially in their name. An apology, perhaps? Maybe a bit of public reflection on the relationship of their statements to the killer's writings?

Imagine how the Right would react if a nutcase shot up a church, and the cops then found books by Eric Alterman, Barbara Ehrenreich, and Barack Obama in his house?

Current Location: home with the kit-kits
Current Mood: disgusted
Current Music: "The Sea," Morcheeba

(Leave a comment)

July 26th, 2008
10:00 pm

[Link]

a really nice thing just happened
I've been honored by two kittens who've agreed to live with me in my new apartment.






The white one with orange and brown markings is called Zirrz (short for Zero), the other is Wunnie (short for One). Hacking at home just got spectacularly better.

A wave of the paw to the Berkeley/East Bay Humane Society: these guys rawk. These kittens are amazingly people-centered and affectionate. Some of that is luck, but more of it is that they were very, very well fostered. I'd like to meet the people who did it and hear about the experience.

Current Location: home, at last
Current Mood: nurturing
Current Music: "Rapt: in the Evening Air," The Art of Noise

(1 comment | Leave a comment)

July 3rd, 2008
02:56 pm

[Link]

dsl and my apartment
I love Speakeasy DSL. They tell the truth, they don't mess around with your connection, they treat you like a valued customer -- quite the opposite of AT&T who has consistently treated me like a victim in their clutches. But it's going to be 2-3 weeks before the service is activated. Yick: how can I feel at home without connectivity?

Anyway, I can tether my Treo, as I've discussed before. It's slower than DSL, it drops occasionally, but it will do svn up and get my mail. I had a little trouble with OSX: Verizon told me that they don't support the Palm 700p and Mac. It's not that big a deal, though: MacNerd explains all.

(2 comments | Leave a comment)

June 29th, 2008
10:45 pm

[Link]

I'm voting Republican
so that my little Caitlyn can be in a classroom with at least 30 other children. That way she can be challenged by fighting for attention.


because:
we need more minorities in prison.
I just don't feel that I deserve health insurance.
sometimes the Constitution is one big pain in the ass.

(Leave a comment)

June 28th, 2008
08:55 pm

[Link]

R performance: linux v mac
A newly-converted-to-mac friend of mine complained to me that an R script computing numeric solutions to 10k integrals is much slower on his new Mac than it was on Windows. Part of his problem, as he admits, is that the new Mac is a 1.6GHz CoreDuo MacAir while the old Dell is a 2.8GHz P4. It seems that the dual cores don't do that much good for R, even with Apple's highly optimized vecLib.

There's some good benchmarking on how the OSX kernel behaves relative to linux, and more good benchmarking about how R performs using different versions of the Basic Linear Algebra Stuff (BLAS -- ok I made up the last word).

There are various BLAS libraries, in addition to the standard one that ships with R and the Apple vecLib. The best of the lot is written by Dr Kazushige Goto at UT-Austin. The R folks make it easy to test different BLAS implementations (scroll down to section A.3.1.5).

This post is lame benchmarking. I ran the following snippet 3x in various combinations of operating systems, hardware, and BLAS libraries.

str <- rep("foo", 10000)
coco<-matrix(rnorm(1000000),1000,1000)

system.time(for(i in 1:1000) nchar(str))
system.time(for(i in 1:100) x <- rnorm(5e5))
system.time(x <- as.Date(rep("01-01-2005", 100000), format = "%m-%d-%Y"))
system.time(coco2<-eigen(coco))

The combinations I used are below:

Mac OSX 10.5.2, 2.4 GHz CoreDuo, 4Gb 667 MHz SDRAM;
[a] R 2.6.2 (2008-02-08) with Goto blas
[b] R 2.6.2 (2008-02-08) with Apple vecLib blas
[e] R version 2.7.1 (2008-06-23)* with Goto blas
[g] R version 2.7.1 (2008-06-23)* with standard blas
[h] R version 2.7.1 (2008-06-23)* with vecLib blas
[i] R version 2.7.1 (2008-06-23)+ with vecLib blas
[j] R version 2.7.1 (2008-06-23)+ with Goto blas

Ubuntu Linux 2.6.22-14-generic SMP, 2.6 GHz Athlon 64,
[c] R version 2.5.1 (2007-06-27)+ [run 3x, min times below], standard blas
[d] R version 2.7.1 (2008-06-23)* [run 3x, min times below], standard blas
[e] R version 2.7.1 (2008-06-23)* [run 3x, min times below], Goto blas

* = my compile
+ = CRAN binary

And these are the results:

rep 1000 100 1000000 1
fun nchar(str) rnorm(5e5) as.Date(... eigen(coco)
[a] 0.88 0.05 0.93 | 7.49 0.42 7.971 | 4.71 0.03 4.78 | 5.67 0.20 5.99
[b] 0.88 0.05 0.95 | 7.49 0.39 7.936 | 4.81 0.02 4.90 | 6.74 0.82 6.56
[f] 0.96 0.04 1.02 | 8.58 0.40 9.200 | 4.76 0.01 4.81 | 5.72 0.17 6.00
[g] 0.95 0.05 1.05 | 8.59 0.43 9.204 | 4.76 0.01 4.81 | 12.60 0.19 13.05
[h] 0.95 0.05 1.04 | 8.59 0.44 9.164 | 4.75 0.03 4.90 | 6.77 0.82 6.58
[i] 0.93 0.04 0.97 | 7.48 0.40 8.036 | 4.70 0.03 4.77 | 6.81 0.83 6.43
[j] 0.92 0.04 0.98 | 7.48 0.39 8.043 | 4.72 0.01 4.77 | 5.74 0.16 5.97

[c] 0.21 0.02 0.23 |11.94 0.30 12.261 | 0.22 0.08 0.30 | 16.98 0.14 17.19
[d] 1.69 0.02 1.72 |14.88 0.48 15.395 | 1.85 4.72 6.59 | 16.08 0.16 16.27
[e] 1.81 0.02 1.84 |15.19 0.40 15.609 | 1.85 4.27 6.13 | 8.35 0.15 8.51

The table doesn't look very nice and I don't want to make it html. Anyway, the results are strange but apparently consistent: R version 2.7 is slightly slower than 2.5; Goto is faster than vecLib which is faster than R's blas; there are unknown tunings that make CRAN's binaries faster than stuff I compile by hand; and it seems that the Mac is faster than Linux in the mathematical transformations but Linux is faster in the string manipulations.

Take these results with a gigantic grain of salt: the machines are different, little compile tweaks could affect all sorts of things. There's an optimized LAPACK library also built into the Linux 2.5.1 version, but that doesn't explain the radically better nchar result. Could be linking against Doug Lea's malloc? Shouldn't be, since the nchar() call is so tiny it wouldn't be triggering a malloc on any platform.

So, the main conclusion is: use Goto's blas. Here's how I did it. Get his tarball from the page above, and unpack it in /usr/local/src; make && make install && cd exports && make dyn. The resulting file is libgoto_core2-r1.26.dylib: this is your new BLAS library.

Go over to /Library/Frameworks/R.framework/Versions/2.x/Resources/lib (where the x is 5, 6, or 7, depending on your version of R). Copy libgoto_core2-r1.26.dylib here, and make a symbolic link ln -s libgoto_core2-r1.26.dylib libRblas.dylib.

Note: if there is already a file called libRblas.dylib, you should move it to a new name so your symlink doesn't overwrite it. That's the native R blas, which is essentially useless. Changing to the Goto blas takes <5 minutes, and decreases matrix manipulation times by about 15%, but YMMV.

(Leave a comment)

June 26th, 2008
10:51 am

[Link]

numerological reflections
with my recent birthday, my age is now evenly divisible only by itself and one. I suppose that means I'm in the prime of my life.

(Leave a comment)

June 23rd, 2008
01:03 pm

[Link]

My new apartment
is in San Francisco, but nonetheless, this image is, to a first approximation, where I now live:

cat

(2 comments | Leave a comment)

[<< Previous 20 entries]

Powered by LiveJournal.com

Advertisement

Customize