This tool, I've created takes the data of the IP ranges for each country shared by http://www.nirsoft.net/countryip/index.html and stores it in a SQL Server database, so later you can query it.

To use it you need to add App.config file based on included App.config.sample. Add there your connection string to SQL Server database, and the desired table name. Those are the steps the tool executes:

  • Drops the table if exists
  • Creates table and all the required indices
  • Gets the CSV file for each country from http://www.nirsoft.net/
  • Turns the IP records of each CSV file into INSERT SQL statements
  • Executes the inserts into the SQL database

I tried the same code as parallel and sequential to compare performance. The results are as follow:

Continued...

Here I would like to share a data structure that I use for navigation in 3D space of a game. In essence it is a binary tree build out of linked lists.

It attempts to combine best of the two worlds 1.Linked Lists and 2.Binary Trees. So you can find a specific item in log(n) time or explore near by items in n time. This is very useful in a game where you always need to know what is near the camera, but once in a while you have to find a specific object. Below you can see the basic schema of the structure:

This pictures only one single dimension. In a game I use three dimensions but the structure allows N dimensions.

Continued...

This is C# implementation for efficient calculation of the median from a continuous stream of numbers.

One way to do that would be to use two heaps. One max heap on the left and one min heap on the right. In the middle will be our median value. When inserting new value we will make sure that the numbers on the left and on the right are the same. Below is a picture of how it would look:

heaps

And here is the implementation: Source Code in C#

Continued...