Posts tagged: FUN

99-byte Python quicksort

Update: Browsing through my Python Cookbook this evening I discovered entry 5.11, “Showing off quicksort in Three Lines”, which includes some code very much like mine below. The entry does a good job of emphasizing that these bits of code are perhaps to be savored but not to be actually used. It also includes an insanely (impressively?) convoluted version that uses three lambdas in a single line and weighs in at 105 bytes. I thought this might be the best possible in Python 2.4 and earlier, but in fact a simpler version can be constructed using the old short-circuit logic trick, and at 94 bytes it’s even smaller than my original. Here it is: q=lambda s:len(s)and q([x for x in s[1:]if x<s[0]])+[s[0]]+q([x for x in s[1:]if x>=s[0]])or s

Enticed by the lovely Haskell quicksort example, and sullied by the code-crunching ways of Codegolf, I decided to see how small a Python quicksort function I could write. I stopped at 99 bytes.

STFU

E-Scribe is not, strictly speaking, a standards organization. However, I think the time is right to release this draft document on an important Internet standard. The document is presented inline here for convenience; however, the preferred permanent reference is: http://e-scribe.com/stfu

Recent trends in internet-based application development have
fostered the rapid spread of asynchronous, Javascript-based techniques
known by the umbrella term "Ajax" and by related terms such as "AHAH",
"POX", and so on.

This brief paper argues for a plaintext, synchronous alternative style
with some compelling advantages, one of which is (naturally) a catchy
name.

Synchronous Text/plain For User-agents -- STFU -- is a content-
delivery standard offering simple, reliable, high-performance routing
of content to Internet end-users. Implementation is orders of
magnitude faster than for typical Ajax applications, with a
corresponding drop in defect rates.

It's that simple. STFU.

  * well-tested
  * cross-platform
  * highly scalable
  * enterprise-ready
  * supports Unicode!
  * compliant with Section 508 Accessibility Requirements

One prominent adopter of STFU technology is the Internet Engineering
Task Force, which uses it for the dissemination of their most
important documents:

  ietf.org/rfc/rfc-index-latest

STFU also sidesteps technical quandaries related to markup formats,
such as those summarized here:

  hixie.ch/advocacy/xhtml

It's no accident that the author of the above (widely cited) document
chose to deliver his important message via STFU. 

Sometimes the debates over emerging standards and technologies become
wearisome, and pragmatic individuals find themselves wishing for a
magic phrase that might quiet the true believers and allow all
involved to move on to more productive activities. May we recommend:

STFU!

If you are already using STFU, you are welcome to display this PNG badge:

Blog flair backlash

It’s now official: right-minded people hate those little “Blog me, digg me, add me to your feed baby!” icons attached to blog posts. References:

http://www.37signals.com/svn/posts/93-its-the-content-not-the-icons
http://mezzoblue.com/archives/2006/10/10/mooching_20/
http://www.codinghorror.com/blog/archives/000587.html

Maybe I’m part of the problem. I avoid the Nascar-style decorations, but I do have text links at the bottom of each post that cover three such sites. My links are tasteful, of course – no icons, just gray text. Faster than a bookmarklet, even, since you can use them right from the front page of the blog. But I do feel mixed about them.

Software for determining image similarity?

This is a lazyweb request – I’m looking for something but I don’t even know if it exists. I have about 200 photos (headshots) and I’d like to make an animation that runs through them in order of, for lack of a better term, visual similarity. I’m not talking about morphing or just fading between the images in arbitrary order. Is there software out there that, given a reference image and a set of images to select from, can choose the most similar image? Open source would be best, as there’s no budget for this, and command-line-only is fine, but I am on a Mac.