Archive for the 'web' Category

Project Euler

Tuesday, June 9th, 2009

I’ve been doing the Project Euler puzzles in Python. Here’s one:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

My solution turned out to be unique. Instead of multiplying three-digit numbers, filtering for palindromes, and then picking the largest, it generates palindromes directly by counting down from 999 and “mirroring” the digits to the right:




Since the result will be six digits (nnn * nnn = nnnnnn), the first number in this series that has a three-digit factor must be the answer. Here’s the code, which returns in under a second:

from sys import exit
def mirror(n):
  s = str(n)
  return int(s + s[::-1])
r = range(999, 100, -1)
for i in r:
  pal = mirror(i)
  for j in r:
    if (pal % j == 0) and (pal / j < 1000):
      print pal


Friday, May 22nd, 2009

I needed an avatar/gravatar for a website.


I found that applying Find Edges and then Invert turns a photograph into something that looks like a drawing. Since I removed some “life” by turning the photo into a sketch, I added some back by animating the result.

The Great Firewall

Friday, April 17th, 2009

I got back from visiting Manny in the Philippines yesterday to find I couldn’t access this site. It had been blocked by the Great Firewall of China. I got my host’s support team to change the IP address, so let’s hope it was just a mistake and not criticism from the censors.

Here’s a relevant article from The Atlantic on “The Golden Shield”. I’ve met a lot of people here who don’t know what a proxy server is or where to find one and just stop reading various sites they can’t access from China.

Shanghai Bob tops the charts

Sunday, March 22nd, 2009

This blog now shows up as the first result if you do a Google search for “Shanghai Bob” (with or without a space). Last summer it was somewhere on page three, when I was in Germany it was in the top ten, and now finally number one. See the “web” category of posts for the history of its progress. I’m thinking I should contact the Shanghai Bob Valve Company (which I displaced from the top spot), and offer them my services as a marketing consultant.

100th post

Friday, November 7th, 2008

And 100 days of freedom.

A Google search for “Shanghai Bob” now brings this blog up on the first page of results (previously it was down on the third page). Admittedly, this probably wasn’t too hard to achieve given that Shanghai+Bob is an unusual combination (which is partly why I chose it).

Making it into the top ten for “Shanghai” or “Chinese” will probably be difficult, but it shouldn’t be too hard to find a niche to exploit once I am settled in Shanghai.

I’m winding down the adventure part of my trip now. I’ll be in Tokyo next week, in San Francisco for my birthday, then I’ll head home for the holidays: Thanksgiving in Montana and Christmas in Boston.

Shanghai Bob climbs the charts

Tuesday, September 16th, 2008

Back in Freiburg it is rainy and cold, and I have a cold. I spent a few minutes online today googling “Shanghai Bob” to see what comes up. Apparently the most competition for this name comes from the Shanghai Bob Valve Company. It’s not obvious what scope Bob has in that name — is it modified by Shanghai (the valve company that belongs to Shanghai Bob) or does it modify valve (the Shanghai company that produces bob valves, whatever they might be).

The fact that the email contact is, and that the inventory lists ball valves, gate valves, globe valves, check valves, butterfly valves, plug valves, and slab gate valves, but no bob valves, suggests that the first explanation is correct.

At any rate, I found my site at the top of page three, which is pretty good considering that it was nowhere to be found just a month ago. I’ll check again over the next year and see how it improves. The real test will be once I make it to Shanghai to see where this blog comes in a search for just the word Shanghai.