Advertisements

Archive

Archive for December, 2011

#occupykidspool

December 28, 2011 Leave a comment

A local photographer, Rex Larsen, had one of his pictures selected for Life Magazine’s 2011 Pictures of the Year contest. I’m trying to think of something witty to say, but this picture has left me speechless. Its beauty is beyond the power of words.

Grand Rapids' Contribution to Life's 2011 Pictures of the Year

Advertisements
Categories: wtf Tags:

Cthulhu on my Kindle

December 27, 2011 Leave a comment

My lovely wife bought me a Kindle as a gift and I’ve been playing with it the first few days. So far, I love this thing.

I’ve been spending a few days hoarding free books that I can find all over the internet. Amazon has a bunch of free books on their site but also recommends other repositories. Project Gutenberg is pretty damn slick. Plus, today I found a totally free collection of HP Lovecraft’s works over at CthulhuChick.com. Well done, Ruth. You rock!

Amazon also has this nifty way of getting books to your Kindle. By registering your device, you have a specific @kindle.com email address assigned (managed on amazon.com) and you can send books as attachments in an email and they’ll show up the next time your e-reader connects to the web. It accepts zip files as well as .mobi files and a few other formats. Plus, they keep a hold of the books you send over email so that if you accidentally delete something, like I already have, you can just pull it up under the Personal Documents section of the Kindle management page and resend it to your device.

I was a bit of a naysayer when these things first came out, but I can definitely see the benefit of having one. Now I just wish I could squeeze my huge-ass hardcover copy of the Autobiography of Mark Twain into digital format without buying it again, because that thing is freaking heavy.

Categories: books, nerd

The Reason for the Season

December 21, 2011 Leave a comment

My very own Hudsonville was in the news the other day. This time, it was a battle over just how Christian the Christmas decorations should be. We haven’t got much secular representation in this community, so we’re left with some bitter Christians roaming around the neighborhood, warning people that having lights on their house is *gasp* a very Pagan thing to do.

http://www.wzzm13.com/video/default.aspx?bctid=1332434026001

I especially love how the people in the video are quick to point out that they’re very Christian, and that some other people just take things too far. True in its own right, I suppose. I just wish I had received one of those letters.

For Christ’s sake, even I, an adamant atheist, have a Jesii on my Christmas tree. He’s right there, knocked halfway down the tree, upside down, having been usurped by a 1990’s era Sugar Bear ornament that still plays Christmas tunes after 20 years. That’s a fucking miracle, folks.

Truly, the King of Kings

Categories: jesii, religion

I’m Sold on Dapper

December 8, 2011 Leave a comment

Don’t get me wrong, I love my LINQ. I just have mixed feelings about LINQ2SQL, or anything that promises to make my life easier by allowing me to write fewer SQL statements.

I’ve been burned a few times too many by seemingly innocuous LINQ2SQL queries that ended up ballooning into resource hogs once deployed to the real world. Often, it’s a sleeper; some query that’s been running just fine for years and then, BAM! You get jolted by a spiked CPU like a shovel to the face because an email campaign hit some remote part of the site that hadn’t been pored over. A little digging finds that LINQ2SQL has drunkenly taken over the kegger at your parents’ house, smashing lamps and vases and shoving your friends into the pool, wreaking all sorts of havoc and running your CPU off the charts.

It’s that friend you learn to limit. He may be great in certain situations, like running the basic CRUD (Create, Read, Update, Delete) routines on all those cumbersome admin screens, but once you take him into the real world, once you expose him to all your other friends on your high traffic ecommerce site, once you give him a broader audience, you run the risk that he’ll show his true colors, and you may not like what they see.

Such has become my relationship with any ORM that promises to lift the burden of having to write straight SQL. It’s fine in the right circumstances and saves loads of time writing basic operations. But once you cook up a slightly more complex query and roll it into a public website with tens of thousands of hits an hour, it’s just not enough. Trusting the black box of ORM SQL generation often turns out to be a risky endeavor.

I’d rather be in direct control of what SQL gets executed when writing finely tuned database access. Thus, I’ve come to love what Dapper has to offer. Dapper, by the folks over at stackoverflow.com, is an extremely lightweight data access layer optimized for pulling raw data into your own POCOs (Plain Old C# Objects). It’s that perfect fit between the nauseatingly redundant world of SqlCommands and DataReaders, and the overzealous and overbearing friend you find in LINQ2SQL. No longer do I have to guess at what kind of query an ORM is going to generate. No longer do I have to worry that LINQ2SQL is going to fly off the handle and take up all my CPU trying to compile the same dastardly query over and over again. I can instead write the SQL myself and get it into my POCO of choice with less effort than it takes to bash my head on the keyboard.

For example, let’s say I’ve got this domain object:

public class OmgWtf
{
public string Acronym { get; set; }
public string Sentence { get; set; }
}

All I have to do to yank the data from the database is this:

using (var conn = new SqlConnection(ConnString))
{
conn.Open();

string sql = @"
SELECT TOP 1 omg.Acronym, wtf.Sentence
FROM OnoMatopoeicGiddiness omg
JOIN WordsToFollow wtf ON wtf.OmgID = omg.ID
WHERE wtf.ID = @WtfID";

var omgwtf = conn.Query<OmgWtf>(sql, new { WtfID = 3 }).First();

Console.Write("{0}: {1}", omgwtf.Acronym, omgwtf.Sentence);
}

The result is, of course:

SQL: I Squeal for SQL!

No longer do I have to suffer the fate of black box SQL generation when all I really want is a clean, easy, and fast way to get my SQL or stored procedure results directly into my domain objects. I’m sold on Dapper for many of my high-performing pages. As we maintain our sites and find the occasional bloated LINQ2SQL resource hog, we’re swapping out the queries to straight SQL, stored procedures, and Dapper, and it has really sped things up.

Go ahead, give it a shot yourself. It’s available on the NuGet Gallery, and only imports a single C# file; no extra assemblies required. They’ve got plenty of examples at the project site. I’m wondering how I ever lived without it.

Categories: nerd

First day at Steamboat is a bust

December 1, 2011 Leave a comment

We flew into Steamboat last night all geeked to hit the slopes today. We noticed it was really windy during the night and we kept waking up to the sound of the condo rattling and the sight of ratty white dudes with mangy afros flying through the air past our window. When I stepped out onto the deck I was immediately assailed by tiny glasslike shards of ice eagerly impaling themselves into the whites of my eyes.

Our condo is on a steep slope facing the ski hills so the wind here is enough to knock over a grown man, with the added insult of flash freezing him on the way down. The result, I expect, is that the poor soul would be smashed to frozen bits on the pavement without ever making it to the gondola. I wished to avoid this fate, so we donned our complete skiing attire before making the steep decline down a road with no shoulder in search of breakfast. The wind was terribly offensive.

We ate breakfast and a few concerned employees, seeing that we were dressed in full skiing regalia, apologetically explained that all lifts would remain closed the entire day, and that all employees of the mountain had been informed to stay inside. Our waiter explained that 120 mph gusts of wind were recorded further up the mountain. I couldn’t be sure whether this was an exaggeration or the truth.

image

A few years ago, I met an aged ski bum with a fondness for Billy Idol while skiing at Heavenly, overlooking Lake Tahoe. He explained that in his youth he had worked the chair lifts at Heavenly and was on staff the night when a few lifts remained operational despite high winds. The ghastly result was a lift whose seats were buffeted to the point where the cable bounced off the pullies, sending the passengers plummeting to the snow below. But that’s not all. You know how, when you hold a garden hose taut, you can yank it in such a way that sends a wave down the length of the hose? The same thing happened with the cable on the ski lift. The tension was so great that, after dumping its load of passengers from the lift, the cable rebounded and snapped back, sending a wave of energy down the length of the cable. As he explained it to me, a number of people were killed instantly. One teenage girl had both legs immediately severed above the knees, and lived. This guy explained how he had been involved in shoveling as much snow as possible to try and cover up all the blood staining the snow.

Suffice it to say, when Steamboat kept its lifts shut down today because of high winds, I was mildly annoyed until I remembered this story and made the conscious decision to appreciate my own two complete legs rather than one missed day of skiing.

Instead, we took the bus around and into town, where the wind was noticeably more mild and our ski clothes were much less necessary. Jen got embarrassed enough from locals apologizing for the unfit conditions that she removed her snow pants in the hope that they wouldn’t assume we were there for the skiing. We’ve got a condo in a great location, with a perfect view of those slopes that are just out of reach. I guess this afternoon will be one of hot chocolate, nachos, a good book, and some wine and steak. It’s not so bad.

image

Categories: travel Tags: ,