Where would you like to go, Toady? RSS 2.0
# Monday, August 31, 2009
Presidental approval explained

Source: back of a napkin

Monday, August 31, 2009 4:22:39 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Bookmark, Tweet, or Share
# Sunday, August 23, 2009

The morning started out normal enough- a sunny Sunday morning with pavement waiting to be ridden on. About 25 members of the Impatient Triad Riders met at the usual spot, the Shell Station in Oak Ridge at 68 and 150. There was a great turnout for this ride in memory of Mason Levin, one of the founders of the group, who lost his life from injuries from a ride on July 18th.

When Trees attackWhen Trees attack

So we rode out and hit Highway 66 near Danbury for some twisties and stopped here at the shack for a short break and then began the ride up to Hanging Rock.

When Trees attack

When I got to the end of Lynchburg Rd I became increasingly concerned that, unlike a minute or two before, there were no riders in my mirrors. I hesitated (and shouldn't have) for about a minute and turned around to find out what was up.

It wasn't instantly apparent what had happened when I arrived on this scene, but I knew it wasn't anything good.

When Trees attack

To make a long story short, the rider behind me, Chris, had a Tree Fall On Him!

His reaction to this completely random flying timber was absolutely spot-on. He cracked open the throttle, hunkered down, and hugged the gas tank as closely as he could. With his side mirrors ripped off and helmet scuffed, he miraculously kept the bike up.

When Trees attackWhen Trees attack

Next in the formation, Richard, wasn't as fortunate. Seriously, what are you supposed to do when a tree falls into your line of travel? There is no amount of experience to prepare you for that kind of thing. He did all he could with the brakes and limited stopping distance and reaction time, and laid it down before impacting the unexpected tree. He sustained some leg and knee injuries, but still made it out relatively unscathed for such a strange chain of events. He was taken to Baptist Hospital for treatment of his injuries.

Overall I was extremely impressed with how the other ITR members reacted on the scene before and after medical personnel arrived.

Kudos guys, you're a top-notch bunch!

All photos

Sunday, August 23, 2009 7:00:47 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [2] -
Bookmark, Tweet, or Share
# Sunday, July 26, 2009

Find nearest object query with LINQ

While LINQ simplifies your DAL in myriad ways, this seemingly simple query made me stop and think about how to properly explain this to the query engine

Problem: Given an input of a current location (latitude and longitude) find all objects in the database within a specified radius

Disclaimer: This is using a bounding box hack rather than an accurate radius forumula, use at your own risk as there is some loss of precision.

     /// Find all courts within a specified radius (in miles) to a point (latitude & longitude)
     /// <param name="latitude">degrees(decimal)</param>
     /// <param name="longitude">degrees(decimal)</param>
     /// <param name="radius">miles</param>
     /// <returns></returns>
     public IQueryable<Court> FindNearbyCourts(decimal latitude, decimal longitude, decimal radius);

The first order of business is to convert miles to degrees of latitude and longitude, respectively.

Latitude:     Factor out Equatorial bulge, and a degree of latitude is simply 69.04 statute miles.
Longitude:     On the other hand, longitude varies in length depending on your current latitude. For this example, I am assuming 30°N. Thus, one degree of longitude is 59.96 statute miles.
     decimal radiusLatitude = radius / 69.04;
     decimal radiusLongitude = radius / 59.96;

Once we have these conversions in place, we are ready to build our LINQ query:

     IQueryable<Court> nearbyCourts = from court in _db.Courts 
where
(Math.Abs(court.latitude - latitude) < radiusLatitude)
where (Math.Abs(court.longitude - longitude) < radiusLongitude)
select court;

Return the IQueryable object nearbyCourts you just generated and you're all set.

Sunday, July 26, 2009 11:34:18 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Bookmark, Tweet, or Share
# Tuesday, May 05, 2009
Bonfire

How do grilled BBQ Ribs, a Cauldron of Brunswick stew, chicken, hotdogs & hamburgers sound for a Saturday in Spring? I thought it sounded great, so I'd like you to join me this Saturday for the festivities. Slated to be an extravaganza of southern food, your tastebuds will not soon forgive you for missing out.

Saturday, May 9th at 7pm


Please RSVP if you have not already



Some suggestions for items you might want to bring:

  • Chips / Dip
  • Sodas
  • Beer
  • Any Adult Beverages you might like (some will be provided)
  • Smores ingredients: Marshmallows, Chocolate Bars, Graham Crackers
  • A Blender (i have the stuff to make Margaritas, but a broken blender)
  • Anything else you might feel inclined to bring and share
  • Or, just bring yourself and a guest if you like

Looking forward to seeing you!



~Chris & Bridget

Tuesday, May 05, 2009 10:19:15 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Bookmark, Tweet, or Share
# Saturday, March 21, 2009
The CWP Train in action
When Travis mentioned to the group that his Barbershop Quartet would be competing in a Barbershop Quartet competition right around the corner in Winston-Salem, NC, a few of us decided to attend to cheer him on. One day we were discussing it in the Common Area and some crazy ideas were thrown out, namely a few of us dressing up as a Train, befitting their group name, Grand Central. It turned into quite a crazy evening, as the video evidence to the right shows. Thanks to Bridget, Rex, Lucas, Brandon, Jason for your participation in the aforementioned silliness. I would also like to thank Tony and David for responding to our tweets and suppling the cardboard and UPS respectively. You may view the rest of the photos here on Flickr.
Saturday, March 21, 2009 3:53:31 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [1] -
Bookmark, Tweet, or Share
# Friday, March 20, 2009

MVI_4166
Originally uploaded by ballance5702
Testing the smokestack system for the official Grand Central train.
Friday, March 20, 2009 12:14:28 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Bookmark, Tweet, or Share

# Sunday, March 01, 2009

Google provides a Charting API with a host of useful charts. I spent a few minutes playing around with the map chart section to create a color-coded map of the states I have visited in the USA.

chart

The Venn Diagram was an interesting option that I had not expected, but good stuff.

chart

If you are building a dashboard, the Google-o-meter might come in handy

chart
Sunday, March 01, 2009 1:32:00 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Bookmark, Tweet, or Share
# Sunday, February 22, 2009

I find myself spending quite a bit of my spare time on Stackoverflow in recent weeks, and decided I wanted to display my current rep on my blog.  A few days ago I built a dynamically generated (and cached for 2 hours for traffic's sake) user ranking report, since my request for this on Uservoice was not approved.

HtmlAgilityPack has been my weapon of choice in recent days.  It was a good fit for this project and the end result looks like this:

stack overflow badge

And in case you might ask "Show me the code!" here you are.  Feel free to use it for your own project if you like.

<%@ WebHandler Language="C#" Class="Badge" %>

using System;
using System.Web;

public class Badge : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) 
    {
        string includeLogo = !string.IsNullOrEmpty(context.Request.QueryString["useLogo"]) ? 
context.Request.QueryString["useLogo"] : string.Empty; string userId = !string.IsNullOrEmpty(context.Request.QueryString["userid"]) ?
context.Request.QueryString["userid"] : "1551"; string jsMode = !string.IsNullOrEmpty(context.Request.QueryString["jsMode"]) ?
context.Request.QueryString["jsMode"] : string.Empty; PageRetriever pr = new PageRetriever("http://stackoverflow.com/users/" + userId + "/"); pr.GetPage(); User userBadges = pr.ExtractBadge(); if (!string.IsNullOrEmpty(jsMode)) { context.Response.ContentType = "text/javascript"; context.Response.Write("document.getElementById('stackoverflowRep').innerHTML = '"); } else { context.Response.ContentType = "text/html"; } if (!string.IsNullOrEmpty(includeLogo)) { context.Response.Write("<div style=\"height:40px\"><div style=\"float:left\"></div><div style=\"float:left;\">");
context.Response.Write(<img src=\"http://www.chrisballance.com/so/resources/stackoverflow-logo-250.png\" />");
} context.Response.Write(userBadges.Rep); if (!string.IsNullOrEmpty(includeLogo)) { context.Response.Write("<br /><a href=\"http://stackoverflow.com/users/"); context.Response.Write(userId); context.Response.Write("\">"); context.Response.Write(userBadges.Username); context.Response.Write("</a></div></div></div>"); } if (!string.IsNullOrEmpty(jsMode)) { context.Response.Write("';\n"); } } public bool IsReusable { get { return false; } } }

 

Sunday, February 22, 2009 11:10:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Bookmark, Tweet, or Share
# Tuesday, February 17, 2009

Since I could not find a chart of some sort showing current rankings on StackOverflow.com, I decided to roll my own.  The link that follows points to a static cached version of the page that will only update manually for now.  Enjoy, and feel free to give your feedback or suggestions for improvements.

Current StackOverflow.com Rankings

Stackoverflow.com Rankings
Tuesday, February 17, 2009 1:16:09 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
Bookmark, Tweet, or Share
Stackoverflow.com Rep
Flickr stream
Archive
<August 2009>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Chris Ballance
Sign In
Statistics
Total Posts: 46
This Year: 11
This Month: 2
This Week: 0
Comments: 11
All Content © 2010, Chris Ballance

Valid XHTML 1.0 Transitional