Charlie's Diary

[ Site Index] [ Feedback ]


Thu, 03 Jun 2004

Geektoys
I haven't updated my blog since last Saturday because I've been suffering from a surfeit of fin-de-siecle anomie left over from 2000 or thereabouts (not to mention the hangover from an SF convention in Glasgow). Not much has tweaked my sense of wonder in the past few days. While it's been fun to watch the White House lurching towards Watergate 2.0 (or Plamegate, as I suppose they'll end up calling it), there's a limit to how much foreign politics I can stomach. And I'm sure the news about Space Ship One's launch schedule has been blogged to the moon and back already. I haven't sold any novels this week (despite a couple of foreign rights queries), and I haven't written much, so I can't even throw in some advertising. Which leaves me short of things to write, except ...

I don't like computer viruses.

Well, that probably goes for you, too. But my way around the problem is to simply not run the Virus Incubation Platform, Windows. Being a smug, bearded old-time UNIX hand I use a Mac. OS/X is sort of like traditional MacOS, with gnarly programmable bits underneath that you don't have to use a can opener to get at -- and sort of like Linux, only with a user interface that isn't brain damaged at birth from having been delivered into the world by a cabal of surgeons squabbling over the forceps. It just works, most of the time. And it is nifty, although some aspects of it are not as friendly as advertised. In particular, I'm thinking of AppleScript.

OS/X is scriptable. You can, in principle, send a stream of commands to any OS/X application with a user interface that make it do things as if you were running it with a keyboard and mouse. Unfortunately the chosen human-readable language for scripting OS/X applications, AppleScript, is too human readable. It tries to look like English. Which is just plain dumb: computers do not speak English, and syntactic sugar that makes a language look familiar is more likely to mislead than to assist. AppleScript is as verbose as COBOL, as regular as Perl, and as irritating as that goddamn talking paperclip. If I want to add two plus two, I do not want to have to say something like Let result equal 2 + 2, when result=2+2 is just as understandable and easier to type. This might sound trivial, but when you get into things like this:

try
    tell application "Finder" to set the source_folder to \ 
       (folder of the front window) as alias
on error -- no open folder windows
    set the source_folder to path to \
        desktop folder as alias
end try

... it becomes obtrusive. (NB: Those backslashes replace a weird character that's frankly not available in the web ISO-8859/15 codeset, as far as I know. They mean "continued on next line". See what I'm getting at?)

Anyway, I've just [re-]discovered a cute tool called PerlPad. I stumbled across PerlPad a year or two ago, but back then it was rather less usable -- now it works on Panther, and it seems solid. Panther comes with a recent (release 5.8) Perl installation. Perl is the Swiss army chainsaw of scripting languages; and I've earned a living coding in it before now. PerlPad is a tool that lets you write arbitrary snippets of Perl code in any editable window provided by an OS/X application, select it, then hit a magic key combination that either feeds the clipboard contents through your code, or evaluates it and replaces it with its own output, or a bunch of other cool tricks. Text mangling, in other words. It's one of the more useful applications of CamelBones, a framework for binding Perl code to Objective-C to let you write Aqua interfaces for Perl scripts (hands up at the back if you understand that).

To get PerlPad running on a Mac running Panther (OS/X 10.3), just grab the latest CamelBones runtime, and the latest PerlPad download. You'll also need to install Devel::Symdump (just open a Terminal window and type sudo perl -MCPAN -e "install Devel::Symdump;" -- then answer the questions about which FTP site to get it from, and so forth). Terse instructions are here -- if you need blow-by-blow instructions then you probably aren't familiar enough with Perl that running PerlPad is sensible.

Then once you run PerlPad, getting a complete word count of whatever's in the clipboard is as simple as scribbling:

my $x; foreach (<$IN>) {$x += split}; print $x;

In a TextEdit window, highlighting it, and hitting command-shift-E.

Well, maybe not, but if you're a Perl geek it makes sense, okay? Just take it from me.

Now to explore the manual. It says I can write Perl snippets and add them to the System Services menu, making them available in most any application on my Mac. Let's get to work ...

[Link] [Discuss toys]



posted at: 14:37 | path: /misc | permanent link to this entry

specials:

Is SF About to Go Blind? -- Popular Science article by Greg Mone
Unwirer -- an experiment in weblog mediated collaborative fiction
Inside the MIT Media Lab -- what it's like to spend a a day wandering around the Media Lab
"Nothing like this will be built again" -- inside a nuclear reactor complex


Quick links:

RSS Feed (Moved!)

Who am I?

Contact me


Buy my books: (FAQ)

Missile Gap
Via Subterranean Press (US HC -- due Jan, 2007)

The Jennifer Morgue
Via Golden Gryphon (US HC -- due Nov, 2006)

Glasshouse
Via Amazon.com (US HC -- due June 30, 2006)

The Clan Corporate
Via Amazon.com (US HC -- out now)

Accelerando
Via Amazon.com (US HC)
Via Amazon.com (US PB -- due June 27, 2006)
Via Amazon.co.uk (UK HC)
Via Amazon.co.uk (UK PB)
Free download

The Hidden Family
Via Amazon.com (US HC)
Via Amazon.com (US PB)

The Family Trade
Via Amazon.com (US HC)
Via Amazon.com (US PB)

Iron Sunrise
Via Amazon.com (US HC)
Via Amazon.com (US PB)
Via Amazon.co.uk (UK HC)
Via Amazon.co.uk (UK PB)

The Atrocity Archives
Via Amazon.com (Trade PB)
Via Amazon.co.uk (Trade PB)
Via Golden Gryphon (HC)
Via Amazon.com (HC)
Via Amazon.co.uk (HC)

Singularity Sky
Via Amazon.com (US HC)
Via Amazon.com (US PB)
Via Amazon.com (US ebook)
Via Amazon.co.uk (UK HC)
Via Amazon.co.uk (UK PB)

Toast
Via Amazon.com
Via Amazon.co.uk


Some webby stuff I'm reading:


Engadget ]
Gizmodo ]
The Memory Hole ]
Boing!Boing! ]
Futurismic ]
Walter Jon Williams ]
Making Light (TNH) ]
Crooked Timber ]
Junius (Chris Bertram) ]
Baghdad Burning (Riverbend) ]
Bruce Sterling ]
Ian McDonald ]
Amygdala (Gary Farber) ]
Cyborg Democracy ]
Body and Soul (Jeanne d'Arc)  ]
Atrios ]
The Sideshow (Avedon Carol) ]
This Modern World (Tom Tomorrow) ]
Jesus's General ]
Mick Farren ]
Early days of a Better Nation (Ken MacLeod) ]
Respectful of Otters (Rivka) ]
Tangent Online ]
Grouse Today ]
Hacktivismo ]
Terra Nova ]
Whatever (John Scalzi) ]
GNXP ]
Justine Larbalestier ]
Yankee Fog ]
The Law west of Ealing Broadway ]
Cough the Lot ]
The Yorkshire Ranter ]
Newshog ]
Kung Fu Monkey ]
S1ngularity ]
Pagan Prattle ]
Gwyneth Jones ]
Calpundit ]
Lenin's Tomb ]
Progressive Gold ]
Kathryn Cramer ]
Halfway down the Danube ]
Fistful of Euros ]
Orcinus ]
Shrillblog ]
Steve Gilliard ]
Frankenstein Journal (Chris Lawson) ]
The Panda's Thumb ]
Martin Wisse ]
Kuro5hin ]
Advogato ]
Talking Points Memo ]
The Register ]
Cryptome ]
Juan Cole: Informed comment ]
Global Guerillas (John Robb) ]
Shadow of the Hegemon (Demosthenes) ]
Simon Bisson's Journal ]
Max Sawicky's weblog ]
Guy Kewney's mobile campaign ]
Hitherby Dragons ]
Counterspin Central ]
MetaFilter ]
NTKnow ]
Encyclopaedia Astronautica ]
Fafblog ]
BBC News (Scotland) ]
Pravda ]
Meerkat open wire service ]
Warren Ellis ]
Brad DeLong ]
Hullabaloo (Digby) ]
Jeff Vail ]
The Whiskey Bar (Billmon) ]
Groupthink Central (Yuval Rubinstein) ]
Unmedia (Aziz Poonawalla) ]
Rebecca's Pocket (Rebecca Blood) ]


Older stuff:

June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
(I screwed the pooch in respect of the blosxom entry datestamps on March 28th, 2002, so everything before then shows up as being from the same time)



[ Site Index] [ Feedback ]


Powered by Blosxom!