I got mentioned on MouseStation!

October 8th, 2007

I got mentioned on the MouseStationListener Feedback” podcast from Friday, October 5, 2007! I was catching up on my Disney podcasts this morning and was surprised to hear my name mentioned on the show (and in the show notes).

I had a problem downloading a previous MouseStation podcast on Friday, September 28, 2007. It was a simple problem with a URL. I had sent an email via the MouseStation web form telling them the problem and how I was still able to get the show. I was surprised back then to get an email from Mark Goldhaber on Saturday, September 29, 2007. This was the weekend when there was a lot of Disney, Epcot in particular, activity. October 1, 2007 was Epcot’s 25th anniversary. I expected the MouseStation crew to be busy. So I was surprised to get an email from Mark, who is the host of the show along with Mike Demopoulos.

Hearing your name on a podcast is a bit like when I had my first web site. It is kind of neat seeing yourself personally in a new technology. Thanks MouseStation guys!

Happy 25th Birthday, Epcot

October 1st, 2007

Epcot’s Spaceship Earth from Family Fun Run in January 2003 (cropped, scaled)Epcot, part of Walt Disney World in Florida, celebrates it’s 25th anniversary today. Here is a picture of Spaceship Earth (with the wand. 🙁 I’m not a big fan of the wand, which has now been taken down. Yeah!) from the 2003 Walt Disney World Family Fun Run.

So in October 1982, when it opened, I would have been 11 and in sixth grade. Being that I was already a computer geek by then, I was fascinated by Epcot. There have been a lot of changes in the 25 years of the park, but I still like it. One of my favorite things is the food available in the World Showcase. I am partial to Les Chefs de France. (I like French cuisine. 🙂 ) I haven’t yet been to the Epcot resort area, which includes Disney’s BoardWalk Inn. (This resort has shops and restaurants in the boardwalk section and is in walking distance to Epcot. You can enter through the World Showcase entrance. But it is a deluxe resort, so I probably won’t be staying there any time too soon.) I haven’t been to the new and improved “The Seas with Nemo & Friends“. (It used to be called “The Living Seas”.) And Spaceship Earth is currently being updated (which is why the wand was taken down) and should be open by my next visit. So, even though it is 25 years old, there is still something new to do in the park.

Sydney’s First Overnight Slumber Party

September 30th, 2007

Sydney had her first overnight slumber party last night. She stayed overnight with two other four year olds. She did very well. They had a good time making tie dyed t-shirts and going to see the movie “The Game Plan“. (She liked the bull dog.) I definitely give kudos to the parents where she stayed. They had a gaggle of girls sleep over. (They have three girls, and it was the oldest girl’s birthday. She had some friends over for her birthday, but the middle and youngest girl both invited a couple friends to stay overnight too! I think that this is foreshadowing of my future. But I only have two girls. Whew!) The “sleep over” door is open. Sydney is growing up so fast.

[Updated 10/01/07]: I forgot to post this. When talking to the mom in charge of the sleep over when I picked Sydney up, she relayed this funny little story. I guess she got a full dose of Syd. That night, the mom was in with the three four year olds, getting ready to sleep. Sydney was in a giggling mood and kept giggling. The mom said to the effect of “Okay, girls. It’s time to go to sleep and stop the giggling.” Sydney said, without missing a beat, “But giggling is what little girls do.” This is classic Syd.

To the moon, Cringely, to the moon!

September 30th, 2007

Robert Cringely announced in his latest column that he plans to participate in the Google Lunar X Prize. The competition challenge is: “soft-landing a robotic craft on the Moon and roving on the surface”. I have been reading Cringely’s column for a long time. I watched him in his PBS show “Plane Crazy“. I wish him well. It would be so cool to work on his team for the challenge. I am sure that he will provide progress reports in his column. I expect them to be entertaining, to say the least. 🙂

“Built in” text field calculator

September 26th, 2007

I have a little web application that I wrote to balance my check book. I often enter a calculated value into a form text field. I usually use the Google Calculator in the Firefox Search Bar to perform the calculations. I often perform simple calculations like “25 * .03”. (Why? I impose a personal finance fee on each credit card purchase that I make. I use a 3% fee. I put all of my personal finance fees into an online high-interest savings account. So, if I charge $25.00 on a card, I transfer “25 * .03” or $0.75 to my online savings account. It isn’t much, but it adds up.) So, yesterday, I thought, “I wonder if I can integrate Google Calculator functionality into my web application?”

Here is what I came up with.

Calculator example.

You can take a look at the source of the “calculator.html“. It includes “JPetersonCalculator100.js“, which is where the JavaScript that actually implements the calculator is sourced. The calculator function is attached to the text input field using an onKeyPress event handler in the HTML:

onkeypress="processCalculatorKeyPress(event, 2);"

Here is the processCalculatorKeyPress function.

001: /**
002:  * Handle a key press from a text field that can automatically calculate a
003:  * derived value. Basically, enter normal mathematical formula like
004:  * "5 * .03 =". When you press the equal ("=") key, the value in the text field
005:  * will be replaced with the calculated value. If the value can't be
006:  * calculated, it is left unchanged.
007:  *
008:  * @param e the event
009:  * @param precision the decimal precision to round to.
010:  */
011:  function processCalculatorKeyPress(e, precision) {
012:   var targ;
013:   if (!e) var e = window.event;
014:   if (e.target) targ = e.target;
015:   else if (e.srcElement) targ = e.srcElement;
016:   if (targ.nodeType == 3) // defeat Safari bug
017: 	targ = targ.parentNode;
018:
019:   if (e.keyCode) code = e.keyCode;
020:   else if (e.which) code = e.which;
021:
022:   if (code == 61) { // '='
023:     var expression;
024:     var result;
025:     expression = targ.value;
026:
027:     try {
028:       // calculate, evaluating arithmetic expression
029:       result = eval(expression);
030:
031:       if (typeof result == "number") {
032:         // round, if necessary
033:         if (typeof precision == "number") {
034:           if (precision > 0) {
035:             if (result.toFixed) {
036:               result = result.toFixed(precision);
037:             } else {
038:               var factor = Math.pow(10,precision);
039:               result = Math.round(result * factor) / factor;
040:             }
041:           }
042:         }
043:
044:         targ.value = result;
045:
046:         // don't display key that triggered the calculation
047:         if (e.preventDefault) {
048:           e.preventDefault();
049:         } else {
050:           e.returnValue = false; // IE
051:         }
052:       }
053:     } catch (e) {
054:       // expression wasn't an arithmetic expression, let normal text be displayed
055:     }
056:   }
057:
058:   // var character = String.fromCharCode(code);
059:   // alert('Code was: ' + code + ' Character was: [' + character + '] targ: [' + targ.value + ']');
060:
061:   return false;
062: }

Lines 12 -10 process the event, makeing a “normalized” version that handles differences in browser implementations. Since the function processCalculatorKeyPress is called for EVERY key press, line 22 filters out all key presses except for the one that we care about: the equals (“=”) key. Line 25 saves the value currently entered into the text field. Line 29 uses the JavaScript eval function to evaluate the arithmetic expression. (This is the actual calculator. The rest of the function make the results look pretty.) The “try”, on line 27, and associated “catch”, on line 53, are there to handle any error thrown by the “eval” function. An error would be thrown if the value entered into the test field was not an arithmetic expression. (Or more generally, not a valid JavaScript expression, since “eval” found evaluate any valid JavaScript expression. But that’s not really useful for the calculator.) Line 31 makes sure that the result of the “eval” is a number. Note that execution will only reach line 31 if “eval” didn’t throw an exception. Lines 33 through 41 perform any required rounding of the result. If available, line 36 uses the “toFixed” function to convert the number to the requested number of decimal places, rounding and padding with zero as necessary. If this function is not available, lines 38 and 39 perform rounding without any padding. Line 44 assigns the result of the arithmetic expression to the text input form element. Lines 47-51 indicate that the calculation succeeded so that the equals sign isn’t added to value of the text input field. Line 58 and 59 are commented out. But they illustrate how you can use an alert box to see what characters are pressed. I used this technique when developing the function.

That’s it. It should be relatively easy for you to include this build in text field calculator into your own web application. The basic steps are:

  1. Include the JavaScript function “processCalculatorKeyPress”.
  2. Add the “onkeypress” to the text fields that you would to support the build in calculator functionality. You can configure the precision value, from no rounding (use a negative value, like “-1”) to whatever decimal place is important. For currency input, I use a precision of “2”.

Lemon-Anise Biscotti

September 1st, 2007

Lemon-Anise BiscottiI baked Lemon-Anise Biscotti for the first time on Thursday night. The recipe is from the cook book

Italian Classics by the editors of Cook’s Illustrated magazine.

The recipe is very simple and doesn’t require too many pieces of equipment. It is basically made with flour, baking powder, salt, sugar, eggs, vanilla extract, lemon zest, and anise seed. The equipment required is an oven, a mixing bowl, whisk, and baking sheet with parchment paper. Biscotti are twice-baked Italian cookies. Once the batter is mixed, it is formed into a long loaf shape and baked. It is then sliced into individual pieces and baked again. This recipe doesn’t use butter, so the cookies should last a couple weeks if stored in an airtight container.

They are a relatively hard biscuit. They are perfect dunked in my favorite tea. The lemon and anise flavors are a unique taste that goes well with the English Breakfast tea that I prefer. The cookies have a nice amount of sweetness too. I would make this recipe again.

Magazine Salesman

September 1st, 2007

I bought magazines from a door-to-door salesman yesterday. I hope it is for a good cause. (I hope that I didn’t get taken.) He was a nice young man and presented himself well. He said that he was from Chicago and was trying to learn skills to help him have a better life. I am supposed to get 36 issues of Condé Nast Traveler for $60.00 plus a $10.00 processing and handling fee for a total of $70.00. I know that I could have gotten it cheaper by subscribing from Condé Nast directly, so hopefully the extra money goes towards the salesman and not just to Midwest Clearing, Inc., the company fulfilling the subscription.

Running headphones: Nike Flight

September 1st, 2007

Nike Flight Sport headphonesYep, the stock earbuds that came with the Sansa Express didn’t work out well while running. They popped out of my ears after a few strides. I found these at my local Target store: Nike Flight Sport headphones. They are designed to fit around the back of your neck, with the cord coming out the back. So I decided to give them a try.

They worked out quite well. The ear piece doesn’t actually fit in your ear like earbuds; the band keeps the speakers pressed against, but not in, your ear. The band itself is plastic that is fexible; it keeps it’s shape, but can flex to shape to your head. The cord runs through a channel in the band. The connector worked fine with the Sansa Express. I used them for the first time on Friday, August 31, 2007. I plan to use them on my next run.

littles3 works with S3Fox Organizer

August 31st, 2007

S3Fox Organizer and “littles3″I have successfully used S3Fox Organizer with the current “littles3” source code. S3Fox Organizer is a Firefox extension which provides a simple interface for managing files with Amazon S3. To get it to work, I needed to control the resolving of “http://s3.amazonaws.com”, which is the URL that S3Fox Organizer is coded to use. I edited my machines “hosts” file, C:\WINDOWS\system32\drivers\etc\hosts on Windows, to have s3.amazonaws.com resolve to 127.0.0.1, localhost. I have “littles3” running within Tomcat. I have it running as the “ROOT” application so that there is no application context. I also have Apache running with mod_jk connecting to Tomcat.

This definitely takes advanced skills to get running and “littles3” isn’t complete yet, but this is a good integration test. The current “littles3” source code has ACL support now. It still needs to implement metadata and the ability to “provision” user accounts. But it is at a personally usable state now.

St. Pius X Sunday School calendar

August 31st, 2007

I have made available a Google calendar for St. Pius X Sunday School for the 2007-2008 year. Click on the button below to access it.