Parsing ASP.NET sites with WWW::Mechanize and Hpricot

Users of Hpricot (which WWW::Mechanize is using as the default html parser) may have discovered that the buffer size for attribute values is set to 16384 bytes default. Typically this isn’t a problem, I mean who would put 16Kb of data into an HTML attribute? Well, ASP.NET uses a hidden input field to store view state in order to save a few clock cycles on the server side (and spare developers the hazzle of coding view state)....

February 18, 2007 · Peter Krantz

Hpricot - My New Favourite Ruby XML Parser

One of the missing features in the default Ruby distribution is the lack of a good XML parser. The included REXML is only sufficient for the most basic scenarios as performance degrades quickly with XML size. Recently I had a situation where I needed to parse a 700 Kb XML file and extract some values with XPath queries. Doing this in REXML proved to be too slow (around 30 seconds)....

February 14, 2007 · Peter Krantz

Using the Apple remote in Ruby

After playing with iremoted and Ruby’s IO.popen I guess I am convinced that Ruby really works as a glue on many levels. So, using iremoted and capture Apple remote commands in the terminal it is trivial to use the remote to control a Ruby application. Of course, calling OS commands isn’t limited to Ruby. Here is a minimal dungeon game which you control with the apple remote. If you ever manage to find your way out I would be surprised…...

February 5, 2007 · Peter Krantz

Making open-uri play nice with HTTPS and expired certificates

I was using the open-uri library to download HTML in an accessibility test when I found that it does not work well when the remote site has an expired certificate. In this case open-uri will throw a “certificate expired” exception. This may be ok as a default behaviour, but there is no option to override the check. Fortunately you can easily change the behaviour by editing the open-uri source. If you are on Windows it is available in C:\ruby\lib\ruby\1....

January 27, 2007 · Peter Krantz

Google Code Search Reveals Anger, Frustration and Hate

Google’s Code search is a great way to spend an evening. Indexing a hefty amount of source code reveals anger, frustration and hate. Some favourites: I hate Java Java sucks Python sucks I hate Microsoft I hate DTDs (that is REXML by the way…) Interestingly, searching for “Ruby sucks” does not return any matching documents…

October 11, 2006 · Peter Krantz

Testing Google's Accessible Search with the Ruby Accessibility Analysis Kit

Recently Google Labs released Google Accessible Search - Accessible Web Search for the Visually Challenged. Running the search page (http://labs.google.com/accessible/) through RAAKT (using the online version) yields three errors and the search result page is using tables for layout. Maybe I am missing something here, but how hard can it be for Google to make sure their search page is using best practices and avoid basic accessibility pitfalls?

July 21, 2006 · Peter Krantz

Languages Influence Your Thought Process

When I studied social antropology a couple of years ago I never thought that it would influence my future programming endeavours. At that time we looked at theories on how things in our surroundings influence thought processes. One theory is called the Sapir-Whorf hypothesis. It states: “…there is a systematic relationship between the grammatical categories of the language a person speaks and how that person both understands the world and behaves in it....

July 20, 2006 · Peter Krantz

Automated accessibility tests in Ruby on Rails

A couple of days ago I released RAAKT - The Ruby Accessibility Analysis Kit gem (I know, it really needs a better name). RAAKT is a gem that can be used independently of Rails and my plan was to make a Rails plugin that would add a custom assert method that did the check. It turns out that it only takes five lines of code so there is no need for a plugin....

July 14, 2006 · Peter Krantz

Porting the Python Accessibility Analysis Kit to Ruby

At RailsConf in Chicago I realized that it would be a good idea to port PAAKT to Ruby and make sure it can be used for automatic accessibility tests in the Rails testing framework. Work has begun and I hope to release it at the end of this summer if all goes well. The project is registered at Rubyforge. Now, all I need is a good name. Maybe RAAKT? Suggestions are welcome....

June 29, 2006 · Peter Krantz

Exporting Exchange calendars to Apple iCal over HTTP and WebDAV

Update: This code has been integrated and greatly enhanced in the rexchange project by Sam Smoot. Update 2: iCal in Lion supports Exchange and none of this should be required anymore. Having recently recieved a brand new MacBook Pro from my employer I needed to get basic things such as mail and calendaring working. We use Microsoft Exchange 2003 which is great if everyone is using Outlook. Since I work with various clients I am subjected to their respective firewall policy which typically only allows HTTP(S) traffic....

April 29, 2006 · Peter Krantz