Where have all the mailboxes gone?

This morning, I stopped at Almaden Plaza on the way into work to grab a cup of decaf from Starbucks and to drop a check in the mailbox there (I don’t leave checks in my mailbox at home any more for fear of theft). I failed in both missions.

The decaf of the day at Starbucks was Decaf Verona Blend; I don’t like the regular Verona Blend, and didn’t think the decaf would be an improvement.

And the mailbox across the parking lot was gone — there was still a UPS dropbox, but the mailbox vanished with no forwarding address. You’d almost think the Post Office didn’t want people to mail things any more….

*sigh*

Today’s technical tidbit

The following code fragment works fine in Firefox but fails in IE:

myform.appendChild(tags);
tag = document.createElement("input");
tag.name = "button";
tag.value = "Tag";
tag.type = "submit";

But reordering it to set the type before the value works fine in both browsers. To play it safe, I decided to set the type immediately after creating the element.

myform.appendChild(tags);
tag = document.createElement("input");
tag.type = "submit";
tag.name = "button";
tag.value = "Tag";

Morse Code Ringtone Generator

And now for something completely different — actual working code!

A long time ago, I decided I wanted a very distinctive ringtone for my cellphone, so I wrote a Morse Code ringtone generator in Rexx, which produced Nokia ringtones in a format suitable to cut-and-paste to AT&T Wireless’s text message sending page.

AT&T Wireless is gone now (although I wouldn’t be surprised to find the name revived once SBC…err, AT&T…buys BellSouth, and, along with it, the rest of Cingular), and so is my Nokia phone. And I find myself writing very little Rexx these days.

So I reworked the code, this time in Python, and now it creates an iMelody (.IMY) file, suitable for several brands of phone, including Motorola. Getting the file to the phone is up to the user (the easiest way, if your phone and PC support it, is Bluetooth file transfer).

One reason I haven’t posted this code before is that I thought it would be difficult to get IBM’s permission to do so — even though I wrote it on my own time, IBM has rights to it through it. But it turned out to be surprisingly simple; since it was clearly not competitive to IBM business, my manager was able to give me permission to post it, as long as I included a suitable license and made it clear that it was my personal work and not the company’s.

Cut and paste the following as morsemelody.py or download it here; share and enjoy.

#!/usr/bin/python

# MorseMelody.py
# Copyright (c) 2006, David Singer (https://readthisblog.net)

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:

# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import sys
if 1 >= len(sys.argv):
  print sys.argv[0], 'word1 [words]'
  print
  print "Creates an IMelody file which plays its argument in Morse code."
  print
  print "The output file is named 'word1'.imy"
  sys.exit(0)

code = {}

code['A']   = '.-'
code['B']   = '-...'
code['C']   = '-.-.'
code['D']   = '-..'
code['E']   = '.'
code['F']   = '..-.'
code['G']   = '--.'
code['H']   = '....'
code['I']   = '..'
code['J']   = '.---'
code['K']   = '-.-'
code['L']   = '.-..'
code['M']   = '--'
code['N']   = '-.'
code['O']   = '---'
code['P']   = '.--.'
code['Q']   = '--.-'
code['R']   = '.-.'
code['S']   = '...'
code['T']   = '-'
code['U']   = '..-'
code['V']   = '...-'
code['W']   = '.--'
code['X']   = '-..-'
code['Y']   = '-.--'
code['Z']   = '--..'
code['0']   = '-----'
code['1']   = '.----'
code['2']   = '..---'
code['3']   = '...--'
code['4']   = '....-'
code['5']   = '.....'
code['6']   = '-....'
code['7']   = '--...'
code['8']   = '---..'
code['9']   = '----.'

input = ' '.join(sys.argv[1:])
outfilename = sys.argv[1]+'.imy'
outfile = open(outfilename,'w')
outfile.write('BEGIN:IMELODY\n')
outfile.write('VERSION:1.2\n')
outfile.write('FORMAT:CLASS1.0\n')
outfile.write('NAME:%s \n' % (input))
outfile.write('BEAT:700\n')
outfile.write('STYLE:S1\n')
outfile.write('VOLUME:V15\n')
outfile.write('MELODY:\n')

note = '*5f'
song = []
for word in input.upper().split():
  for letter in word:
     if letter in code.keys():
       char = code[letter]
       for element in char:
         if element == '.':
           song.append(note+'3;')
           song.append('r3;')
         else:
           song.append(note+'1')
           song.append('r3;')
       song[-1] = 'r1'
       outfile.write('  ')
       outfile.write(''.join(song))
       outfile.write('\n')
       song = []
  song.append('r3;r1')
# We'll be left with an unwritten wordspace, but no harm done.
outfile.write('END:IMELODY\n')
outfile.close()
print outfilename, "created successfully."


Shana Tova 5767

It’s been a busy week, and, indeed, a busy year.  And although many things went well this year, I’ll always remember it as the year I lost my Mom.

I’m looking forward to 5767.  Shana Tova, and may you be inscribed for a good year!

Work is the curse of the blogging class

I barely got out of my chair today at work; I was nearly heads-down designing and coding enhancements for an upcoming project.  I didn’t even check my e-mail from noon till 5, which is almost unheard of.

But now I’m home, and the laptop is safely hidden away in my briefcase, at least until Sunday.  Good thing I have other computers.

Jeff’s at a party in Morgan Hill, and since he doesn’t drive yet, we had to schlep him.  So Diane and I took advantage of that to go to Rosy’s at the Beach, where she had Pepper-encrusted Salmon and I had Salmon Tacos.  We both enjoyed our meals; I’d go back cheerfully (in fact, we will be going back in a week and a half for my 30th service anniversary lunch, though that meal will probably be without beer or wine).