Weighted random selections in SQL Server

There are no built-in functions for selecting weighted averages in SQL Server. Fortunately it's a simple task to do so oneself.

Read the complete 1755 bytes...

Digg it | Kick it | Dzone it | Reddit


Automatically mapping datatable to objects

I often need to transfer data from my business layer to my presentation layers in a strongly typed way. In this example I'll use the following very struct and corresponding DataTable to represent the data I need to transfer:

Read the complete 3308 bytes...

Digg it | Kick it | Dzone it | Reddit


XmlDocument fluent interface

I do a lot of backend programming for Flash frontends. That basically means a lot of ASPX pages that simply return some XML and accept some incoming XML for parameters. Most of the UI logic ends up getting cluttered with manual XML stringbuilding, so I saw this as an obvious opportunity to play around with a fluent interfaces.

Read the complete 9230 bytes...

Digg it | Kick it | Dzone it | Reddit


Accessing my privates

Recently I was developing a couple of simple ORM classes that had me confused.

Read the complete 2541 bytes...

Digg it | Kick it | Dzone it | Reddit


Handling DBNulls

Reading and writing values to the DB has always been a bit cumbersome when you had to take care of nullable types and DBNull values. Here's a way to make it easy.

Read the complete 5431 bytes...

Digg it | Kick it | Dzone it | Reddit


Compiling Java in Visual Studio

I often see my fellow comp. sci. students writing their (relatively) simple Java code in applications like Emacs, Nano or Eclipse. I'm not fond of either application. I much prefer Visual Studios text handling, solution overview, output windows and so forth. What most people don't know is that you can actually extend Visual Studio to a great extent. One way to extend Visual Studio is to write plugins using .NET, but there's a way that is much simpler (albeit also more limited). I will now show how you can make Visual Studio compile and run your Java applications all within Visual Studio itself.

Read the complete 3355 bytes...

Digg it | Kick it | Dzone it | Reddit


JAOO 2007

I will be attending JAOO this year, I'm looking forward to a packed calendar in excitement:

Read the complete 627 bytes...

Digg it | Kick it | Dzone it | Reddit


Zune causing license resets?

I've had my Vista PC running for quite some months now without problems, as well as Adobe Acrobat Professional and Adobe Photoshop. But not anymore...

Read the complete 1277 bytes...

Digg it | Kick it | Dzone it | Reddit


Creating a .NET bootstrapped installer using NSIS

If you have ever deployed .NET windows applications, you have without doubt tried the Visual Studio Install project type. The Install project will create .MSI install applications for you, they're great for basic installations, but nothing more than that. The .NET bootstrapper is quite lacking, at times it won't be able to find the framework download file as it's changed it's location, at other times it's not able to download it. And finally, if it does determine that the user needs the framework, it's shown in an ugly uncustomizable GUI.

Read the complete 10751 bytes...

Digg it | Kick it | Dzone it | Reddit


Cascading windows

In Photoshop we often work with multiple windows open. They can be cascaded to more easily be able to view the different windows and tell them apart. There's an API function that does the same to any windows you specify, you can even define the rectangle where they should be cascaded within.

Read the complete 1751 bytes...

Digg it | Kick it | Dzone it | Reddit


Animating windows

Let's be a bit more graphic. This time I'll show you how to use the Windows API to make your forms fade in/out, slide in from the side or do various other animations. For this example we'll have to use a Windows Forms project as we have to utilize a Form object in the example.

Read the complete 2369 bytes...

Digg it | Kick it | Dzone it | Reddit


Activating windows

Now we'll see how to activate windows and sending them to the foreground. I will be using the WindowFinder class that I introduced in the blog Finding specific windows.

Read the complete 2420 bytes...

Digg it | Kick it | Dzone it | Reddit


Getting key state

Here's an example of how to retrieve the state of any keyboard key.

Read the complete 2718 bytes...

Digg it | Kick it | Dzone it | Reddit


Minimizing and maximizing windows

This time I will show how to maximize and minimize windows. I will be using the WindowFinder class that I introduced in the blog Finding specific windows.

Read the complete 2459 bytes...

Digg it | Kick it | Dzone it | Reddit


Modifying window location and size

Last time we saw how to obtain a windows location and size. This time I'll show how to change a windows size and location. I will be using the WindowFinder class that I introduced in the blog Finding specific windows.

Read the complete 2862 bytes...

Digg it | Kick it | Dzone it | Reddit


Getting window location and size

This time I'll show how to obtain the size and location of a window. I will be using the WindowFinder class that I introduced in the blog Finding specific windows.

Read the complete 4252 bytes...

Digg it | Kick it | Dzone it | Reddit


Finding specific windows

Last time I made an example of how to enumerate windows. This time I present to you a class that greatly simplifies the process of searching for specific windows, types of windows, windows belonging to a specific process, having a specific text. You can search for any number of these parameters at the same time, using regular expressions for all string matches to provide optimal flexibility.

Read the complete 7688 bytes...

Digg it | Kick it | Dzone it | Reddit


Enumerating windows

Until now we've seen how to retrieve basic properties of windows as well as how to interact with them by sending keypresses. Up until now we've had to find the handle by using Winspector or a similar program. This time I'll present a way of finding the handles programmatically.

Read the complete 3973 bytes...

Digg it | Kick it | Dzone it | Reddit


Sending keypresses to a window

Now to complete the toolset required to make a great spyware / browser hijacking application, we'll make Internet Explorer navigate to the address we set.

Read the complete 2149 bytes...

Digg it | Kick it | Dzone it | Reddit


Set text by handle

This time we won't be reading the text from a window, we'll be setting it.

Read the complete 1377 bytes...

Digg it | Kick it | Dzone it | Reddit


Getting text from handle

This time we want to retrieve the text from a given window, represented by a handle. Like last time, open an Internet Explorer instance. Now open Winspector and select the address field, ensure that it is the address field itself (class = Edit) and not the ComboBox that you select.

Read the complete 2705 bytes...

Digg it | Kick it | Dzone it | Reddit


Getting a process from a handle

So we have a handle, what process does it belong to? Our goal is to obtain a .NET System.Diagnostics.Process object that corresponds to the owner process of the handle we input.

Read the complete 1842 bytes...

Digg it | Kick it | Dzone it | Reddit


The basics

First of all, to manipulate and use the Win32 API, we must know about the system itself, the windows, the controls and so forth. Visual Studio comes bundled with Spy++ which enables us to identity the various windows and controls of application, but honestly, it's pretty bad. Instead you should download Winspector.

Read the complete 1600 bytes...

Digg it | Kick it | Dzone it | Reddit


Dedicated to the API

Unfortunately it's been quite silent around here for the last couple of months. I want to change that, so why not make a promise?

Read the complete 668 bytes...

Digg it | Kick it | Dzone it | Reddit


Turning the world upside down

So, tell me, do you notice anything unusual in the picture below?

Read the complete 2123 bytes...

Digg it | Kick it | Dzone it | Reddit


Car fire :(

Boy am I glad I've got my baby insured, guess I'll need it now :(

Read the complete 131 bytes...

Digg it | Kick it | Dzone it | Reddit


UML Love

I was asked to make a graph of my most recent relationship, what other way is there to express oneself than UML?

Read the complete 196 bytes...

Digg it | Kick it | Dzone it | Reddit


Audi TT

I've been asked quite a lot of times why I hadn't put up any pictures of my new ride yet. There's still a couple of things missing such as the Audi logos for the rims, at least I got the alarms installed yesterday, this is now officially the most secure car in Denmark, sporting a Viper 5000XL, Cobra CONNEX GPS/GSM tracker and a Credex VGS MK-III smoke machine :D

Read the complete 489 bytes...

Digg it | Kick it | Dzone it | Reddit


$6.000 an hour

First off, let me give you the good news. I just bought a new car. A '2000 Audi TT 1,8T to be precise. The bad news however is that I'm 21 years old, only got about one and a half years seniority and at last, I'm male. Those three properties make up for a worst case scenario for any insurance application form. Anyways, here's a chronological list of the insurance companies I called and their reponses:

Read the complete 2200 bytes...

Digg it | Kick it | Dzone it | Reddit


CES 2007 Pictures

A series of pictures I took at the 2007 CES show.

Read the complete 2065 bytes...

Digg it | Kick it | Dzone it | Reddit


One mans sin, another mans blessing

This is a reply to the Top 5 sins of Vista blog post written by Steve Wiseman.

Read the complete 4271 bytes...

Digg it | Kick it | Dzone it | Reddit


Playing at Caesars Palace

One of the few places left that I haven't played at is Caesars Palace. Fortunately I can now cross Caesars off my list.

Read the complete 1346 bytes...

Digg it | Kick it | Dzone it | Reddit


Royal flush baby!

I wanted to log a lot of poker playing hours today. At about 12 PM I went to the MGM Grand, a room that I'd never visited. After playing there for about 5-6 hours (please don't ask how it went, I got butchered), I've got mixed feelings about the room.

Read the complete 2995 bytes...

Digg it | Kick it | Dzone it | Reddit


Day 1

Since I woke up at 6 AM this morning I decided to just stay in bed and watch The Prestige through the hotel movie system.

Read the complete 1282 bytes...

Digg it | Kick it | Dzone it | Reddit


Arriving in Vegas

Honeeey, I'm home!

Read the complete 3174 bytes...

Digg it | Kick it | Dzone it | Reddit