dans.blog


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

Windows Live Writer 2009 released…

As I mentioned in my last post, I just got a new PC and have been in the process of loading up all my old software. In doing so, I discovered Windows Live Writer 2009 has been released.

There's a whole slew of new features, but the one thing I noticed immediately was that there's much better support for BlogCFC. In the previous version, none of the preview stuff would work. In the new version both the preview and the "Edit using theme" feature both work. There's also plug-ins to auto-notify Twitter and many more related to photos and videos. The new upgrade looks really good so far.

Here's what's new:

  • New border treatments (including Instant Photo)
  • Crop and tilt photos
  • Insert multiple photos
  • Toolbar alignment commands enabled for images
  • Insert and upload Windows Live photo albums
  • Insert and publish video to YouTube
  • Additional spell checking languages: Arabic, Basque, Bulgarian, Catalan, Croatian, Czech, English (Australia), Estonian, Greek, Hebrew, Hungarian, Indonesian, Latvian, Lithuanian, Malay, Polish, Romanian, Russian, Slovak, Slovenian, Turkish, and Ukrainian
  • Server-side tagging (for supported blogs)
  • Type-down filtering in the Open dialog
  • Twitter, Digg and Flickr Plug-ins
  • Improved blog account setup
  • Lightbox and Windows Live Spaces inline preview support
  • Improved category control: adding categories, type-down filtering
  • Tabbed view switching
  • AutoLink glossary
  • Smart quotes/typographic characters
  • Word count
  • Support for bidirectional languages (like Hebrew and Arabic)
  • Tabs for view switching
  • Updated look and feel


Firefox generating error when opening URL when already running…

Last week my old dev system bit the dust. Since the box was 6 years old, I figured I was better off replacing the unit rather than repairing it—especially considering it was the motherboard that got fried (which would have meant replacing the motherboard, CPU, video card and possible power supply since all components were older technology.)

Anyway, in the process of setting up my system, I finally thought it was time to change from using Firefox 2 as my default browser and use Firefox 3 instead. I've been running both browser simultaneously for a while, but had just kept using FF2 mainly for development purposes.

When I initially set up the new box, I used the same --no-remote technique I had previously blogged about so that I can have both Firefox 2 and Firefox 3 open at the same time. However, whenever I'd try to open up a link from Outlook when Firefox 3 was already running I'd see the following error:

 Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

 

After doing some Googling and not finding anything that matched my issue, it finally occurred to me that the problem might be stemming from the fact that I was initially opening my Firefox 3 instances with the --no-remote switch still.

Sure enough, after removing the --no-remote switch from my quick launch icon, the error went away. I know only start Firefox 2 with the --no-remote switch.

So, if you're seeing the "Firefox is already running, but is not responding." message when you try opening up links from applications (such as your e-mail client) make sure you're not opening your instance of Firefox initially with the --no-remote switch.


Fading a 24-bit transparent PNG in IE7

Internet Explorer 7 has some issues with fading transparent PNGs. If you've gotten to the this page because you're seeing a black border where the transparent edges in your PNG are, then here are some tips for fixing the problem:

  1. Do not fade the element directly, but fade a parent container holding the PNG. This may mean you need to add a wrapper element to your code.
  2. Give the parent element a background color.
  3. Lastly, if you're still having problems, try give your parent element the old "zoom: 1" trick. Give the parent element a style declaration of "zoom: 1" (either via CSS or an inline style.) This will force IE to give the element hasLayout—which tends to fix all sorts of weird display issues in IE7.

The above tips will usually sort out any fading issues I'm having in IE7.


One year anniversary of my Lab's knee surgery...

A year ago today our Black Lab, Nikki, underwent surgery to have her canine cruciate ligaments repaired in both rear knees after having ruptured them. It was rough day for the wife and me and I'm glad it's well behind us.

Nikki's been doing excellent since the surgery. Other than a slightly strange gate (which is only really noticeable if you're looking for it) you would never know she had both knees replaced. Last summer she enjoyed many a days running and playing ball in the backyard. Occasionally the knee would "give out" on her when she'd try to make a quick cut and she'd come up limping, but I think she limped only because it felt foreign because within minutes she was back to running and jumping at full speed.

It's amazing to me everytime I see her run around the backyard or jump around that a year ago she could barely walk. While the surgery was costly, we're just glad we got our dog back. :)


The Sixburgh Steelers and Mike Tomlin's prophecy...

As a Steelers fan, I might be considered a bit biased, but last night's Super Bowl was one of the best I've seen. That's back-to-back years where the Super Bowl has been exciting and it's hard to believe a game could have topped the end of last years, but these game I think did it.

I couldn't sleep at all last night and I'm still feeling little bursts of adrenaline—just an amazing game with huge plays at the end of each half. From James Harrison's INT for a TD at the end of the first half (which was simply amazing and was the difference in the game) to Holmes fantastic catch in the corner of the endzone—what an amazing game.

Anyway, after the Steelers beat the Ravens in the AFCC game, I kept thinking about an article I read about Tomlin shortly after he was hired. The article was about Mike Tomlin and was an interview with his mother. The article was about how Tomlin has always set lofty goals that his mom often that were unrealistic, but time after time her proved his mom wrong and reached his goals. The one quote that always stood out to me was the following quote that he would win the Super Bowl sooner rather than later:

"He already told me he was winning the Super Bowl," said Mrs. Copeland, and what son would fib to his mother? " 'I will be hoisting that trophy, and I won't be patient about doing it, either.'

"Those were his words."

After years of small doubts, she has learned to believe.

"Because everything you've said so far," she told him after he was hired as the Steelers coach in January, "you've done it."

Pretty amazing.


The Terrible Towel at Obama's Inauguration

The Terrible Towel turns up everywhere. It's to the point when I look for it like a "Where's Waldo?" game at every crowd event. Here's a video of the towel at Obama's speech:


Get pumped up with this Steelers highlight video...

This is a very well done highlight video. The creator did a create job of syncing up the video to the music. This is the kind of stuff to watch to get you even more pumped up for the Super Bowl!


Getting Microsoft SQL Server Management Studio to automatically log in to a server

I finally got tired enough of having to click the "Connect" button at SQL Server Management Studio startup, that I decided to look for a way to bypass this prompt. Since in development, I typically am only ever dealing with the same server, the connection dialog always added an extra step to the process of getting up and running.

So, a quick search on Google turned up a list of the following command prompt switches you can use to specify a server (and database) to use when starting up:

Usage:
sqlwb.exe [-S server_name[\instance_name]] [-d database] [-U user] [-P
password] [-E] [file_name[, file_name]] [/?]

[-S The name of the SQL Server instance to which to connect]
[-d The name of the SQL Server database to which to connect]
[-E] Use Windows Authentication to login to SQL Server
[-U The name of the SQL Server login with which to connect]
[-P The password associated with the login]
[file_name[, file_name]] names of files to load
[-nosplash] Supress splash screen
[/?] Displays this usage information

So, all you need to do to get SQL Server Management Studio to automatically log in to a specific server is to right-click on your SQL Server Management Studio icon, and change the "Target" to something like:

"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe" -S SERVERNAME -d DATABASENAME

SQL Server Management Studio Properties Box


Useful tips and tricks for dealing with date/time in SQL

I've come across several clever and convenient tricks for dealing with dates recently in SQL Server. I previously blogged about how to remove time from date/time stamp in SQL Server, but I've come across a group of other really useful date/time manipulations that can be very useful when dealing with SQL Server.

The basic idea behind most of these tricks is that by using a known base datetime stamp, you can then use simple addition and subtraction to calculate the new dates. For example, if I calculate the difference in days between Jan 9, 2008 at 08:00 Jan 1, 2000 at 00:00, I'll end up with a whole number of days which I can then and add back to Jan 1, 2000 at 00:00 and I'll end up with Jan 9, 2008 at 00:00.

Take the tricks below and play around to see what other useful combinations you can develop. If you have any other useful date/time tricks, let me know!

more…


Dynamically generating a table of dates in Microsoft SQL (Part Deux!)

Yesterday I wrote a blog entry talking about dynamically generating a table of dates in MSSQL 2005. My original solution involved common table expressions (CTE) and involved recursion. While there's nothing wrong with using recursion this way, I mainly was using recursion to simplify the UDF code into a single SQL expression.

However, the more I started thinking about the problem last night, I decided I really needed to revise things a bit further. I decided I really needed to have the query return both a start and end date for each row in the recordset—as this would make it much easier to things such as find all the orders placed during each hour of the day.

So, this morning I came in and re-wrote my query and optimized a few things. The first thing I did was remove the recursion, so this UDF should now work in SQL Server 2000 as well as SQL Server 2005. It's important to note that you could do the same thing with a physical table, but for my uses my date range table generally would only include at most a few dozen rows and there's not enough of a performance difference to warrant the pain of maintaining a table of every date and possible combination you may want to return aggregate results over.

The new code looks like this:

more…


Dynamically generating a table of dates in MSSQL 2005

[UPDATED: Thursday, January 08, 2009 at 11:04:25 AM]

UPDATE:
I've revised this concept, so please see the new version: Dynamically generating a table of dates in Microsoft SQL (Part Deux!)

I'm working on some code where I need to show some trend date over various periods of time. One of the issues with working with SQL and aggregate values is that it'll only show you values where there was some data, so if you want to print the number of orders on each day and some days had no orders, they wouldn't show up in the results.

For what I was working on, I needed to ensure that even missing days would show up in my query results. This got me thinking about the best way to accomplish this task. After thinking about the problem for a while, I decided the ideal method would be if I could dynamically generate a table of dates that I could then use in a LEFT OUTER JOIN.

more…


Organizing the icons in your Firefox status bar...

One thing that's always bothered me about Firefox, is the lack of the ability to customize the icons in the status bar. As you add various plug-ins, the order of icons in the status bar can change and isn't always ideal. Plus, when you have multiple installs of Firefox on multiple boxes, I find it disrupts my workflow when icons are in a different spot for each browser (even with the exact same plug-ins installed.) So, I decided I finally wanted to re-arrange the order of my icons and get things working in a fashion that suited me better.

There are two main ways to change the order: 1) via a manual editing or 2) via another add-on.

You can manually re-arrange the order of the icons by editing the extensions.ini file located in your personal profile directory in the folder C:\Documents and Settings\{username}\Application Data\Mozilla\Firefox\Profiles\{profile}. What you need to do is change the order and position of the entries in the [ExtensionDirs] section of the INI file. While this works, it's a bit of a pain since the entries aren't easy to decipher (since values don't match up to a user friendly label.)

This led me to a find an add-on to simplify the task. The add-on I found was the Organize Status Bar v0.6.2 add-on. Using this plug-in gives you a very visual way of organizing your status bar. You can completely order things in any manor you want. Here's a screenshot of the add-on in action:

image

What I like about the add-on is that it highlights in yellow the currently selected icon and also has options to hide or show an icon if you don't want it to show up in the status bar. This add-on does exactly what I needed—I just wish the functionality was native to Firefox like the organizing toolbar feature.


Find the longest running queries on your MSSQL 2005 Server

[UPDATED: Wednesday, January 21, 2009 at 8:19:25 AM]

I was reading the SQL SERVER - 2008 - 2005 - Find Longest Running Query - TSQL on Pinal Dave's blog and thought I'd run the query on my development machine to see what interesting things I'd fine.

However, right off the bat I was seeing something I thought was odd—my execution times looked way too high. After some quick searching, I confirmed my initial thought that MSSQL reports time in microseconds (which is one millionth of a second or one thousandth of a millisecond.)

For my needs reporting in milliseconds is more than enough, so I revised the query to report the time in milliseconds instead of microseconds. I also made some other modifications so that the query breaks the actual SQL statement and extra parameters into 2 columns (I derived this code from the an article on MSSQLTips.com.) I also added last execution time and minimum elapsed times for the query. I also changed the query to show the results by the average elapsed time—since I occasionally you'll see a single query spike with a high maximum elapsed time that might be due to external circumstances (although this is good to know too.)

Here's my revised version:

select distinct top 10
    substring(t.text, (s.statement_start_offset/2)+1, (((case s.statement_end_offset when -1 then datalength(t.text) else s.statement_end_offset end) - s.statement_start_offset)/2) + 1) as SqlText
    , (case when s.statement_start_offset >
0 then substring(t.text, 0, (s.statement_start_offset/2)+1) else '' end) as SqlParameters
    , s.execution_count as ExecutionCount
    , (s.max_elapsed_time/1000) as MaxElapsedTimeMs
    , (s.min_elapsed_time/1000) as MinElapsedTimeMs
    , isnull((s.total_elapsed_time/1000) / nullif(s.execution_count, 0), 0) as AvgElapsedTimeMs
    , s.creation_time as LogCreatedOn
    , s.last_execution_time as LastExecutionTime
    , isnull(s.execution_count / nullif(datediff(s, s.creation_time, getdate()), 0), 0) as FrequencyPerSec
from
    sys.dm_exec_query_stats as s
        cross apply
    sys.dm_exec_sql_text(s.sql_handle) as t
order by
    isnull((s.total_elapsed_time/1000) / nullif(s.execution_count, 0), 0) desc

UPDATE:
I added another nullif() statement to further prevent divide by zero errors.

One thing to keep in mind is that the DBCC FREEPROCCACHE will clear the cache and reset the log (obviously a reboot of the server or restart of the services would do the same thing.) You may have some maintenance scripts that might issue the DBCC FREEPROCCACHE command, so just keep this in mind when looking at the results.

You can use the query above for lots of purposes. With a little refactoring, you could change the ORDER BY clause to return queries that had executed recently—which can be useful if you're trying to debug a slow running template.


Merry Christmas Everyone!


A public service message from Plaxico Burress...