Stupidfool.orgtag:typepad.com,2003:weblog-82011-02-08T10:28:44-08:00From pork to Prince to Project Runway.TypePadPerl, best practices, and language designtag:typepad.com,2003:post-6a00d83455876069e20147e26c07d3970b2011-02-08T10:28:44-08:002011-02-08T10:28:44-08:00Last night, I said this: Writing Perl after months of coding in Python is really frustrating.less than a minute ago via web Benjamin Trott btrott And I thought I'd expand on it, as a couple of people had questions and/or...btrott
<div xmlns="http://www.w3.org/1999/xhtml"><p>Last night, I said this:</p>
<p><!-- http://twitter.com/#!/btrott/status/34856410210639872 --> <style type='text/css'>.bbpBox34856410210639870 {background:url(http://a2.twimg.com/a/1296099941/images/themes/theme3/bg.gif) #EDECE9;padding:20px;} p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block}</style> <div class='bbpBox34856410210639870'><p class='bbpTweet'>Writing Perl after months of coding in Python is really frustrating.<span class='timestamp'><a title='Tue Feb 08 06:09:50 +0000 2011' href='http://twitter.com/#!/btrott/status/34856410210639872'>less than a minute ago</a> via web</span><span class='metadata'><span class='author'><a href='http://twitter.com/btrott'><img src='http://a0.twimg.com/profile_images/29015962/6a00b8ea0714f01bc000b8ea0715191bc0_normal.jpg' /></a><strong><a href='http://twitter.com/btrott'>Benjamin Trott</a></strong><br/>btrott</span></span></p></div> <!-- end of tweet --></p>
<p>And I thought I'd expand on it, as a couple of people had questions and/or interpreted it in different ways. There were roughly 3 interpretations: 1. moving from Python to Perl is frustrating; 2. moving from X to Perl is frustrating; and 3. moving from X to Y is frustrating. And that's sort of the order of the feelings that inspired that tweet; it was first and foremost about moving specifically from Python to Perl.</p>
<p>Here's the thing: I love Perl. It's still the most natural (coding) language for me to think in, and when I'm prototying, I usually use Perl (even if I'm going to rewrite the final version in another language). It's the most natural way for me to think through how an application/tool/library should work, design the interfaces, and so on.</p>
<p>Perl is my native language, in many ways.</p>
<p>But. What's most frustrating to me about returning to Perl, after months of coding in Python, is the lack of standardization in the core language for things like exception-handling, logging, proper objects, &c, that are well-defined and consistently-used in Python. Contrast that with Perl, where, just for the object model alone, you've got libraries that use <a href="http://search.cpan.org/~drolsky/Moose-1.21/">Moose</a>, others that use <a href="http://search.cpan.org/~kasei/Class-Accessor-0.34/">Class::Accessor</a>, others that use <a href="http://search.cpan.org/~mstrout/Moo-0.009005/">Moo</a> or <a href="http://search.cpan.org/~gfuji/Mouse-0.89/">Mouse</a>, others than use <a href="http://search.cpan.org/~adamk/Object-Tiny-1.06/">Object::Tiny</a>, and so on. And so if I'm writing a new project--of moderate complexity--that'd end up on CPAN eventually, the lack of a core standard around (say) objects/classes or exception handling is frustrating.</p>
<p>And this is where the "more than one to do it" philosophy hits its natural limit, for me. As <a href="http://www.modernperlbooks.com/mt/2011/02/when-the-dependency-problem-is-core-language-problem.html#comment-738">chromatic said recently</a>, "Sometimes you have to provide one good way to do most things without excluding the possibility of doing other things." At its worst, having more than one way to do everything leads to fragmentation and a lack of best practices.</p>
<p>Language design involves curation; having more than one way to do it might give you a collection of options to choose from, but at some point, you've got to choose.</p></div>
tag:typepad.com,2003:post-6a00d83455876069e20148c74f269a970c2011-01-04T13:32:37-08:002011-01-04T13:32:37-08:00My daughter (Penelope) is learning her letters. One of our favorite activities is to use the built-in say command in the OS X terminal: she types in a word, presses [return], and the computer speaks. To make this easier, I...btrott

My daughter (Penelope) is learning her letters. One of our favorite activities is to use the built-in say command in the OS X terminal: she types in a word, presses [return], and the computer speaks.

It's fun! And it's even more fun to use it to annoy the dog ("Maddy, go to your crate.").

tag:typepad.com,2003:post-6a00d83455876069e20147e0c05231970b2010-12-15T20:59:34-08:002010-12-15T21:31:01-08:00Sam said: A tiny program that puts an icon in the right side of your menu bar. Click it to prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers. Click it again to go...btrott
<div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://shutupandclickit.com/2010/12/caffeine-for-os-x.html">Sam said:</a></p>
<blockquote>
<blockquote>
<p>A tiny program that puts an icon in the right side of your menu bar. Click it to prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers. Click it again to go back. Hold down the Command key while clicking to show the menu.</p>
</blockquote>
<p><a href="http://ben.stupidfool.org/" target="_self">Ben</a>&nbsp;pointed me at this one. I can’t count the number of times I’ve wanted to override my defaults for screen timeouts, and now I can!</p>
</blockquote>
<p>Everyone needs <a href="http://www.apple.com/downloads/macosx/system_disk_utilities/caffeine.html">Caffeine</a>. And they really do, because every time I see someone's screen sleep during a presentation, I think, "everyone needs Caffeine".</p></div>
A Refined Desktop Collectiontag:typepad.com,2003:post-6a00d83455876069e20133f5884165970b2010-11-02T11:31:21-07:002010-11-02T11:32:07-07:00via davidslog.com I'm using the Dark one.btrott

An Optimization Anecdotetag:typepad.com,2003:post-6a00d83455876069e20133f588376d970b2010-11-02T11:22:49-07:002010-11-02T11:22:49-07:00The other day, a friend asked me a seemingly simple question: what's the best way to convert a list of integers into a string, presuming that the integers are ASCII values. For instance, the list [97, 98, 99] should be...btrott

The other day, a friend asked me a seemingly simple question: what's the
best way to convert a list of integers into a string, presuming that the
integers are ASCII values. For instance, the list [97, 98, 99] should be
converted to the string 'abc'. Let's assume we want to write a function to
do this.

Just for fun, I rewrote most of the functions in Perl (you can check my work in this gist); the results are actually somewhat interesting (f1() is very fast in Perl, for instance, while it's one of the slower implementations in Python). The results, using a 256-item list:

Panic does good email.tag:typepad.com,2003:post-6a00d83455876069e201348035cc1a970c2010-04-28T11:51:46-07:002010-04-28T11:53:44-07:00This is a great trick: To work around image blocking, the airmail line at the top of the email is actually just plain old "/" characters in 260px Helvetica. Using CSS (namely a fixed height and negative letter spacing) they've...btrott

This is a great trick:

To work around image blocking, the airmail line at the top of the email is actually just plain old "/" characters in 260px Helvetica. Using CSS (namely a fixed height and negative letter spacing) they've managed to style the text to give the perfect airmail appearance, all without a single image. ... And here's what it looks like in the email, even with images disabled.

In addition to great software (and status boards!), Panic does some impressive email marketing.

30% faster responses in the TypePad APItag:typepad.com,2003:post-6a00d83455876069e20134802f4181970c2010-04-27T12:33:14-07:002010-04-27T12:33:14-07:00After a few long whiles of upgrading and updating our Motion and client library code, last week we removed the links array from the API. While this may not seem like a big deal, it means our API responses are...btrott

After a few long whiles of upgrading and updating our Motion and client library code, last week we removed the links array from the API. While this may not seem like a big deal, it means our API responses are much smaller and tend to be a bit faster for us to generate.

Snowflaketag:typepad.com,2003:post-6a00d83455876069e201310ffd26d7970c2010-03-31T09:22:13-07:002010-03-31T09:22:13-07:00For a mini-project written in Perl, I wanted pretty syntax highlighting. I've used pygmentize directly in the past from the command line, but I wanted a simple wrapper in Perl. Something like Albino, but for Perl. So, I ported Albino...btrott

For a mini-project written in Perl, I wanted pretty syntax highlighting. I've used pygmentize directly in the past from the command line, but I wanted a simple wrapper in Perl. Something like Albino, but for Perl.

So, I ported Albino to Perl, and here's Snowflake, a Perl wrapper for pygmentize (named after Snowflake, the only known albino gorilla).

It's easy to use:

Faveplayertag:typepad.com,2003:post-6a00d83455876069e20133ec56bff6970b2010-03-30T12:31:42-07:002010-03-30T12:31:42-07:00Inspired by Mark's choonplayer (both creatively & visually), I wrote a simple app to show off my favorite posts on TypePad (or yours, or anyone's). The player is on github, if you'd like to check it out; it's a nice...btrott
<div xmlns="http://www.w3.org/1999/xhtml"><p><a style="display: inline;" href="http://ben.stupidfool.org/.a/6a00d83455876069e201310ffcbf88970c-pi"><img class="asset asset-image at-xid-6a00d83455876069e201310ffcbf88970c" alt="Faveplayer" src="http://ben.stupidfool.org/.a/6a00d83455876069e201310ffcbf88970c-500wi" width="500" height="326" /></a></p>
<p>Inspired by <a href="http://markpasc.typepad.com/blog/2010/03/choonplayer.html">Mark's choonplayer</a> (both creatively & visually), I wrote a simple app to show off <a href="http://profile.typepad.com/btrott/favorites">my favorite posts on TypePad</a> (or yours, or anyone's). The player is <a href="http://github.com/btrott/faveplayer">on github</a>, if you'd like to check it out; it's a nice simple demonstration of how to use <a href="http://www.typepad.com/services/apidocs/endpoints/users/%253Cid%253E/favorites">TypePad's favorites API</a>.</p></div>