Dec 13

Google Analytics performance monitoring details

The first rule of benchmarking: make sure you know what you actually measured

Google Analytics has a very handy "Site Speed" report which measures the average load time for your pages as seen by your users. Unfortunately, there are two implementation details which are important to keep in mind:

  1. The reports are heavily based on the average load time, which can skew the results pretty heavily: one multi-minute load time from someone in Haiti on a satellite connection outweighs quite a few users with .8 second load times. There is a bucket report but it's a bit clunky and there's no easy way to get the data out to run your own stats. Even a simple switch to using the median would make this report less ominous at first glance and it'd be a really good use for some sort of distribution graphic.
  2. The more interesting problem is that Google Analytics uses the W3C Navigation Timing API and reports only the value of window.performance.timing.loadEventStart - window.performance.timing.navigationStart. The browser won't fire the load event until all resources on the page have been loaded including external services like Google Analytics. Unfortunately, you will find situations where http://google-analytics.com/ga.js takes a considerable amount of time to respond (yesterday I had 40 second response in a webpagetest.org session) and this will be reflected in your stats even if the page loaded considerably faster from the user's perspective.

    I'm currently experimenting with deferring loading Google Analytics until after the load event using this code. Initial testing appears promising and the elapsed time to load everything else is definitely more accurate:

    Relying on NavigationTiming does mean that you won't receive any information from older versions of Internet Explorer unless they have the Google Toolbar installed, which means some of your worst-performing clients will be invisible. Chrome Frame would be my preferred response…
May 15

Where to eat in DC around Thomas Circle

Someone recently asked for some restaurant tips. On the off chance anyone else finds this useful…

A relative asked for some tips for a friend who was visiting DC and staying near Thomas Circle. This ran a bit long…

Sounds like fun. Just off the top of my head, you’re right around the corner from one of DC’s best beer bars (Churchkey); I haven’t been to the restaurant downstairs (Birch & Barley) but it’s also supposed to be good. Brasserie Beck is a very popular Belgian place with excellent mussels and a good beer selection. Peregrine might have their second coffeeshop open on 14th St. by then; otherwise your best option for high-quality coffee is probably Chinatown Coffee.

For Ethiopian food, Dukem is quite nice - there’s a big vegetarian platter which is quite good for variety - and Lalibela is good and also quite close to where you’re staying. In general, you can’t go too far wrong if you walk up to U St. (not too far) and stop when you smell something tasty. One word of caution: we haven’t been to a quick Ethiopian place yet, so plan for a comfortable, leisurely dinner.

Heading down to Chinatown, Burma is good for variety and Jaleo has good Spanish food. Rasika is a good high-end Indian restaurant - perhaps if you were thinking “upscale night out” - but to be honest, the best Indian food in the area requires a car trip up to College Park. Zaytinya is great option for Greek/Turkish/Lebanese and has good happy-hour pricing and specials.

Around the Mall, there aren’t many options on the south side - the cafe at the American Indian museum is easily my favorite as they feature a wide selection of Native-American food. One option which has really improved matters during the week is the new wave of food trucks competing with the traditional hot-dog vendors; the locations vary and the easiest way to track the options is to use a Twitter aggregator like Food Truck Fiesta - they frequently tend to cover the areas around the Mall since there are a ton of visitors and federal workers looking for better lunch options.

If you found yourself on Capitol Hill, Seventh Hill Pizza is superb and Belga is another good Belgian option.

Our favorite chocolate covered figs come from Biagio which is heading into the Adams-Morgan (18th St. NW up past U St). If you were up there, perhaps walking on the way to the Zoo, a really fast, tasty and cheap option is the Amsterdam Falafelshop and if you were looking for light meals and good coffee or drinks, Tryst is a coffeeshop with a liquor license and a full kitchen. There’s also a hispanic street market there during the day with most Central & South American cuisines represented by at least one stand. (One note: there are many places which claim to serve Mexican food in DC; none of the ones I’ve tried have been good. The closest option to moving back to San Diego which I’ve found is a taco cart in Northern Virginia).

I’m not sure how you were planning to get around town but one new option is Capital Bikeshare You can spend $5 for unlimited 30-minute rides within a 24-hour period or $15 for 5 days, there’s a great iPhone/Android app to find the closest station, and it’s extremely convenient for dodging traffic while still seeing the city. I use this heavily to head down to work and have been quite happy with it.

Jan 09

See you at PyCon

I'm looking forward to heading off to PyCon in a couple months, particularly as this time I'll be staying for the full sprints. Hope to see you there!

PyCon 2011, Atlanta, March 9-17

Dec 23

Django quickie: custom admin filters with 1.2.4

NOTE: the call signature changed slightly for Django 1.2.5 - the gist below has been updated but you will need to update anything coded against 1.2.4

Django 1.2.4 was released earlier today with a security improvement which might impact some admin customizations. Django admin uses the querystring to implement list_filter and date_hierarchy but prior to 1.2.4 it also allowed you to simply link to a change list with arbitrary other filters. This wasn't a supported feature but was quite handy when you want to filter on something which doesn't make sense as a normal list filter: for example, a library wouldn't want many thousands of list_filter entries but might want book/change_form.html to link to {% admin:library_book_changelist %}/?author__exact=42 as a convenient way of navigating relationships.

The release notes are somewhat cryptic so it's easier to read the source for the new rules: ModelAdmin now has a lookup_allowed method which is used to either allow a lookup or raise a SuspiciousOperation exception. By default, lookup_allowed whitelists fields in list_filter or date_hierarchy; adding additional fields may be done by a simple subclass:

Nov 04

Google BidiChecker bookmarklet

Run Google's BidiChecker using a bookmarklet

Google just announced their rather handy BidiChecker utility for testing that your site correctly handles mixed LTR/RTL text. Running it in a unit test as they demoed is great but sometimes I just want to check a single page quickly, which lead me to combine it with my earlier bookmarklet template to produce this:

Run BidiChecker

Source: https://gist.github.com/662454

Oct 05

Plugging PromoteJS

The fine people at Mozilla are working to promote better JavaScript documentation than what you typically find with widely-linked but somewhat stale resources. This definitely deserves a plug, particularly to stay ahead of certain SEO bandits:
JS Array .pop