Wednesday, September 30, 2009

MS SQL Data Analysis Server

I was doing some investigation on the Stack Overflow data dump, and ran across a rather interesting blog posts: Data Mining the StackOverflow Database. He uses a tool called 'SQL Analysis Server' (or something like that) to automatically create fuzzy comparisons between records in a database. The software ends up spitting out trend categories. Neat stuff.

django-uploadify Released

So I finally joined the rest of the Django community in releasing a re-usable app on GitHub. Announcing... django-uploadify!

Uploadify is a great flash-based jQuery plugin which allows users to upload an un-fixed quantity of files through a single interface. It looks and works great.

Django-uploadify is a django app that serves as a wrapper for the functionality, allowing it to interface with Django. The app works by firing a signal whenever a file is received from Uploadify, allowing developers to tie uploadify into their existing apps rather easily.

Tuesday, September 29, 2009

Microsoft Marketing and Kylie age 4.5

I recall reading 6-8 months ago that Microsoft had recently hired a marketing firm to re-make the company's image after continuous negativity surrounding Windows Vista (the same firm incidentally which was behind 'The King' in Burger King's marketing strategy). Their work began to show up a few months ago, first in the form of the "we'll give you $800 to buy any computer you want" type of ads.

However, with Winodws 7 on the horizon, it seems that a new campaign has been launched: Kylie, age 4.5

When I saw the first of this ad series, I didn't think much of it. It's a 4 year old plugging in a camera to USB and downloading the pictures. Ok. Exciting. As with most of my TV watching experience, half of the fun is analyzing the commercials for intent. I couldn't figure out who Microsoft's target was at that point. The message seemed to be "Windows 7: so easy a preschooler can use it." But at the same time, I wondered why they would be targeting the sub-section of society that was looking for an OS that was that easy to use.

And then came the "happy words" commercial...


I saw that and went "wow that was awesome!" Odd thing is, all of my computer tech/programmer friends that I sent that video too also thought it was amazing. So I told myself, "Hey, Microsoft is doing their homework and trying to make cool commercials to target to techies who have long since stopped believing in them." It was exciting. Momentarily. (Ok, I'll admit to looking up what song that was a buying it on Amazon MP3 downloads, which if you're still buying stuff from iTunes quit messing with the DRM already and get it from amazon!)

I felt on several levels that this commercial worked because it...

  • The music. The epic conquer the world music makes the commercial. Hands down.
  • The juxtaposition of elements works -- ponies, and pink, and rats with hats have nothing to do with Windows, but what it does is push the concept of Windows out of the "boring" category -- effective!
  • The very last words on the ad are perfect: "I'm a PC!! ...and more happy is coming!" They're short and choppy like a kid would actually say it (well an ornery kid, but it fits rather well with not being in the "boring" category)

And then just a day or so ago I saw what is apparently the next 'episode' in the campaign:


So they're playing A-Team music... meh. I'm wondering if the "happy words" ad was just by luck that it was cool, and we won't be seeing much like that for the rest of the campaign.

By the way, if you didn't catch it, there is a pig in a bonnet in the first commercial. Watch it again!

Sunday, September 20, 2009

Token Testing Slides

OH-MAN. This has to be some of the coolest TDD stuff I've ever seen, and it's in the web platform I'm already using. Django 1.1 introduces some super-awesome new features for testing. I'll probably spend some time this week trying them out. So far the coolest is easily the...

django-admin.py test --coverage --report
...to generate a %-based coverage report of all your web app's code. Man that's sweet.

Here's where I'm seeing all these new features:

Monday, September 14, 2009

Extending Django's Built-In Template Filters

Django provides quite a few built-in template filters right out of the box. However, eventually you might need them to work in a specific way that isn't quite the default behavior. In my case, the django date filter worked great, but I needed something specific:

By default, the date filter takes a value, along with a formatting argument, and returns a "rendered" string:

{{ value|date:"F d, Y P" }}
This would render as:
January 18, 2009 1:30 p.m.
However, what happens if time information is entered for some datetime's and not for others? We end up with stuff like "January 18, 2009 midnight". Not what I wanted.

Turns out it's quite easy to not only implement your own custom filters, but also to tap the power of the built-in filters as well. To achieve the functionality I was looking for, my custom filter needed to...
  • Work just like the default date filter, taking an argument of format
  • Check if there was no time information on the datetime
  • Remove the time formatting if so
Starting out, here's the base custom filter, along with the code to remove time arguments from the formatting argument:
import re

@register.filter
def smart_date(value, arg):
if value.hour == 0 and value.minute == 0 and value.second == 0:
arg = re.sub(r'[aAfgGhHijlLPOsTZ]', '', arg)
What I did not want to do was re-implement the functionality of the date filter. However, it's easy to bring that functionality into your custom filter by simply importing it (yeah, it's really that easy).

Here's my completed "smart_date" tag:
import re
from django.template.defaultfilters import date as date_filter

@register.filter
def smart_date(value, arg):
if not value.time():
# remove all time-related formatting
arg = re.sub(r'[aAfgGhHijlLPOsTZ]', '', arg)

return date_filter(value, arg)

  © Blogger template 'Minimalist G' by Ourblogtemplates.com 2008

Back to TOP