The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Monday, January 23, 2012

A disconnect

R stops by my desk and drops off a new toy unit to play with test. It's a network device you can plug a POTS line into and make calls over the Internet. I guess we're testing the toy to play with unit to see if our phone network features work with it.

It's a nice looking device and as R hands it to me, I see that's it still on (yes, it comes with both an internal battery and a wall-wart). The tests aren't complicated, but I do need to read the manual to figure out how to run a few of them (involving conference calling, and forwarding phone calls elsewhere). R also hands me the box the toy to play with unit came in.

As I searched through the box for the manual, I come across a USB cable, still in it plastic wrap. Okay, the unit comes with a USB port; what doesn't these days? I then find the manual and start flipping through it. There's the diagram of the toy to play with unit with a description of each port and button on it. I notice the USB port has a note:

NOTE: Never place a USB-based device into the USB port of the XXXX XXXXX XXXXXXX under any circumstances. Doing so may damage the device and negate its warranty. The port was designed for diagnostic purposes only; it is not intended for customer use.

So, not only is there no sticker over the USB port saying “removal of this sticket voids warranty” but they give you a USB cable not to plug into it!

Methinks there is a disconnect between manufactoring and packaging at the factory that makes these toys to play with units.

99 ways to program a hex, Part 15: Lua

I'm still taking a break from C, and today's version is in Lua.

#!/usr/bin/env lua
-- ***************************************************************
-- Copyright 2012 by Sean Conner.  All Rights Reserved.
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <>.
-- Comments, questions and criticisms can be sent to:
-- ********************************************************************

-- Style: Lua 5.1

function do_dump(fpin,fpout)
  local offset = 0

  while true do
    local line = fpin:read(16)
    if line == nil then return end
    	string.format("%08X: ",offset),
        line:gsub(".",function(c) return string.format("%02X ",c:byte()) end),
    	string.rep(" ",3 * (16 - line:len())),
    offset = offset + 16

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

if #arg == 0 then
  for i = 1 , #arg do
    local f =[1],"r")


What I'm noticing (besides my text editor's horrible attempts at syntax highlighting in this entry) is that the non-C versions are quite a bit shorter than the C versions. I'm sure part of that reason is the high level of abstraction obtained by not using C. For instance, in this version, the code to dump the data is easily half the length of the shortest C version, thanks to the clever string.gsub() routine in Lua.

Obligatory Picture

[It's the most wonderful time of the year!]

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site:, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2019 by Sean Conner. All Rights Reserved.