« | » Main « | »

Partition for Python

Sunday 30 July 2006

This article about new assignment semantics in JavaScript 1.7 used Ruby's partition method as an example of multiple assignment. It was a funny example to me, since I'm quite familiar with multiple assignment, having used it many many times in Python code. The new thing for me was partition. I'd never heard of it, though a number of programming languages have it.

It's easy to implement in Python:

# An implementation of partition for Python

def partition(l, pred):
    yes, no = [], []
    for e in l:
        if pred(e):
    return yes, no

And it's easy to test:

import unittest

def is_odd(n):
    return (n % 2) == 1

class PartitionTest(unittest.TestCase):

    def testSimple(self):
        odd, even = partition(range(10), is_odd)
        self.assertEqual(even, [0,2,4,6,8])
        self.assertEqual(odd, [1,3,5,7,9])

    def testAllYes(self):
        odd, even = partition([1,3,5], is_odd)
        self.assertEqual(odd, [1,3,5])
        self.assertEqual(even, [])

    def testAllNo(self):
        odd, even = partition([2,4,6], is_odd)
        self.assertEqual(odd, [])
        self.assertEqual(even, [2,4,6])

    def testEmpty(self):
        odd, even = partition([], is_odd)
        self.assertEqual(odd, [])
        self.assertEqual(even, [])

if __name__ == '__main__':

I also wondered about generalizations: take a function returning a small integer, and return a list where the i'th element is a list of all the values for which the function return i? Or return a dictionary whose keys are the values returned by the function, and the values are lists of input values that caused them? I imagine different cases could be made for either of these.

I don't have a use for any of this at the moment, just an idle mental exercise.

BTW: JavaScript 1.7 turns out to have a ton of new stuff. It sounds very cool, but how will developers make use of it generally? They can't count on these features being in general deployment. I guess it's just for version-specific development.


Saturday 29 July 2006

Odd Job Jack is an animated TV show on Canadian TV, so I've never seen it. The reason I mention it is that they are open-sourcing their production files. FreeJack is their give-away of all of the files used to produce each episode. The whole thing is done in Flash, and they've made available all of their work for others to learn from, borrow, and re-purpose.

It's fascinating to see how the open source movement will translate into other domains. Will this be common, or is Odd Job Jack going to remain the odd man out? In either case, it's great for students of animation who want to see how a show like this is put together. And they've got what looks like detailed tutorials explaining what they do.

The files are distributed over bittorrent because of their size (about 800Mb per episode)!

Nonsensical spam

Wednesday 26 July 2006

More about comment spam: Recently I started getting a new style of spam, and I can't for the life of me figure out why anyone would bother. The web site URL is gibberish, and the comment itself includes two links to web sites which are gibberish:

name: Austin
email: chad(at)pochta(dot)com
website: http://rdrritkk.com/wclp/fqqe.html

Thank you!
http://rdrritkk.com/wclp/fqqe.html | http://ydjkxpiu.com/dymt/phzj.html

Not only is there no site at those two domain names, they aren't even registered. I thought, maybe they're trying to get some Google juice for the domains before registering, and then they'll register the ones that do well. But of course Google won't index sites that don't exist, and there isn't even any content in the comment for Google to index. It's a content-less pointer to nowhere. If they mentioned Xanax or something, then maybe there's a way it would help the spammers, but there's nothing here.

The spams come in bunches, with different random domain names. Any theories? What's the point?

WebInno 7

Tuesday 25 July 2006

I attended WebInno 7 last night in Cambridge. This regular gathering is growing quite large, there were probably 150 people there.

There were three companies doing formal presentations:

  • SwapTree, a site for trading books and the like, kind of bartering eBay.
  • MyBlogLog, a visitor stats package for blogs, with social networking built on top based on traffic patterns.
  • PawSpot, a social site for pet owners.

These demos were all concise and to the point. One thing they had in common: none of them mentioned their business model! The first question for the two social sites was, "What's your business model?", and the answer was "targeted advertising". MyBlogLog didn't get asked. I assume they'll have a pro account model, where blog owners can pay for the really juicy factoids.

SwapTree had a fairly complete app, including printing of mailing labels with postage when the time came to ship your stuff to someone else. They've written a browser plugin so that when you're on Amazon pages, you can query SwapTree to see if you can trade for the product rather than pay for it. They've done a lot of work. It remains to be seen whether people will want to participate in these ad-hoc bartering networks, and whether they can support themselves with ads (at least long enough to get bought by eBay).

The PawSpot guy had the most information at his fingertips about the business side of his product, which makes sense because he mentioned in his opening sentence that he was from Sloan. Actually, one audience member mentioned to me that they stopped listening at that point! The interesting thing about the crowd at WebInno is that there are distinct sectors: technical people, people wanting money, people with money, and so on.

There were also four side-dish demos that I didn't manage to catch at all.

Another thing all the demos had in common: all of these sites were really nicely designed. As a result, none of these seemed like technology demos, they seemed like product demos. Hard to know while sitting in the audience where things really stood. Design really helps the perception of a completed product.

Five Tabblo'ers showed up to hear the buzz and to spread the word about Tabblo. The people I spoke to about Tabblo were very positive about it. Antonio took some pictures:

Tabblo: Boston Web Inno 7

Simile Timeline

Monday 24 July 2006

Timeline is a pure DHTML implementation of a horizontally-scrollable timeline. They've done a nice job on the interface (though an overview of the entire timeline would be nice), and a great job on the documentation. It's the kind of library that makes me want to think up a reason for needing a timeline.


Sunday 23 July 2006

One idle afternoon in the summer, Ben (8) was playing with some Silly Putty, and asked, "How come no one does claymation with Silly Putty?"

No one had an answer, so with Max (14) as cinematographer with a still camera, Ben started animating. Fifteen minutes later, we had this basic proof of concept:

It can be done! Silliputtimation is possible!

BTW: this is the first video I've uploaded to YouTube. They do a good job of the process, making it very straightforward to get content on their site. I liked their wording for three-option radio buttons, for example, for allowing comments on videos. The choices are "Yes", "No", and "Kinda", meaning moderated.

Spamlent Green is people

Friday 21 July 2006

Back in May, I wrote a post about spam that was written by genuine humans. In the comments that ensued, a number of people theorized that the spam was still generated by machine, since it isn't that hard to synthesize sentences that are kind of on target, and they had stopped the spam with captchas.

Since then, I've continued to get comments which are strangely relevant, reinforcing my belief that people are actually typing these comments one at a time. This morning, though, I had stronger evidence.

Yesterday, I changed my comment software a little bit, and in the process, added a small bug: web site URLs would be rejected if they had any spaces in them, including trailing spaces. I should have trimmed the URL first, but forgot to.

On yesterday's Unnecessary censorship post, a commenter named "Samantha" tried eight times to post a comment. The URL she was using was a .info domain about contact lenses, but I'll replace it here with stupidspammers.info.

Her first comment (at 3:21 am) was a typical on-topic spam comment (The important trailing spaces are shown as bullets):

name: Samantha
email: samanthajoseph46(at)gmail(dot)com
website: http://www.stupidspammers.info••

I was laughing so hard, my stomach hurts :-) And that Bush part was amazing, great work altogether.

error: That's not a good website.

At 3:44, she tried five more times with the exact same comment, probably re-editing the URL to see if she had mis-typed something that was getting caught in the URL validation.

Then she posted again, but with a different URL, one to help people stop smoking, but her trailing spaces were still there, so it failed again.

At 3:48, she removed the URL altogether, and the comment finally worked (the web site URL is optional). Now that she knew she could get a comment posted, she made another one, with the URL in the body:

name: Samantha
email: samanthajoseph46(at)gmail(dot)com

I was laughing so hard, my stomach hurts :-) And that Bush part was amazing, great work altogether. <a href="http://www.stupidspammers.info">funny</a>

I can see how you might think the content here could be auto-generated (though I didn't mention that Bush was in the video, so that's also a give-away), but the trial and error displayed in these attempts is very clear: Samantha is a real person typing comments to get links for a cheesy spam site. The time between her first attempt at 3:21 and her second at 3:44 were likely spent re-checking the web site herself, or re-checking instructions from her spam-master.

Ick ick ick. What a world.

The diversity of digital media

Wednesday 19 July 2006

One of the things that makes the digital world so powerful is that digital signals can be embedded in so many different media. Of course, this may be taking it too far: Guillaume Reymond recreates short snippets of video games using stop-motion movies, with people in auditorium seats as pixels: GAMEOVER. Very well done, considering the difficulty. How do you convince 50 people to spend a day in an auditorium with you, acting out the pixels in a video game?

Web 2.0 over thin pipes

Tuesday 18 July 2006

The Daily WTF has a Web 2.0 entry: Incompatible with Web 2.0. Basically, a really fat Web application wouldn't work well over very thin pipes. In fact, it was unacceptably slow because even with the browser's page cache working properly, each request was downloading up to 600KB of data. The solution: install remote desktop software to a terminal server, and the whole thing works "amazingly fast".

Everything old is new again. Technology pushes more smarts to the browser, and makes use of downloadable programs to execute at the client (in the form of JavaScript). But when the going gets tough, the clever guy uses remote desktops to essentially implement a mainframe model: all of the work happens on a central computer, with purely cosmetic display instructions sent to dumb terminals! Who came up with this? Austin Powers? It's like the '60's all over again, baby!

Not being a dot-bomb 2.0

Tuesday 18 July 2006

Dead2.0 writes anonymous snarky reviews of new web services, full of jabs about how stupid they are, or why they will fail. But his latest post is 11 Suggestions For Not Being a Dot-Bomb 2.0, which is a really good list of success criteria for small companies. Stuff like "Have a revenue model". OK, so it isn't all subtle tricky stuff, but the fact is, plenty of sites get launched that seem to have overlooked these basic tenets of running a business. It's a good list to keep in mind, and in a nice touch, it ends with "Ignore the hype and have fun".

He also points off to a lot of other interesting pages discussing similar issues. My favorite was Web 2.0 or Star Wars Character?, a quiz to determine if you know the difference between meebo and dooku or django and jango. I scored 35, "As your doctor, I recommend moving out of your parents' basement."

Quick links: Etch-A-Sketch, Linea, Fancypants, Lost Mac ads

Saturday 8 July 2006

Some random stuff that caught my eye this afternoon:

¶   La Linea: A series of great minimalist animations from the sixties.

¶   Etched in Time: A kid with an insane ability to make pictures on an Etch-A-Sketch.

¶   Fancy Pants Adventures: A fun little Flash game with some cool moves.

¶   Best Week Ever >> The Lost Mac Ads: Sick of that smug Mac guy? Watch these.

Black tie at the White House

Friday 7 July 2006

I know this seems really unlikely, but I will be attending a black-tie dinner at the White House on Monday night. Yes, the White House.

It all still seems a bit unreal, but here's what we know so far. The President and Mrs. Bush are honoring Maria Shriver and the Special Olympics with a formal dinner. My wife Susan is on the guest list, at the suggestion of the Special Olympics, probably because of her series of op-ed pieces in the Washington Post, most recently A Golden Moment with Nat, published a few weeks ago. She has corresponded with Tim Shriver about these pieces in the past, so he probably put us on the list.

Susan was checking our home voicemail from the Cape on Monday, one of those "Oh, there won't be anything there, but I might as well check" calls, when she heard the voicemail from a social director at the White House!

So she has bought a gown, and I am renting a tux, and we will be extending our vacation by a few days to fly to DC and report at the White House Monday night. We don't know who will be there, other than the President, Mrs. Bush, and Maria. Maybe Arnold? Maybe Ted? There are many many unknowns.

We checked out some questions with the social director. Can Susan give Mrs. Bush a copy of her book? Yes, but you give it to the Secret Service, and they eventually give it to her. Can we bring a camera to the event? Yes, but you can't take photos of the President or the entertainment, and you have to be discreet. Does Atkins count as a dietary restriction? No, dear, but you'll love the food.

As anyone who has followed my politics on this blog must know, it is too bad I'm not more of a fan of the President. Of course I won't do anything unseemly, but it would be an easier visit if I liked the guy. I've thought about sending a pro-Bush friend in my place!

And in the back of our minds is the sinister possibility that the entire thing is an elaborate hoax. It's an outlandish theory, but in a way more plausible than actually being invited to the White House.

It'll be an experience and a half. More to come...

One less beta

Saturday 1 July 2006

The Web 2.0 trend to label everything beta has been continuing unabated. The Museum of Modern Betas lists nearly 1500 sites labeled "beta".

Over at Tabblo, we've done our part to combat this pernicious phenomenon by leaving our public beta period after only six weeks. In a nod to older software distribution models, we're labelling it Tabblo 1.0. Of course, it's a web site, so in all probability the live code will be updated again before the week is out, so numbering a release is kind of pointless. But it's better than calling it "beta" for years and years.

« | » Main « | »