GIGO: words unreadable aloud
any item with some pictures or links to pictures should go into this category
 

 

  Tuesday 5 June 2007
Heisenberg's Video Principle

The observer affects the observed. It's much easier to get unobtrusive candid still photos than videos.
11:54:17 PM   comment/     


  Wednesday 9 May 2007
Condors in Big Sur

Condor image from wikipedia

[image source]

Since it hadn't been affecting my life much, I had sorta lost track of how well the California Condor reintroduction program was going. But Deborah and I were in Big Sur last Saturday, having breakfast at Cafe Kevah (at Nepenthe), and watching the red-tailed hawks and turkey vultures soar in the updrafts just south of us. And then one of the big birds flew straight toward the open deck, passing only about 30 or 40 feet above us. Although it was at least turkey-vulture sized, I had just about become sure that it wasn't a turkey vulture — the dark/light pattern on its wings was reversed fore-and-aft from the t.v.'s pattern, and less distinctly black-and-white — and was admiring the long finger-feathers at the ends of the wings, when someone elsewhere on the patio said "Condor".

Wow.

Here are some related Condor links:



11:55:59 PM   comment/     

  Thursday 12 April 2007
Python Snippets for the BayPIGgies

Point Lobos Piggie Sign I contributed a comment (about Ruby's "Array#flatten" method) in a mailing list thread about python code snippets, and as a result I was asked to present some python snippets at tonight's meeting of the (SF) Bay Area Python Interest Group. So I picked four little bits of code. The code itself is at http://got.net/~landauer/sw/snippets/dl_snippets.tgz , or as separate python sources in that directory.


1. Invert Color

This snippet is a whole command-line command; it takes a string representing a (hex) html color value, and prints out its bitwise inverse (one's complement). It's non-scientific and pretty much unrelated to any optical notion of color complements. Inspired by a ruby version at http://www.bigbold.com/snippets/posts/show/582 . There are only two bits of note here:
  1. The join/map/lambda thing expands a three-hex-digit string into a six-digit string, by replicating each digit.
  2. I thought of using the unary "~" complement operator, but it turns on too many other bits.

def invert_color (color):
    if color[0] == '#':
        color = color[1:]
    if len(color) == 3:
        color = ''.join( map( lambda m,n: m+n, color, color ) )
    return "#%06X" % (int(color, 16) ^ 0xFFFFFF)
#
import sys
for a in sys.argv[1:]:
    print invert_color(a)


2. Undent (aka "margin")


Point Lobos China Cove Arch This function "undent" is nice to have in a utility library. It allows you to use nice source-relative indentation in triple-quoted strings, and it will strip off the extra indentation.

I posted this snippet of code on the BayPIGgies list in February (2007). It was inspired by Hal Fulton's "margin" method from his Ruby book The Ruby Way. This does its work at runtime, and isn't as strict as the similar recipe that's in the Python cookbook. It's short (just four lines of meat) and a bit easier to use (less cluttered-looking at usage site) than other, more efficient compile-time versions.

The code is very straightforward except for maybe the "rstrip" -- that removes the last line (of spaces and a newline).

import re
undent_pat = re.compile( r"^\s*\S(.*)$", re.M  )
def undent (str):
     return undent_pat.sub( r'\1', str.rstrip() )
#######################################
# Usage Example:
#
def getCustomerInfo(cust_id):
     sql  = undent( '''\
             |select customers.id as %s,
             |        sum(invoices.amount) as amount_total,
             |        blah as blah
             |   from customer 
             |   etc...
             ''')
     return sql % cust_id
print getCustomerInfo( '2345' )

Update: At the meeting, Drew pointed out that the standard library module "textwrap" has, since version 2.3, had a "dedent" function which does something similar (i.e., dedent does what the abovementioned cookbook recipe does).


3. My time/date stamp

See my "GIGO beH" posting for details. This command prints out my time/date stamp. No tricky code here.
import datetime
from string import digits as d, lowercase as lc, uppercase as uc
dom= '!' + d[1:] + uc[4:]      # Used for day of month
hms= d + uc + lc               # Used for mins, seconds.
now = datetime.datetime.now()
date_code= lc[ now.year - 2001 ] + lc[ now.month-1 ] + dom[ now.day ]
time_code= hms[ now.hour + 10 ] + hms[ now.minute ] +  hms[ now.second ]
print date_code + '_' + time_code

4. "flatten"

Because the flatten method was the subject of my contribution in the abovementioned email thread that got me into this trouble in the first place, I guess I ought to snip a bit of that here. This is a very minor tweak to Alex Martelli's cookbook version. Slightly shorter, probably slightly less clear, but I get to include a "no_can_do" function:
def can_do ( fn, exc = Exception ):
    try:          fn()
    except exc:   return 0
    else:         return 1
#
def no_can_do ( fn ):
    return not can_do( fn )
#
def isScalar(obj):
    return (    can_do( lambda: obj+'', TypeError ) or
             no_can_do( lambda: iter(obj) ) )
#
def flatten(sequence, scalarp=isScalar):
    for item in sequence:
        if scalarp(item):
            yield item
        else:
            for subitem in flatten(item, scalarp):
                yield subitem 



Finally, for no good reason, here's a link to the rest of those Point Lobos pix.
12:52:53 AM   comment/     

  Sunday 8 April 2007
A few days in Avalon

I spent much of last week on vacation on Catalina, in Avalon. We stayed at the Inn on Mt Ada (formerly Wrigley's mansion), above Avalon. It was a wonderful respite from the nonstop startup pace I've been sustaining for the past couple of years.

Bison, standing on the beach (scanned postcard)

We drove down south Monday after work, and stayed in a doubletree hotel in Carson. Most notable thing was that they had a poster of Winslow Homer's "Breezin' Up", which is a painting my Mom has a copy of on her wall. I may well not have noticed that except that I had snagged a .jpg of that painting, and included in a set of slides I made for her a couple of weeks ago, which I'll try to put up somewhere near here some day soon.

Tuesday AM was hectic getting to the boat (freeways stopped up, and the Catalina Landing exit was closed), but the ride over was the smoothest I've ever experienced. We slept most of Tuesday, took the bus tour up to the airport on Wednesday, and the Casino tour on Thursday.

The tour guides will tell you that Avalon is a city of contradictions -- Beach Bison; flying fish; swimming birds; a casino with no gambling; a mausoleum where no body was kept; a bird park with no birds; a city with a 3rd street, but no 1st, 2nd, or 4th (and 3rd Street is actually the second street from the beach); etc.

The Inn loans you the use of a golf cart for the duration of your stay. I drove it around much of town. Other folks in town have some pretty amusingly customized carts.

Fun trip.

11:56:53 PM   comment/     


  Sunday 1 April 2007
My parents around 1965

A few days ago, I linked to Dick Oakes' Aman Folk Ensemble pages. They include links to a couple of photo galleries, but most of the photos are low resolution shots of groups of dancers, so I didn't really inspect them in much detail. So imagine my delight when I noticed the bottom of page 4 of Tony Shay's photos — a close-up of my parents, singing together.

Strikes me as being somewhat like a nice metaphor for their 58 years together! (Note: the date of this posting date is completely coincidental. No fooling.)
3:24:11 PM   comment/     


  Wednesday 7 March 2007
Sentence of the day

On my way in to work this morning, I heard part of prosecutor Patrick Fitzgerald's press conference about the verdict in the Scooter Libby trial. I found one sentence he said to be somewhat amusing. A while after he makes statements like "we don't talk about anyone not on trial" and "I'm not gonna comment on things that have not happened", some reporter persists with questions about a possible appeal. Fitzgerald's response (about 40 seconds into the "part 2" youtube clip) was

"Out of respect for the appellate process, we're not going to predict how three judges who have not been selected will rule on an appeal not yet filed based upon arguments not yet made."
I just thought it was a nicely crafted amusing response to that kind of persistence.

Here are youtube links to the two parts of the press conference:

Here, I try embedding part 2 ...



12:11:35 AM   comment/     


  Friday 9 February 2007
Home Sunset

2002 sunset, home in ben lomond Now that I'm on a roll, aiming (apparently) to break my posting-days-in-a-row record (don't worry, it's only in the low thirties), I look at my referrer stats once in a while. They're dominated by google searches for various nicknames from various cities, due to my city nicknames page.

But I kept seeing this one home sunset photo that I shot in 2002 showing up. Weird, why would this nice but relatively obscure picture, that I hadn't really thought about for years, be referenced, on average, once or twice a day via google image search? The question didn't bubble up to being interesting enough to pursue until today. So ... I ran the google image search for home sunset. Whaddaya know, that shot is (currently) the first result shown. An inadvertent case of SEO, I guess.

12:22:15 AM   comment/     



Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/6/5; 23:54:48 .
Click here to send an email to the editor of this weblog.

June 2007
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
May   Jul

Previous/Next