(2)
Wed Mar 01 2006 21:35 Random Books:
The main problem is the arbitrary restriction of Amazon Web Services where you can't get more than 250 pages of query results. If it weren't for this restriction, you could pick a random number from a huge range and do a Browse Node search to get the corresponding page of results. This is still a pretty good solution if you want to search for products in a restrictive set like the set of science fiction books: find the corresponding Browse Node and do a browseBestSellers.
As it is, the simplest solution is to only search for a single word, instead of Jarno's two. Here's some code that does that and works pretty well.
import amazon
import random
def random_product(keyword, max_page=250, associate="crummthesite-20"):
result = None
while result == None:
page = random.randint(1, max_page)
try:
results = amazon.searchByKeyword(keyword, page=page, type="lite",
associate=associate)
if results:
result = random.choice(results)
except amazon.AmazonError:
results = None
if not results:
max_page /= 2
return result
def format_product(p):
print '<a href="%s">%s</a>' % (p.URL, p.ProductName)
keyword = random.choice(open("american.0").readlines()).strip()
format_product(random_product(keyword))
Sample book: Reutilization of Waste Materials.
The other solution is screen-scraping. As covered earlier, there is an Amazon URL such that you can randomly vary a parameter and get a more or less random set of books. Here's some code that fetches one of those URLs and grabs an ASIN at random. Then it does an AWS lookup of that ASIN because life is too short to scrape all the appropriate information off that big ol page. This is a little less reliable than the earlier implementation, but it gets a better random distribution of books (since the other one picks a word to search on, and word distribution is not random).
from BeautifulSoup import BeautifulSoup
import amazon
import random
import urllib2
import re
import socket
URL = "http://www.amazon.com/exec/obidos/tg/new-for-you/top-sellers/-/books/all/books/0/1/%s/1/"
def random_book(max_page=150000, associate="crummthesite-20"):
product = None
while product == None:
url = URL % random.randint(1, max_page)
req = urllib2.Request(url)
try:
soup = BeautifulSoup(urllib2.urlopen(req).read())
asins = soup.fetch("input", {"type" : "hidden",
"name" : re.compile("asin\.*")})
if asins:
asin = random.choice(asins)['name'][5:]
product = amazon.searchByASIN(asin, "lite", associate=associate)[0]
except socket.error:
product = None
if not product:
max_page /= 2
return product
def format_product(p):
print '<a href="%s">%s</a>' % (p.URL, p.ProductName)
print format_product(random_book())
Sample book: Choice, Welfare and Measurement
Wed Mar 01 2006 21:55 Restaurant Tradeoff:
Now I've discovered Rice to Riches, which only sells rice pudding with lots of different toppings. I think if I start a restaurant it would be easier to start one of the really specialized ones. Let's say, I would sell only choux puffs with various sweet and savory fillings. Meanwhile, here's a copycat recipe for their Rocky Road rice pudding.
Wed Mar 01 2006 22:17 Flickr Rebus:
(1)
Thu Mar 02 2006 22:23 Link dump:
Turns out double rainbows are caused by inflation. Now here's Bob with the weather!
The Bard subsists on simpler food:
A dinner, not severely plain,
A pint or so of really good
Champagne--
I don't understand anything about poetic meter or why one meter is funny and another one is serious, but that one's funny. It's a meter with a punchline.
(5)
Fri Mar 03 2006 13:32 Humanocentrism:
Just part of my longstanding tradition of taking the logic of Transformers at face value when nobody else does.
Fri Mar 03 2006 19:55 Amazing New Web Meme:
Unfortunately, this web meme has no way of propagating, so it is sure to die out. Just like the laser harp.
Fri Mar 03 2006 20:05 Language Games:
For a while before I A game was designed; Non- reliability of conversion and the inclusion of mendacity of translator. Boredom without finding that very, one condition in order to do the game went the tool which in order to distort message with use to converting that of the automatic translator on front and back is automated. Multibabel There is a kind of thing which I had with heart.
The latest entrant into this fray is lib.rario.us, which looks just like del.icio.us except it's for keeping track of things that have an ASIN or ISBN. I like the del.icio.us interface a lot (mainly because it's easy to hide it behind a NewsBruiser interface), but lib.rario.us doesn't offer even one tiny web service.
Amazingly, though, the traditional del.icio.us rip-off name proves itself useful for once: it's given me the obvious-in-retrospect idea of just using del.icio.us to keep track of my wish list. Use it as a platform. Why didn't I think of that before? It could work, once I put up something between me and del.icio.us that looks up ISBNs from titles.
(1)
Fri Mar 03 2006 22:25 Paleoworld:
"Troodon: Dinosaur Genius" is about the Troodon, which had an opposable finger and the largest brain/body mass ratio of any dinosaur. Pretty soon the documentary will reach the traditional "unwarranted extrapolation" phase, where people will speculate that, were it not for the K/T event, Troodon could have continued its trend towards greater intelligence and become a sentient lizardoid species. Yes, just like in that episode of Star Trek: Voyager.
The main problem with Paleoworld is that there's no warning when it goes to commercial, and the voiceover announcer for the show sounds just like the voiceover announcer in the commercials. So you hear things like this. "But the story of Troodon does not end here. It launches us from the dinosaur age to the space age. The latest Mars Orbiter is about to arrive!" And "Troodon was a dinosaur with incomparable brainpower. All of us have internal plumbing. But sometimes our pipes doesn't work as well as they should."
I once worked with a guy who was going to voiceover school nights, and he said that there is a standard set of voices that you learn in voiceover school. I guess this is so the school and employers can grade you on an objective scale, but it's really creating a voiceover monoculture.
I first noticed the popularity feedback loop back in the BBS days. A common feature of BBSes was a "Most Popular Files" list, and people just kept downloading the files on the list, which to my mind defeated the purpose of advertising these files. I set up a "Least Popular Files" list that listed all the files that had never been downloaded. It didn't really work.
(2)
Tue Mar 07 2006 23:20 Search Request:
Thu Mar 09 2006 08:32 Crosspost:
Thu Mar 09 2006 21:55 Off By One:
Bonus Wikipedia link: Kappa
Fri Mar 10 2006 14:08 Alternate Universe News:
The White House maintains that Gamera is a friend to all children.
Sat Mar 11 2006 20:35 QOTD:
I redid the outline so it shows the reviewer coverage of the various recipes. I'm also working on a script that grabs the code snippets out of the recipes, runs them, and sees the results match what it says in the book. That one's a little tricker.
(3)
Mon Mar 13 2006 16:48 Formal:
Incidentally, I recently became a Texas oil millionaire. Why you laughin', li'l buttercup? Ain't it the truth, why it says so right here on this printout of a web page about my bank account.
(2)
Wed Mar 15 2006 23:15 Done!:
Thu Mar 16 2006 10:15 I'm Partched!:
(7)
Sun Mar 19 2006 01:09 Once Upon a Time Variant:
So, the variant: you start off with two ending cards. Whenever it's your turn, you must play one of your ending cards before you can play a story card. You can just play the ending card and start tying it into the story, or you can talk for a few sentences before playing the ending card, to connect the current story to the ending. No one can interrupt you before you play your ending card, but you can't play any of your story cards either.
Once you play the ending card, your turn continues as in vanilla: you play story cards and try to get to the point where you can play your second ending card. If someone interrupts you, you must draw a story card and an ending card (so you begin each of your turns with two ending cards).
If someone's story gets to the point where you could play an ending card, you can interrupt with the ending card and start your story from there. (This actually happened.)
Since OUaT stories jump around a lot anyway, it's not difficult to use an ending card to close one thread of the story or to spawn a new thread. The additional constraint is generally what I need to feel comfortable making up an OUaT story.
Update: See comments for feedback from OUaT co-author James Wallis.
(5)
Sun Mar 19 2006 13:33 Why Do You Exist Here?:
Does anyone else remember this paper? Maybe I should have developed an intense emotional hangup when I first discovered it, so that I'd always be revisiting that moment and I could remember the URL.
I am reading The Dalkey Archive but so far it's a much less funny ripoff of The Third Policeman. It better get surreal and fast, or I'll... regret my purchase!
(2)
Tue Mar 21 2006 07:43 Caution: Congratulations!:
(2)
Wed Mar 22 2006 20:59 Pac-Man Heresy:
But come on. They look like ghosts. Specifically they look like Charlie Brown ghost costumes, baggy sheets over the head with holes cut for eyes. That's why people think they're ghosts, not because one port twenty-five years ago couldn't handle five moving objects on the screen at once. People don't see random things flickering and say "oh, that must be a ghost". There has to be some preexisting resemblance to a ghost. So don't blame people for thinking that the monsters are ghosts.
Instead of simply asserting that the monsters are not ghosts, it's pretty easy to prove it, a la Aristotle. A ghost is the disembodied essence of a dead person. When Pac-man, under the influence of a power pellet, eats a monster, the essence of the monster is separated from its body and goes into the penalty box to regenerate. What is that disembodied essence but the monster's ghost? How can a ghost have a ghost? It does not make sense.
Hopefully this proof can bring some civility to the enlightenment of those who think the Pac-Man monsters are ghosts. This is my Pac-Man heresy, brought on, I believe, by Pac-Man fever.
I originally tried to write this entry in the style of an Arrested Development episode, but though it was formally correct there were no jokes in it. This is how you repay me for how I repay you?!?!
Fri Mar 24 2006 20:29 Emergency Samosa Sauce:
I developed a samosa song which I sing when I'm awaiting samosas. It goes: "Samosa!" Except you say it on the fourth beat of the measure. I think it could be the next "Tequila".
(1)
Sat Mar 25 2006 00:57 Terror of Fox Terrier:
I reread this essay today and I must have gone through postmodern puberty since my first reading, because this time I saw the subtext. Human culture is supposed to change and propagate quickly, by Lamarckian means. But the blind, semantics-ignorant copying seen in these textbooks shows that culture propagates by slower Darwinian processes too.
Textbooks evolve through sexual selection. Nothing selects against this bizarre and useless (and, Gould claims, wrong) comparison between Eohippus and a fox terrier, because nobody ever reads that sentence and tries to make sense of it. It is junk DNA. The whole text of the textbook only exists to make it larger, so it looks more attractive to school districts. All the resources are going into improving the textbook's plumage.
The reason I read the essay in the first place is that I've seen the fox terrier comparison three times in the past month or so. This is twenty years after big-shot paleontologist Gould publishes an essay totally slamming the comparison, with no one coming forward to explicitly defend it. The first time I saw it was next to an Eohippus in the horse evolution exhibit at the American Museum of Natural History. I guess it was about the right size, but I've seen a real Eohippus fossil and I've never seen a real fox terrier, so what do I know? Could we get a more helpful comparison in a real museum exhibit right next to the actual skeleton? (The Gould essay makes a tenuous connection between the AMNH and the original source of the comparison, so maybe they're just being stubborn.)
The second place I don't remember where I saw it. The third place was in a book I just read called The Eternal Frontier, an ecological history of North America. Apart from the fox terrier comparison it was a pretty good book, though it was written by an Australian which means it exhibits the cowboy obsession common to non-North Americans who write about North America. It was also pretty depressing since it portrays the entire history of life as organisms going in and really screwing things up for other organisms (though occasionally an non-organism like an asteroid or an ice cap really screws things up for everybody).
Nothing has really happened except slow spotty progress on editing the book. People are starting to ask me what I'll do next. Next I will decide what to do next.
Mon Mar 27 2006 19:54 Abominations:
I could buy the robonic (were they trying to get a trademark?) modifications if the show took place in a Harrison Bergeron society, where as a matter of social policy people at the Stooges' level of competence were given special abilities to bring them up to the level of the general population. But it ain't so. There aren't even any Three Laws of Robonics. The only thing this cartoon has going for it is that according to IMDB, the guy who dispatches the Six Million Dollar Stooges is code-named Agent 000. The show predates and has the same basic plot as Inspector Gadget (minus the PSAs, but if you started doing PSAs after Stooges shorts you'd never be able to stop). You think that'd be worth something, but it's not.
Obviously the Stooges are not some wonderful cultural icon that has been demeaned by this stupid cartoon, but that doesn't excuse anything. Though by any measure the Stooges come up short when compared to the Marx Brothers, they have the same basic dynamic, and it's one you don't see enough anymore. Characters with no marketable skills, who cling together more through inertia than attraction or synergy. Coveting a position in high society, they end up going for it because they've seen that nothing really separates them from the current inhabitants of high society (who have no marketable skills either). But their plans are jeopardized by their own self-destructive behavior. <-- This paragraph doubles as my "outreach" attempt to explain to women the appeal of the Stooges, such as it is.
(1)
Tue Mar 28 2006 23:17 Earwax:
Would you like to learn more about earwax? Too bad. Already the knowledge burrows through your tympanum and into your brain!
Tue Mar 28 2006 23:36 And then I FREEZE-DRY the marshmallows!:

(8)
Thu Mar 30 2006 23:31 Vowecowedrrr:
(1)
Fri Mar 31 2006 15:04 More Cat, More Girl:
With further ado, the comic:
Tomorrow: Kevan's constraints, if I have time.
Fri Mar 31 2006 21:48 Mini Game Roundup: