Dave's Blog

Search
My timeline on Mastodon

Off to Germany

2008 Nov 28, 1:27

Sarah and I are off to Munich tomorrow. I was about to lose a lot of vacation time if I didn't use it so its good timing and it will be nice to get away from work for a bit. I've made a map of some of the places I'd like to visit. Prost!

PermalinkCommentsgermany personal vacation

Munchner Verkehrs- und Tarifverbund - Information

2008 Nov 25, 6:03Munich's metro site includes a great journey planner.PermalinkCommentsgermany travel munich metro subway train bus

"Ever since I started working with Motorola" - Google Search

2008 Nov 25, 2:48PermalinkCommentsvia:boingboing.comments marketing advertising motoral phone cellphone viral-marketing

Anna Garforth / ABE

2008 Nov 24, 8:12Graffiti done with moss.PermalinkCommentsgraffiti ecology art cultural-disobediance moss

H5

2008 Nov 23, 9:34The folks who made the awesome inforgraphic music video for Royksopp's 'Remind Me' has it as well as a bunch of their other videos on the site.PermalinkCommentsvia:swannman visualization music video music-video art advertising design animation france

The (Mostly) True Story of Helvetica and the New York City Subway: Voice: AIGA Journal of Design: Writing: AIGA

2008 Nov 22, 6:01"There is a commonly held belief that Helvetica is the signage typeface of the New York City subway system, a belief reinforced by Helvetica, Gary Hustwit's popular 2007 documentary about the typeface. But it is not true - or rather, it is only somewhat true"PermalinkCommentsvia:swannman nyc subway history font typography sign helvetica

Best Esquire Magazine Stories - Top Articles in History of Journalism - Esquire

2008 Nov 22, 5:59"Five years ago, we named 'Frank Sinatra Has a Cold,' by Gay Talese, the greatest story Esquire ever published. Here, as we close out our 75th anniversary celebration, are the top seven, with several republished online in their entirety for the first time ever."PermalinkCommentsvia:swannman esquire article essay humor

STREET WITH A VIEW: a project by Robin Hewlett & Ben Kinsley

2008 Nov 22, 5:22"On May 3rd 2008, artists Robin Hewlett and Ben Kinsley invited the Google Inc. Street View team and residents of Pittsburgh's Northside to collaborate on a series of tableaux along Sampsonia Way. Neighbors, and other participants from around the city, staged scenes ranging from a parade and a marathon, to a garage band practice, a seventeenth century sword fight, a heroic rescue and much more."PermalinkCommentsgoogle map street view pittsburgh streetview internet art

What's New with the Glue Society - Hi-Fructose Magazine

2008 Nov 21, 3:52I like the melted ice cream truck. "Our Australian friends 'The Glue Society', a group of artists, designers and projecteers, have created these amazing series of sculptures and films where they've created chair rainbows on the frozen tundra, a curb-side wrap party, gratuitous nudie pictures for airplanes passing by, a house of crates, and a blow-up doll's vacation paradise."PermalinkCommentsstreetart art prank culture nature photo sculpture ice-cream-truck via:boingboing

Obama Looks to Axe Daylight Time -- NYT Explains Why - Green Daily

2008 Nov 21, 3:47"In order to conserve energy, President-elect Barak Obama wants to eliminate daylight saving time."PermalinkCommentsenergy politics obama dst time date datetime

Clips: The Kids In The Hall Think Portal Is HILARIOUS

2008 Nov 20, 11:30KITH + Portal! "We're not sure how deep into the goof juice the Kids in the Hall were when troupe funnyman Scott Thompson started sulking and playing Portal in the back of the tour bus, but something got into Kids during this sad little gaming session. Yes, the comedic stylings of Valve writer Erik Wolpaw are most amusing, as is the struggle of watching Thompson attempt to do anything more than move a cube - uncrouch already! - but something tells me there's something magical in those cups. Thanks for the tip, Sascha23!"PermalinkCommentsportal video humor valve kith scott-thompson

Wallace & Gromit - Forum - Latest News - A Matter of Loaf and Death Comes to BBC One This Christmas

2008 Nov 20, 11:01Woo! "I love making films for the cinema but the production of Chicken Run and Curse of the Were-Rabbit were virtually back to back and each film took five years to complete. A Matter of Loaf and Death will be so much quicker to make. I'm delighted to be back into production and back with BBC One with Wallace and Gromit. Over the years the BBC has been incredibly supportive of Wallace and Gromit, this film feels like their homecoming."PermalinkCommentswallace gromit wallace-grommit bbc animation clay claymation via:kris.kowal humor

Broke Man Tries Paying Bill With a Picture of a Spider - Urlesque

2008 Nov 20, 10:58I, like Matt, am a bit incredulous but this is still funny. "Check, cash or money order are acceptable forms of payment when the bill collector comes knocking (or e-mailing), not a picture you doodled of a spider."PermalinkCommentsvia:swannman humor art spider money

Evil Mad Scientist Laboratories - Binary Birthday

2008 Nov 19, 4:28"A binary birthday candle. It consists of a single candle with seven wicks, where the wicks that are lit represent the birthday individual's age in binary. This single candle design works flawlessly to represent any age from 1 to 127, never requiring anyone below the age of 127 to blow out more than a mere six candles at a time."PermalinkCommentsvia:swannman birthday geek math humor howto cake birthday-cake candle binary

Windows PowerShell Core

2008 Nov 19, 3:34PowerShell function syntax and helpPermalinkCommentspowershell reference microsoft msdn function shell

Text/Plain Fragment Bookmarklet

2008 Nov 19, 12:58

The text/plain fragment documented in RFC 5147 and described on Erik Wilde's blog struck my interest and, like the XML fragment, I wanted to see if I could implement this in IE. In this case there's no XSLT for me to edit so, like my plain/text word wrap bookmarklet I've implemented it as a bookmarklet. This is only a partial implementation as it doesn't implement the integrity checks.

Check out my text/plain fragment bookmarklet.

PermalinkCommentstext url boring bookmarklet uri plain-text javascript fragment

Tab Expansion in PowerShell

2008 Nov 18, 6:38

PowerShell gives us a real CLI for Windows based around .Net stuff. I don't like the creation of a new shell language but I suppose it makes sense given that they want something C# like but not C# exactly since that's much to verbose and strict for a CLI. One of the functions you can override is the TabExpansion function which is used when you tab complete commands. I really like this and so I've added on to the standard implementation to support replacing a variable name with its value, tab completion of available commands, previous command history, and drive names (there not restricted to just one letter in PS).

Learning the new language was a bit of a chore but MSDN helped. A couple of things to note, a statement that has a return value that you don't do anything with is implicitly the return value for the current function. That's why there's no explicit return's in my TabExpansion function. Also, if you're TabExpansion function fails or returns nothing then the builtin TabExpansion function runs which does just filenames. This is why you can see that the standard TabExpansion function doesn't handle normal filenames: it does extra stuff (like method and property completion on variables that represent .Net objects) but if there's no fancy extra stuff to be done it lets the builtin one take a crack.

Here's my TabExpansion function. Probably has bugs, so watch out!


function EscapePath([string] $path, [string] $original)
{
    if ($path.Contains(' ') -and !$original.Contains(' '))
    {
        '"'   $path   '"';
    }
    else
    {
        $path;
    }
}

function PathRelativeTo($pathDest, $pathCurrent)
{
    if ($pathDest.PSParentPath.ToString().EndsWith($pathCurrent.Path))
    {
        '.\'   $pathDest.name;
    }
    else
    {
        $pathDest.FullName;
    }
}

#  This is the default function to use for tab expansion. It handles simple
# member expansion on variables, variable name expansion and parameter completion
# on commands. It doesn't understand strings so strings containing ; | ( or { may
# cause expansion to fail.

function TabExpansion($line, $lastWord)
{
    switch -regex ($lastWord)
    {
         # Handle property and method expansion...
         '(^.*)(\$(\w|\.) )\.(\w*)$' {
             $method = [Management.Automation.PSMemberTypes] `
                 'Method,CodeMethod,ScriptMethod,ParameterizedProperty'
             $base = $matches[1]
             $expression = $matches[2]
             Invoke-Expression ('$val='   $expression)
             $pat = $matches[4]   '*'
             Get-Member -inputobject $val $pat | sort membertype,name |
                 where { $_.name -notmatch '^[gs]et_'} |
                 foreach {
                     if ($_.MemberType -band $method)
                     {
                         # Return a method...
                         $base   $expression   '.'   $_.name   '('
                     }
                     else {
                         # Return a property...
                         $base   $expression   '.'   $_.name
                     }
                 }
             break;
          }

         # Handle variable name expansion...
         '(^.*\$)([\w\:]*)$' {
             $prefix = $matches[1]
             $varName = $matches[2]
             foreach ($v in Get-Childitem ('variable:'   $varName   '*'))
             {
                 if ($v.name -eq $varName)
                 {
                     $v.value
                 }
                 else
                 {
                    $prefix   $v.name
                 }
             }
             break;
         }

         # Do completion on parameters...
         '^-([\w0-9]*)' {
             $pat = $matches[1]   '*'

             # extract the command name from the string
             # first split the string into statements and pipeline elements
             # This doesn't handle strings however.
             $cmdlet = [regex]::Split($line, '[|;]')[-1]

             #  Extract the trailing unclosed block e.g. ls | foreach { cp
             if ($cmdlet -match '\{([^\{\}]*)$')
             {
                 $cmdlet = $matches[1]
             }

             # Extract the longest unclosed parenthetical expression...
             if ($cmdlet -match '\(([^()]*)$')
             {
                 $cmdlet = $matches[1]
             }

             # take the first space separated token of the remaining string
             # as the command to look up. Trim any leading or trailing spaces
             # so you don't get leading empty elements.
             $cmdlet = $cmdlet.Trim().Split()[0]

             # now get the info object for it...
             $cmdlet = @(Get-Command -type 'cmdlet,alias' $cmdlet)[0]

             # loop resolving aliases...
             while ($cmdlet.CommandType -eq 'alias') {
                 $cmdlet = @(Get-Command -type 'cmdlet,alias' $cmdlet.Definition)[0]
             }

             # expand the parameter sets and emit the matching elements
             foreach ($n in $cmdlet.ParameterSets | Select-Object -expand parameters)
             {
                 $n = $n.name
                 if ($n -like $pat) { '-'   $n }
             }
             break;
         }

         default {
             $varNameStar = $lastWord   '*';

             foreach ($n in @(Get-Childitem $varNameStar))
             {
                 $name = PathRelativeTo ($n) ($PWD);

                 if ($n.PSIsContainer)
                 {
                     EscapePath ($name   '\') ($lastWord);
                 }
                 else
                 {
                     EscapePath ($name) ($lastWord);
                 }
             }

             if (!$varNameStar.Contains('\'))
             {
                foreach ($n in @(Get-Command $varNameStar))
                {
                    if ($n.CommandType.ToString().Equals('Application'))
                    {
                       foreach ($ext in @((cat Env:PathExt).Split(';')))
                       {
                          if ($n.Path.ToString().ToLower().EndsWith(($ext).ToString().ToLower()))
                          {
                              EscapePath($n.Path) ($lastWord);
                          }
                       }
                    }
                    else
                    {
                        EscapePath($n.Name) ($lastWord);
                    }
                }

                foreach ($n in @(Get-psdrive $varNameStar))
                {
                    EscapePath($n.name   ":") ($lastWord);
                }
             }

             foreach ($n in @(Get-History))
             {
                 if ($n.CommandLine.StartsWith($line) -and $n.CommandLine -ne $line)
                 {
                     $lastWord   $n.CommandLine.Substring($line.Length);
                 }
             }

             # Add the original string to the end of the expansion list.
             $lastWord;

             break;
         }
    }
}

PermalinkCommentscli technical tabexpansion powershell

the dullest blog in the world

2008 Nov 18, 1:55This is blog: 'the dullest blog in the world'PermalinkCommentsblog humor

knitta and obey on delancey on Flickr - Photo Sharing!

2008 Nov 18, 1:49Double meme score FTW!PermalinkCommentsmeme photo flickr obey knitta streetart street graffiti cultural-disobediance

For a Washington Job, Be Prepared to Tell All - NYTimes.com

2008 Nov 18, 1:10"...Just in case the previous 62 questions do not ferret out any potential controversy, the 63rd is all-encompassing: 'Please provide any other information, including information about other members of your family, that could suggest a conflict of interest or be a possible source of embarrassment to you, your family, or the president-elect.' ... For those who clear all the hurdles, the reward could be the job they wanted. But first there will be more forms, for security and ethics clearances from the Federal Bureau of Investigation and the Office of Government Ethics."PermalinkCommentsgovernment obama fbi privacy
Older Entries Creative Commons License Some rights reserved.