Friday, October 27, 2006

django on windows mobile 5


Hey, I just got the web framework django running on a Windows Mobile 5 PDA. I'm running under python 2.5 from here.

There is a bit of messing about which I'll blog about later but mostly it's installing stuff and getting around the lack of the command line shell. The only other tip is to start the development server with --noreload.

As sqlite3 is available it should be possible to build a proper web app but I haven't tried that just yet.

Update: mentioned on the Django blog!

Wow, I am so proud to be mentioned on the django site, thanks very much.

Here's my startup script that lets you use the server over WiFi. To run it you open it in File Explorer:

import sys
import socket

sys.argv.append("runserver")
ipPort = "%s:%d" % (socket.gethostbyname(socket.gethostname()), 8000)

sys.argv.append(ipPort)
sys.argv.append("--noreload")

from django.core.management import execute_manager

import settings # Assumed to be in the same directory.
execute_manager(settings)

# so we can see any error
raw_input()

I installed Python on a compact flash card. Here's the layout from the "Program Files" directory down. I simply copied the django directory over from another machine.

Thursday, October 26, 2006

Sucker for a PDA


I've always been attracted to PDAs. Possibly it's my fear of being stuck somewhere and getting bored with nothing to listen to or read.

A loyal, and satisfied, Palm OS user for many years, I recently got tired of the lack of advancement of the OS and particular the poor web browser and started tinkering with Microsoft CE, PocketPC, Windows Mobile 5.0 or whatever they're called these days, devices around the office.

I ordered a Dell Axim X51v and thought I'd share my impressions.

  • The v means the screen is full VGA (640x480) and the resolution is lovely.
  • Windows Mobile 5.0 seems to have better battery life than earlier versions due to some memory tricks with flash memory and that's a good thing.
  • Bluetooth is there but is lame. It doesn't support OBEX so I can't browse the device from my computer which I've done on mobile phones for years.
  • Wifi works well as in quite sensitive, but the UI is a shambles. It's very hard to figure out how to leave one network and connect to another. Other users give me tips like click the icon in the top bar, don't use the Settings->Connection tools. Dell provide their own utility but it shouldn't need to.
  • Dell provide a little app for switching between running applications but it's pretty rough and overwrites things in the top bar.
  • Heaps of storage slots. I have populated the SD and Compact Flash sockets which is great.
  • I use MacOS computers and so use Missing Sync which works quite well at least over USB. It's nice that they let you "upgrade" from the Palm version.
  • The device has needed a soft reset 4 times this week. Twice when plugged in to USB for some reason, the other times on being unresponsive possibly due to a buggy app. Anyhow, too much really. My Palm TX almost never needs re-booting.
  • Python 2.5 runs pretty well and I'm trying to get Tkinter going on it.
Anyway, the Palm PDA with it's inferior screen and browser is still sitting near by, it hasn't gone to eBay just yet.

Sunday, October 22, 2006

They know where you live


Searching a torrent indexer (for public domain content) the other day I noticed that the "find pretty girls in..." ad has got unnervingly accurate.

Forestville is the suburb right next to where I live.

How on earth do they do this? I know that there are geolocation systems that triangulate where people are by tracerouting from several locations around the globe, good for things like pre-selecting the country in a popup menu or tailoring a banner ad, but how can this work down to the suburb?

There are some services around that can figure out the ISP and your state but they're not as good as those super smart pretty girls.

Saturday, October 21, 2006

Vista RC1 experience

I was working on site this week and thought I saw MacOS X running on a Dell laptop. On closer inspection it turned out to be running windows Vista.

The owner gave me a quick demo, expose equivalent, gadgets, window animation, it looked pretty slick and seemed to run well in 1G of RAM.

We have a recent HP laptop so I thought I'd give it a go at home. I think it's great they have a free download installer available.

The download was great, using an Akamai java download manager on our Optus Cable connection gave me a sustained 1Mbit/sec download rate and I had burned the .iso file to a DVD on my Mac within minutes. (The image is 2.52G).

The installer said it was incompatible with some HP Protect software and forced me to exit and remove it before it would go on. It took some searching to figure out how to do that as the utility has no uninstaller and in the end needed to be killed and the .exe manually deleted.

I did an upgrade from XP and takes over 2 hours to install. There are a couple of mysterious steps including "Gathering files" and "Completing upgrade" that seem to take a long time.

In the end it does look great, clearly security is increased as it keeps asking the user if it's ok for things like the google toolbar to talk to a server. This might be annoying for an end user but it's a bit like running little snitch all the time.

It looks like an improvement over windows XP but I still like MacOS X better, but then again having unix underneath is something I see as very valuable.

There's some nice eye candy, I do like the transparency with blur through window title bars.

No Junk Mail - works!


Each fortnight our paper recycling bin was filled to the brim. The combination of a daily broadsheet newspaper (my wife likes inky fingers) and a heap of junk mail was too much.

I printed a very simple "No Junk Mail" notice and stuck it on the letterbox.

It worked instantly, and comprehensively. Clearly the folks that walk the streets delivering the junk mail are under instructions to not waste the printing on folks that ask not to receive it. Our house is less cluttered, the paper recycling bin has some room, and no doubt there's some products we haven't felt compelled to buy.

If only there was a way to associate the label "No Junk Mail" with an email address. Maybe SMTP could be extended to be able to return properties. On the other hand mail goes through many servers and that would have to be passed back somehow. Perhaps it belongs in the DNS for the domain that accepts that email.

Sunday, October 15, 2006

Belkin TuneTalk mini review


From time to time I record stories for radio and these need to be recorded in the field in "HiFi" quality. Currently I use a Marantz PMD660 digital recorder, which is fantastic quality, but rather large.

I was excited by the idea of using my Video iPod to record "CD Quality" audio in the field and so rushed out to get a Belkin Tunetalk.

It's physically a neat little unit that clips on to dock connector on a Video iPod as shown above.

The recording quality is good, using the built in microphone, and on "High" quality setting is recorded in WAV format at 44,100 Hz sampling.

There is no way to see the audio level on the iPod and you only have the choice of turning "Autogain" on or off. Basically, on means mic level and off means line level. The recording for me is rather low in level but I guess that's needed to avoid clipping. It's here.

I tried an external mic, a high quality Sony mic, and it sounded rather thin and low level compared to the built in mic.

Apple must have changed the software since the manual was printed as recordings now seem to be automatically transferred into your iTunes library rather than needing to be dragged or respond to a prompt to get them over. This mystified me for a while and I thought it was not saving my recordings.

High quality recordings are going to be big. My 12 second test is already 2.2Mb so this is not a dictation machine. I guess the application is recording interviews for podcasts or radio, which suits me but I find the lack of a VU meter and any way to monitor the recording a bit worrying.

Summary

Yes, it works and the internal mics sound really great. iPod user interface for recording is not great, it needs a VU meter, monitoring of the recording in the headphones, and it seems to take a long time to "Save" the recording when you stop.

Oddly the Belkin device includes one of those mini USB sockets (why can't they standardise these) and a cable so you can charge your iPod while recording. Wouldn't it have been better to repeat the dock connector on the device?

Note that this product only works with the iPod with video.

Saturday, October 14, 2006

Better locate with mdfind

I wanted a way to search for the name of a file locate style but using mdfind. mdfind finds files with the search term in any way associated with the file. I created this little script called mdf, did a chmod +x and placed it on my path:

#!/bin/bash
mdfind "kMDItemDisplayName == $1"

Now I can find files by doing: $ mdf filename

It's better than locate because spotlight is updated live.

Python and Xcode


I've been doing a lot of very productive python work recently and have been looking around for the best programmer's editor but still haven't found it.

If you spend you whole day in an application you do start to think about how it could be made more productive, and of course anyone who programs can't help but customise.
Features I'm after are:
  • Syntax colouring
  • Syntax aware (auto indenting etc)
  • Real code completion (I mean language aware like looking into imported modules for possible completions)
  • Ease of showing documentation on a module and it's methods
  • Code folding might be nice
  • A full gui debugger might be nice
  • Native MacOS X application
  • Handles large projects fast
  • Subversion GUI
TextMate blew me away and was the first editor to get me off a long term addiction to BBedit, but I got a bit dissatisfied with how long it takes to check all the files in a large project when I switch back to it. (I know you can turn this off but that would be a pain too).

XCode

I've used XCode of course for Cocoa development and it has python syntax colouring built in. XCode is particularly good with large numbers of source files, it's fast and searching is really great. There's a little Script menu I hadn't played with before now and I want to share what I've discovered with you.

User scripts for that little menu go in ~/Library/Application Support/Apple/Developer Tools/Scripts/ (insane eh?).

Inside that Scripts directory you should copy the default StartupScript and 10-Users Scripts folder from /Library/Application Support/Apple/Developer Tools/Scripts/

Here are my scripts, mostly adapted from the excellent ones that come with TextMate.

10-PyChecker.sh

#! /bin/bash
#
# -- PB User Script Info --
# %%%{PBXName=PyChecker}%%%
# %%%{PBXKeyEquivalent=}%%%
# %%%{PBXInput=None}%%%
# %%%{PBXOutput=None}%%%
#
PYCHECKER=/opt/local/bin/pychecker
TEMPOUT=/tmp/check.txt

${PYCHECKER} --only %%%{PBXFilePath}%%% > ${TEMPOUT}
open -a /Developer/Applications/Xcode.app ${TEMPOUT}

20-run.sh

#! /bin/bash
#
# -- PB User Script Info --
# %%%{PBXName=Python Run...}%%%
# %%%{PBXKeyEquivalent=}%%%
# %%%{PBXInput=None}%%%
# %%%{PBXOutput=SeparateWindow}%%%
#
#
PYTHON=/opt/local/bin/python
TEMPOUT=/tmp/out.txt

echo "Running %%%{PBXFilePath}%%%..." >${TEMPOUT}
${PYTHON} %%%{PBXFilePath}%%% >> ${TEMPOUT}

open -a /Developer/Applications/Xcode.app ${TEMPOUT}

30-pydoc.sh

#! /bin/bash
#
# -- PB User Script Info --
# %%%{PBXName=pydoc}%%%
# %%%{PBXKeyEquivalent=}%%%
# %%%{PBXInput=Selection}%%%
# %%%{PBXOutput=None}%%%
#
#
pydoc -k %%%{PBXSelectedText}%%%

# This command takes the currently selected word and
# displays the python documentation for the module
# corresponding to said word.
#
# It falls back on the current word.

# change to /tmp to avoid possibly overwriting
# an html file in the working directory.

PYDOC=/opt/local/bin/pydoc

cd /tmp

${PYDOC} -w "%%%{PBXSelectedText}%%%" >/dev/null
if [[ -f "%%%{PBXSelectedText}%%%.html" ]]; then
open "%%%{PBXSelectedText}%%%.html"
#rm -f "%%%{PBXSelectedText}%%%.html"
else
echo "

No documentation found for:

%%%{PBXSelectedText}%%%

This command only looks for Python modules."
fi

40-python reference.sh

#! /bin/bash
#
# -- PB User Script Info --
# %%%{PBXName=Python Reference}%%%
# %%%{PBXKeyEquivalent=}%%%
# %%%{PBXInput=None}%%%
# %%%{PBXOutput=None}%%%
#
#
open http://www.python.org/doc/2.4/modindex.html

Thursday, October 12, 2006

One image spam

I've been getting tons of spam that gets through our office's SpamAssasin filter. This was brought home to me big time after being away from the internet for 10 days. I was faced with almost 300 emails - mostly spam to plough through.

Apple Mail's spam filter is good if it has something to munch on, but these messages have one big gif image and then a random few lines of text from a story.

I created this little mail rule to filter them and it works nicely. Note that I get mail from several servers so I only do this filtering on mail direct to the office server.

I check the Junk folder and if there's somebody there I do want to get mail from I simply right click their name and "Add to Address Book".