Thursday, December 30, 2010

The future is already here – it's just not very evenly distributed. (An open letter to AT&T)

Dear AT&T,

Attached you'll find a picture my wife and I took on a boat traveling through Vietnam's Mekong Delta.  Our abilities with our new camera are admittedly lacking, so it's hard to make out the orange life vests lining the boat's ceiling and green jungle in the background, but then, this is my blog, not a court of law.  The real crux of this photo is the 5 bars you see on my iPhone: I had good reception throughout the Delta -- much, much better than I get in America's second most density populated big city*.
AT&T, I've loved my iPhone these past 2 years, but long for a phone call that doesn't end mid-sentence, and will be thrilled to move to a network that can compete with the 3rd world the moment my contract expires.
  -- kieran

* - These kinds of comparisons hinge on the definition of terms like "big city," of course, but scan through Wikipedia's density stats and look for a city you recognize that isn't NYC.  And if you haven't tried AT&T in San Francisco, don't bother.

Thursday, October 14, 2010

Konichiwa

Hello from Osaka. God knows what's going on with that very uncomfortable rhino up there, but one thing I'll say for Japan: it's dense.

That shot out the window of a train is exurban, far-out Osaka. No sprawl in sight: dense, multi-story housing and ... woods.

Sunday, August 1, 2010

OpenOffice makes me appreciate Firefox' search function.

The search dialog that appears when you hit Command- [or Control-, depending upon OS] F is a bit of UI that's improved greatly but subtly in Firefox: instead of a separate dialog appearing, an embedded interface shows up at the bottom of the page.

This means the dialog location is consistent and predictable, but more importantly, it means that I can always search by hitting Command-F.  Under OpenOffice, Command-F toggles between opening and closing the search dialog; if I was searching for something earlier, I've now CLOSED the dialog rather than opening it.  Very annoying.

Thursday, July 22, 2010

Quick link: shameless self-promotion edition

In the interest of raising the site's Google Pagerank, and as a plug for my wife, who did the site design, here's a link to my sister-in-law's optometry site, Lake Vision Optometry, located in the verdant, exotic lands of Riverside, CA.

Wednesday, July 21, 2010

The Eee, Ubuntu, and Songbird

After years reading about super-cheap Netbooks, I finally picked one up for a friend, though ASUS' Eee PC 1201t skates pretty close to the line separating Netbooks from Notebooks with its 1.6ghz AMD CPU, 12" LED LCD screen and 250G drive.  All for $380!

Don't try to get an OS on the beast, though.  That'll be tough.  After determining that MeeGo doesn't support the Eee's Radeon GPU and finding EasyPeasy kinda clunky, I decided to put Ubuntu 10.04 on it. Unfortunately, Canonical has mostly dropped support for USB installers, and this little machine has no DVD drive, leaving me to pull off bits of cheap Taiwanese plastic until I hit hard-disk.

Now that Ubuntu's loaded, however, I couldn't be happier.  All the hardware -- Wifi card, webcam, everything -- was supported without any tinkering, and Ubuntu looks great.

I do miss iTunes, though.  Songbird (installed via Skyzim's deb) is a gorgeous replacement, so long as you don't want to listen to any w4a files from the iTunes store -- which I do. This thread explains the fix, though it's tough for the command-line-phobic. After installing the various gstreamer libraries, you'll want to open your favorite editor and add one line to /usr/bin/songbird:

export SB_GST_NO_SYSTEM=1

Thursday, July 1, 2010

Quick links: succinct non-English words

Care of reddit, a site devoted to non-English words that don't have a good counterpart. Shadenfreude hasn't appear yet (perhaps it's officially English now?), but drachenfutter has:

Literally translated as dragon’s food.

Drachenfutter are gifts that a husband brings to his wife after pissing her off. It is usually an attempt to avoid her wrath by giving her chocolate, flowers or other small gifts.

Friday, June 11, 2010

On leaking memory like a sieve


I tend to leave browser tabs open for weeks on end, and if it's not entirely clear from the gratuitous screen-grab above, those 19 Google Chrome processes each consume anywhere from 16 to 108M of memory, for a grand total of 577M.

And here I thought Firefox was bad about memory management.

Tuesday, June 1, 2010

Faster than a speeding mushroom


This growth occurred over the course of two days. Moving clockwise from the top left, pictures were taken at: 7pm on Wednesday, 8 am Thursday morning, 11pm Thursday night, and finally 7pm Friday night.

Wednesday, May 26, 2010

Accidental Mycology

This houseplant has been looking unhealthy for a while, but I didn't know it was this bad:
I'm lame enough to post update pictures, so my non-existant readers can look forward to watching these mushrooms grow in near real-time. (PS: Bren should get credit for this one; she noticed the growth and took the picture)

Thursday, May 13, 2010

Quick link: Knoppix on a USB jump-drive

Everyone's favorite bootable Linux CD can be written to a USB simply by running the flash-knoppix command:

  http://www.knopper.net/knoppix/knoppix62-en.html

It worked on an off-brand USB stick, but my SanDisk Cruzer refuses to play along. SanDisk implements their encryption via some weird juju that makes their USB drives very uncooperative; I wouldn't recommend them.

Thursday, May 6, 2010

Banksy?

Bren with a potential Banksy.

(And it seems that blogger strips EXIF tags from uploaded files.  No fun!)

Wednesday, May 5, 2010

Python debugging quickie

I've gotten into the habit of using pdb to interactively debug python code. I'll plug import pdb; pdb.set_trace() into the middle of an uncooperative function in order to examine machine state as the code runs.  (Note that I don't need to full capabilities of a debugger here; I'm not stepping through the code line-by-line.)

iPython is a much better choice, as this posting lays out:
import IPython.Shell; IPython.Shell.IPShellEmbed(argv=[])()

That's all you need to drop out of your function and into an iPython shell. When you're done twisting knobs, ctrl-D will exit iPython and return to your function.

Monday, May 3, 2010

Inchoate musing: what does it mean to own a device?

There's talk that the DoJ is looking into antitrust action against Apple for their recent decree that iPhone / iPad developers only use Apple-approved tools, ie, C/C++/Objective-C under Xcode.

I don't really know how antitrust law works, but it's not clear to me that Apple's move violates it. Microsoft was only prosecuted for bundling IE because they already had a monopoly on desktop OS's; it would be hard to argue that Apple has a smart-phone monopoly.

But I still think Apple's wrong, and government intervention is probably right.

In my mind, this falls under the broader problem of technology companies prescribing some narrow range of approved uses for the products we buy. A pernicious example is the license shipping with every camera that records video as MPEG or h264, which forbids making any money off any video you record with a consumer-grade camera, because that would make your work "professional." So if you've ever uploaded a video to YouTube, you probably violated your license.

I think I'd like to see something like a Gadget Owner's Bill of Rights: if I buy it, I can use it as I see fit. The vendor can eschew support for altered devices, of course, but I can't be legally prevented from modifying the device, and third parties can't be prevented from helping me.  (And let's pass laws to keep the 'Net neutral, while we're at it!)

Only moderately tangential updateReddit links to another great example of the kind of legal machinations that enable device manufacturers to claim excessive control over what you do w/ your device: a 92 page Terms of Service agreement.

Wednesday, March 17, 2010

More Python weirdness

You can almost use Python as a functional language, but ... you run into trouble.  The following code, discovered by Nithin Reddy, will raise an exception:

funs = [lambda i: i + j for j in [1,2,3,4,5]]
del j
funs[0](1)


The issue is that lambda, which executes in the context of the lambda call rather than the lambda creation. Using a proper def won't work either -- the following code fails in precisely the same way:
funs = []
for j in [1,2,3,4,5]:
  def f(a): return a + j
  funs.append(f)
del j
funs[0](1)



The fix is to curry your function:

def partial(f, *args, **kwargs):
  def bound_f(*args2, **kwargs2):
    x = kwargs.copy()
    x.update(kwargs2)
    return f(*(args + args2), **x)
  return bound_f

import operator
funs = [partial(operator.add,j) for j in [1,2,3,4,5]]
del j
funs[0](1)


I'm not quite sure what to make of this. Is function context bound on return?

Wednesday, March 10, 2010

Too many options

The autocomplete module that comes with jQuery UI is not the same as the jQuery Autocomplete plugin. Totally different interface.  Using the documentation for one while running the other will not make for an enjoyable afternoon.

jQueryUI comes with all manner of functionality beyond autocomplete, so that'd be my recommendation.

Friday, March 5, 2010

Write once, read many

Nice: the PEDANT database contains the output of many common genome annotation tools against 3,000 complete genomes, notably including the human genome. I've been looking for the results of running, say, TMHMM against every human gene.

(For more, see the paper: PEDANT covers all complete RefSeq genomes.)

Monday, February 15, 2010

Tiny, neat Django trick

In SQL, you can retrieve a list of records via the "IN" syntax:


   SELECT * FROM mytable WHERE id IN (1,2,3,4,5,6);

Django supports near-identical syntax:


   MyTableModel.objects.filter(id__in=[1,2,3,4,5,6])

nice!

Saturday, February 13, 2010

Happiness

Small bit of Scientology bashing: Is it possible to be happy?

Thursday, February 11, 2010

Screen recordings under Snow Leopard (OS X 10.6)

For all your software demo needs: Snow Leopard will create screen recordings out of the box.

Just run Quicktime, go to File -> "New Screen Recording."

(Thanks to Nithin Reddy for the heads-up)

Animal adjectives

That I found this on a site called "PubQuizHelp" seems appropriate enough. You probably know that "simian" refers to all things monkey-related--hence the adjective's popularity during the Bush administration--and you may have heard that "ursine" is the word for all things bear ... but did you know that calling someone "lapine" likens them to a rabbit?

Very useful stuff.

Friday, January 29, 2010

jQuery 1.4

The jQuery Javascript library, without which cross-browser Javascript development is unthinkable, has reached version 1.4.1.

Particularly useful is the ability to create new DOM elements. (See this brief discussion, though no anchor link means you'll have to search for "Quick Element Construction.")

What those docs overlook is the .text property, which enables you to create a proper element:

$("#foo").append( jQuery("<div>", {
id: "foo",
text: "I'm a new DIV element",
click: function() {
$(this).css("backgroundColor", "red");
}}));


or even create a nested elements via .html:
$("#foo").append( jQuery("<select>", {html: "<option value='1'>One</option>"}) );

Sunday, January 24, 2010

The Great Pacific Garbage Patch, local edition

This week's massive storm system seems to have washed up a small taste of the Great Pacific Garbage Patch:


We're doomed.

Thursday, January 21, 2010

Multi-line strings

Javascript doesn't have multi-line strings, but offers a variety of hacks ranging from concatination ("line 1\n"
+"def")
to the CDATA hack, but as always, your milage will vary depending upon your browser.

Python has dedicated multi-line string denominators, namely the triple-quote -- """ and '''. Quite workable, but not as elegant as simply allowing newlines in a string.

C and shell have the backslash:

char * s = "line 1\n\
line 2";

Haskell extends that to the double-backslash:

s = "line 1\n\
\line 2"


PHP, in a rare moment of elegance and usability, treats a newline in a string as a newline.

$s = "line 1
line 2";


Now why is that so hard?

Update: Jake is right: C-style backslashes work in Javascript (at least on Firefox).

Friday, January 8, 2010

stackoverflow.com, in which we circumvent Django's template system

The whole separate-code-from-presentation imperative that inspired Django's template system ... let's say I have my doubts. From my experience, Django's particular approach to templates diverts much too much of my attention to circumventing its limitations.

Update:

In response to Jake's observation that "variables should always be set in the view, not the template," in general, I agree.

But the specific counter-example I'll supply is the very common title example. Let's say you'd like to create a base template like so:

<head><title>{% block title %}</title></head>
<body>
<h1>{% block title %}</h1>
...


And then you inherit from that template:

{% block title %}User Feedback{% endblock %}

This is a very simple, commonplace scenario, and it's simply unsupported. Django will error out on the second call to {% block title %}, and I think that's dumb.

Monday, January 4, 2010

Python's Zipfile library

So you want to generate a big bundle of files all at once, and send 'em in one convenient package? Python's ZipFile library to the rescue! You can create each file, write it to a zip, then send the whole mess over the wire without ever touching the disk! (StringIO is pretty essential as well.)

Ahh, but wait: anyone unzipping your files will find each file marked unreadable/unwritable/unexecutable. And the Python ZipFile docs have zilch to say about it.

This turns out to be the requisite incantation, care of Stackoverflow:

info = zipfile.ZipInfo(name)
info.external_attr = 0777 << 16
zip.writestr(info, bytes)

Obvious, no? Of COURSE you need to bitshift the permissions by 16! (File perms clearly occupy the first 16b of an int, which might even be the standard on Unix, but that doesn't excuse the Python docs' utter silence on the matter.)