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.

Monday, July 28, 2008

Unexplainable

I won't prepare you for this photograph except to say: this is one of the greatest photographs ever taken.

Kids

A couple people that I have reconnected with on Facebook have asked for some pictures of my kids. So, since I think my kids are pretty much the cutest (and what self respecting father doesn't?! the only difference in this case is that I am right...buahahahahah!)

 
This is one of my favorite pictures of my daughter. She looks so completely innocent that it makes me smile. Then you add the puppy face makeup on top of it, and there just isn't anything more I can say. She got this face paint do-up at the open house we had when the market didn't suck as much as it does now (it still sucked then too though). We had a couple people come look at the house, but I think this picture might be the highlight for me...oh...and the AWESOME florescent green with gold faux overcoat paint job in our bedroom. I didn't sleep well for several weeks.
 
 
This is the Girl in all her Joy School Graduation glory. She was smiling to humor me I'm sure, as she would have much rather been outside playing with her school mates. She did great during her program, she kept an eye on the boy who was rubbing his eyes the ENTIRE time during singing. Afterwards, she asked "Why was so-and-so rubbing his eyes during all the songs?" I didn't have a good answer, but at least she made sure he was ok and didn't let the singing interrupt her watching him.

 
No, my boy is not staring at the wall. What you can't see is the television that is in the little alcove not 2 feet in front of him (ok, more like three or four). His favorite spot for television is one of two places: as close as he can get physically to the television, or tucked nicely in next to me on the sofa. I prefer that latter.
 
 
Slide-o-Wife made this outfit for my boy from a button up shirt she found at the DI. I've been trying to convince her she should sell them based on the number of comments I've gotten at church from various mothers as to how they wished they had one. I haven't had success yet. The wheelbarrow in the background sat in that position for roughly 8 months after my wonderful wife went out and did some weeding for the first time ever in her life (j/k). I piled more weeds on it about a month after this picture was taken and then finally disposed of it all when half of it blew around the yard during a storm. Sweet.

So, there are my kids. Enjoy.

Sunday, July 20, 2008

Don't Read My Blog

I'm trying some reverse psychology on the lot of you...

Chili con Family

My family has been out of town for nearly a week (Tuesday). When my family is out of town that usually means I stay up REALLY late writing code, browsing the web and general geekery. This time has been completely different. I've stayed up REALLY REALLY late writing code, browsing the web and general geekery.

I miss my family quite a bit. It's the small things that really get to me and make me into a sappy dork (which I don't mind). I miss when my wife wakes up just a little bit when I am leaving and says "I love you" in her sleepy voice, and then falling right back to sleep like it never happened. I miss my daughter wanting to type her name on my computer. I miss my son getting so excited when I get home that he shakes a little bit. My wife is the noticer and rememberer in the family (she can remember outfits she wore when she was three, I have a hard time remembering what I wore yesterday without looking in the dirty clothes hamper), and it's not until I don't have something that I realize how much I notice and how much comfort it brings me.

My wife would insert a comment on how sappy I am...I miss the way she makes fun of me... :-)

This coming week I am committing myself to running again. I used to run 6 miles a day (3 in the morning and 3 at night) and I actually really enjoyed it. It's hard to start back up again after 3 years of not doing it though. I can often find rationalizations for not going out, but once I'm out and hit my stride, I do like it.

The intervals program I did a couple weeks ago was pretty good as well. It is supposed to increase the amount of oxygen your body can process, and increase your speed over all. I liked the results (and the workout I got from it) when I did it and need to get back doing it.