Saturday, August 14, 2010

Visual C++ and Googletest

This post will probably only be of interest to Chip, but I'm writing it anyway.

  • First step was to download my software packages. I got visual C++ 2010 from http://www.microsoft.com/express/Windows/. Then I got the version 1.5 zip of Googletest from http://code.google.com/p/googletest/downloads/list.
  • Visual C++ installed without a hitch, although there is a mandatory reboot required by the install. Googletest doesn't even require an install, you just unzip the package and stick it somewhere.
  • Looking for a pattern to follow, I found http://www.freshclickmedia.com/blog/2009/10/getting-started-with-googletest-the-google-c-testing-framework/. This is a short video, and being a video is both it's greatest strength and weakness. If you use it, you'll probably be rewinding a lot and cursing the inability to cut and paste. However, watching someone clicking on the interface is very useful. This really covers everything you need to get up and running, but you have to play close attention. I cost myself some time searching for files that were pointed out in the video by not rewinding far enough.
  • The fist step is to compile the vcpp version of Googletest. The google example was probably built as a vcpp 2008 project because my version told me I needed to convert the project. At first the conversion failed because the project was read-only. I figured that I had the original zip, so it wouldn't hurt to make these files read/write. After I did this the project built without any issues.
  • There are two "gotchas" I missed the first time through. The first is the runtime library. Multi-threaded debug and multi-threaded debug dll are not the same thing. There is a warning about linker errors if you get these wrong, but the warning in the video isn't really stern enough. The other is that the 2 libraries built when you compile Googletest ~\msvc\gtest\Debug where ~ is wherever you unzipped Googletest. This is the part where I didn't rewind far enough and had to hunt for these files.
  • I started a new console project. You need to add the two libraries, gtest_maind and gtestd to Configuration Properties | Linker | Input.
  • Next, under Configuration Properties | c/c++ | General, add the ~\googletest\include to Addition Include Directories.
  • Time for the second issue I ran into, I didn't set Configuration Properties | c/c++ | Code Generation to Multi-threaded Debug (/MTd). The default is Multi-threaded Debug DLL (/MDd) which is very similar looking, but not quite the same.
  • I've seen a few ways to include the tests. The one that seems the most intuitive to me is to set up a header file which declares a test class and has the constructor, destructor, SetUp, and TearDown methods. This creates a class which can be used as a test suite. The easiest way to get started is to paste in some boiler plate code from http://code.google.com/p/googletest/wiki/GoogleTestPrimer.
  • The actual tests go into a cpp file with the same name as the header. Here is a simple test set up by the TEST_F Macro: TEST_F (SimpleTest,DemoTest1) { ASSERT_EQ(1,1); }
  • Two lines of code go into the main function to cause the tests to run:
  • ::testing::InitGoogleTest(&argc, argv);
  • return RUN_ALL_TESTS();
  • One thing I like about this is that you just tell it to run all tests, you don't have to list each test suite you created. For my simple, just get it running, project, this doesn't matter, but for a large project, automatic inclusion seems like a very nice feature.
  • My first try was a complete loss because of the run time library mistake I made. My second try, I realized my mistake and I got to see the test results pop up at the end of my run.

Monday, August 9, 2010

Books I've Decided I Need to Read

After going through several lists of top 100 books, I decided that there are some things I need to read that I haven't. In no particular order.

  • Atlas Shrugged - Ayn Rand When I told someone at work about my lists, he had only two. This was one of them. I do remember from high school that the person who read this when we each picked a different book from a list enjoyed it.
  • Illusions - Richard Bach This was the other book that the guy from work would have put on his list. Atlas Shrugged would have probably ended up on my list without his recommendation; this would not have. (In fact, I wouldn't have even known about it.)
  • To Kill a Mockingbird - Harper Lee My English class never read this, but the people in the classes that did liked it. On the theory that high school students don't like anything I need to read this.
  • Catch-22 - Joseph Heller This book has spawned an English phrase and I think I'd like it for the irony contained within it.
  • The Catcher in the Rye - J. D. Salinger See the comments for To Kill a Mockingbird
  • Slaughterhouse Five - Kurt Vonnegut I thought I had read a Vonnegut short story or two, but when I checked on the Internet, the story I was thinking of was by a different author.
  • The Godfather - Mario Puzo My dad doesn't read many books, but my mom said he stayed up all night reading this one.
  • The Maltese Falcon - Dashiell Hammett I keep coming across the phrase "hard boiled" when I look for reasons to read this.
  • Kidnapped - Robert Lewis Stephenson I bought this thinking it would be good to read a classic. I need to make myself read it and decide if I was correct.
  • The Canterbury Tales - Geoffrey Chaucer I got this one from a pile that was otherwise headed to Half Price Books. This has some of the appeal of The Odyssey (although not nearly as old) in that people are still reading it many centuries after it was written.
  • Le Morte de Arthur - Sir Thomas Malory I've read several versions of Arthurian legends, but I'm fairly certain that I haven't read this collection.
  • Adventures of Huckleberry Finn - Mark Twain This is mainly on the list because I feel the need to include a uniquely American writer.
In addition to books I have never read, I decided I need to re-read Hitchhiker's Guide to the Galaxy and A Wrinkle in Time while composing my book lists.



Saturday, August 7, 2010

Books (I Think) Everyone Should Read Part II

Last time I published the books that didn't fit onto my should read list for one reason or another. This list is the 10 books I would say everyone should read.

  • Frankenstein - Mary Shelley This book is embedded in our culture mainly through movies. You could argue that Dracula is as well, but I think this book has more universal appeal with the theme of there are some things man was just not meant to know.
  • Gulliver's Travels - Jonathan Swift Gulliver's first journey to the land of the Lilliput gave us a word, Lilliputian. If giving us a word and providing iconic images of a man tied down by thousands of strings isn't enough, the satire in all four is still valid today. We've still got countries going to war over things just as foolish as which end of the egg to open. Also, it was someone who was not at all familiar with this book that got me thinking about a must read list.
  • The Oddessy of Homer The fact that people are still reading this after over 2000 years speaks for itself. I think this is the more readable of the first part of the story, the Illiad. You couldn't go wrong reading any of the major classic epics, but I think this one is a must read.
  • A Wrinkle in Time - Madeleine L'Engle How can you not put a book on the list which starts with: "It was a dark and stormy night." Many books have stories about a secret struggle between good and evil, The Dark Is Rising comes to mind, but I think that this is a particularly well written one. It was also the first book I ever read that used a four dimensional construct known as a tesseract . Traveling through one is the namesake wrinkle.
  • A Wizard of Earthsea - Ursula K. Le Guin Long before J. K. Rowling had ever gone into the coffee shop to write about Harry Potter, Le Guin wrote this book to answer the question: Where do wizards come from. When I was in second grade, this book was featured in a Reading Rainbow type show. Several of the boys in the class with me had been excited by the excerpt of the book which featured the Wizard's battle with a family of hatching dragons. We worked out a plan to get a copy of the book and the order in which we would read it. As far as I know, I'm the only one who ever got a hold of the book and read it. Rereading the book as an adult, I realized I that I had absorbed much of the philosophy of the book without even realizing it.
  • Dune - Frank Herbert I've lost track of the number of times I've read this book. There are so many ideas contained in it. Politics, religion, planning, revenge, loyalty, hero worship, human thought vs. thinking machines, ecology. Forget the David Lynch movie, this is one of the finest books ever written.
  • Hitchhiker's Guide to the Galaxy - Douglas Adams Usually I don't want too much humor in my novels, but this is an exception. In what other book can you learn the answer to Life, the Universe, and Everything?
  • Brave New World - Aldous Huxley In some ways, I feel like we're living in the dystopian world predicted by this novel. It's amazing that it was written in the 1930's, it feels like a book that could have been written today.
  • Lord of the Rings - J. R. R. Tolkein I know this is a trilogy, but that's because the publisher wouldn't put it out as a single volume. There is probably a big section at your favorite bookstore that wouldn't exist if Tolkein hadn't written this tale of middle earth. While it is a work of fiction, the world of Middle Earth is so well thought out, it reads like a history of another world. While inventing languages for the people of world to speak isn't a prerequisite for great literature, it does add something to this story.
  • Alice in Wonderland - Lewis Carroll This is another story with imagery embedded into the culture. The rabbit in a waist coat, the Cheshire cat, and little bits of food and drink with the labels eat me and drink me should be familiar to everyone.
One thing that struck me after I had assembled this list is how many of the must reads I've picked are often put in the young readers section of a bookstore.

Wednesday, August 4, 2010

Books (I Think) Everyone Should Read Part I

I'm going to start of with books that didn't make the list. I was going to create a top 10 list, and promptly put 20 items on it. I'm not even going to start on books that I think are excellent, but lack some feature of universal appeal.

So, in short, while you should read these, I've got another list of books that I think are more deserving of being read.

  • Ender's Game - Orson Scott Card If two alien races meet but cannot communicate, is one fated to exterminate the other? To what limits can you go to defend your entire species? This would probably be the first novel to move up to the main list if I expanded to 11, but I think this lacks just a touch of universal appeal.
  • Aesop's Fables - Not on the list because it's not a novel, but everyone should be able to come up several fables off the top of their head. "Grasp at the shadow and loose the substance", "Try to please everyone and you'll end up pleasing no one", "sour grapes", "slow and steady wins the race"
  • Grimm's Fairy Tales - See above, everyone should be able to come up with several Fairy Tales off the top of their head too.
  • 1001 Nights - Again, not a novel and not as familiar to Western culture as the first two, but still full of stories people are familiar with.
  • Neuromancer - William Gibson A novel about crime, drug abuse, artificial intelligence, and great wealth. Apart from that, it essentially launched an entire sub-genre of fiction, cyberpunk. It's amazing to think that this book was written before the 90's internet boom.
  • Diamond Age - Neal Stephenson If Neuromancer is a book about the age of computers, this is a book about the age of nanotechnology. In this novel, diamond is literally cheaper than glass. Carbon atoms are lined up in the proper pattern by a fabricator to make diamond, but glass requires someone heating up sand in a fire. This novel raises questions of society, culture, education, and what it means to be a parent.
  • Little House on the Prairie - There is so much science fiction on my list, I thought for a long time on something to balance it. I think this is a good choice. Everyone probably knows the title of the book from the Michael Landon TV Show, and it's an interesting slice of life from 140 years ago.
  • Starship Troopers - Robert A. Heinlein First, forget everything and anything you might know about the Paul Verhoeven movie. In some ways, this is not on the main list because it is more political manifesto than space opera, and in other ways because the solution to organizing a society can't be as easy as Heinlein makes it out to be. However, reading this book will make you think.
  • Do Androids Dream of Electric Sheep - Philip K. Dick First of all, this is the book that inspired the movie Bladerunner. Second, it's the only book on my list that thinks about the question of how our relationship (after we've nuked the vast majority of them to extinction) with animals separates humans from androids, unless of course, the android hunting Deckard, who is very fond of his electric sheep, is an android himself.
  • The Omnivore's Dilemma - Michael Pollan - This non fiction, but you'll never look at a chicken nugget or think about a feed lot or a corn farm the same as you did before reading this book.

Wednesday, June 23, 2010

Moody Blues Concert

I went to see this at the outdoor stadium at the riverboat casino in Southern Indiana. It was a little bit warm and bright at the start of the night, but the sun set shortly after we arrived and the night was really comfortable.

It looked like some people in the audience were trying to relive Woodstock, but I had fun. It was the 4th time I had seen them play live. Here's a review of the concert I found online.

http://www.louisville.com/content/moody-blues-leave-no-doubt-they-are-singers-rock-and-roll-band-music

Saturday, June 12, 2010

Chess, Africa & a Wedding

I played in the KY Open chess tournament last weekend. I ate some good food downtown, Bearno's by the bridge, Z's Fusion, and Cunningham's. Laura's husband Dallas was working at Z's when I stopped in. That was the best meal of the weekend. I got a chicken stir-fry, but the vegetables tasted like they had been grilled first. The fish sandwich at Cunningham's for lunch Sunday was quite tasty as well.

The chess on the other hand was not good. The two games I won I should have lost, but held on and fought back. I lost the best game I played, then in the final round, I accidentally picked up my d pawn instead of my c pawn on the 2nd move of the game. It didn't cost me the game, but I wasn't playing the variation I wanted to play. In the end, I won 2 games out of 5 and beat the people ranked lower than me and lost to the ones ranked higher.

My cousin David went to Senegal and my friend Chip is headed to Kenya. Chip is probably about halfway through the 29 hour trip to Kenya. They're going to be on opposite sides of the continent, but it's unusual to have two people I know in Africa at the same time.

Finally, my cousin Kim got married last night. St. Brigid really isn't far from my old house on Oak St. The reception was at the Olmstead. The reception was very nice and I got to see a lot of family that I hadn't seen in a while. Also, I got to see Jessica's daughter Tess for the first time. As Emily's husband Brian said, if Max could get through the reception without busting his head open and if I could avoid a stomach flu the next day, it would be a successful reception. After Laura's (Kim's older sister) reception I picked up a stomach flu that had torn through the Clarks during the week leading up to Laura's wedding. That was one of the worst 12 hours of my life.

Saturday, May 15, 2010

Lisbon Day 3

10-22-2009
We went back to the hotel after breakfast, but we didn't get as lucky with the TV as we had the day before. We got a Simply Red top 10 video countdown, only in Europe. Then we got the same geezers behaving badly show. We ended up watching the news and saw how some robber had prayed with the woman he was robbing before he turned himself in. We stayed in the hotel because we were going to need to check out and didn't have any really concrete plans for the day. We left our luggage at the hotel, but they really didn't have a luggage room. We were a little nervous about leaving it just sitting under the stairwell by the check-in desk, but we couldn't very well lug it all over town. We stopped by the Internet cafe after checking out, then headed into Lisbon for our last day here.

We walked back to the main square, and there was some sort of soccer festival going on there. The main portion of the square was packed, and there were team and national tents and booths set up. One of the British teams was doing some sort of chant, and it looked like the police broke up a minor scuffle elsewhere in the plaza. We walked to see some of the public monuments, which took us through the heard of the modern business district. After we ate lunch, we found an English language bookstore. It wasn't what I had expected, but perhaps it should have been. It really catered to the students reading English language books for classes. I found two books that I bought. One was a dictionary of mythology and the other was the start of a Robbin Hobb series I hadn't picked up yet.

From there, we took a shortcut to the botanical garden and the Lisbon Basilica. After getting thoroughly lost on our first outing, taking a shortcut from the bookstore to our next destination was something of a triumph. I know a basilica is the highest designation for a Catholic church, but after some of the churches we saw this trip, this seemed modest by comparison.

We used one of our last two metro rides to get back to Intendente station. Michele had trouble with getting her ticket to be recognized as valid. We went to information, and they showed it had the two rides we thought it should have. One of the metro workers had to fiddle with her card to get it to scan. I had put my card in the back cover of one of my books, so I was able to enter and exit the metro just by setting my book atop the scanner. I almost looked like a native navigating the metro. Another metro worker had to fiddle with Michele's card again, but this time I saw how they bent the card to get it recognized.

The station turned out to have one last surprise for us. There were, we though, two ways to exit the metro, and it seemed to me like we usually picked the one further from the hotel no mater what we tried. It turned out that there was yet a third exit that we hadn't even noticed before on our trips to and from the hotel. I picked up a Lisbon shot glass and a little writing pad and pen so I could write down some notes on the trip during the flight home.

We snacked at the cafe to rest after a long day of walking around town. It had taken half an hour to take the metro back to Intendente from where we had ended up in the city. We got sweets and soup for our final meal in Portugal. We had plenty of time to kill at the bus station, but we had gotten tired of sitting in the cafe. By getting there early, we had an unusual experience at the bus station. A guy said something in Portuguese to us, and when I said English he ended up asking for money in English, which turned out to be quite good. He said he was homeless and wanted to get a sandwich. I pulled out a single 50 cent piece first, and I didn't think that was really enough money to be helpful. I reached in again and came out with a 2 euro piece. That was more than I had planned on giving him, but at that point I thought it would be rude to put it back in my pocket. He was genuinely surprised and said, "Wow! Thank you." I'd have just bought a half liter of coke with it from an airport vending machine, so it probably did him more good than me.

The overnight bus ride back to Madrid was a strange one. When we crossed the border, Spanish police boarded the bus and checked every one's documents. They pulled three people off the bus, but one got back on. Michele thought she understood enough Spanish to gather that two of the people were from Africa, but had no documents. When one of the police told one of them that he couldn't go to Madrid, he responded that he would go to Barcelona instead. The police laughed and said something like, "Madrid, Barcelona, it doesn't matter. You can't stay in Spain at all."

Then at the first stop for a meal, two girls who looked like they were Japanese tried to get back on the bus shortly after we stopped and the bus driver got really mad at them. I was a little bit afraid that the bus driver would leave people behind from the stop. They sat with us for a little while and we talked a bit in English. We couldn't figure out what they had done to make the bus driver so mad. Despite the strange events of this bus ride, we were back in Madrid that morning. Michele and I split up on the Metro. I headed to the airport and she headed back to the hotel at the Plaza Mayor.

It was a really good trip, but there are three things I would have done differently.
  • I would have paid more attention to the little warning light on the camera for blurry pictures. Seeing some of the blurry pictures next to ones that came out crystal clear made me sad.
  • I would have waited to get more cash until we were in Villanueva. We had plenty of cash for the trip and I'd still have my backpack if I'd have done that.
  • I'd have flown out of Lisbon. Flying into Barcelona would have made it difficult to meet up with Caroline, but the amount of time we spent on buses would make me plan a second trip to Europe differently.