Sunday, July 24, 2011

The Great Lakes Science Center in Cleveland, Ohio

The Great Lakes Science Center is a fantastic place for curious kids and adults. It has a lot of exhibits, is easy to get to, and seems to keep the kiddos entertained indefinitely.

The only drawback may be that some of the exhibits are difficult to grasp for very young children. My 3.75 year old, Thing1, has only recently developed the patience needed to notice what’s happening enough to be in awe. This isn’t to say that the venue doesn’t work for younger kids. In fact, Thing2 (two years old), has a great time, too. The difference is that she spends most of her time running from booth to booth mashing buttons like she just doubled down on a bet to be settled by Mortal Kombat and doesn’t know any combos. She has a great time, but if you’re not ready for it, you’ll be frustrated that you can’t experience any of the science yourself. Having been a few times before, this isn’t an issue for Wife or me anymore.

They also have a fantastic play area that any kid under about seven or eight would love (any older than that and you’ll probably enjoy the actual science stuff more). We save it for the end so we can use it as a bribe, and take a break while the kids literally run themselves out of steam. Most of my pictures are from this area.

Getting ready (wife made amazing banana chocolate chip pancakes while I slept!):

science-center science-center-3

NOM NOM NOM

science-center-1 science-center-2

With full bellies, we made it to the Science Center after stopping to calm the troops just once.

science-center-5 science-center-4

(Pro tip: take a decent cell phone pic of your kids when you get to a busy place. This way, if they get lost you have a handy picture of exactly what they look like and what they’re wearing. If it’s on a cell phone, you can share it quickly if needed, too. And, if you don’t need it, you at least have a couple cute pics.)

science-center-6 science-center-7 science-center-8

Bernoulli’s Principle:

(Note: video cuts out as Thing1 begins to climb the exhibit in pursuit of the beach ball.)

They had a neat display on DNA sequencing, including a board asking people what they thought about it:

science-center-18

science-center-22 science-center-19 science-center-21

And this one that triggered a memory of a hilarious comic:

science-center-20

Maya filled out her own sheet:

science-center-25 science-center-26

I bet her feelings are shared by many.

Before we left that exhibit, Wife got a chance to school us in DNA building:

science-center-17 science-center-16

Then we did something new: took a tour of the steamship William G. Mather. Unfortunately, I have very few pictures of it. Suffice it to say, it’s utterly massive. Here’s a pic from Wikipedia that really doesn’t do it justice:

mather

science-center-30 science-center-28science-center-29 science-center-27

Thing1 tailing Thing2 in a flight simulator: “I’m on your six!”

science-center-14

“Uh oh!”

science-center-11

“I got this one, Goose.”

science-center-12

“Engage.”

science-center-13

And finally, the ball pit.

science-center-9

The pit has this cool bucket that the kids fill through various means. At any time, someone can pull a chain to dump it.

science-center-10

And they often do.

If you’re looking for a fun afternoon, check it out.

Tuesday, July 19, 2011

Reseeding *All* Identity Values in a Database

(This post was written against SQL Server 2000. The concepts apply to more recent versions, but the batch script may not work on them.)

If you work intimately with databases for very long, you might run into an issue where you can’t insert a record because of some weird duplicate primary key error:

Msg 2627, Level 14, State 1, Line whatever
Violation of PRIMARY KEY constraint 'PK'. Cannot insert duplicate key in object '<table>'.

The statement has been terminated.

“That’s strange,” you’ll say, because it’s failing on an identity column, which is supposed to auto-increment. Here’s a test case that demonstrates this behavior, and the fix:

CREATE TABLE IdentityTest (ID INT IDENTITY PRIMARY KEY)

-- insert auto-incrementing values
INSERT IdentityTest DEFAULT VALUES -- 1
INSERT IdentityTest DEFAULT VALUES -- 2
INSERT IdentityTest DEFAULT VALUES -- 3

SELECT * FROM IdentityTest -- 1, 2, 3

-- reseed the identity column
DBCC CHECKIDENT (IdentityTest, RESEED, -3)

-- insert more auto-incrementing values (note, things *work*...for a while)
INSERT IdentityTest DEFAULT VALUES -- -2
INSERT IdentityTest DEFAULT VALUES -- -1
INSERT IdentityTest DEFAULT VALUES -- 0
INSERT IdentityTest DEFAULT VALUES -- BOOM

DBCC CHECKIDENT (IdentityTest, RESEED) -- fix!
INSERT IdentityTest DEFAULT VALUES -- phew!

SELECT * FROM IdentityTest -- 1, 2, 3, -2, -1, 0, 4

DROP TABLE IdentityTest

The easiest way to fix this is to reset (“reseed”) the table’s identity value:

DBCC CHECKIDENT (IdentityTest, RESEED) -- fix!

This script, pulled from RedGate’s forums (an awesome company, by the way), resets those identity values for every table in the database:

-- courtesy of RedGate forums http://bit.ly/plJNx2
DECLARE @table NVARCHAR(4000), @column NVARCHAR(4000)

DECLARE row CURSOR FOR
  SELECT 
    a.name TableName, 
    b.name IdentityColumn
  FROM sysobjects a
  JOIN syscolumns b
  ON a.id = b.id
  WHERE COLUMNPROPERTY(a.id, b.name, 'isIdentity') = 1
    AND OBJECTPROPERTY(a.id, 'isTable') = 1
    AND a.xtype='U'
  ORDER BY a.name
OPEN row

WHILE 1=1
BEGIN
  FETCH NEXT FROM row INTO @table, @column
  IF @@FETCH_STATUS = -1
     BREAK
  
  PRINT @table
  EXEC sp_executesql N'DBCC CHECKIDENT (@table, RESEED)', N'@table varchar(4000)', @table = @table   
  PRINT ''
END

CLOSE row
DEALLOCATE row

This is handy to have in the toolbox when a data sync screws up a bunch of tables. In fact, that’s the primary reason I’m posting it here—so I can refer back to it in the future as needed.

Monday, July 18, 2011

Statistics are Misleading At Best, Filthy Liars at Second Best

Back in April, I somehow came across this site blaming President Obama for raging gas prices:

obamagasprices

The implication is that since the moment Obama took office, gas prices have gone crazy. My god!

Wait wait wait…why the steep decline at the end of 2008? Let’s uncrop a bit (I downloaded some public data from an energy gov site, dropped it into Excel, and annotated it with SnagIt):

fuel prices

That’s a pretty different picture, isn’t it?

I’m not posting this to indict or vindicate anyone. I’m not even going to guess at explanations for the dramatic changes in that chart. I only post this to encourage people to be skeptical of charts, and to be especially suspicious of sensationalism.

Oh, and if you hate paying $3-4 dollars/gallon in the United States…it could be worse.

A Ridiculous Jury Duty Questionnaire

A while back I got a jury duty notice. A couple weeks before I was due to appear I received a huge questionnaire in the mail. This thing was more comprehensive than everything Wife and I did for premarital counseling. Over 100 questions.

After I sent this in, but before I had to appear the case was continued so I never appeared. With that in mind, and because no one told me not to, I’d like to share some select answers.

Before you think I’m just cherry-picking questions, I’m not. This thing was personal:

IMG_20110302_191000IMG_20110302_191012IMG_20110302_191019IMG_20110302_191026IMG_20110302_191033IMG_20110302_191038

That covered my detailed family history, religion, politics, career, salary, parenting, education, etc. Yikes!

Here are some of my favorite answers:

IMG_20110302_191429

IMG_20110302_191835

Once I even did computer stuff at a pizza place.

IMG_20110302_192155

Wife compelled me to not attach a list describing her job.

IMG_20110302_195136

(Before you assume I hate authority, check out questions 96-98 farther down.)

IMG_20110302_195104

And finally, after nearly eight years, the secret to my lasting marriage is revealed in question 102.

IMG_20110302_195122

As a genuinely curious person, with a strong sense of civic duty, I was sincerely disappointed that this fizzled out as quickly as it did. I’ve seen 12 Angry Men and tons of Law and Order so I’m basically an expert.

(Apologies for any damage my handheld “scanner” causes to your eyes.)

How to Cook Bacon on a George Foreman Grill

Place strips of bacon on hot grill:

IMG_20110131_194415

Burn grill marks into bacon, without cooking evenly.

IMG_20110131_194319

Eat bacon anyway.

Never try cooking bacon this way again.

(Note: this was attempted for convenience, not in a doomed attempt to make bacon healthier.)

Fixing My Hipster Dryer

As wonderful husbands often do, I went downstairs to switch the laundry the other day without being asked and discovered a load of wet clothes in the dryer. My wife likes to say the baby stole her brain so I chuckled heartily and started the dryer, assuming that she forgot to start it when she loaded it.

I returned a few hours later to try again at switching the laundry only to discover the clothes in the dryer were still wet. Uh oh. I turned that puppy on and found it ran, it's lint trap was empty, but it didn’t get hot.

Rats.

I called my appliance repair guy, Google, and did some reading. With the full knowledge of 10 minutes of browsing, I decide to check out this “heating element” thingamibob. First, pop open the back, right?

No. First make sure the vent is clear. Check!

Next pop the back open.

No! Unplug it first!

IMG_20110709_160741

I was pretty sure the plug was fine but I tested it with my multimeter just in case. ~220v check!

Now pop it open already!

IMG_20110709_160758

OK… hey, what’s that? A burned up wire?

IMG_20110709_160840

Now’s a good time to say, “now there’s your problem.” Why’d it burn up? Who knows. Condensation, chassis short, something or other, I don’t know. Normally these wires have little clips on them that let you easily attach them to other components (don’t you love how I say “normally” like I knew that before I started this project?). Unfortunately I don’t have any of those and the one that was attached here is not really up for the job. YOU’RE FIRED WIRE CLIP GUY!

Never fear, I’ll just grab my soldering iron. Actually, before I go through the trouble of soldering this back together (I suck at soldering), let’s see if that’s the problem first by reattaching it with a special wire reattacher tool:

IMG_20110709_160811

With that attached by what is one of the most useful tools ever, me a safe distance away, no children present, and fire extinguisher at the ready (just kidding, it was way far away), I verified the dryer operated as expected. Hooray!

Next I soldered the wire on, put the cover back on, and enjoyed some self congratulatory snickering. And what’s my true reward? I get to fold laundry (and avoid spending any money on this, or a new dryer).