Tuesday, August 30, 2011

C++ is hard.


map<int,int> a;
... put stuff in a ...
int loc=foo(some,data);
for(int i=0; i<a[loc]; ++i)
{
  ...do some stuff.. 
} 
for(map<int,int>::iterator it=a.begin(); it!=a.end(); ++it)
{
  ... do some other stuff ...
}

The above code has at least one(!) big potential bug in it:

If the value of loc is not one of the values already stored in a, then the map will create an entry automatically using the default constructor for the value type (a zero in the case of integers). This is potentially disastrous for the loop that iterates over the map. It's also annoying to try to find when debugging!

A safer method would be to use map::find to return an iterator to the element you want or map::end if it doesn't exist. So much for syntactic sugar! A straight replacement for the code is too ugly for my taste, but I found a reasonable workaround using std::copy.

Monday, August 29, 2011

Use Makes Master

Awhile back, I learned to tie my shoes correctly. It turns out that I'd been doing it wrong all these years.

The basic shoe bow is, in some ways, 3/4ths of a Granny Knot or a Square Knot, depending on how you tie it. If you pull the loose ends of each side of the bow all the way through the knot, you get one or the other depending on how you started. A Granny Knot is a considerably poorer knot that the Square and can work itself apart much more easily leading to untied shoes. Double knotting can help, but if you've been tying Granny Bows the whole time, doubling the knot can compound your problem.

While buying a pair of shoes recently, I was told: "UR DOIN' IT WRONG!"

Since then, I've been slowly trying to retrain myself to time my shoes properly. This is harder than it seems. Three decades of shoe tying are hard to overcome.

Wednesday, July 13, 2011

Waffle House Density

People per Waffle House.

I ate at the Waffle House outside of Columbus for breakfast the first morning. It was my first WH experience. The food was fine, but the thing I noticed was that the combined weight of the 10 or so employees was near on a ton and a half. Most of the customers were thinner. It was kind of disgusting.

I tried the Denny's in Texarkana the next morning, but besides the rail thin short-order cook, the situation was not much improved. There's a saying about not trusting skinny chefs, but I did OK. I presume that Denny's has made a science of short-order cookery.

Sunday, July 10, 2011

Day 3 Roundup

Unicorn successfully brought all the way home. In the end, no virgins were sacrificed. Texarkana to Austin: ~7 hours with a stop at Czech Stop in West, TX. The countryside while considerably more familiar is much less interesting. Though the bridges over Lake Ray Hubbard were a nice surprise. I didn't think there was any surface water left in Texas.

I'm also happy to report that my road bike fits in the back with plenty of room to spare. I was a bit worried that after all of this, that I'd still be taking the front wheel off at the very least. There's probably room for 2 with strategic stacking/packing.

Now I need to get the Texas state inspection, proper insurance, and the front license plate hung. It has Pennsylvania inspection now, but a) the lousy sticker is peeling off from the heat, and b) I have 3 days to get it done, anyway. Insurance on the Subaru covers 5 days from pick up, so I've got two days left on that. I have the front license bracket and screws, but I'm not going to drill the front bumper myself. So, tomorrow morning, I'll head over to State Farm and to the local Toyota dealer. Hopefully the latter will want my business.

Day 2 Roundup

Apparently, if your seat is comfortable enough, you can sit in it for 13 hours with only a few breaks. I crossed 5 states (barely) yesterday: Ohio, Kentucky, Tennessee, Arkansas, and Texas. I made it a few hundred yards into my home state before stopping for the night. There's a La Quinta just across the border on State Line Rd. Not as nice as the Hampton Inn from last night, but it was half as much. I'll move a substantial fraction of the way back to Arkansas just by going to breakfast. I'll try not to cross back over.

Unfortunately, doing this much driving means I didn't do much stopping, and that I did precisely no sightseeing, which is too bad. I drove through some beautiful and unfamiliar country yesterday. All of it green and lush and full of life. Much of the time was spent alternating between narrow, green-walled canyons of beautiful tall trees allowed to grow close to the highway and broad lush fields of corn and soy and some horses munching on Kentucky Bluegrass. Someday it will be worth doing this drive again but stretching it out so that we can stop and see some sights.

Today is the easy part: 7 hours, Texarkana to Austin, through mostly familiar country. The colors will shift rapidly to brown and yellow as I enter the droughtier part of the state. The long familiar East Texas hills and pine forests will temporarily replace the broad, flat flood plains of Arkansas, but soon I'll return to the central plains of Texas.

I promised pictures, but I've not taken any. Maybe next time.

Saturday, July 9, 2011

Day 1 Roundup

From the Pitrsburgh airport I had a nice, if not long, cab ride to the UHaul place with Kevin. It was in his hood, and he knew almost exactly where it was. Driving a 14' moving van as a one-way rental felt a little ridiculous to me, but having confirmed that none of the rental car companies were interested in helping me out, I got over myself.

Pennsylvania 28 was a nice country road. It followed the Alleghney River for the first hour or so--nice semi-mountainous road through some beautiful forest and pasture land.

I drove out of the rain somewhere around New Bethlehem and had great weather from there on out.

Ron and Pete and I had a good laugh about my mode of transport, and then we got down to business. We returned the UHaul, put the plates on, and turned me loose. I'd really like to thank Ron for coming in on his day off.

The DuBois Diner had a great burger and fries, and it looked exactly like you're imagining it. Down to the counter and the waitress saying "Hon'".

The drive from DuBois, PA to Columbus, OH was pretty and perfect the whole way. I don't think I'd like the winters much, but the Ohio countryside is as beautiful and pastoral and you can imagine. Every half mile was like a scene from John Scalzi's Flickr stream.

In any event, it's time to check out, and head across the highway for breakfast at the Waffle House. The Highlander is basically perfect and awesome. I'm making better than 30 mpg out here on the highway, which is more than I expected. It's so full of gadgets I've been squeeing a little. It's not all economy driving, though, it's got power and a nice exhaust note when you need it. I've got a few niggles with the nav system, but I'm sure some more poking around will help me sort those out. I keep finding stuff I didn't know I'd bought!

Today: Nashville, or maybe Little Rock. I'll try to update today from my lunch stop--maybe with some pictures.

Wet.

Friday morning.

Spilled OJ in lap.

Neighbor spilled water on floor.

Raining in Pittsburgh.