Stuff I learned over the weekend

1. Finding stuff in lists of dicts in Python If you have a list of dicts in Python like this: [python]items = [{“id”:1, “name”: “Rasmus”}, {“id”: 2, “name”: “Rick”}][/python] …and want to check if there are any dict items with an id of a specific value (e.g. 2) I first came up with this: [python]2 in map(lambda x: x[‘id’], items)[/python] The downside is that it will loop all items which may be inefficient for larger lists. Niklas eventually pointed me at Python’s any() function which I managed to miss while googling for other ways. Thus, a nicer version is: ...

October 27, 2008 · Peter Krantz

Building your own Twitter client with Fluid and jQuery

Like many before me, I was searching (unsuccessfully) for a decent twitter client. There are many, but most seem to be ad sponsored or based on a rather hefty framework like AIR (which by now, I guess, has been silently installed on my computer anyhow). Update: This project is now deprecated and Twitter has removed basic authentication. Custom apps have major implications for usability so I decided to roll my own. I wanted to try out Fluid, the Prism-like app to contain web apps in their own process/window, to see if it is possible to build a complete open source ad-free twitter client in a single web page only using javascript and HTML. ...

July 31, 2008 · Peter Krantz

RDF vs Microformats and the Semantic Web

James Simmons writes about some of the pros and cons of Microformats and RDF (with an extended discussion at InfoQ). On the benefits of Microformats (with which he means Microformats.org-style microformats) he mentions: Designed for humans first, machines second Modularity / embeddability Enables and encourages decentralized development, content, services A design principle for formats Adapted to current behaviors and usage patterns Highly correlated with semantic XHTML I am new to RDF and the semantic web (but have used microformats in previous web projects) but to me the advantages of RDF and RDFa (the “sprinkling” framework) are clear. Microformats may work for a limited set of use cases but I have not yet understood how to use microformats efficiently for the bulk of what I need. However, it is great that a lot of development is going on in the area of embedding machine readable data in documents. Without microformats the pace would probably have been much slower. ...

October 31, 2007 · Peter Krantz

SimpleCrawler for your everyday web crawling needs

Over at the standards-schmandards blog I often test websites to gather statistics on specific HTML use, accessibility and other things. Each time I have written a web crawler to collect the data. In Python and Ruby this is a simple task but last time it was like a déjà vu and I decided to create a Ruby library that I could use in the future. SimpleCrawler is a Ruby gem that covers basic web crawling needs. Coupled with Raakt and Ruport it can be used to create a basic accessibility report for a website. ...

August 27, 2007 · Peter Krantz

MySpace Layouts and Markup Quality

I have received an increasing number of advertising inquiries from MySpace layout sites. Apparently the term “MySpace layouts” is a very popular search term these days. Looking at the default MySpace layouts one can unserstand why. I am confident that they didn’t hire a designer to create the default MySpace look and feel. Looking at the MySpace HTML, they certainly didn’t hire a GUI developer. The markup looks like it was ripped from a teenage fan site from the early nineties: ...

August 16, 2007 · Peter Krantz

What happened to plain old HTTP redirects?

So, I was looking for an offer on IP telephony and thus decided to point my browser to one of the larger ISP:s. I get a blank page back (blank as in “all white”). A couple of years ago, this wasn’t uncommon if you were brave enough to use a non-mainstream browser. But today it is 2007. A brief look at the HTML source gives: ...

June 5, 2007 · Peter Krantz