brainsnorkel.com

Manifesto-driven development. Eclectic thoughts.
  • Home
  • Tech
    • Getting wireless WPA-PSK working under Ubuntu Linux on a Dell Inspiron with Netgear WG511
    • Troubleshooting
      • iTunes freezes up randomly
      • Add media buttons missing from WordPress?
      • Lenovo ThinkVantage System Update troubles
      • Ubuntu 10.04 LTS: “prepare partition” page is blank
      • Fix for Canon LiDE 200 scanner error code 2,252,0
      • iOS iPhone Music app skips songs continuously
    • Sites I maintain
    • VoIP + Networks
      • FreeBSD box
      • Router
      • OzTell
      • Installation
      • Configuration
      • Requirements
      • Sipura SPA-3000
      • References
      • Using Asterisk
      • WRT54GP2 and iiNet VoIP
  • Development
  • Writing
    • Australian Republic
      • Chapter I – Introduction
      • Chapter II – Historical Background to Australian Republicansim
      • Chapter III – Republicanism as a Political Issue in Modern Australia
      • Chapter IV – Multiculturalism as a Basis for Republicanism
      • Chapter V – Conclusion
      • End Notes and Bibliography
    • Miscellaneous Pages
      • Requirements Matrix: Julian vs Flickr
      • Links
  • Games
    • Follower
    • myphatlewt.sh
    • Flash Asteroids (for IE)
  • About

Death by radix

13-Jul-2011

This post is reinforcement of a programming trap I should avoid in future, and punishment for selecting poor test cases. It’s not a bug of epic proportions, so move along if you have better things to laugh at than a bug in my Daily WTF-candidate code.

I threw together a simple booking calendar that uses a touch of JavaScript to make it a little more animated than a basic web form on cheapo PHP hosting. Part of the magic of this calendar is that it creates a string of the form “Your booking is for one night from Wednesday July 13th 2011, departing Thursday July 14th 2011″ to help reinforce to the user that the correct dates have been understood by the booking system.

When I implemented this booking calendar it appeared to work nicely. Nonetheless, I wrote test cases for it. When there were plenty of tests and they all passed I was feeling smug that my JavaScript was probably provably better quality than most of the JavaScript in existence given it had tests.

It operated for a few months with no complaint. Then there were several reports in one week that the code wasn’t generating the correct weekday.

“Inconceivable!” I thought.

I tried it myself with the dates users complained about and found it was generating crazy weekdays. I checked, and my regression tests were passing just fine. I then plugged the reported problem dates into my test suite. My old test cases succeeded and the new ones failed.

So, down to diagnosis.

The “bulk” of the code is pulling the date string apart so I can use date-related utility functions. The problem was my use of parseInt().  

parseInt() parses a string and returns an integer. I discovered that it works fine for some months (01, 02, 03, 04, 05, 06, 07, 10, 11, & 12) and not for 08 and 09. This is because parseInt() assumes that if the string it is parsing begins with a 0, then it’s an octal number. That works for 01-07 because they generate the same number whether you parse them as octal or not. 11 and 12 work because parseInt() correctly guesses that they are base 10. 08 and 09 are automatically detected as octal, but they fail to parse as octal numbers. I used the error return value to populate the month in a Date object which dutifully interpreted the value as December. The weekdays were right… for December.

Sure enough, none of my test data contained a date in August or September.

The main fix is that the parseInt() function takes a second optional argument that sets the radix to use and stops it from guessing.

I’m still trying to think of a situation when you might want parseInt() to guess the radix for you.

Comments
7 Comments »
Categories
silly, software
Comments rss Comments rss

Beam “Slavery to Star trek” to Edinburgh

14-Jun-2011

What use is my dormant blog if not for blegging?

My friend Andreea Kindryd started doing stand-up comedy at age 68 and has recently started performing an amazing autobiographical show. After great reviews at the Adelaide Festival she has the chance to perform “Slavery to Star Trek” at the Edinburgh Festival this year, but she needs some help to get there (and back).

Come along to a performance in Sydney later this month, or visit the Pozible project pageand pledge a little support.

Comments
No Comments »
Categories
family, links, silly
Comments rss Comments rss

Improved boot times: Vista vs Windows 7

19-Jun-2010

I think it was Andrew who pointed me to Soluto as a method of improving boot times on Windows PCs.

I have mentioned before that my Vista-running X61 tablet takes a while to boot. Soluto measured boot time at just over 10 minutes. I followed its advice, and through delaying and removing various crapware and legitimate startup programs I got boot time down to 5 minutes and 10 seconds.

Emboldened, this weekend I took some advice from Ian’s comments on my last post and shelled out AU$300 for a copy of Windows 7 Professional (upgrade).

Now, with a few tweaks recommended by Soluto I’m recording a consistent boot time of 1 minute 35 seconds.

My aging tablet feels like new again (during boot).

Update: Actually, it feels pretty snappy all over since the Windows 7 makeover and some hybrid SSD drive loving. Boot time is now a shade under a minute and application launches are snappier then they’ve ever been.

Comments
2 Comments »
Categories
hardware, software, tech
Tags
gadgets, hardware, software, tablet, windows 7, x61
Comments rss Comments rss

The Lenovo X61 Tablet three years later

11-Apr-2010

In a previous post I had talked about the rate of decay and the usefulness of a fairly shiny new X61 tablet. Now three years later it’s time for a quick update on how it’s travelling.

Lenovo Thinkpad X61 Tablet

As you can see, the tablet is pretty much the same as it was at 3 months old. There are legends about how hard-wearing ThinkPads are. After lugging it back and forth from work, and on vacations, for three years it’s looking like a role model for laptop longevity.

The screen is a bit blotchy with grease now, I haven’t found a good cleaner that I trust to not melt or damage the surface, so I put up with a dirty screen. The screen is also pulled away at the bottom exposing some glue that picks up dust and won’t let it go, but the problem is just aesthetic.

The pen is still held together by sticky tape.

The hard disk is now a 500GB Seagate 7200rpm drive, and I have added 4GB of RAM. The battery is now a non-Lenovo battery that works fine except that the Lenovo power management software courteously questions my commitment to safety and morality every time I log in. The original battery went stone cold dead with error messages from the power management system along the lines of “Get this battery thing outta me NOW! Stat!” when it was just over 2 years old.

None of the keys have come off the keyboard. The marvellous screen-rotating and reversing hinge feels as firm as the day it came out of the box.

The biggest problem is still Vista and the load of Lenovo crapware required to keep it alive. It has always taken a long while to boot and get settled (5-10 minutes), so I’m tempted to start from scratch with Windows 7, but haven’t made the investment in time yet.

Comments
5 Comments »
Categories
general
Tags
gadgets, hardware, lenovo, review, tablet, x61
Comments rss Comments rss

Blog moved!

11-Apr-2010

After checking the PHP options and benchmarking hosting & database speeds at spry.com’s dirt cheap hosting against options at the dirt cheap hosting I have at GoDaddy.com I decided to move Brainsnorkel to the garish world of GoDaddy.

While moving I found a couple of things of interest.

  1. That the Freshy2 theme I use has been bequeathed to the open source community by its creator, so I will move to a newer theme when I find one and modify it to taste. (Ignore the WordPress 2.9 incompatibilities for now, ok?)
  2. That exporting MySQL defaults to latin character encoding, and phpMyAdmin defaults to utf8 for import.
  3. That TPG has one of the slowest to update DNS servers in the world:

    sh-3.2$ nslookup brainsnorkel.com 203.12.160.35
    Non-authoritative answer:
    Server: dns1.tpgi.com.au
    Address: 203.12.160.35
    Name: brainsnorkel.com
    Address: 64.79.220.169
    sh-3.2$ nslookup brainsnorkel.com 203.12.160.36
    Non-authoritative answer:
    Server: dns2.tpgi.com.au
    Address: 203.12.160.36
    Name: brainsnorkel.com
    Address: 97.74.215.189

Comments
4 Comments »
Categories
general
Tags
dns, hosting, meta-blogging
Comments rss Comments rss

Dear reader

30-Oct-2009

Oh strange new Internet that has such people in’t.

The few very hasty blog posts in the last year is a clear indication to y’all that Brainsnorkel is barely registering in my consciousness. I don’t blog about work, and work is hard at the moment.

Actually, home is hard too.  To make our house bigger, we have to squeeze into one end of it for a while. Hopefully all of this squeezing will be a thing of the past soon. We’ll move back into our proper places and the sardines can move back in to where we’re living.

Enough excuses! Brainsnorkel doesn’t need excuses.

Brainsnorkel needs the dust blown off it.

Given how consuming work is, maybe meta-work is fair game now. It has been in the past.

Comments
2 Comments »
Categories
general
Comments rss Comments rss

Yet another Röyksopp video

23-Jul-2009

There is so much to love about this music video.

Comments
No Comments »
Categories
games, silly, software
Comments rss Comments rss

iPhone 3GS

3-Jul-2009

I can’t review my new iPhone 3GS. Frankly, I haven’t used it enough. I’m still waiting for my old carrier to port my number so I can use it as something more than a very expensive iPod Touch.

One of the first things I did after getting it was to sit down with a couple of our kids and show them the maps, video camera, photos, some Wall-E, Phineas and Ferb and then an iPhone version of Peggle which they had played on PC extensively.

When I had decided that demo time was over my 3 year old daughter insisted that the iPhone was hers. To encourage me to hand it over she started ripping up and throwing things around the house with some impressive, wanton, and very primal, rage.

This experience has brought me to the realisation that slavish iPhone desire is nature, not nurture.

I’m seriously considering buying a decoy.

Comments
1 Comment »
Categories
hardware, silly, tech
Tags
apple worship
Comments rss Comments rss

Doom Bunker!

3-Apr-2009

This (and the clip that follows) has to be the best Colbert segment for some time.

The Colbert Report Mon – Thurs 11:30pm / 10:30c
Doom Bunker – Glenn Beck’s “War Room”
comedycentral.com
Colbert Report Full Episodes Political Humor NASA Name Contest
Comments
1 Comment »
Categories
silly
Tags
funny
Comments rss Comments rss

Battlestar Galactica: A great TV series ends

24-Mar-2009

When I recall very good TV series like Six Feet Under and The Wire I feel could go back and watch the final episode any time for a reminder of the quality of the series and the characters in it. Battlestar Galactica is an excellent TV series, but I think I’ll be watching the pilot episodes, season 1, and not the finale.

Tonio sums up all that was good and bad about the series finale (beware, here be spoilers):
Battlestar Galactica Ends

Here’s my take on the end of the best Science Fiction TV series in history: it hit the right emotional notes, and it was reasonably satisfying, but it was not a worthy ending to the series, and I suspect that as we all go back and watch the whole thing through we’ll find a lot of threads left dangling or essentially forgotten by the writers.

Comments
No Comments »
Categories
kudos, links
Tags
bsg, reviews
Comments rss Comments rss

Jung talent time

4-Feb-2009

I’m in leadership training.  It’s pretty good so far.

Notable occurrences:

  1. Though the Chris of 2000 was an INFJ, the Chris of 2009 is an ESTP. Abracadabra!
  2. The 2×2 leadership analysis grid keeps reminding me of this…

Dilbert.com

Comments
No Comments »
Categories
manifesto, vignette
Tags
management
Comments rss Comments rss

Two ideas for Christmas gatherings

20-Dec-2008

Christmas can be a long day. Hopefully these two YouTube gems will help pass the time.

How to fold a T-shirt in 5 seconds:

Orange teeth:

Comments
No Comments »
Categories
family, silly
Tags
media
Comments rss Comments rss

« Previous Entries

Recent Posts

  • Death by radix
  • Beam “Slavery to Star trek” to Edinburgh
  • Improved boot times: Vista vs Windows 7
  • The Lenovo X61 Tablet three years later
  • Blog moved!

Navigation

  • games
  • general
    • family
    • kudos
    • links
    • vignette
  • manifesto
  • politics
  • silly
  • tech
    • hardware
    • networks
    • software

Advertising!

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox