Endianness

We were having endianness issues reading in some binary data in the
Windows version of my project at work… While we were able to use the
network byte-ordering routines (htons(), etc) to swap the
integer values, byteswapping floats were a bit trickier… After beating my
head against the desk for a few hours yesterday, I gave up and went home…
When I got home I read the IEEE Floating Point spec (IEEE 754) until I
understood how they were represented in memory, and this morning I wrote
this code to properly do the swapping:

double fswap( float f ) {
union {        
float f;        
unsigned char b[4];
} u1, u2;

u1.f = f;

u2.b[0] = u1.b[3];
u2.b[1] = u1.b[2];    
u2.b[2] = u1.b[1];    
u2.b[3] = u1.b[0];

return u2.f;
}

When I first learned C a gojillion years ago I thought to myself “What
the hell could you possibly use a union for?” Guess I found
the answer… :)

You’d have to change it up a bit to swap a double… Here’s a stab at an
implementation for doubles, although I haven’t tested it:

double dswap( double d ) {    
union {
double d;
unsigned char b[8];
} u1, u2;

u1.d = d;

u2.b[0] = u1.b[7];
u2.b[1] = u1.b[6];
u2.b[2] = u1.b[5];
u2.b[3] = u1.b[4];
u2.b[4] = u1.b[3];
u2.b[5] = u1.b[2];
u2.b[6] = u1.b[1];
u2.b[7] = u1.b[0];

return u2.d;
}

Thought y’all might find it interesting, and it might be good to add to your
toolchest in case you ever run into this same problem.

Soft Restart

Had a dentist appointment this morning at 9:45pm, which provided me an excuse to sleep in a bit, which definitely aided in my sleep schedule adjustment.. Had the crown prepped and the mold taken, and will have to go back in a few weeks (after my trip to CA) to have it installed. Got into work around noon, went straight to lunch, and have been playing catch-up for the rest of the day. Looks like I will be working on a new project soon, which sounds pretty interesting…

This weekend I just lazed around, although I did come up with caching versions of my CD List and DVD List. The old versions would hit the database server every time, these new versions check the table modified time first and rebuilds the cached version if necessary. This wasn’t a huge deal at CSH, but it was at sean-graham.com, since it was hitting up the CSH database, which was slow over the net. Those pages now load much faster, unless you are the unlucky soul who hits it when the cache is stale… :)

Happy New Year!

Had a great time yesterday, after a bit of a rough start…  Before landed in Boston I needed to get to the store to do some preparations for the party we were throwing…  I headed down to the Alewife area to hit up TRU to get a copy of Outburst that Corinna wanted.  There is a Hippie Mart over there, so I figured I would get my grocery shopping done as well.  Well, it took me like 20 minutes of searching the store to FIND the game, then another 20 minutes to check out.  I made my way through the parking lot over to the supermarket, but there were so many people in the lot that THIS took 20 minutes before I gave up, not having enough time to shop before I had to be at the Airport.

Corinna landed safely, and I was there in time…  We got back to the apartment, after stopping at the River St. Hippie Mart,  and pretty much instantly set about preparing for the party…  I also received my awesome hand-made slippers from Corinna’s Stepsister, ..  Holy crap are they comfortable…  I have to shrink them a bit to fit right, which will require some laundromat maneuvers, but it shouldn’t be that bad even for a laundry gimp like myself.  Everyone started showing up around 7:30pm last night, , , Michelle, Audra, and all came over, and stayed well into the night (Audra spent the night).  We made way too large of a commitment to food and drink preparations, but it wasn’t too bad.  There are lots of leftovers, but they hopefully won’t be leftover for long.  We celebrated the arrival of the new year on the roof of the building, watching the Boston Harbor fireworks in the distance…  The view up there is truly beautiful (if you like cityscapes, that is.. :P).

Woke up pretty late this morning, around noon, but I wasn’t even tired when I tried to sleep at 3am last night, so it took a long while to fall asleep.  I did all the dishes this morning, which was surprisingly not as shitty as I had expected…  Now Corinna and I are going to settle in and watch our first movie of the new year, The Last Samurai, which I’m not expecting to be great, but want to see anyway.

The Movies I saw in 2004

Here’s a list of the movies I saw this year…  If you compare it to last year’s list, you’ll notice that I saw a few more films in the theatre this year, more than one a week on average (which isn’t surprising since I head up the Boston Sunday Night Film Club).  You might also notice that I saw fewer films on video this year…  I guess that’s what getting a job’ll do to ya…  Damn employment! :)

This year’s list should be far more accurate than last year’s, since I kept track of the movies as I watched them, as opposed to trying to reconstruct the list from memory and Netflix history like I did last year.  I might have missed a few, but overall it is pretty comprehensive.  I even decided just now to link each of the films to their IMDB page (some are linked to Amazon because IMDB has no listing), so if you are wondering what a particular film was all about, you don’t have to hunt the info down.

Obviously, if I watch a film in the next 11.5 hours I will add it to the list, but I don’t expect to…  Then again, given that on average I’ve watched a movie almost every other day, you never know… :)

Continue reading “The Movies I saw in 2004”

My General Theory of Christmas Decorations

I have been observing trends in Christmas decorations for some time now, and I think I have developed a generalized theory to describe their trends.. There are four phases to the Christmas decoration product lifecycle, and the first three phases typically last one holiday season. They are as follows:

  1. Bleeding Edge – One or two people in your area have the decoration. These people are almost like the beta testers for the product… More accurately, they are like Patient 0 for the meme.
  2. Cutting Edge – A handful of people, perhaps 5% of your local population, have discovered this decoration and have purchased it and put it on display. What’s interesting about this phase is that if the product has made it to this phase, it will continue on through the subsequent phases. While a product might die on the vine at the first phase, once it’s “cool” enough for this handful of people to adopt it, it will achieve traction with the rest of the decorating community.
  3. Fad – A huge percentage of the decorating population has bought several of these decorations.. Things are completely out of hand, and headed for disaster. (i.e. 2004’s “Inflatable Decoration” craze)
  4. Passé – This is the endgame… The only people who continue using this decoration in their display are those who don’t realize how lame it has become. Sometimes this period is very brief, and only a few people try to perpetuate this decoration (i.e. the christmas lights with complicated, seizure-inducing blink patterns), but this period can also be drawn out and involve a reasonable swath of the population (i.e. “Icicle Lights” in 2004).

Now, applying this theory to the present, and I have made some predictions… We are comfortable saying that this year’s “Bleeding Edge” decoration is Orb Lights (strings of baseball sized orbs, similar to the Ambient Orbs, which either are a constant color or slowly cycle through many colors). We are also comfortable predicting that one of this years “Cutting Edge” decorations are animated light displays (featuring a set of lights that turn on or off to create a few “frames” of a jerky animated scene…).

It is important to note that I expect it to be possible, on the rare occasion, that a decoration mired in the “Passé” could circle back around to “Bleeding Edge” if it had become obscure enough and “rediscovered”. In fact, I suspect that the “Animated Light Display” has been around the block before. It is also important to point out that distinguishing between Bleeding and Cutting edge can be difficult at times, so it is possible that both the orbs and animated displays are still in their infancy..

Master Spelunker

Sorry, , this bout of spelunking wasn’t in the back yard, but instead in the basement.. asked me to bring back my stereo so we could have one in the bedroom, so I had to dig down through the strata of stuff to get to it… I took this opportunity to consolidate some of the boxes and retrieve some books I’ve been meaning to bring to work. It was a real pain in the ass, but it gave me the opportunity to get rid of some crap that I should have gotten rid of a long time ago (like a bunch of VHS tapes and the old 486 laptop that I haven’t used since the days of BeOS [as a debugging serial console]).

is out grabbing lunch from the bagel shop and bringing some back for me.. Her little doggie Oscar was freaking out for a bit but he seems to have mellowed… The little pansy is a total momma’s boy and can’t stand to be away from her.