Junk Drawer – A quick and finally simple way to import misc data into SQL

Dale Newman’s post on Junk Drawer caught my eye and I put it on my To Read list (basically one of my browser tabs, mocking me until I got to it). I finally took time to read it and boy am I glad I did.

This definitely goes into my Bat Utility Belt of dev/dba tools. 🙂

Frequently I need to throw some data into SQL to query against, join against production data, etc, for instance when someone from another department throws a spreadsheet of staff at me and asks if I can add their email addresses. A quick join against our export of Active Directory and away I go.

However, getting this data into SQL is usually a mind numbing dance using the SQL Import Wizard, fretting that I’ll get a truncation error or assigning a column as an Int when clearly there was a single row on line 1765 that happened to have a decimal point. Ugh.

Junk Drawer is a tool that any of us should have thought of, and probably did, but Dale actually created. The article was a real pleasure to read. Dale is a fun and true programmer in that “good” techniques like dependency injection just don’t always make it into one-off toolbox tools. It’s the perfect mix of humor and real-world practicality.

Thanks Dale! If you ever quickly import misc data into SQL you own it to your sanity to check this out. 🙂

How to Create Great Rounded Corners on Images with an Alpha Mask and Paint.Net

For a recent website I was working on I wanted to have some nice looking rounded borders for the main body of the page and some of the images.  Since I’m an avid jQuery user it was a no-brainer to use the jquery.corner plugin.  It looks great and works across multiple browsers.  It defaults to using more modern CSS styles for newer browsers but falls back on some neat tricks for older browsers.

Unfortunately the tricks don’t always come out perfect and some users with older browsers complained the image corners were “jaggy”. Rather than tell any users they need a newer browser I decided to make it look nice without the hack, by actually creating images with rounded corners. Yeah, we’re still in the early 2000’s sometimes. Smile

Paint.Net is a great tool that meets many of the needs for web developers.  Naturally this was my first stop.  There are several great tutorials for corners and even some nice plug-ins already created, however, none of them seemed simple or did what I wanted.

For instance, here’s a great tutorial from Micah Sewell on manually creating rounded corners but, unfortunately, it forces you to use the rounded rectangle tool, which has no options for changing the corner size or getting it positioned exactly, nor does the process described create antialiased corners, an absolute must.

Here’s a great plugin by Tim Mathais for creating rounded rectangles for things like buttons, but this doesn’t work on an image that already has a background.

What I would rather do is draw upon the power of alpha masks.  If you don’t know what these are take a look at this great Wikipedia article.  In essence you use a grayscale image to change portions of your desired image opaque or transparent.  If you have a grayscale gradient from the top to the bottom and apply it as an alpha mask to your image your image will go from opaque to transparent from the top to the bottom or vice-versa.

Using Tim’s plugin and the Alpha Mask Import Plugin we can get exactly what we want: user customizable rounded corners on images with antialiasing.  Tim’s plugin allows great control over your borders and the coloring used for the mask.  The Alpha Mask plugin allows great easy features like pulling in the mask from the clipboard rather than having to save it first, which is exactly what we’ll do.

To do this simply:

  1. Load the Rounded Rectangles and Alpha Mask Import plugins into Paint.Net.
  2. Open your desired image in Paint.Net.
  3. Create a new layer and switch to that layer for drawing.
  4. Using the Rounded Rectangle plugin create a new rectangle with your desires properties.  To make this an alpha mask it needs to be grayscale so make sure you don’t use color.
  5. This should place a rectangle with your desired settings on the second layer.  My rectangle is simply black with with a radius of 20 and antialiased.
    test mask2
  6. Select the entire layer and copy it to the clipboard.  Now that the mask is in memory you can either delete the mask layer or simply hide it.  I sometimes make mistakes and hate redoing work so I just hide mine until I am sure that I’ve got what I need.
  7. Now, on your original image simply use the Alpha Mask plugin and it will default to pulling the mask you copied into the clipboard.  You may need to check the Invert Mask option depending on how you created the mask:
  8. Hit OK and you’re all set with great results!  This process only takes a few seconds once you get it down and it is very customizable. 
    test mask

Enjoy! Winking smile

A Quick Script to Help Update Your Current Student Photos in Destiny from Aeries

At my district we use Aeries, our Student Information System from Eagle Software.  We also use Destiny, our district-wide library system from Follett Software.  Both are great products and, better yet, both are housed on our Microsoft SQL Servers.  This allows us another level of integration since we can get to the raw database for various needs.

One way we take advantage of this is how we load our student photos into Destiny.  Destiny takes a zip file, which contains jpeg files of the students as well as a idlink.txt file, which is an index file that ties the jpeg to the student’s record.

I’m subscribed to the Follett Talk list serve, which is an email list that several Follett Destiny administrators are a part of and every day there are great discussions and help from various users around the country.

When I mentioned that we had a script to help out when updating student photos in Destiny, several were interested .  I’ve been trying to write up a formal blog post on this with great screenshots and directions but, alas, I haven’t had the time.

Anyway, one of our neighboring libraries politely called me about it this morning and I thought I should just put it out there as is for anyone who can use it.

The SQL script file and a quick documentation document are attached to this post.  Get them below.

What it does is grab all the photos (from the school sites you designate) from the server you store your Aeries photos on (this used to be our ABI server but is now our Aeries.Net server), generates the idlink.txt file and puts them all in a zip file for you.  Since it pulls the photos straight from the information in Aeries and also generates the idlink.txt automatically I always get the latest photos (such as from a picture makeup day or newly enrolled students) and also any corrections that may have been put into Aeries.

The script runs in less than a minute for our entire district and then I have a nice easy zip file to upload to Destiny.

There is a little documentation attached but whomever will do this procedure at your site will need some foundational knowledge of Aeries and SQL.  This is not for a librarian at a site that does not have knowledge/access to the Aeries server.

This does not write to any data in the Aeries database so there is no harm in running it.  If there is an error in the script (for instance, you forgot to add your proper school sites and server name) it will simply give you an error but will not cause any changes to data, so don’t worry. 

I hope this helps!

P.S. For those of you who also use BlueBear I had two extra lines of code on the script.  We use BlueBear as our ASB accounting system for our high schools.  It takes photos in the same way but needs them unzipped, all just stored in a single folder.  The last line in my script would unzip the results from above into a folder per school site for our high schools.  This way I would just run the Student Photo Update process in BlueBear and point it at the folder for the correct site.

If you have BlueBear here are the two extra lines I use:
print ‘ECHO Extracting photos for Blue Bear…’
select distinct ‘”c:Program Files7-Zip7z.exe” e c:pics’ + cast(stu.sc as varchar) + ‘Pics.zip -oc:pics’ + cast(stu.sc as varchar) + ‘  >nul 2>&1’
from stu
join #pics on (stu.sc = #pics.sc and stu.bm = #pics.shortname)
where del = ” and tg = ” and bm <> ”
and stu.sc in (310, 320, 410, 430)

Destiny Student Photo Import Quick Documentation

Student Photo Queries.sql

Visual Studio JavaScript & CSS Outlining

Sometimes it’s the little tools that really make your day.


I finally got fed up with my growing JavaScript files and thought it would be great if Visual Studio allowed me to collapse functions just like it does with c# and other source files.  So I did a Google search.


Well, Velio Ivanov created a great little Add on that does just this and for CSS too!  Thanks Velio!!!


Check it out: http://jsoutlining.codeplex.com/

KeyNote on the iPad–A pleasure to use and a touch interface done right

Recently I’ve started using an iPad 2 in my work environment and I’ve been doing a few presentations about it.  So I was on the hunt for a decent presentation software.  I just picked up KeyNote on the iPad and I have to say I love it.  So much that I had to blog about it, and that’s saying a lot. Smile

KeyNote is a touch app done right.  There is a discussion going on that touch devices should have a touch O/S and a point and click device should have a point and click UI, and very rarely should they actually be merged.  That’s one reason why Windows on an iPad has never really worked and probably never will unless Windows 8 changes the game.

KeyNote is an example of a great app that is designed with the iPad as the only device it is intended for.  The entire interface is based on the touch/swipe model of the iPad, of course.  The UI is very intuitive and very easy to use .  All the interactions make perfect sense and are very easy to use, including adding images, sizing, rotating, adding animation effects, etc.  I’m amazed at the power of the editor while still being a simple touch device.

It’s nice being able to create presentations on the fly with it.  Had I not had Internet access when I was at the Ontario airport I would have been severely hampered when trying to create a recent iPad presentation on the fly.  Had I had KeyNote it would have been a snap other than the graphics I downloaded from Google Images.

I’ll be using KeyNote for the majority of my presentations from now on.  I’ll probably spring for the $0.99 KeyNote presenter remote app that allows me to control the presentation from my iPhone along with viewing what slide I’m on and the presentation notes.

It is just such a pleasure to use an app that blows away all expectations of the iPad and just makes perfect sense.  KeyNote hits the ball out of the park. I know it sounds like I’m an Apple fan boy but believe me, this app deserves it.

Adding a group of computers to an AD Group using PowerShell

PowerShell is a lot of fun but I don’t always get to play with it.  Anytime I have to do large tasks that move a lot of simple data or AD type tasks then I’ll sometimes pull it out.

Recently we installed Windows 7 across our district.  During that process we renamed all the computers because our old naming convention wasn’t always followed and it created a lot of confusion and inconsistency.

All our library staff computers have a special application that allows them to download barcodes that are read using a handheld barcode scanner for inventories.  This previously was pushed out by a group policy.  Since the computers were erased during the Win7 install and the computer names had changed we had about 25 computers that needed to be added to the group again.

Sounds like a perfect chore for PowerShell.

First of all, I forgot the name of the group that they needed to be added to, but I knew it had “dolphin” in the name, since that is the name of the software.  Active Directory Users and Computers (ADUC) won’t let you search on a portion of the name, just the beginning or the end.  Not much help there.

PowerShell makes this trivial:

Get-ADGroup -filter {name -like "*dolph*"}

This returned the following:

DistinguishedName : CN=g-InstallLibraryDolphin,OU=Computer,OU=Software Install,DC=valverde,DC=edu
GroupCategory     : Security
GroupScope        : Global
Name              : g-InstallLibraryDolphin
ObjectClass       : group
ObjectGUID        : 0909537b-ddcc-41c1-bd37-667fdb943a95
SamAccountName    : g-InstallLibraryDolphin
SID               : S-1-5-21-1659004503-746137067-682003330-69446

That’s the one!

Our naming convention for or library computers is wXX-Library, where XX is the two character code for the school the computer is at.  However, simply filtering on this wouldn’t help, because we name all our library student computers as follows: wXX-LibrarySYY, where YY is simply a number stating at 01 and goes up for however many student computers are in the library.

So, here is the PowerShell command that stores all our library staff computers into a $libcomps variable, excluding the student machines:

$libcomps = Get-ADComputer -filter {name -like "*library*" -and name -notlike "*libraryS*"}

Since you cannot pipe computer objects straight into the Add-ADGroupMember commandlet (why, I have no idea but it doesn’t make sense to me) you have to iterate over the $libcomps collection and add them one by one:

foreach ($c in $libcomps) {Add-ADGroupMember g-InstallLibraryDolphin -Members $c}

The command ran for about .25 seconds and did all the work for me.  I think researching the right commands to use took about 2 minutes, which is still faster than had I had to move them all over one by one. 

Heck, this post took longer than the entire task all together. Smile

Microsoft Surface 2 with PixelSense

This is just amazing stuff.  When Microsoft Surface first came out you knew this was opening the door to the future.  All the flashy futuristic movies where video screens are interactive and everywhere, tables, walls, etc are now coming to reality.

With Surface 2 they have really taken a huge leap forward.  Now they are using LCD screens with what they call PixelSense technology.  Along with R, G and B pixels there is now a fourth pixel that can detect in the infrared range.  The LCD screen actually can detect the objects on the table.

What this does is change the older hardware with complex projectors, cameras and sensors into a sleek tabletop design.

Just to give you an idea here is what the original Surface typically looked like:

The large enclosed portion below the glass is actually hiding the set of projectors and cameras along with the computer hardware.

Now, with most of the complex sensing technology actually built into the LCD they can now produce tables that look like this:

I’ve seen Microsoft Surface products built into the wall at fancy hotels or casinos in Las Vegas.  Now we’ll start seeing a lot more of these pop up everywhere.

It’s an amazing time to be alive! Smile

The Real Debate About Gaming in the Cloud and the Future of Technology

Toms Hardware has a lot of great tech news every day.  This one caught my eye from a gaming cloud vendor talking about where gaming was going.  Here’s a hint, he thinks it’s going to the cloud. Smile

I’m really surprised at a lot of the comments about the article. In fact, I was hard pressed to find a single optimistic one.

A good percentage of the arguments seem to be that "games" should be physical media that you can buy in a store and touch. That’s the same argument music providers and purchasers were pushing 10 years ago. Now if you want to actually visit a store to browse and purchase a CD it’s more because you’re a purist or you want to take a walk in "simpler times". If I hear a song I like and actually want to buy it I don’t think twice about going to my favorite online provider and downloading it to my phone. In fact I love the convenience, speed and knowing that that purchase is mine no matter what happens to my phone. There is no physical medium to break or lose.

Other arguments seem to think that bandwidth is too slow/inaccessible/expensive/capped/et and set in stone. Bandwidth will always get faster and more accessible. I know that right now there are arguments at the cost, ISP caps, geographical limitations, but these have always been the same issues in one form or another. ~15 years ago (I’m 34) I was downloading at 2400bps. 10 years ago ISPs were having wars as to which 56k bps technology was to be used. DSL and Cable then started fighting it out and the government was being lobbied as to whether telco companies should be allowed in the entertainment medium (because Internet was seen as serving video and other "TV killers") or whether cable companies should be allowed in the telecommunications medium (because Internet was seen as communication and "telco killers"). Meanwhile computers have been getting faster and mobile devices smaller/more capable. In the end, 10 years from now communication methods will be much faster and potentially very different, but I’m sure there will be similar "debates" going on.

Another set of arguments seem to be geared towards real games are only fit on consoles or high end desktops. I really don’t know why the gaming genre constantly has to be fit into a small space. Already gaming is on a variety of platforms in variety of forms from simple little text games on old cell phones to Crysis II on a $4,000 gaming rig. The gaming platform as a whole is already incredibly broad and it won’t be getting any smaller.

The real argument in this article is where are high-end games going. Again, I don’t think it matters what one guy (who obviously wants to promote his company and that’s what marketing is, don’t be surprised or offended) thinks about where gaming is going.

In my personal opinion (because hopefully much of the above was objective 🙂 ) I have no problem with another company attempting to push gaming into the cloud with an alternative publishing platform. If I don’t like it I don’t have to use it. No big deal.

However, the potential is actually quite amazing and simply mirrors what other industries have done (i.e. music purchases/distribution and now movie subscription/distribution). I’ll just use the Microsoft XNA platform as an example. Potentially (not yet but potentially) the XNA platform can run on the XBOX, PC, Silverlight and a Windows Phone 7. If Microsoft can take this to the ultimate end then why can’t I subscribe or purchase a game online and play it on my XBOX when I’m at home on my 50" LCD and play it on my laptop or enthusiast PC when I want, then play it online within my Silverlight hardware accelerated browser and finally pop in for a few minutes on my dual-core (or whatever in the future) WP7 phone? I purchased or subscribed to the game and have four platforms. I think the argument in the future would be "what do you mean you’re going to sell me a game on a single DVD and not let me play it on any device I want?"

Right now if I buy a song I would expect to be able to play it on any of my devices in any location I’m at and it would infringe on my right as a customer to be told I can’t play it on my phone and my stereo at home and in my car or on my computer at work. We only allow gaming companies to do this because the current technology doesn’t allow me to move Crysis to my phone as easily as a song. Technology will one day make that available and I fully expect to be able to one day buy/subscribe to a game once and play it on any device I choose to because it’s my game/subscription and my devices.

Heck, I expect that one day bandwidth will be fast enough and $500 PCs will be fast enough that I can travel to another country, take photos, go into an Internet cafe (or just use my phone), upload photos to my online account, retouch them and edit video, make them available to family and friends, and even play a WoW (or whatever) for a little bit all without having to carry around a laptop.

That’s where I think we’re going.

Making F1 Do Something Useful in Visual Studio

Have you ever wished that hitting the F1 key in Visual Studio actually returned good search results in a quick manner? 

Personally I think the F1 key returns decent results, but there certainly are a lot out there who don’t.  I mostly work in .Net so I’m in the camp of users that F1 works well for.

The think I really don’t like though is the 30 seconds or so it takes to launch the help window.  Once you’re there navigation is pretty painful.

For the last several years I’ve all but abandoned F1 and just search Google with “msdn” and my search term.  95% of the time this returns exactly what I want in the first hit.

Wouldn’t it be nice if we could make Visual Studio do this for us?  Well, we can, and have been able to for years!

Check out OriginalGriff’s solution on Code Project.  He clearly outlines the steps and I have to say his solution is quite nice and tidy.

However, I had two very minor criticism, purely for my own tastes.  This solution opens the webpage inside of Visual Studio’s web browser inside the IDE.  This works, but I really like using my own default browser (currently Chrome).  This allows me to open up various hits in several tabs and bookmark interesting solutions.  I can’t do that in the VS browser window.

Second is it grabs the selected text and performs the search on this.  If you don’t select anything it just opens up a search for “msdn”.  The original F1 functionality use to search whatever word your text cursor was on, nothing had to be selected.  I’m lazy and I like this ability.

Last, but not least, as I was writing this blog post and stated above that 95% of the time my search term came up in the first result it hit me. OMG If I think that what I want will be my first hit, why not just return Google’s first result; the equivalent of hitting the older I’m Feeling Lucky button on Google’s home page. If you look at Griff’s solution you will see below it that I proposed an alternate solution that adds these three features.  Now, when I hit F1 or Shift+F1 I, respectively, get the Google search or the first hit directly.