Wednesday, July 1, 2009

The Coming of the Quantum Cats, part deux

So, originally I was going to post on every chapter of this book. It was a really quick read (I finished it a couple weeks ago). I've been pondering what to write. I liked the book. I didn't love the book. It jumped around a lot between a couple different viewpoints. Basically, we get to know the same character from a couple different universes. I really liked how different the three versions of the same person were. Depending on the history of their world, they turned out remarkably different.

One of them was a low level mortgage broker, another was a high level scientist and the last was a US Senator. They didn't talk about where each one's history differed to get to the point they were at, but it was interesting to see.

I don't know if I would recommend this book to anyone, but if you want to borrow it I think I still have it.

Saturday, May 30, 2009

The Coming of the Quantum Cats

We have a great little used book store somewhat close to us called Pass the Book. I was able to find a couple books that I have been looking for to fill in my SciFi collection a little bit which is always nice. I was there the other day while waiting for my pizza to get done when I came across this book:



Yes, indeed. "The Coming of the Quantum Cats." How could I possibly resist buying this book? It was $2.00 to start with, and they were having a 25% off sale, so I paid a remarkable $1.50 for this gem. I've decided that I will do a post for each chapter. I will try to not give anything away because I am sure everyone will want to go out and purchase this exceptional literature achievement, but if I do, I'll mark it with "SPOILER ALERT" so you have ample warning. I go into reading this book with the expectation that it will be laughably horrible, but I could be pleasantly surprised and it could be fantasic. I am not holding my breath.

Chapter 1 review to follow shortly.

Wednesday, December 17, 2008

The Nameless One

My wife is into naming cars. Her first car was named Meridith; this is what Meridith looked like:

(Photo courtesy of Ford Motor Company)

That's a 1993 Ford Escort. The color was black. Stick shift. Nice little car. I taught her how to drive it (she hadn't driven stick before) and she was great.

When we got married, we had the Escort and a 1998 Chevy Cavalier that looked like this:


Apparently she didn't like this car very much because she named it Donkey Ass. I assume she was just using two synonymns for the beast of burden. She couldn't possibly mean anything else.

Then, I got into a car wreck in Donkey Ass and it got totaled, so we went and bought a 2004 Jeep Grand Cherokee, which she named The Rugged Gentleman, obviously she liked this car much better.


The Rugged Gentleman
was a great drive. It handled really smoothly and was by far the best car I had ever owned. We decided that the payments were too much for us and that we wanted to get out of debt, so we sold it to my mom (she still drives it now).

With the money we got from the sale of The Rugged Gentleman, we purchased two vehicles.
One, a 2001 Mazda Tribute for my wife to drive; she named it The Lasso.

I don't think we ever took ours anywhere quite this nice looking. Ours didn't have a sun/moon roof either. I liked the Mazda. It had some pep to it, nice engine for a smallish SUV and it fit our needs for car seats at the time. We drove it until the air conditioning started going out (a sure sign of death in Arizona!). We traded it in for our current vehicle, which I will get to in a minute. She named it The Lasso after her brother sent her a picture of his facial hair, which was side burns that wrapped into a lasso on his cheek. As a fan of facial hair, I was intrigued and liked it. I'll try and find the picture to post here.

The other vehicle we purchased was for me to drive; a 2002 Mitsubishi Lancer.


It's a stick (and definitely not as shiny as the one in the photo). I'm using it as a commuter car (~40 miles round trip per day, to and from work). One of the hubcaps is missing and the front left tire has some issue that I need to get looked at again (yes, I had it looked at a month or so ago).

I refuse to name this car. My wife may very well replace "Lancer" with "Judge Reinhold" or "Fritz McGovern" in her mind when we talk about the car. I just don't know. I don't know why I refuse to name my car, perhaps I just don't get attached to vehicles the way she does. I see a car as something to get me from point A to point B. As long as it has A/C (we do live in Arizona after all) I am ok with just about anything (except a New Beetle...don't like those).

Now, on to the car we got when the A/C started going out on The Lasso. It's a 2008 Honda Odyssey.
She named this one Dusty Miller; even my daughter calls it that. I really love this vehicle. It drives VERY well, the features are great (DVD, MP3, headphones for the screen, leather, back-up camera, etc). I even love the color of this car. It drives smooth...smoooooooth. It gets pretty good gas mileage, and fits our car seat space needs at this point. Lots more room for travel too.

I NEVER refer to these vehicles by the name that my has given them. I say "the van," "the Lancer," "the Mazda," "the Cavalier," etc. Again, I don't know what I have against it, perhaps if I were talking to a shrink they might suppose it's because I don't want to become too attached or something, but who knows. Maybe one day, I'll give in and name the Lancer, but I don't think so.

Sunday, December 14, 2008

Senor Cardgage owns Norton Furniture

If you aren't familiar with who Senor Cardgage is, please see the following Homestarrunner Wiki entry

The voice of Mark (you can count on that being his name) reminds me so much of Senor Cardgage.

Friday, November 21, 2008

One Hit Wonders

I often find a song from a band that I really, really like. The problem is, I think to myself, "Gee, if I like this song, I will probably like more of their songs." Most of the time I am sadly disappointed.

Let's look at a few examples:

1. The Redwalls - Summer Romance

Sadly, this is the best video I could find on YouTube...doesn't do the song justice.


I can listen to this song over and over. To me, it sounds like something that The Beatles would have put together. The slow build, rowdy interlude and back to the slow melodic verses. I really, really like this song. So, again, I thought to myself, "I have to check out the rest of their stuff, it's probably just as awesome!" WRONG. I couldn't find another song by them that I liked. Perhaps I didn't give them enough of a shot; perhaps I was asking for too much out of them, and maybe I'll check them out again. I put them on my list of one hit wonders; bands that I can only find one song I like.

2. Avenged Sevenfold - Seize the Day



The first thing I have to mention about this is the part of the video where the guy starts into his guitar solo on top of the coffin. CLASSY. I want someone to do a guitar solo on top of my coffin when I die. That would be awesome. Back to the song.

This song has a certain raw quality to it that I really like. The lead singer's voice is both melodic and raw at the same time. The guitar solo in the middle has a great sound to it and I like the speed change in the middle. Again, I went looking for other songs by Avenged Sevenfold, didn't find a single one that I could even listen to more than one time.

3. M.I.A - Paper Planes


Paper Planes Video

I have a buddy who HATES this song, which might be part of the reason I like it so much. Actually, I really, really like the beat on this song, and I like the usage of the gunshots and cash register as percussive "instruments." The lyrics are pretty much nonsense to me, but they are ok. It's a good song to relax to, as the beat is nice and slow and doesn't require a lot of thought. I listened to some of M.I.A.'s other stuff and thought it was crap, pure and utter crap.


I don't know what it is that catches my fancy on some of these songs, they just inch their way into my head and I dig them. I wish I could find another band that I liked more than 3 or 4 of their songs (I like a majority of the Beatles), but I haven't found a band like that yet.

Tuesday, October 28, 2008

Code looks terrible

Source code looks terrible on here...any tips to making it look nicer?

Update: adding a pre tag around the code makes it at least format somewhat correctly...

C++ is fun again!

Lately at work I've been playing around with C++ and the Boost libraries; specifically I have been using Boost.Any, Boost.Filesystem, Boost.Program_ptions, Boost.Python, and last but not least Boost smart pointers.

These libraries, in conjunction with some of my own macros and setup have made for a very nice transition back to C++ from C#. The awesome things about C# are the class libraries and the syntactic sugar (foreach, lambdas, anonymous methods). Similar things can be done with C++ and Boost (Boost.Foreach, etc).

I'm going to talk about the way I've setup my command line options parsing, to give you an idea as to how I am using Boost.

First off, I have a static class called OptionsParser which looks like this:

class OptionsParser 
{
public:
  static bool isParsed(void);
  static void parseOptions(const std::vector<std::string>& options);
  static void registerOptions(const std::string& owner, const boost::program_options::options_description& options);
  static void printAllOptions(std::ostream& output);
  static const std::vector<std::string> getUnrecognizedOptions(void) const;

  template<class T>
  static T getValue(const std::string& option, T def)
  {
    T result = def;
    if(!isParsed())
      throw std::exception("You must call parseOptions before trying to retrieve values");

    if(_variables_map.count(option))
      result = _variables_map[option].as<T>();

    return result;
  }

  template<class T>
  static T getValue(const std::string& option)
  {
    T result;
    if(!isParsed())
      throw std::exception("You must call parseOptions before trying to retrieve values");

    if(_variables_map.count(option))
      result = _variables_map[option].as<T>();

    return result;
  }

private:
  OptionsParser();

  static boost::program_options::variables_map _variables_map;
  static bool _parsed;
  static std::vector<std::string> _unrecognized;
  static boost::program_options::options_description* _all_options;
};
The real meat of this class are the two methods registerOptions and parseOptions.

registerOptions is used from the constructor of some static class instances I have which setup the options when statics are initialized (before main).

The OptionsProvider class is what I use for this, along with some macros:

class OptionDefinition
{
public:
  OptionDefinition(const std::string& option_string, boost::program_options::value_semantic* value, const std::string& description);

  const std::string& getOptionString(void) const;
  const boost::program_options::value_semantic* getValueSemantic(void) const;
  const std::string& getDescription(void) const;
private:
  std::string _option_string;
  boost::program_options::value_semantic* _value_semantic;
  std::string _description;
};

class OptionsProvider
{
public:
  OptionsProvider(const std::string& owner, const std::string& description, OptionDefinition* options[]);
  virtual ~OptionsProvider(void);

  const std::string& getOwner(void) const;
  const std::string& getDescription(void) const;
  const boost::program_options::options_description& getOptions(void) const;

private:
  std::string _owner;
  std::string _description;
  boost::program_options::options_description _options;
};

#define BEGIN_OPTIONS_ARRAY(owner) static OptionDefinition* Options##owner[] = { 
#define DECLARE_OPTION(option_string, value_type, description) new OptionDefinition((option_string), \
new boost::program_options::typed_value<value_type>(NULL), \
(description)),
#define DECLARE_BOOL_OPTION(option_string, description)   new OptionDefinition((option_string), \
(new boost::program_options::typed_value<bool>(NULL))->default_value(0)->zero_tokens(), \
(description)),      

#define DECLARE_DEFAULT_OPTION(option_string, value_type, def_value, description) new OptionDefinition((option_string), \
(new boost::program_options::typed_value<value_type>(NULL))->default_value(def_value), \
(description)),
#define END_OPTIONS_ARRAY()  NULL };   // add terminator to the end of the list

#define DECLARE_OPTIONS_PROVIDER(owner, description) static OptionsProvider OptionsProvider##owner(#owner, description, Options##owner);

#define OPTIONS_PROVIDER(owner) OptionsProvider##owner
Now, here is an example usage of these macros:

BEGIN_OPTIONS_ARRAY(TestManager)
DECLARE_DEFAULT_OPTION("testid", unsigned long, 0L, "Step ID from automation")
DECLARE_DEFAULT_OPTION("timeout", int, -1, "Number of seconds before stopping a\ntest with a timeout result")
DECLARE_DEFAULT_OPTION("board-path", fs::path, fs::path("boards"), "Path to directory containing board libraries")
DECLARE_DEFAULT_OPTION("test-config", fs::path, fs::path(""), "Path to file containing the test configuration")
DECLARE_DEFAULT_OPTION("manager-path", fs::path, fs::path("managers"), "Path to directory container manager libraries")
DECLARE_DEFAULT_OPTION("output-dir", fs::path, fs::path("output"), "Path to output directory")
END_OPTIONS_ARRAY()

DECLARE_OPTIONS_PROVIDER(TestManager, "TestManager options")
This sets up the array and then creates a static OptionsProvider instance which will register the options with the OptionParser static class. Then I can just call OptionsParser::parseOptions(vector_created_from_argv) and it will parse all the options into the boost::program_options::variables_map.

If I have a plug-in class that is loaded later, I just do something like this after it's options have been registered:

OptionsParser::parseOptions(OptionsParser::getUnrecognizedOptions())
I could probably just have an overload of parseOptions with no parameter and have it automatically use the unrecognized options, but I haven't decided on that yet.

Then in my classes I can do stuff like this to get option values:

_testid = OptionsParser::getValue<int>("test-id");
to retrieve the value. If I used DECLARE_DEFAULT_OPTION, it automatically sets up the default value since the boost library sets that up. If I don't, then I'd probably call the getValue overload that takes a default value.