sixtyPercent: Cochlear Implants, Aviation, Technlology, and Philosophy 2004/12
BSOD Phone
I noticed this phone in the gate area of the San Francisco Airport:
The photo is from my T616 camera phone, so it the quality is pretty poor. The pattern on the screen is still pretty unmistakable as a Windows blue screen of death. The was actually the third public broken Windows based kiosk I have seen this week.
by David Creemer : 2004/12/31 : Categories technology (permalink)
Quixote and Cheetah
I've been playing with Quixote, a Python-based web application framework a bit for a personal project. Among other things, I like the simplicity of the basic concepts. At its heart, it "just" maps from URLs to Python callable objects. There is other structure available, but the various pieces seem to nicely stay out of the way if you don't need them.
As a quick experiment, I created a simple class to add Cheetah template support. This class is simplified from an example of linking Quixote with another template system for Python, SimpleTAL.
from Cheetah.Template import Template as CheetahTemplate
class Template(object):
_q_exports=[]
def __init__(self, path):
self._template = CheetahTemplate( file=path )
def _makeEnvironment(self, request):
t = self._template
t.cgi = request.environ
t.form = request.form
t.session = request.session
def __call__(self, request):
request.response.set_header('Cache-control', 'no-cache')
self._makeEnvironment(request)
return str( self._template )
_q_index=__call__
***
highlight file error
***
That's it! You can stuff nearly anything you want in the _makeEnvirontment method to setup the Cheetah namespace. The __init__ method will load, compile and cache the compiled template. The _q_exports and _q_index attributes are sufficient to implement Quixote's callable protocol. In my Quixote published namespace, I can then just do this:
home = Template( 'home.tmpl' ) _q_exports= [ 'home' ] *** highlight file error ***
to use a template.
by David Creemer : 2004/12/12 : Categories python (permalink)
False Positive Spam Identification with Python
My email system typically sees hundreds of spam messages per day. SpamAssassin catches most of these, and Apple Mail generally gets the rest. However I do worry about false positives even though these days that case seems to be very rare. I've set my SpamAssassin threshold level to be relatively low, and procmail moves all spam with scores from 20 down to my threshold into a junk folder. To make sure I don't miss any false-positives, I run the Python script below to scan the junk folder for potentially interesting emails.
What's nice about this script is the efficiency of using it: just type junk at the command prompt, and I see a list of all of the messages with scores below 10 (by default), nicely lined up for a very quick scan. If something looks like it might not be junk, I can just type junk -p 5 for example, to have a quick look at message number five. If it's not junk, I'll either use the command line or Apple Mail to move the message out of the junk folder. The output ignores any human readable From address (which is usually forged anyway) and just prints the raw email address. Here's an example:
$ junk Mail message with spam scores below 10 Msg SL From Subject --- -- --------------------------------- ------- 3 8 PCVZJ@djkjkkkd.com ****Cheap Cialis**** 0 9 zjhsiyfsx@cashette.com what will your kids do when you die 1 9 miachung_rz@worldonline.de =?ISO-8859-1?B?WW91ciBwYXltZW50cyBjYW4gY
The script is setup to use Maildirs, but it should be easy to use other mail box formats as well. Perhaps someday I can add logic to see if the 'received-from' headers make sense with respect to the from address, but for now this works well enough.
#! /usr/bin/python
import sys, getopt
import mailbox, email
from email.Utils import parseaddr
#
# settings you will need to change
#
maildir = '/home/username/.maildir/.junkmail'
spamtag = '***SPAM***'
defaultSpamLevel = 10
###
spamtaglen = len(spamtag)
def buildList( tlevel ):
tlist = []
i=0
jf= mailbox.Maildir( maildir, email.message_from_file )
for msg in jf:
l = 0
if 'x-spam-level' in msg:
l = len(msg['x-spam-level'])
if l <= tlevel:
(tmp,f) = parseaddr(msg['from'])
s = msg.get('subject', '')
if s.startswith( spamtag ):
s = s[spamtaglen+1:]
tlist.append( (i, l, f, s, msg) )
i += 1
return tlist
def printMessage( tlist, i ):
(i,l,f,s,msg) = tlist[i]
print msg
def usage():
print "junk [-s | --spam ] [-p | --print ]"
def main():
try:
opts, args = getopt.getopt(sys.argv[1:],
"s:p:h",
["spam", "print", "help"])
except getopt.GetoptError:
usage()
sys.exit(2)
printMsg = None
tlevel = defaultSpamLevel
for o, v in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-s", "--spam"):
print "option: spam level=", v
tlevel = int(v)
if o in ("-p", "--print"):
printMsg = int(v)
l = buildList( tlevel )
if printMsg != None:
printMessage( l, int(sys.argv[2]) )
else:
printList( l, tlevel )
if __name__ == "__main__":
main()
***
highlight file error
***
2004/12/07 : Categories technology python : 0 trackbacks : 2 comments (permalink)
Back in the Air
I managed to get back into the air for the first time in several months. I kept thinking it's been "about a month or six weeks" since I've last flown, but a check of my logbook showed that I last flew July 24th -- yikes five months! Needless to say I decided to fly with a CFI and start the process of getting sharp again (again!).
Rather than just climbing back into another beat up old PA-28, I decided to finally make an effort to get my tailwheel endorsement, so I headed back to Amelia Reid Aviation, found a nice instructor, and went up in one of their Citabrias. I felt like a beginner again -- and not in a good way. I was behind the plane a lot (a 115 HP Citabria no less!), flew un-coordinated, and felt uncomfortable for much of the flight. I do enjoy flying this plane more than the PA-28 in many ways, though -- it just feels quite responsive to control inputs and is a great pleasure to flick around the sky. The view from the front seat is pretty good -- the nose appears quite low in level flight, and I'm sure it will take a while to get used to the sight picture. I have a tendency to keep the nose up a bit on the PA-28's when flying by sight, so this plane might exacerbate that problem.
Some of my uncomfortable feelings was undoubtedly due to the unfamiliarity of this plane -- it's just different from the Pipers of course, but also the the gauges are non-standard, which meant I had to hunt to look for the airspeed indicator for example, rather than just glancing in the known spot. In addition, I had the ongoing feeling that the instructor was providing some control inputs. Some of this feeling was probably due to the rudder pedals, which are a bit heavy to control, but I'm sure he was tweaking things from time to time. This has always bothered me -- it puts me into a "do I have control or does he have control?" mindset -- which is very bad. Less bad, but also troubling is the "did I do that or did he do that?" feeling. I emphasized the "I have the plane -- you have the plane" protocol with him, but I will discuss this in more detail before the next flight.
The approach and landings he suggested were fun: cut the power to idle on downwind just abeam the numbers, then "dead-stick" it on in. Due to traffic in the pattern we were unable to do this as described, but came close. In three landings I only added power once to get back to a decent glide slope. Even then we just add enough power to get up the right glide slope -- it's back to idle once on the slope. The landings were all OK... but did the CFI help...?
2004/12/06 : Categories flying : 0 trackbacks : 5 comments (permalink)