22 September 2009
That Big Shop
I've always found shopping at Amazon a bit of a cumbersome experience. The pages seem a little cluttered and when choosing between products there's lots of back-and-forth as you switch between search results and product detail.
So I thought I'd make use of the Amazon Product Advertising API and write my own interface. The result is That Big Shop. It's not old browser or search engine friendly but it does, I think, have a more responsive feel to it than the standard Amazon interface.
To create the site, I choose to use the Cappuccino framework and I'm glad I did. The painful part of writing web applications is getting them to look and work the same across browsers. With Cappuccino I didn't need to worry about that; as long as I coded to the framework API, Cappuccino would take care of rendering what I wanted consistently across browsers.
categories: amazon, cappuccino, that big shop
12 August 2008
QR codes for cogteeth.com

With a little help from the Google Chart API, I've added the ability to create QR code t-shirt, mugs and cards over at cogteeth.com.
QR codes are quite nifty little two-dimensional barcodes which can store a surpising amount of data in a small space. There are numerous readers available to decode them including mobile phone apps which enable you to decode them using your phone camera.
Any data can be stored in these codes but there are a number of standards or conventions recognised by the readers. For example, many will detect an encoded URL and automatically pull up the referenced web page. The documentation for the zxing reader gives a good summary of these conventions.
15 April 2008
Google App Engine
It took less than two hours to convert cogteeth.com to run with the Google App Engine. Admittedly this is a pretty simple example since cogteeth doesn't use a database and Django is supplied with the App Engine environment.
All that was necessary was:
- Create a
main.py: Since the app is Django based this was just a modified copy of the version on this page. - Create an
app.yamlto pass all URLs ontomain.pyand serve the static files directly. - Modify some URL fetching code that previously used
urllib2to useurlfetch.
categories: app engine, cogteeth, django, python
11 October 2007
Blogger custom domains
This blog is currently hosted at http://www.codesimple.net. This is a pity since the more succinct http://codesimple.net would be preferable. Unfortunately if I try and set the custom domain in Blogger to just "codesimple.net" it complains with a somewhat dubious "Another blog is already hosted at this address" message.
I think perhaps this is related to also having Google Apps active on this domain. Both services require you to point your DNS at ghs.google.com.
Also slightly odd is that Google do an HTTP redirect for any requests to http://codesimple.net to http://www.codesimple.net. I can't find any setting in Google Apps to control this "feature".
categories: blogger, google apps
WordPress to Blogger
I recently decided to switch my blog from Wordpress to Blogger. Not because I think Blogger is better but because I wanted to avoid maintaining my own instance of Wordpress and Blogger would host my blog on my domain for free.
To copy the posts across I wrote a small Python script which takes a file of exported Wordpress posts and uses the Blogger Data API to upload them to Blogger.
If you want to do this yourself, you will need to:
- Download the script wptoblogger.py.
- Ensure you have Python 2.5, BeautifulSoup and Google's GData Python Client.
- Create your target Blogger blog and note its ID.
- Export your Wordpress blog to an XML file (I think this is only available in version 2 and above of Wordpress).
- Run wptoblogger:python wptoblogger.py -u your_blogger_username -b your_blog_id -a author_for_posts wordpress_xml_file
- It doesn't support multiple blog authors - all posts will be marked with the author_for_posts.
- A limitation with the Blogger API means that comment authors can't be set (they always appear as the blog author). As a workaround, I prefix each comment with a "Comment from..." line (see the existing comments on this blog).
- Blogger impose a limit on the number of posts you can create via the API in a certain time period. So if you have a lot of posts to transfer you may need to modify the script to post them in batches over a number of days.
21 June 2007
Join and split
It always amazes me when I try out a new programming language and find that the standard library doesn't include join and split functions. join is used to combine a list of strings into a single string with each item separated by a delimiter. split takes a delimited string and divides it into sub-strings. Python, thankfully, does provide these functions:
>>> ':'.join(['a','b','c'])
'a:b:c'
>>> 'a:b:c'.split(':')
['a', 'b', 'c']
Erlang provides regexp:split but it looks like I have to add my own join function. Not sure this is the most efficient implementation but it will do the job:
intersperse(_, []) -> [];
intersperse(Element, List) ->
tl(lists:reverse(lists:foldl(fun(X, A) -> [X,Element|A] end, [], List))).
join(List, ListOfLists) -> lists:append(intersperse(List, ListOfLists)).
> intersperse(":", ["a","b","c"]).
["a",":","b",":","c"]
> join(":", ["a","b","c"]).
"a:b:c"
And since strings in Erlang are just lists of integers this can be applied to other lists as well.
16 November 2006
Flickr bookmarklet
I've just added Flickr support to the Cogteeth Bookmarklet. Obviously it worked with Flickr before (since it works with most web pages) but now it will automatically detect Flickr images and provide the following additional features:
- It will retrieve the largest available version of the selected image from Flickr to ensure the best quality product is produced.
- Make the image clickable so that the user can easily go to the Flickr photo page.
- Provide links to any other available sizes of the image.
- Show the license that the image poster has attached to it.
