Posts tagged: PROGRAMMING

dpaste.com

I’ve re-launched my little Django-powered pastebin (formerly paste.e-scribe.com) under its own shiny new $8 domain name: dpaste.com. Not that the world really needs another pastebin, but people have been using it daily and it’s a fun side project. From the about page:

Philosophy: Simplicity and usability. The grayscale look makes the colorized source code stand out. Cookie-based personal defaults eliminate lots of extra form widgetry. Automatic expiry means the database never fills up. Auto-focus on the Code field means mouse-free operation. No required fields means you can paste, tab, return, and go. No running list of recent items means the spammers remain invisible. And Django makes nice clean URLs the path of least resistance.

TextMate command for paste.e-scribe.com

After seeing a similar offering from the Web 2.0 pastebin Attachr I couldn’t resist. So here’s a simple TextMate command that submits selected text to paste.e-scribe.com, opening the new URL in your default web browser. Bonus features: the filename is used as the title, and the language syntax is guessed from the file extension.

This is a very crude little script, but too much fun not to share. Download paste.tmCommand.zip and double-click the resulting .tmCommand file, that should be all there is to it.

Pastebin update: Pygments

This past spring I posted about a simple pastebin app I wrote using Django. This week I updated it to use the excellent Pygments syntax-coloring library (formerly known as Pykleur).

Pygments has support for a healthy number of languages/syntaxes, offers a great deal of flexibility, ships with several different color schemes, and can produce output in HTML/CSS, LaTEX, or ANSI terminal colors. I created a “pcat” alias to take advantage of that last one when working in the shell.

Quotation punctuation evolution

With English teachers for parents and a degree in literature, I’ve always felt a certain burden to uphold consistent, proper English usage. Over the past few years, though, one of the firm rules that I learned in my younger days – that commas and periods go inside quotation marks – has become impossible for me to follow.

This is an American rule, one that is mostly, if not entirely, about typographic appearance. If you place a comma or a period after the closing quotation mark, it’s kind of floating there in space. Placed before, it’s nestled tidily against the preceding letter. The American use of double-quotes intead of single makes this contrast even more dramatic.

International Freedom From Stupid Software Patents Day

LZW – that is, the formerly patented Lempel-Ziv Welch compression algorithm – is free today. The footnote on the Free Software Foundation’s GIF history page says:

The Unisys patent expired on 20 June 2003 in the USA, in Europe it expired on 18 June 2004, in Japan the patent expired on 20 June 2004 and in Canada it expired on 7 July 2004. The U.S. IBM patent expired 11 August 2006, The Software Freedom Law Center says that after 1 October 2006, there will be no significant patent claims interfering with employment of the GIF format.

The "path" module

Somewhat belatedly I’ve started using Jason Orendorff’s path module for Python. It’s great. Here’s a comparison with the stock os.path facilities, grabbed from Jason’s site:

# with os.path.walk
def delete_backups(arg, dirname, names):
    for name in names:
        if name.endswith('~'):
            os.remove(os.path.join(dirname, name))
os.path.walk(os.environ['HOME'], delete_backups, None)

# with path
d = path(os.environ['HOME'])
for f in d.walkfiles('*~'):
    f.remove()

The second snippet is not just shorter, it’s easier to read and easier to write. I’m writing some code to recursively process a tree of short text files (Blosxom entries), and the path module is a godsend. If you’re curious, see the description and examples on Jason’s site; he also posted some interesting comments on Ian Bicking’s blog about the design of the module.