Blog

Updating This Site

Format Status

Over the next few weeks I’ll be updating this site to be more of a personal landing page with links and references to all my projects. I might possibly start posting here again. However, my main blog currently is my Expanding Frontier blog. Go check it out. Planned updates include:

  • Moving the blog off the main page and setting the home page to a static bio page
  • importing posts from my older blogs to this site (with links back to the originals). You should see the archives grow (I’ve already imported one site)
  • Create several detail pages for projects I’m working on
  • Possibly change the theme
Format Aside

I’ll be posting some small bits and pieces to the blog over the next little while in different formats to test out some of the features of the theme I’m using and see how things look.  This one is posted as an “Aside”,

And as an aside, I’m trying to figure out why Google+ posts with links to this site (and a few others on the same host) vanish into the ether.

Vanishing Act

Today’s prompt was:

Three dice with pictures of a magnifying glass, a magic wand, and a teepee

Inspector Karl Evanson pulled up outside the large three-ring circus tent and got out of his car.  The place was deserted this early in the morning and had an empty, almost forlorn look to it.  There were a few birds flying around investigating debris on the ground but no one was visibly out and about.

Karl shrugged as he walked up to the tent entrance.  Circus people probably liked to sleep in just like everyone else.  And given that the circus is open until late, probably more than most.  He stopped just inside the big entrance, allowing his eyes to adjust to the dimmer light inside the tent.  Here at least was a little bit of activity.  Some of the animal trainers had their charges out and were working with them.

The circus master spotted him as he looked around and hurried over. “Inspector, I’m Mark Gimmel.  Thank you for coming so quickly.”  Mark was an elderly gentleman, probably in his late fifties or early sixties, Karl thought.  Despite his age he looked to be in excellent shape and capable of performing many of the acts circuses were famous for.

“What seems to be the issue, Mr. Gimmel?” Karl asked. “You sounded quite upset on the phone.”

“Well,” Mr. Gimmel replied, “it seems that, Barbra Dalton, one of our star performers, has disappeared.”

“Disappeared? When was she last seen?”

“Last night at her performance.  She returned to her trailer and then she just vanished.”

“Okay,” Kark said. “I assume someone tried to talk to her at some point and she wasn’t there.  There are any number of possible explanations.  What makes you think there is something more involved than that she just stepped out for a bit and will be back?  And what exactly is her role here?”

“Barb is our magician,” Mr. Gimmel said in response to the last question.  “As for why I think it’s something more, it would be easier if I just showed you.”

As Mr. Gimmel passed him and led the way back out of the tent, Karl rolled his eyes.  Why did every incident related to circuses always seem to involve the magician.  It’s like no one else in the entire company ever had issues.  And invariably the owners claimed a supernatural event that always turned out to be something completely mundane.

As Karl followed Mr. Gimmel across the compound, he began to see more people stirring.  They were also staring.  At him.  “How many others know about this?” he asked as they walked.

“Only a few people so far, why?”

“Your crew is wondering what a stranger is doing walking across the compound with the boss this early in the morning,” Karl commented as they stopped in front of an RV and Mr. Gimmel pulled out his keys.

“Well, I’m sure they’ll find out quick enough,” Mr. Gimmel said. “We’re a small, close group and Barb’s disappearance won’t stay quiet for long.”  He found the key was looking for and started to unlock the door.

“Shouldn’t we knock first?” Karl asked.  “Just in case she has mysteriously reappeared.”

“Not very likely,” Mr. Gimmel replied.  But he knocked anyway.  After a few moments of no response, he opened the door, stood aside, and gestured for Karl to enter.

Karl climbed up the steps into the RV.  “Hello,” he called out looking around.  The room was fairly clean and organized with everything seemingly in its place.  Although it appeared that Barbara Dalton had a thing for lizards as there were hundreds of figurines, stuffed animals, posters, and other knick-knacks all shaped as or decorated with the reptiles.  The loft area above the driver’s seat was sealed off with a fine wire mesh and had been turned into a terrarium.  Looking closely, Karl noticed a large iguana staring back at him.

“I’m guessing she uses reptiles in her act,” Karl commented to Mr. Gimmel who was still standing outside the trailer watching him.

“Yes she does,” he replied.

Karl continued to scan the interior of the RV.  The sleeping area in the back was closed, so he couldn’t see in there without going back and opening the door.  The kitchenette looked as if it had been used to cook something but not cleaned up.  The table had a plate with a half-eaten meal on it as if the person had stopped mid-meal to do something else.  There was no sign of struggle anywhere in the RV.  And with all the decorations, any amount of struggle would have made a mess.

Then he saw what had probably freaked Mr. Gimmel out.  Crumpled on the seat and floor at the table were clothes: slippers, sweat pants, and a T-shirt, that look like they once contained a person who had just disappeared and the clothes had collapsed down once the body vanished.  It was actually quite eerie.  Karl started to walk over toward the table to get a closer look when the hackles on the back of his neck started to rise.  Just then he heard Mr. Gimmel let out a squawk of fright, the iguana hissed in anger, the light in the room dimmed, and he heard a woman’s voice let out a wail of terror.

The Unexpected Target

Today’s writing prompt was:

three dice showing a plant, a lightning bolt, and a skyscraper.

His back against the wall, electrostunner in hand, Ratyn swore to himself under his breath.  There was another guard on this level between him and the office he was trying to get in to.  Maddup had promised when Ratyn accepted the job that the path up would be clear.  Instead this was the third guard he’d had to deal with.  He should have never trusted that irritating blob or gotten mixed up in this.

Getting up to the thirty-second floor had been easy enough and the outer doors opened to the code that Maddup had supplied. But roving security hadn’t been part of the deal.  The place was supposed to be deserted.  Instead he’d had to stun two different guards and now a third had just appeared out of nowhere.  He was going to charge Maddup extra.

Taking a deep breath, Ratyn listened for the steps of the guard, and, just as the guard approached the corner, he stepped out and fired his stunner at point blank range.  The guard toppled, but Ratyn knew that he only had a few minutes before one of the guards would wake up.  Moving quickly, he found the office in question, typed in the access code he had been given, and entered, relocking the door behind him.

The room was fairly large, definitely the office of someone fairly high up on the food chain in the organization.  Right inside the door was a comfortable meeting area, a couch and chairs arranged around a small table.  On one side of the room in the middle distance was what looked like a drafting table, covered in papers and diagrams.  At the far end, beside the floor to ceiling wall of windows, was a large executive desk and chair.  His prize was supposedly there.

The room was illuminated by a flash of lightning just a moment after he entered.  Which was another source of consternation to Ratyn.  One of those glass panels behind the desk was actually a door that opened onto a balcony, or so he’d been told.  His exit was supposed to be simple, as a Yazirian, he could just step off the balcony and glide away.  Sure, he was over 150 meters in the air, but that just meant he could get farther away before he landed.  But a lightning storm outside put a nix to that plan.

Approaching the desk, he could see that it was not nearly as cluttered as the drafting table.  There were a couple of stacks of paper, a few photographs, a lamp, and a couple plants all arranged neatly on the desktop.  But nothing that looked like what he had been hired to retrieve.

Maddup had said he was looking for a Laco Diamond and Ratyn hadn’t asked any questions.  He knew what a diamond looked like.  Although he had thought it weird at the time that the owner would have something that valuable displayed on their desk.  Supposedly the diamond would be on the far right corner of the desk relative to the person sitting at it but the only thing there was one of the plants.  The owner had probably locked it away for the night.

Busting out his lockpicks, Ratyn prepared to work on the old fashioned key lock but when he tried the desk, it wasn’t locked at all.  Odd, but he was grateful since time was running out if he was going to get back down the elevator before the guards woke up.  As quickly as he could, he started searching through each of the drawers in the desk but didn’t find anything that resembled a diamond.  Maybe he should have asked more questions.

Not finding anything, and feeling each second tick away, he sat down in the chair to think for a moment.  Obviously designed for a human, the chair was a little small for his large 2.3 meter tall frame.  Soft though.  He looked again at the plant that was sitting where the Laco Diamond was supposed to be.  It actually looked a little strange with square leaves and little translucent buds.  Looking closer the buds kind of looked like a small gemstone. “Or a diamond,” Ratyn muttered.  “You’ve got to be kidding me.”

Picking up the pot, he noticed some writing etched along the bottom: Rosa Laconis Diamantus.  The Laco Diamond Rose.  It was official, someone had lost their mind.  He’d been hired to steal a plant?  Well, he had his target, time to get out of there.

Scooping up the plant, he wrapped it as best he could to keep it from getting too crushed and spilling its soil everywhere and stuffed it in his flying bag.  He started toward the door of the office but stopped, hearing voices outside.

“Tanj,” Ratyn muttered under his breath, “the guards are awake.”  Walking over to the glass balcony door he stared out at the rain as another flash of lightning illuminated the sky.  “Maddup is really going to pay through the teeth for this.  Well, if he had any.”  Opening the door he stepped out into the downpour.  The rain was going to make gliding hard and he’d fall a lot faster than he’d like, especially from 150 meters up. It would be a hard landing.

Just as he was deciding it wasn’t worth the risk, the office door opened and he saw two guards silhouetted in the doorway, weapons drawn.  With no choices left, Ratyn leaped off the balcony.


“blob” is a somewhat derogatory term for the Dralasite race in the Star Frontiers RPG.  Dralasites are an amorphous alien, very much like a large amoeba,  that can change shape slowly if desired.  They have no mouth per se but rather eat by surrounding their food with their skin and absorbing it.

Yazirians are a tall, light-weight simian race that have flaps of skin connecting their arms, torso, and legs that can be stretched out into wings much like a flying squirrel.

A Troubled Return

For Christmas I got a set of Rory’s Story Cubes. I currently just have the original set but will probably get more in the future. I thought it would be a fun exercise to use them as writing prompts to generate ideas for short snippets of stories or maybe even longer ones as time goes on.  A common type of post that I had envisioned for this blog in getting it set back up was to be my writing exercises and stories I develop along the way.  And that was before I got the story cubes.

So here’s the plan, on a regular basis (as yet to be determined, but possibly daily eventually), I’ll pick 3-5 cubes at random from my bag of nine and roll them.  The images will form the basis for some sort of short story snippet.  I might try to weave them together to form a continuous (or at least related) setting or they may just be random.  It just depends on how I’m feeling that day.  For this first attempt I just used three dice and I ended up with these images:

three dice showing a shooting star, a castle tower, and the letter L in a box

Now, I have to admit, I had no idea what the L in the box was supposed to be or represent.  So I went and looked it up and it turns out it is a representation of a sticker that is common in the UK and hung in cars that have beginning drivers.  To the creators of the cubes, it represents the idea of learning or training.  Once knew that I was ready to go.  The following is what sprung to mind as I started typing.


Sara and her team were returning from their last training mission.  It had been a long exercise and the team was exhausted.  Ahead in the distance they could see the walls of the castle glistening in the light of the setting sun.  The castle had been their home for the last six months while they had trained for the soldiers and scouts for the King’s Army.  It was a welcome sight that cheered them greatly after two long weeks in the forests and marshes of Talnok.

As the sun set and the stars began to appear, Sara noticed something unusual in the night sky.  Hanging over the castle was a faint comet, just on the horizon and poised as if hurtling toward the castle to destroy it.  She shuddered as an uncomfortable premonition ran through her.

“Captain,” she called out, “have we seen that comet before?”

“What comet?” Captain Atlair replied, scanning the sky.

“There, hanging low over the castle,” Sara said as she rode up beside him and pointed.

“I don’t see anything.”

Looking again, Sara realized that it wasn’t visible any longer to her either, but there hadn’t been enough time for it to set.  And it was in the south, not the west anyway.

“I guess it was just the fatigue, sir,” Sara added after a moment.  But the feeling of the premonition still lingered with her and she wondered what it meant.


I realized as I was writing this that I need a name generator.  Or to generate a list of names that I can draw from as I need them as I’m horrible at inventing names on the fly.  I’ll just have to add that to my to do list.

Slowly getting organized

I’m finally getting this site set up after it has lain dormant for several years.  There will be a few changes to the style and layout as I settle on something I like.  Look for random posts on a variety of topics in the days ahead.  In addition to random thoughts, you can also expect to find links to other blogs and projects I’m working on.

What I Learned Today – CSS Padding vs Margin

I’ve been working through the design course at Hack Design.  I’m about a month behind and decided to try to catch up a bit.  I’m currently working through the whitespace lesson and stumbled across the answer to a vexing issue I’d noticed in some of the websites I’ve been working on.  I’m a relative novice when it comes to CSS and so many of you out there may have already known the answer but it was news to me.

In this article on Scale & Rhythm, Iain Lamb talks about how he adds vertical space between the text and heading blocks on a page.  In the article he points out that he adds padding to get the spacing desired.  He then goes on to say:

At this point, you might be asking: “Why set subhead padding rather than margin?” The answer: vertical margin collapses between two block elements.

That little bit right there stuck with me.  I had never known that and had never come across that little tidbit in my reading about CSS margins and padding.  I had run into this problem of the vertical space collapsing and had never been able to figure out why.  Now I know.

And just so I wouldn’t forget, I jumped over here and recorded it so I could find it later.  Now I need to go back and finish the article.

This post originally appeared on my old Programming Space blog.

Updating a Database in a Deployed Mobile App

One of the issues I had to deal with in building my mobile app was the evolving database schema as more features were added and the app grew.  I needed a way to update the database scheme without blowing away the old one and forcing the app to redownload all the data.  While I could have done that without any loss of data (there is no user supplied data to be lost), the main data set is over 8 MB in size and that isn’t nice to users’ wireless plans.  What I needed was a way to incrementally change the schema as the app was updated.

First Attempt

My first attempts just used if() statements.  i.e. if the current app version was one value and the new app version was a different value, apply this update.  This worked well enough for my development versions where I was strictly controlling the upgrade versions.  But I quickly realized that if I were to try to do that with versions of the app out in the wild, where I had no control over when it was updated, I’d quickly have a mess of conditionals to deal with.  So I scrapped that idea and went looking for something new.

Final Solution

I don’t think this solution is new to me as I’m sure I saw it somewhere to give me the idea but I couldn’t tell you where I saw it off the top of my head.  The answer was a switch() statement, with each case() block having a bit of the upgrade path from old to new schemas.  In order for this to work, you need to track a version number for the database schema that increases each time you make a change.  Simply start at one and every time you change the schema increment the value.  This value, which I called current_version, is simply a coded variable.

Additionally, the app needs a second value that it stores as part of the application data which contains the database version that is currently installed (installed_version).  Then, each time the application is run, you check these values.  There are three possibilities[1]:

  1. There is no stored value for installed_version. This should only be true the very first time the application is run.  In this case, you simply need to create the entire database schema as it now stands and store the current_version as the installed_version.
  2. The current_version equals the installed_version.  This is the simplest case of all.  Since the database schema is all up-to- date you don’t have to do anything.  Continue on to the main part of the application.
  3. The current_version is greater than the installed_version.  In this case there is work to do and we now need to do the update.

To make the update we simply enter a switch() statement based on the installed_version.  Each case() block should have arguments that start at 1 and increase by one each time.  The first case() block (i.e. case 1:) would hold the commands that were necessary to upgrade from version 1 to version 2.  The second would hold the commands modify the schema from version 2 to version 3, and so forth.

None of the case statements should have the break command associated with them so that after execution they would fall through to the next one and cascade all the way to the end.  That way if a user skips one or more app updates that include database upgrades, each one will be applied in turn and none will be skipped.

Finally, the default() block at the end of the switch statement should contain the code up update the value of the stored installed_version so that it is also up-to-date for the next time the application is run.

Here is a bit of sample code that shows how this works.  It is lifted in modified (with additional comments added) from my application which is written in using Titanium Studio’s Mobile SDK.  It should be noted that the c object is a configuration object that holds a lot of information such as the database name, the table names, and column names among other things.

// Check that we have a stored value for the installed database version
if(!Ti.App.Properties.hasProperty('installed_db_version')){
  // if not, the database has never been created
  createDB();
} else {
  var installed_version = Ti.App.Properties.getInt('installed_db_version');
  if (c.current_version > installed_version){
    Ti.API.info("Performing an upgrade from database version "+old_version+" to version "+c.version);
    var db = Ti.Database.open(c.name);
    // We need to do an upgrade to the new version based on the old version.
    // We'll do this incrementally adding in all the changes since the installed
    // version was created.
    switch(installed_version) {
      case 1:
        db.execute("REPLACE INTO daily_data (source,start,duration,flux_1000_300000,error_1000_300000,ul_1000_300000," +
        "flux_300_1000,error_300_1000,ul_300_1000,flux_100_300000,error_100_300000,ul_100_300000,test_statistic)" +
        "VALUES (1,56000,86400,10,1,0,9,2,0,1,0.5,0,32)");
        db.execute("REPLACE INTO daily_data (source,start,duration,flux_1000_300000,error_1000_300000,ul_1000_300000," +
        "flux_300_1000,error_300_1000,ul_300_1000,flux_100_300000,error_100_300000,ul_100_300000,test_statistic)" +
        "VALUES (1,57000,86400,12,2,0,10,1.5,0,2,0.5,1,32)");
      case 2:
        db.execute("DELETE FROM " + c.T_DAILY);
        db.execute("DELETE FROM " + c.T_WEEKLY);
        Ti.App.Properties.setString('last_lc_data_update','0');
      case 3:
        db.execute(DATABASE_CREATE_GCN);
        Ti.App.Properties.setString('last_GCNNotice_date', '0');
      case 4:
      ...
      ...
      default:
        Ti.App.Properties.setInt('installed_db_version',c.current_version);
        break;
    }
  db.close();
  }
}

In version 1, I was using some dummy data that I was setting explicitly.  In version 2, I had updated the code to get the data from a web service so I needed to remove all the old data and add a stored variable to track the date of the last data point.  In version 3, I added a table to the database and an internal stored variable to track the date that data was last updated.

At the beginning of the code block, I check to see if the database is installed at all.  If not I call a createDB() function.  This function simply contains the code that creates the current version of the database schema.  Another option would be to just set the installed_version to 0 and have a case 0: block that creates the original database schema that all the modifications are applied to but I believe it is faster and cleaner to just create the current schema rather than run through all the old ones applying one updated at a time.  While probably not an issue if you only have a few changes, as the number of modifications grow, so does the time involved in the creation of the new database.

And there you have it.  A simple straightforward way to make sure that your database updates go smoothly across updates of your application code.

One final note is that you don’t have to call this each time the app runs, but only the first time the database is used.  Now I suspect in most cases, the database is used every time the application is run but if there are sections of your app that don’t use the database, this check can be delayed until first use of the database.  This allows the app to load up a bit faster, although the difference may not be noticeable.


[1] There is a fourth possibility and that is that current_version is less than installed_version.  But if you’re properly incrementing current_version then this should never happen unless you roll back a distributed version of your application.  If you do that, all bets are off and you’ll need to find another way to handle the update.  Of course this is only a worry if the older code can’t work with the newer schema.

This post originally appeared on my old Programming Space blog.

Headaches of Switching to Mac OS X for Development

When you’ve been working primarily in one environment for nearly two decades, switching to a new one is never painless.

This is the fifth of several articles about my  journey developing an application for NASA’s Fermi Gamma-ray Space Telescope mission.  Earlier articles can be found here:

Let me say right from the beginning that I have nothing against OS X.  In fact, there are many nice things about the operating system and it definitely looks nice.  It’s just that I’ve been using some form of Linux (mostly RedHat and it’s derivatives) since 1997 and was using VAX and Solaris before that.  That was for school and work.  At home I run Linux and Windows.  I’ve never owned a Macintosh computer although I’ve occasionally used one here and there through the years.

I knew when I started developing the mobile app, I would eventually find myself on a Mac for development work because of Apple’s restriction that iOS apps can only developed on OS X.  And I knew there were going to be adjustments to be made.  Here are the ones I ran into that caused me the most grief.

Focus follows mouse

The first was the lack of “focus follows mouse” behavior on OS X.  I’ve spent the last 15 years with my windows set up so that when I move the mouse, the window it is over has focus and I can immediately start typing.  Many times I’ll have multiple terminal windows open (sometimes with just a line or two showing) and slide the mouse from window to window and launch programs.

No longer having that as an option definitely caused me several false starts and a bunch of retyping.  It wasn’t so much of an issue for the mobile development and that was mostly being done in a single IDE plus the emulators, but for my other Mac project, which involved a lot of building and compiling and running tools in the terminal windows, it was definitely causing a hassle.

I can understand completely why OS X doesn’t have this as an option.  The windowing system design with the menu bar always at the top of the screen and not attached to the individual windows definitely makes the idea of focus follows mouse undesirable.  It’s just something I’m used to that I miss on the Mac.

Command vs Control Key and Muscle Memory

I think of all the adjustments this one has caused me the most grief.  My hands have been trained, over the past two decades, to know exactly where the Control Key is located for all my keyboard shortcuts and the spacing between that key and the other keys in the command.  All of those same short cuts, on a Mac, use the command key which is one key over and which I still continue to miss for the first hour or two working on the Mac unless I make a conscious effort.  Eventually, I remember that I’m on a Mac and hit the right key, but in the mean time, since my IDE responds differently to Control-C versus Command-C for example, I’m having to hit a lot of extra key strokes to recover form my mistake.

Middle Mouse Button ≠ Paste

This one I use extensively and it’s absence drives me batty.  Instead of doing this:

  • highlight selection
  • move mouse to target window
  • click the middle button

I have to do the following:

  • highlight selection
  • Command- (not Control-) C to copy
  • move to the new window
  • click to activate the window (remember, no focus follows mouse)
  • Command- (again not Control-) V to paste.

In my Linux windowing environment, this works everywhere, no questions asked.  In fact, I can’t think of a single place where I’ve not been able to use it.

On the Mac, it does work (sort of) in the terminal windows.  But in the Titanium IDE it doesn’t work at all.  Maybe it works in other places but I don’t use much else right now and where I do spend my time, it doesn’t work.

In the terminal windows, it works like on Linux but with one exception.  When you middle click, it doesn’t count that as clicking to activate the window.  A lot of times I’m pasting in a command and I then want to hit Enter and have it execute.  On the Mac, the Enter key keystroke is captured by the window you copied from, not the one you just middle clicked in.  You have to middle click and then left click to activate the window you just pasted to.  Maybe Linux does the same with click to focus window behavior but with focus follows mouse enabled, the window I’m in is the active one so it’s not an issue.

Fuzzy Screen

I’ve seen flame wars and huge discussions on the font rendering engine on the Mac vs. Windows vs. Linux and I don’t intend to reignite those, but for me, the Mac screen is fuzzy.  I should say that I’m using an external 24″ 1920×1200 monitor on the Mac (it’s an HP LA2405wg)  and it is being driven by the Mac at it’s native resolution (the Mac is a MacBook with a 1440×900 LCD screen that is just way too small for a guy that uses dual 1920×1200 screens on all his other systems).  I get used to it after a bit but whenever I have to be switching back and forth between systems, its definitely an irritant.

Slow Response

I don’t think this really has anything to do with the fact that the computer is a Mac, per se, other than the fact that the machine has an old Core 2 Duo processor where my other systems are a Intel i7 and an AMD Phenom which are both quad-core and much faster.  I’m running Mountain Lion on a system that originally shipped with Leopard and I can feel it.  Luckily, this is soon to be rectified and I’m getting a new MacBook in a month or two with a faster processor and more RAM.

The other area of slow response is when I do switch between systems.  I have all my computers hooked up to a pair of monitors, keyboard, and mouse via a KVM switch.  For some reason the Mac has issues with the switch.  Many times it doesn’t connect the keyboard and mouse and sometimes just doesn’t grab the keyboard.  It also doesn’t seem to respond very well to the video switch when the screen saver is on.  Again, I think these are mainly issues of the old hardware and are only an issue when I switch to the Mac for the first time any given day.

Final Thoughts

Overall, the experience of working on the Mac has been fine.  I don’t have adapters to do the dual screen setup like I do with my other computers (only one video out on the MacBook) but that typically isn’t an issue since my work on the Mac is fairly focused.

Would I ever switch to a Mac as my primary system?  Probably not, although it’s not out of the question.  If I was doing mobile development full time and had to target iOS, then I might just out of necessity.  But while that’s only a side project, I think I’ll stick with what I’ve been using longer and am more familiar with.

I think the biggest thing I learned by starting to do development on the Mac is how ingrained some habits are and what I took for granted in my usual environment.  It has helped me to realize what is core to my workflow and what is extras provided by the environment I’m working on.

This post originally appeared on my old Programming Space blog.