UPDATE
After testing my code through based on JP’s comments, I’ve realized my implementation was way too naïve and cannot be used for most datasets. For a correct weighted random implementation, see Dems’ answer on StackOverflow.
After testing my code through based on JP’s comments, I’ve realized my implementation was way too naïve and cannot be used for most datasets. For a correct weighted random implementation, see Dems’ answer on StackOverflow.
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:
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.
Recently I was developing a couple of simple ORM classes that had me confused.
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. Based on this post by Peter Johnson and this post by Adam Anderson I gathered a couple of ideas and combined them to make a completely generic class that will handle DBNulls for both reads and writes, as well as handling nullable types. Let me present the code, I’ll go over it afterwards:
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.
I will be attending JAOO this year, I’m looking forward to a packed calendar in excitement:
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…
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.
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.
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.
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.
Here’s an example of how to retrieve the state of any keyboard key.
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.
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.
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.
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.
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.
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.
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.
This time we won’t be reading the text from a window, we’ll be setting it.
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.
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.
So, tell me, do you notice anything unusual in the picture below?
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?
Boy am I glad I’ve got my baby insured, guess I’ll need it now :(
I was asked to make a graph of my most recent relationship, what other way is there to express oneself than UML?
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
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:
A series of pictures I took at the 2007 CES show.
Microsoft didn’t exactly hide itself at the CES, you could see Vista icons, banners, stickers and posters everywhere!
This is a reply to the Top 5 sins of Vista blog post written by Steve Wiseman.
One of the few places left that I haven’t played at is Caesars Palace. Fortunately I can now cross Caesars off my list.
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.
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.
Honeeey, I’m home!
It’s good to be back. After all, it’s been about 4 months since I were here last, that’s simply too long time!