Thursday, January 12, 2006
Thursday, January 12, 2006 7:30:28 AM (India Standard Time, UTC+05:30) ( Musings )

One of the things I missed the most about being without an iPod for 6 weeks was not having podcasts to listen to on my 45 minute commute to work.  Coinciding with my return to the iPod club was the release of a new podcast by Scott Hanselman, the author of my favorite blog Computer Zen.   The podcast is called HanselMinutes and is produced by Pwop.com, the people behind two other podcasts that I listen two regularly, .Net Rocks and Mondays.  

 

Aside from a dopey introduction by the Pwop recording guy Lawrence (what happened to Geoff Maciolek?  Geoff is the Rodney Dangerfield of podcasting, gets no respect from Carl,  Richard Campbell or especially Mark Miller), the HanselMinutes podcast is a very well produced show.  Pwop does know how to make a good sounding recording.   I was, however, surprised that Carl Franklin hosted the show and led the discussion.  I had expected it to be a one-man show, similar to Adam Curry and most other podcasts.  The result wasn’t disappointing, Scott was so focused on what he wanted that a couple of times he steered Carl in the right direction.

 

The show covered various gadgets and cool software tools (Blogjet, Xbox 360, Twonky) and ended with a technical problem that Scott or his crew has faced recently.   Today’s problem was an issue with caching ASP.Net and culture specific formatting. 

 

Perhaps I am a bit biased because I am a daily reader of Computer Zen, but this podcast is clearly on my favorites list.   For the developer or aspiring developer I recommend this podcast and my other favorites:  .Net Rocks (feed), Polymorphic Podcast and Software as She’s Developed.

Comments [0] | | # 
Wednesday, January 11, 2006
Wednesday, January 11, 2006 11:52:30 AM (India Standard Time, UTC+05:30) ( )

I finally picked up my Christmas present.  After waiting an extra couple of weeks to see if Apple would announce an upgraded version at MacWorld Expo this week (they didn’t) I picked up my new iPod.

 

 

A 60GB iPod video.   First song on my new favorite gadget:  Comfortably Numb, by Dar Williams.  Comfortably ideal to describe how nice it is to have an iPod again.  Amy gave my last one to her dad when she went to visit him in Fiji.  I fully supported her desire to do this, because I knew that this day would come as well.  6 weeks without one was painful but worth the wait. 

 

What does it say about me that the indescribable joy of turning on a new iPod for the first time bears an eerie resemblance to holding a new born baby.  The baby is definitely better, but the feeling of holding that iPod in my hands was similar.  (more on this topic soon).

 

Now I am complete.  My essential gadgets are all here: iPod video, Blackberry, Motorola RAZR.  On the weekends, throw in my dirt lovin’ Nissan Frontier and my Garmin Rhino 210 GPS and I am happy.

Comments [0] | | # 
Sunday, January 08, 2006
Sunday, January 08, 2006 10:44:39 AM (India Standard Time, UTC+05:30) ( Musings | Technology )

My Sunday night hobby for the past couple of months is to try and programatically solve the NPR Sunday Puzzle.   Each Sunday morning on Weekend Edition Sunday Will Shortz and Liane Hansen offer a puzzle.  I have been a fan of this for well over ten years, but recently started using it as a way to have fun programming.  Most of the recent puzzles have involved words of a certain type (such as job titles or animals).  Since I don't have a complete database of words in a particular category, my resolution of the Sunday puzzle has not been complete, (i.e. to the point of saying "The Answer is: x").   After 5 or 6 weeks of getting a range of possible answers they finally gave me a puzzle that could easily be solved.

I missed last weeks puzzle because I didn't wake up in time, but remembered on Saturday night just in time to solve it before waking up to the answer tomorrow morning.

Last weeks puzzle is:

From Ed Pegg, Jr., who runs the Web site mathpuzzle.com: The numbers 2, 4, 6 and 30 are the first four numbers whose names lack the letter "E." What is the 23rd number whose name lacks an "E?"

I had wondered what the significance of the 23rd number was, if I was more quick witted, that alone should have been enough of a clue to solve the first puzzle of the new year.

Instead, I decided to use T-SQL as the language for this, in part because I think that the .Net Framework has a function that does what I did in the function below, taking the fun out of it.

So, here is the T-SQL code.  I know it is choppy and clunky, and the variable names don't make sense, but it works really well (for numbers up to 4 digits long) and was very easy to write.  In addition, it is a nice example of recursion, which makes me feel good after reading this post by Joel Spolsky.  I noticed as I pasted the code into this post that I have done a number of implicit variable conversions, this code would not hold up well in a code review, but it got the job done.

create function fn_NumberToText(@value int) returns varchar(100)

as

BEGIN

-- ********************************************************

-- * CODE COPYRIGHT 2006, Shawn Swaner *

-- * http://www.shawnswaner.com *

-- * Published under *

-- * Creative Commons Attribution Share-Alike 2.5 License *

-- * No warranty, express or implied is provide by author *

-- ********************************************************

declare @name varchar(100), @valueText varchar(9),

@Left1 char(1), @RightOrdinal char(1), @RightPair char(2),

@RightTrio varchar(3), @Left2 char(2)

set @valueText = Convert(varchar(5), @value)

if LEN(@valueText) = 4

BEGIN

set @Left1 = Left(@valueText, 1)

set @name = dbo.fn_NumberToText(@Left1) + ' ' + 'Thousand'

set @RightTrio = RIGHT(@valueText, 3)

set @name = @name + ' ' + dbo.fn_NumberToText(@RightTrio)

END

if LEN(@valueText) = 3

BEGIN

set @Left1 = LEFT(@valueText, 1)

set @name = dbo.fn_NumberToText(@Left1) + ' ' + 'Hundred'

set @RightPair = Convert(varchar(2), Convert(int, right(@valueText, 2)))

set @name = @name + ' ' + dbo.fn_NumberToText(@RightPair)

END

if LEN(@valueText) = 2 and LEFT(@valueText, 1) <> '1'

BEGIN

set @Left1 = LEFT(@valueText, 1)

set @RightOrdinal = Right(@valueText, 1)

select @name = case @Left1

when 2 then 'Twenty'

When 3 then 'Thirty'

when 4 then 'Forty'

when 5 then 'Fifty'

when 6 then 'Sixty'

when 7 then 'Seventy'

when 8 then 'Eighty'

when 9 then 'Ninety'

end

select @name = @name + ' ' + dbo.fn_NumberToText(@RightOrdinal)

END

if LEN(@valueText) = 2 and LEFT(@valueText, 1) = '1'

select @name = case @value

when 10 then 'Ten'

when 11 then 'Eleven'

when 12 then 'Twelve'

When 13 then 'Thirteen'

when 14 then 'Fourteen'

when 15 then 'Fifteen'

when 16 then 'Sixteen'

when 17 then 'Seventeen'

when 18 then 'Eighteen'

when 19 then 'Nineteen'

end

if LEN(Convert(varchar(4), @value)) = 1

select @name = case @value

when 1 then 'One'

when 2 then 'Two'

When 3 then 'Three'

when 4 then 'Four'

when 5 then 'Five'

when 6 then 'Six'

when 7 then 'Seven'

when 8 then 'Eight'

when 9 then 'Nine'

when 0 then ''

end

return @name

end

go

-- test statement

-- select dbo.fn_NumberToText(1111)

-- script to solve the problem

declare @iter int, @match int, @text varchar(100)

set @iter = 1

set @match = 0

while @match < 23

BEGIN

set @text = dbo.fn_NumberToText(@iter)

if charindex('e', @text) = 0

BEGIN

set @match = @match + 1

if @match = 23

print 'The Answer is: ' + @Text

-- TESTING CODE -- print Convert(char(2), @match) + ': ' + @text

END

set @iter = @iter + 1

END

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Comments [0] | | # 
Saturday, December 24, 2005
Saturday, December 24, 2005 1:35:37 AM (India Standard Time, UTC+05:30) ( Musings )

Wasting time before heading home for the Christmas weekend, I decided to see which Peanuts character I am most like.   I think many would agree that I fit this profile:

 

Lucy
You are Lucy!

Which Peanuts Character are You?
brought to you by Quizilla
Comments [0] | | # 
Saturday, November 12, 2005
Saturday, November 12, 2005 1:14:45 PM (India Standard Time, UTC+05:30) ( Musings )

Rubbing of name Michael M Woynarski from Vietnam War Memorial

 

Richard M Woynarski was born in 1946.  After enlisting in the US Navy he was assigned to VA-164, an A-4 fighter-bomber squadron embarked on the USS Oriskany.   In late 1967 the Oriskany was stationed off the coast of North Vietnam.  On October 16, 1967 his plane was shot down.  He was initially listed as MIA, later as KIA.

 

That is all I know of this man.   This morning I had never heard his name.   At lunch time today I went to Steele Park in Phoenix to see a traveling replica of the Vietnam War Memorial.  It seemed very appropriate to see the memorial on Veteran’s day.

 

I have seen the memorial in Washington DC.  Back in 1999 I was there in the fall.  The remnants of a hurricane were blowing up the east coast, and by the time I made it to the memorial a strong rain was falling.  For 20 minutes I slowly walked along the wall, alone in the pouring rain.

 

I don’t go to these memorials to mourn or remember anyone in particular.  In fact, I can find no evidence that anyone named Swaner has ever died in the line of duty.  Instead I go to remember people who I didn’t know who died for people they didn’t know. 

 

Today a volunteer asked if she could help me find a name.  When I said that I didn’t know anyone on the wall she suggested that I should do a rubbing anyway; to “show those on the wall that they are not forgotten”.    I chose a name at random.

 

As I look at the rows and rows of names my thoughts are focused on a rapid series of “what ifs”.   I look at a name and think “He would have been a school teacher”, “He might have been a great writer”, “He might have found a cure for cancer”.  My thoughts then turn towards the reality that this wall is a record of loss.   Of the 58,195 names on the wall, how many family and friends grieved and still grieved for their loss?

 

When I was in High School I wanted nothing more than to be a pilot in the US Air Force.   During my Junior year I borrowed my father’s Oldsmobile and drove to Hill Air Force Base for a recruiting open house.   I stood with a bunch of other teenagers in a hanger between two F-16 fighter jets.  After a stern warning about not taking pictures of the cockpit, we were lined up to climb inside one.  As I was about to climb the ladder, as captain asked how tall I was.  When hearing that I was 6’5” he said “Sorry son, the maximum height is 6’3”, you are too tall to fit in the cockpit.  That dream died that day.

 

A few years later I walked into an Army Recruiting office.  I had every line on the enlistment paperwork filled out except for the signature line.   Under intense pressure from the recruiter I got feedback from my parents and a professor.  Their influence convinced me to back out.

 

Then, two years after that, at a college job fair I asked the Navy recruiter for the enlistment forms.  He asked my major and when I told him that I was studying Philosophy he said the Navy only had openings for doctors and engineers.

 

I don’t know why I never talked to the Marines, but I think that if I had I would have signed up.   I went to see the movie “Jarhead” and it seemed so natural to me, almost familiar.  The only thing more powerful than the urge to join up now, before I turn 35 in January and become ineligible is the responsibility and love for my family.  As much as I want to sign up and request service in Iraq or Afghanistan, they are far too important far too important and they are my primary responsibility now, not my country.

 

I have often wondered why I have such a fondness for the military and a deep respect for those who serve, yet am so opposed to war.  The answer lies in the rows of names on a wall and the rows of crosses in a cemetery.   It brings to mind a favorite poem:

 

In Flanders Fields
By: Lieutenant Colonel John McCrae, MD (1872-1918)
Canadian Army

IN FLANDERS FIELDS the poppies blow
Between the crosses row on row,
That mark our place; and in the sky
The larks, still bravely singing, fly
Scarce heard amid the guns below.

We are the Dead. Short days ago
We lived, felt dawn, saw sunset glow,
Loved and were loved, and now we lie
In Flanders fields.

Take up our quarrel with the foe:
To you from failing hands we throw
The torch; be yours to hold it high.
If ye break faith with us who die
We shall not sleep, though poppies grow
In Flanders fields.

 

I am certain that Richard M Woynarski loved and was loved.  Now he lies in St. Patrick’s Cemetery in Hartland New York.  His life was cut short after 21 years.   Now, years later I look at his name and wonder what he would have become.   What experiences he was prevented from having.     It was an awful fate that he was killed on an October day 28 years ago.  Maybe it is fate that I tried three times to join the military and never did, but instead I have the freedom to live the “what-if’s” and experience the joys and sorrows that Richard and so many others never had.  It is the least I can do to honor and respect his and their sacrifices.

 

 

Comments [0] | | # 
Wednesday, November 02, 2005
Wednesday, November 02, 2005 11:53:24 AM (India Standard Time, UTC+05:30) ( )

I am testing out Blogjet, a blog editing program.  Seems to work very well so far.

Railway Platform at Egmore Station, Chennai
The platform at Chennai Egmore station on a slow Friday night.

First view of the Western Ghats, from the train.
I passed time in the morning reading, but when I took a break I got my first look at the Western Ghats out of the window.

An elephant on the streets of Madurai
You can see the sores on the side of this poor elephant.  It is considered good luck for an elephant to pat you on the head with its trunk.  As compensation for this service you are expected to hand a coin to the elephant.   The elephant, using its trunk, then hands the coin to the driver.  The driver of this elephant is obviously hard up, he is working this poor elephant past any point of decency.  Very sad.   This is, unfortunately, very consistent with all episodes of animal treatment I encountered in India.

 

Comments [0] | | # 
Saturday, October 29, 2005
Saturday, October 29, 2005 2:48:42 AM (India Standard Time, UTC+05:30) ( )

Last night at about 11:30 PM Amy (my wife) asked me to go to the store and pick up some medicine for Abby (my daughter).  She is teething and was having a hard time sleeping.   I got down to the kitchen and realized that I had not hung up my keys where they go, and instead of going back upstairs to get them, I grabbed the spare set hanging on the key rack.   Back at the truck after buying the Children’s Tylenol, I inserted the key into the door to unlock it.  Usually I click the button on the little fob, but the spare key doesn’t have one.   As I twisted the key in the lock I set off the car alarm.   The only way I know to turn off the alarm is to push the unlock button on the fob.   But the fob was at home.    I frantically tried everything I could think of, I looked for the fuse to the horn in the fuse case, I pushed every switch, and I tried to start the car.  Nothing would work.   As I was looking a second time at the lid to the fuse case, trying to find a fuse I could pull, a flashlight shown on me.  Turning around I noticed one of Gilbert’s finest standing a few feet away, one hand resting on his holstered pistol, the other holding a flashlight.   I asked him if he had any ideas how to turn off the car alarm.   He paused for a long couple of seconds, probably deciding if I was a stupid thief or a clueless Nissan owner.   Finally he said “No”.   After watching me for a long 2-3 minutes I explained to him that I only knew how to turn it off with the fob thing, but that it was at home.  He took my license and registration to make sure it really was my truck and then offered me a ride home.   The back seat of a police car is never a comfortable place to be.  But the officer was nice.  He even offered to handcuff me and then knock on the door and tell my wife that I had been arrested.   I declined that offer; it was enough humiliation to have been sitting for 10 minutes in a car that won’t stop honking in the middle of a parking lot in the middle of the night.   He gave me a ride back to the store and I finally was able to start my truck and go home.

 

Fast-forward ten hours to this morning.   I am in a good mood, scanning the channels to catch the latest indictment news from Washington, racing down the freeway with the windows down, and enjoying the perfect Arizona weather.  As I near my exit (3Rd Street HOV exit on I-10) I switch to the oldies station which was playing “Age of Destruction” by Barry McGuire        .  I instantly started singing along. Now this song is not something for the gentle singing.  It is a song of anger and protest.  The only way I know to sing along to this song is a full on, take this protest scream.   Racing up the off ramp, windows down I stop at the light at the end of the ramp. 

 

My turn is to the right.  I am still singing as I look to the left to see if I can turn.  Right as I do so I am singing “Think of all the hate there is in Red China, then look around to Selma Alabama”.   At about “Selma” I realize that there is this woman in the lane next to me on a big Harley-Davidson motorcycle, wearing a white shirt, blue jeans and strawberry blonde hair coming out from beneath her helmet.  This mental image I have of her will be in my mind for a long time.  She is looking right at me and laughing and shaking her head as if to say “This is the most pathetic sight I have seen in a long time”.   I give her a sheepish nod, certainly turning bright red and racing away as quickly as possible.  The last words of the song that I heard before switching to NPR were “The pride and disgrace”…….

 

 

Comments [0] | | # 
Wednesday, October 26, 2005
Wednesday, October 26, 2005 2:56:00 AM (India Standard Time, UTC+05:30) ( )

I just read the following and am pretty upset about it:

 

Reuters

Updated: 1:56 p.m. ET Oct. 24, 2005

JAIPUR, India - Indian police have brought charges against a Finnish tourist for swimming naked in a holy lake in a Hindu pilgrim town, a police officer said Monday.

Police said the tourist walked to her hotel in the nude after taking a dip in the lake in Pushkar in the desert state of Rajasthan on Saturday, angering several local people and priests.

“We have framed charges of indecency against the lady tourist from Finland under section 294 of the Indian Penal Code (IPC),” Sugan Singh, a police officer in Pushkar, told Reuters.

I guess in the old days you used to go to Disneyland and ride the “Small World” ride.  Now, it seems that people think that the whole world is their personal amusement park.  Now it may be perfectly acceptable to swim and walk around naked in Finland, but spend 5 minutes in India and anyone will know that is not acceptable there.  This episode seems like a callous disregard for the beliefs and traditions of the people of Pushkar and all of India.   I hope they lock her away for a long time.  I hope that many people thinking of traveling to India read the Reuters article.  What makes India so amazing is its people, their culture and beliefs.                                                        

Comments [0] | | # 
Tuesday, October 25, 2005
Tuesday, October 25, 2005 6:48:16 AM (India Standard Time, UTC+05:30) ( Technology )
How do you get a kid to be interested in learning to program?   Show them how to create a program to do/help do their homework:
 
Josh has frequent assignments that involve reading a page long story and then answering some questions about the story.  Included are some scrambled words that appeared in the story.  Josh asked if a computer (like what they used in "National Treasure" to decode Abby's password) could help out.
 
The result, I told Josh that he could use any program he created to do his homework, and that I would help him out with his programs.
 
To show him how easy it could be, I created a program to provide a list of possible matches to word scramble questions.
 
create procedure usp_TextUnscramble @input varchar(20)
as
declare @query varchar(1000),
 @position int, @length int, @currentLetter char(1)
 
set @query = 'select top 1000 WordItem from WordList where '
set @length = LEN(@input)
set @position = 1
print @length
 
while @position <= @length
BEGIN
 set @currentLetter =  SUBSTRING(@input, @position, 1) 
 set @query = @query + ' charindex('''
 set @query = @query + @currentLetter
 set @query = @query + ''''
 set @query = @query + ', WordItem) > 0 AND '
 
 set @position = @position + 1
END
set @query = @query + ' LEN(WordItem) = ' + convert(varchar(5), @length)
 
print @query
exec (@query)
go
 
exec usp_TextUnscramble 'rmragrporm'
 
The WordList table is an import of the Moby Word List.  Tonight we are going to wrap this code in a Windows application so that he doesn't need to use Query Analyzer to run it.
Comments [0] | | #