dans.blog


The miscellaneous ramblings and thoughts of Dan G. Switzer, II

ESPN Photo shoot of the Steelers Defense.

Here's a good behind the scenes look at the comradery amongst the players on the Steelers Defense.


Yeah! No more car payments (at least for the immediate future)

Just last week I sent in my final car payment and I just received the title in the mail. This leaves Jenn & I without a car payment (as Jenn paid off her car earlier in the Spring.) It's a nice feeling to get out from having a monthly car payment. I guess the timing of paying off the car comes at a pretty good time, as I can know put the bulk of that money away each month. It'll also help me to pay off all the Holiday bills next month in a more timely fashion.


The Steelers/Ravens game and the NFL Rulebook

There was a lot of discussion last night on whether or not Santonio Holmes scored a TD against the Ravens last night. However, it appears like there's a real lack of understanding of the NFL rulebook by the media, so I'm going to quote the NFL rulebook:

Rule 11 Scoring

Section 2 Touchdown

Article 1      It is a touchdown (3-38):

(a) when a runner advances from the field of play and the ball touches the opponents’
goal line (plane); or
(b) while inbounds any player catches or recovers a loose ball (3-2-3) on or behind the
opponents’ goal line.

I've bolded the important part. Notice that the rule says as long as "player" is on or behind the opponents goal line, it's a touchdown. There's nothing in the rule book that says the ball must break the plane on a catch. It specifically states this is the case for a "runner", but in the case of a receiver it states "any player catches or recovers a loose ball on or behind the opponents' goal line."

I don't think there's any doubt that Holmes clearly had two feet in the endzone when he caught the pass. However, the only thing being brought up by the media has been that the ball has to break the plane—which doesn't appear to be the case.

I must confess, I was unclear of this rule as well, but most fans learn the rules from listening to broadcasts, which in the past they've always declared the ball must break the plane of the goal line.

I had to look this rule up after hearing the refs ruling after the review. If you listen to his ruling, he specifically doesn't mention anything about the ball breaking the plane—just that the receiver had two feet down with clear possession of the ball while being the endzone.

Anyway, there's much debate about this ruling yesterday and the Ravens fans are up in arms about the call. Hopefully this rule adds some clarity to the situation.

NOTE:
This quote comes from the 2006 NFL Rulebook (page 79), but I can't find any rule changes that indicate this rule has changed over the past two seasons, so I believe this ruling is still accurate.


You can't crack-back block on James Harrison...

I had a great view of this play in person on Sunday and it completely jacked me up. Notice how Harrison turns his head and locates Roy Williams trying to set up a block and then completely blows Williams up. Harrison is playing lights out football—and has been for the past two years. He should be the Defensive Player of the Year this year.


My trip to see the Steelers/Cowboys game...

Over the weekend, Jenn & I took our annual trip to Pittsburgh to see the Steelers play. We meet up with our friends Bob & Tina (from Indiana) once a year to see a game at Heinz Field. This is a trip we look forward to all year.

We drove over to Pittsburgh on Saturday, in the middle of the first winter storm of the season. While the weather wasn't that bad, we drove by dozens of car accidents on I-70. Lots of cars that spun off the road and a few multi-car accidents. We even detoured off I-70 briefly due to traffic being completely halted. We ended up jumping on SR-40 (old National Rd) for a few miles to get around the traffic jam. Fortunately we got to Pittsburgh and back without incident.

more…


Blinking cursor in Firefox 2 bleeds through divs...

[UPDATED: Thursday, December 04, 2008 at 4:36:59 PM]

I have a weird problem I'm running into again, but haven't been able to find a fix. In FF2, when I place a <div /> over an <input /> element that currently has focus, the blinking cursor shows up through the top layer.

I put together this little video to show off the problem:

Here's a working example of the bug. If you open the page in Firefox 2, you should see the cursor blinking in the middle of the word overlay.

Does anyone know of a fix for this problem?


Remove time from date/time stamp in SQL Server

I thought I've blogged this tip before, but I saw someone else mention it on a mailing list this morning. If you ever want to remove the time portion in a MSSQL Server, you can do this by removing the decimal portion of the date/time stamp.

SQL Server stores date/times as a numeric value where the integer portion of the value represents the number of days since epoch and the time is represented by the decimal portion of the value. This allows us to cast a datetime field as a float and then round down to the nearest integer:

select cast(floor(cast(getutcdate() as float)) as datetime)

We first convert the datetime to a float:

cast(getutcdate() as float)

We next use the floor() function to round down to the nearest integer:

more…


Using Photoshop to colorize an image to match your color palette

I'm not a designer. I can make may way around Photoshop, but the majority of my time in Photoshop is spent chopping up layers to convert them into images to use in my HTML & CSS. Occasionally I need to create new graphic assets or tweak the colors in an existing image.

We have a large collection of icons at work, but occasionally I need to adjust the color of an icon to better match the graphical assets where the icons will be used. My need today was to change some blue arrows to match a specific green hue.

Photoshop actually makes this very easy to do.

  1. Set the foreground color to the base color you want to colorize your image to
  2. Next, we need to create an Hue/Saturation "Adjustment Layer" (Layer > New Adjustment Layer > Hue/Saturation...)
  3. Give your adjustment layer a name and click the "Ok" button

    NOTE: If you want to limit your changes to only one layer, check the "Use Previous Layer to Create Clipping Mask" option, otherwise all layers below the new adjustment layer in your Layers Panel will have the mask applied to it.
  4. Click the "Colorize" checkbox

    image
  5. The "Hue" value will now match the color of your foreground color. The "Saturation" value is preset to a value that is consistent with the elements on the current screen. The "Lightness" value is preset to zero.
  6. You can now tweak the settings to get the exact colorization you're looking for. Just note that playing with the Saturation and Lightness settings can start to distort the image by losing the original white and blacks in the image.

I hope this helps someone else. I figured I better finally blog this, since I always seem to forget how to do this and end up having to rediscover the process when I need to go through the process again.


The Black Friday 2008 Buying Guide Spreadsheet

I stumbled across the SlickDeals.net Forums' Excel Spreadsheet - BF Filtered Ads - BF2008 Buying Guide yesterday and thought this is a useful spreadsheet for anyone looking for shopping deals this week. They look to be keeping the spreadsheet up-to-date, so it's worth checking again later to see what changes may have been added.

This list seems to have ads from just about every major and is a great way to compare prices between companies to find the best deals. The spreadsheet also allows for easy filtering to specific categories/headings and allows you to choose the sort order of the fields.

So, if you're trying to map out the stores you should be visiting over the next couple of days, I recommend downloading this spreadsheet right now and looking it over.

NOTE:
You can even view a Google version of the spreadsheet (which doesn't require that you have Microsoft Excel,) but I haven't been able to access it this morning due to the volume of people viewing the document.


Google adds new features to search results with SearchWiki...

[UPDATED: Wednesday, November 26, 2008 at 8:41:22 AM]

I just noticed that Google appears to have added some new features to the results page. The new features are buttons for "Promote", "Remove" and "Comment".

New Google Icons...

The "Promote" feature appears to be a way to give your "thumbs up" to content—which I'm sure will affect the rating of a page and thus affecting SEO. The "Remove" feature appears to be the way to report a bad link (like a Black Hat attempt, or just some general spam page.) Lastly, the "Comment" feature appears to be a way to add a comment about a page.

This new feature is part of Google's new SearchWiki. I think they must be selectively releasing this functionality, because I'm not seeing it every browser on my machine—so it's either cookie-based or browser-based.

UPDATE:
It appears all you need to do is log in to Google in order to see the SearchWiki features. Logging out will turn the feature off.

Here's a video that talks more about SearchWiki:


Show the execution time of any query in ColdFusion 8

I was working on some code today where I was getting back a query object from a CFC and needed to get the execution time. You can get this information from the <cfquery /> tag by using the result attribute, but since I was getting my query object back from a CFC, I needed to try and determine the execution time from only the query object.

Since the <cfdump /> tag is outputs additional meta data about a query (including the executionTime,) I knew this information could be obtained if I could just find the correct internal Java methods to call. After playing around for a few minutes I discovered that the additional struct keys that ColdFusion 8's <cfdump /> tag outputs come from: query.getMetaData().getExtendedMetaData().

So, to grab the execution time of any query in your code, you can just use:

<cfoutput>#queryName.getMetaData().getExtendedMetaData().executionTime#</cfoutput>

Since I was using this information on a search results page, I wanted to show the execution time in seconds to the user (carried out to the 3rd decimal.) Because query's can often return a 0ms execution time (either because of timing issues on Windows or due to cached queries,) I came up with the following code to show the execution time in seconds. I use the min() function to at least show a 1ms execution time (since 0ms time just looks weird.)

<cfoutput>
     #numberFormat(max(GetCustomers.getMetaData().getExtendedMetaData().executionTime, 1)/1000, "0.000")# seconds
</cfoutput>

The obvious disclaimer here is that since we're using internal methods, this can change in future versions of ColdFusion—which means your code could break.


Use existing UI Design Patterns to solve your UI problems...

I came across a couple of sites this morning that show off examples of existing UI design patterns that I believe will be useful to all developers. While there's always room to improve, many of the design problems we run into while developing applications can be solved with existing design patterns. The links below are good resources for showing existing patterns, why they're useful and examples of when to use them.

I'm working on laying a "dashboard" page where we need to display lots of various information, but in as small a viewport as possible (our goal is to try to avoid scrolling.) I'm using this sites to give me some ideas of ways to implement various solutions.

I'd highly recommend everyone just spend some time looking through the sites today and see what kind of creativity it sparks.


Minimizing all background windows using Windows 7's "Aero Shake"

Windows 7 is introducing a new feature called "Aero Shake." The concept is you simply drag and "shake" a window's title bar and all background windows will either be minimized or restored (based on their current status.) Here's a YouTube video of the feature in action:

While this feature looks cool, I'm wonder how useful it really will be and how intuitive it will be to the user. Since I tend to run most windows maximized, I'm not sure if this will provide much value to me.

Do you see this as be a good or bad UI design pattern?


Division of integers in MS SQL

Yesterday I was trying to divide two values to calculate a percentage, but the value was always coming up zero. What really threw me off was I had a query similar to the following and that was working fine:

select
    floor((avg(Rating) / count(Rating)) * 100) as [Percentage]
from
    Ratings

The above query was properly returning the percentages I needed, but when I had a query like the following, all of the sudden it was just returning 0 (zero) as the result—which I knew was wrong:

select
    count(1) / (select count(1) from Sales where datediff(dd, OrderDate , getutcdate()) = 0 ) as SameDayShipPct
from
    Sales
where
     datediff(dd, OrderDate , getutcdate()) = 0
and
    datediff(dd, ShipDate , getutcdate()) = 0

The reason the above query kept returning zero, was because the SQL COUNT() function returns an INT. When MS SQL Server performs an operation on INT values, it returns an INT value. This means the division of two INT values will always return an INT.

The solution is to cast at least one of the two values to a FLOAT. The reason my first query was working fine is because the Rating column was a FLOAT column, which meant the division would return a FLOAT value.  The following is the same query, but will correctly return a FLOAT.

select
    cast(count(1) as float) / (select count(1) from Sales where datediff(dd, OrderDate , getutcdate()) = 0 ) as SameDayShipPct
from
    Sales
where
    datediff(dd, OrderDate , getutcdate()) = 0
and
    datediff(dd, ShipDate , getutcdate()) = 0

Take a look at the following in Query Analyzer to see how MS SQL Server handles the division operation:

declare @r1 float, @r2 float, @r3 float
set @r1 = 3/4
set @r2 = 3/4.0
set @r3 = 3/cast(4 as float)
print @r1
print @r2
print @r3

Just something to keep in mind when using division operations in SQL Server. I thought I could simple cast my expression to a FLOAT to fix the problem, but since the division operation has already converted the value to an INT the resulting value will still be based on the original INT value.

NOTE:
Always remember to watch out for potential "Divide by zero error encountered" errors when performing division operations in SQL server. This can easily crop up, so make sure your query accounts for the possibility. An easy workaround is do something like:

ISNULL(dividend / NULLIF(expression, 0), 0)

The NULLIF(expression, 0) will make the value return null if the expression ends up being 0. This will then make the division operation return null as the result. The ISNULL() will then convert the resulting null value so that it actually returns 0 instead of null.


Prince of Persia and the birth of motion capture...

Jordan Mechner, the creator of the original 1989 state-of-the-art animation image game Prince of Persia, has recently released the videos he took of his brother that he used for the animations in the game. When this game was released, it really took animations on the PC to a new level. For those that remember playing the game, I'm sure you'll recognize the moves performed in the video—especially his brother "struggling" to get up the wall.

It's pretty impressive to see the original footage that lead to the ground breaking animation. It's basically the birth of motion capture in video games.