Google AdSense ViewComponent for MonoRail

Like many, I use Google AdSense to host ads on my web sites. Including the ad code typically requires you to paste a block a block of JavaScript onto the page. I don’t mind injecting the JavaScript, but I wanted to come up with a better way.

The solution I came up with was a quick MonoRail ViewComponent, AdUnit. It has a simple purpose: to render a block of code for an ad unit of a given size.

The first task was to create an enum which represented all the possible ad unit sizes, based on what’s offered by Google. . . . → Read More: Google AdSense ViewComponent for MonoRail

Separating SQL script files generated by Microsoft SQL (by type)

There’s one great feature in SQL: the “Generate Scripts” command. Unfortunately, it has one limitation: the default filenames of scripts look something like this:

dbo.fnc_PlayerValue.UserDefinedFunction.sql
dbo.UserSelect.StoredProcedure.sql

I’d much prefer the filenames to match the object name, without the owner (‘dbo’) or object type. In other words, I’d prefer the above two files to look like this:

UserDefinedFunction\fnc_PlayerValue.sql
StoredProcedure\UserSelect.sql

How do we get from point A to point B without a lot of manual file copies and renames? We use the FOR command!

First, create a subdirectory for each object type (Table, StoredProcedure, UserDefinedFunction, View, Schema, Trigger, and User), then run the following from a command prompt.

for %i in (*.User.sql) do for /f “delims=., tokens=1-3″ %j in (“%i”) do move %i %k\%j.%l
for %i in (*.Schema.sql) do for /f “delims=., tokens=1-3″ %j in (“%i”) do move %i %k\%j.%l
for %i in (*.Trigger.sql) do for /f “delims=., tokens=1-3″ %j in (“%i”) do move %i %k\%j.%l
for %i in (*.sql) do for /f “delims=., tokens=1-4″ %j in (“%i”) do move %i %l\%k.%m

The command . . .

→ Read More: Separating SQL script files generated by Microsoft SQL (by type)

A bug in Microsoft Word’s Insert Hyperlink feature

Try this in Microsoft Word 2007:

Open a new document.
Type the following: http:// some.domain.com
Note that there’s a space after the two forward slashes and before the domain name.
Select the text you just typed, and press Control-K (the shortcut key to Insert Hyperlink).
Note that nothing happens.
Go to the Insert ribbon and click the Hyperlink button (essentially the same thing as #3 above).
Note that nothing happens.
Edit the text you previously typed, removing the space after the two forward slashes, so the text looks like this: http://some.domain.com
Select the text you just edited (all of it), and press Control-K.
Note that you now see the Insert Hyperlink dialog.

Apparently, Word is trying to verify your URL before opening the Insert Hyperlink dialog, and aborting when it runs into the problem with the incorrectly formatted URL. The good thing is that Word doesn’t crash outright. The bad thing is that it shouldn’t work . . .

→ Read More: A bug in Microsoft Word’s Insert Hyperlink feature