Peter's Blog

Redefining the Impossible

Items filed under safari


I was studying my access logs and noticed visitors using the Safari web browser under Windows. I thought, "No, can't be right, maybe Safari is lying to the server about the OS to get around compatibility problems" since Safari is an Apple OS/X browser.

I was at the Apple site for something or other and discovered it is true: there is a version of Safari for Windows here. It's a beta but everything is beta these days.

I've been using it at home and I'm liking it. It has the features of Firefox that I actually use but it feels leaner and meaner. There is something about the way it presents web pages that makes them look nicer. Don't ask me what, it's a subtle Apple designer thing that an engineering brain cannot put a finger on: if mine could I would be outta here and busy growing a ponytail.

One thing about Apple design I must address: the brushed metal look gets old very quickly, I'm already tired of it from iTunes I don't see any way to change the 'theme' and Windowblinds cannot change it (did I mention that rather than buy Windows Vista I just bought Windowblinds?).

It has crashed on me once, the text box I am typing this in has tiny weeny text and is making me squint (my glasses are two flights of stairs down sad ) I have found one or two sites with problems but I'm still using it. Oh, and it seems to insist on installing Quicktime when you install it which is a minus to me.

Firefox is seeming more and more bloated these days and takes about thirty seconds to boot on my crappy work computer. Opera is ok but whenever I try it I drift back to Firefox. Safari is quite likely to go the same way but it's a new toy for a few days. Internet Explorer, well HA I only use it on sites that don't work with anything else.

I so want an iPhone.


Filed under: firefox safari windowblinds

4 Comments

My latest Safari book is Python in a Nutshell a very comprehensive reference guide to python, plenty to learn. In some places, like the standard library section, it just summarises what the module does in a way that is not so enlightning but I have picked up some stuff in passing that I was not aware of before. The standard python documentation is very dry and it can be hard to find a useful descriptions. Python in a Nutshell does explain things in a more understandable way and it does include more example code. I may well keep the safari book in my bookshelf permanently (or buy it) to use in parallel with the python documentation.

I read the section on testing which described the doctest and unittest modules. I have tried docstring in the past, it involves putting test scripts in the docstrings of each function and to my mind this made the code bloated and hard to read.

I hadn't tried unittest before so I gave it a try with some django code, specificly code to convert a string of tag names into correct database entries. I started off doing it the Right Way by writing the tests first, before I started coding. It was a good exercise, just thinking of what I wanted and what could go wrong before I started to code.

The unittest module requires creating TestCase classes with three phases of testing:

  • a setUp function to initialise things
  • various tests in arbitrary order (because each test is a method and the methods are stored in a dictionary there is no guarantee on what order they will be executed)
  • a tearDown function to close things up

In my case of manipulating the database I needed setup and teardown code for each individual test to ensure that the correct tags and tag->post mappings were created for each tag string under test. I could have created multiple TestCase classes, with seperate setUp and tearDown functions for each individual test but that seemed like too much typing. The problem here was really due to the arbitrary order in which the tests could be performed: each test cannot rely on what state the preceeding test left the database in so each test has to set the database up first.

As I slept last night I tossed and turned with this on my mind. Writing lots of setUp and tearDown code just to get around the arbitrary order. I could write just one big test function that went through a sequence of tests but it felt like cheating. To make this worse, I looked at the django tests and they used something similar to docstrings but in seperate files, a straight sequence of tests as if typed into the command prompt. It looked good and reading it is like reading example code. However, I have two problems with working this way:

  • it needs more editing to create the script than unittest
  • because all the code is inside a string, it is all one colour, I lose syntax highlighting. Do I need editor macro's to toggle the string delimiters on and off?

I think what I will do is use unittest without excessive setup and teardown code and just write long test functions. The aim of the exercise after all is to test, not to write test code.

Conclusion: testing: keep it simple and don't lose sleep over it.

Update: single stepping through the unittest code with WingIDE, it seems that the test case methods are sorted by name using the cmp function so they are probably alphabetic. Hence I could just name my functions test_001, test_002 etc or I write something to determine line numbers, or I define an array of test functions...


Filed under: books django python safari

1 Comment

I succombed and subscribed to safari, the scheme that lets me read ten technical books a month for about £10]. I have been tempted since I first found it, I've been studying the site and my mouth has been watering more each day. It means I can write some potted book reviews here (ten a month). I can also do quotes, up to 250 words.

I went for basic subscription rather than premium: the latter lets you download a limited number of chapters as pdf files and gives you discounts if you buy the books but it costs nearly twice as much. Also, I cannot use the books for commercial purposes so anything I learn I will have to try to forget while I am at work (not normally a problem).

First book: Mind Hacks an interesting book about various tricks to do with analysing the workings of the human brain. This kind of thing:

  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  milk
  what do cows drink?

It is interesting so far but I haven't really got into it.

Second book: Windows XP Cookbook, a collection of recipies for making Windows XP more spicy. This has been a little disappointing to me so far, it's mostly stuff I am already aware of, a lot of it I wouldn't bother to put on this site. It has told me how to disable taskbar notifications that never seem to do anything and yet are not hidden automatically (right click taskbar, properties, customize, get a list of icons and the ability to hide each one).

Conclusion: how am I going to find time to read two books a week?


Filed under: safari