This blog entry is based on Siraj Raval's YouTube video called Build a Neural Net in 4 Minutes

I translated the python code there into C# on this github page. The code is written as test but you can easily turn it into command line by moving the code from Run method into the Main static method of console application.

While the python code involves implicit matrix operations that are happening in hidden black boxes in this example all the matrix logic is implemented as extension methods and are on the same page in a static class named SimpleNeuralNetExtensions


Web API vs ServiceStack

In this blog post I will examine the claim made in a twit by Anil Mujagić. The claim is that ServiceStack is 3 times faster than Web Api. It is backed by test project These are the results of that test:


Here you can find a WPF app with a click once deployment. I use Roslyn script engine to turn C# code into function that is being graphed on a canvas.

This is how a common output looks:

For example you can write something like:




OR something more complex like:


If you need to execute some long running task on the background in Unity, you may find this tool I just wrote, useful. This is BackgroundWorker for Unity 3D

BackGround Worker for Unity3D

You will only need the class BackgroundWorker

It worth noting that a lot of seemingly background tasks can be implemented with Unity Coroutines. For example using WWW service to send or receive data from a remote server. Or any case where we just wait for a response from a remote computer.


This tool, I've created takes the data of the IP ranges for each country shared by 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
  • 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:


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.


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:


And here is the implementation: Source Code in C#


Frog Fu is iOS game written on C++ with OpenGL 2 now available as open source project on GitHub

You can find it on the App Store at:

Please review and rate it!

Here is an open source tool we developed at Move.

You can also find it in Nuget repository

The tool takes an existing object and wraps it in interface able to implement this object. For example if you would like to wrap HttpRequest in an interface that you can later pass to your business objects and mock in your tests.

This is how you would use it:


This is one application I have developed for WP7. It is a map of the night sky and at the same time a three dimensional map of the nearest stars. You can switch between a view from the Earth and a Space view of the nearest stars. A 3D view of the solar system is coming soon. This is a link to the Windows Phone Marketplace:

The website for the project is

A short introductory video can be found on YouTube at and also another one at


When working with XNA on XBox 360 or Windows Phone 7 you have to register each font used in a sprite font file. You can just define there a big range that would ensure that the Unicode characters you use will be within, but that would increase the file size. The best option would be to only use the character ranges you need.

Here I would like to present a free open source Silverlight tool that you can use to determine the exact regions you need to include:

Just drag and drop your text file onto the screen. Your file will not be sent to a server, the code is completely client side. On the left side you will see characters regions XML that can be copied and pasted into your XNA font sprite. The right side pane shows visually what characters are included in each range sequence.


My latest work is this Silverlight control for discovering and visualizing the difference between two text files or just two strings that you copy and paste. You can choose files either by clicking on the file buttons and selecting them from the file dialogue or you can just drag and drop them in the boxes.

Demo is available here:

Unlike my previous post at where I just wanted to prove the concept that it is possible to implement the Longest Common Subsequence Algorithm in JavaScript, this app is optimized and capable to handle much bigger strings. It also can work with files.


When we use SqlCommand with a set of parameters, they are being executed as a parametrized query. You may or may not pass the desired type with each SqlParameter. If you do not specify desired database type it will be determined by the ADO provider, but you will not know what the actual SQL type is. Below I provide a code that will give you the actual parameters. This code can also help you find out what the actual SQL query executed in the database is.


This is a tool for finding the differences between two text files and in particular finding what parts have been edited, deleted or added. It implements one of the algorithms for finding the Longest Common Subsequence between to data sources.

You can see a demo at:

The main idea of this algorithm is to build a matrix with rows – future state, and columns – previous state. This matrix will consist of squares incorporated one into the other as steps in a stairway. The path of following those steps from the top left corner to the right bottom corner determines the actual graph. Moves to the right are deletes, to the bottom – inserts. Inserts followed by deletes are changes.


I would like to show you a project I was working on recently, involving Microsoft Robotics Developer Studio and Lego NXT 2.0 Mindstorms robot. It consists of a DSS service that controls the robot and a WPF application that draws the current state of the sensors of the robot on the screen.

This is a link to an article that I wrote about this project: Using Microsoft Robotics Developer Studio with Lego Mindstorms NXT Robot

The code is written in C# as DSS Service within MRDS. The complete source code can be found at


We are all familiar with using the embedded code block in the MVC framework views. They give us a powerful way to implement the functionality of the views without removing the separation between code and UI. One of the most common use is for generating UI of different controls through the use of HTML helpers.

But there is one significant limitation of that approach. All the code defined in a common embedded code block will be executed during the render stage of the page execution cycle.

But what if you had the following scenario: you register different css files in different parts of the view. Perhaps in different partial views and then you print them in the header section on top of the page. Something that would look like that:


This is one Silverlight 4 control I wanted to share. It extends the RichTextBox control in a way to add coloring of HTML and XML tags. The tags are colored as you type. I am planning also to add intellisense. It also has right click menu with Cut, Copy and Paste options for now but more can be added including custom links, activated by contextual position. Below you can see how a typical HTML looks when formatted:

This is the link to a demo page:

And here you can find the complete source code:

In the source code you will also see a full set of tests. To see the tests when you load the project go to the /Tests folder of the project web site.


This is one tool I wanted to develop for quite a while but I was never able to find the time for this, until this weekend when I finally got it done.

This is a 3D map of the nearest stars within 16 light years from the earth. There are some tools like that online but non is showing the stars in relationship to some known constellations. I wanted to see the nearest stars as 3D but also placed in a way so if I go out at night I can picture those stars in their right positions, even though most of them are not visible with the naked eye, but at least I can visualize them in their real positions.


Visual software development through diagrams and other visualizations was a dream that persisted for a long time in IT, but never came true for any software platform. Yes it is true that UI design or database modelling can be very visual these days but the main bulk of any serious software project remains as of this day primarily text based. There are many reasons for that, but I don't want to discuss them here. Instead I want to express my opinion that despite the apparent lack of progress in this area, the visual expression of any abstract concept for most people makes it much more easier to grasp. So perhaps we should make more steps in that direction, even if we cannot turn the whole programming into a visual work yet.


I was playing the other day with some equations and thinking about how I was taught the logarithmic function back in school and how we usually think about it these days. And correct me if I am wrong but I can't remember a case when this concept was introduced in a some kind of visual way. The most visual thing I've ever seen about it was a graph of the logarithmic function – the well known curve. And may be you would say, this is because there is nothing visual about the logarithmic function per se. May be it is a purely mathematical concept, having nothing to do with visualizations.


This is a WPF control I just put on CodePlex that implements the basic functionality for a source code editor.

You define it in the XAML with something like this (of course after you put the assembly com.bodurov.WpfControls.SourceCodeEditor.dll in your bin folder):



This is one C# tool that I want to share. It can be used for extracting a portion of an HTML code without cutting the HTML tags in half or leaving unclosed tags. It also allows to measure the length of the extracted part in number of letters, words, sentences, closed HTML tags, closed P tags, closed DIV tags and closed P or DIV. When counting the number of letters or words, those contained within the HTML tags are not considered.

If you have some content stored as HTML in a database, or if you want to summarize an HTML page residing on a remote server you have to be able to extract a certain number of words or letters without considering the HTML tags them self and without leaving unclosed HTML tags. This is the exact tool for this kind of scenario.


This is a short You Tube video I made last month, to visualize the Quick Sort sorting algorithm. As you all know this is one of the most efficient algorithms for sorting data. There are many implementations of that algorithm so this is just one of them.

The basic idea of quicksort is to choose one element that we call pivot, and to place all the elements lower that the pivot on the left side and all the elements higher than the pivot on the right side. This way the pivot is placed on the right place and we repeat the same procedure for the two remaining sub lists and so on recursively until we have the entire list sorted.


The main idea of the Unity Framework is to give us the ability to quickly replace different parts of big application without having to recompile or re-factor our code. Ideally that means adding another assembly to the bin folder or GAC, and certainly that is the right way to add new providers or class implementations. But sometimes you may want to quickly script a provider in order to test a new idea on your staging server or debug a problem without having to deal with all the hassle of adding a new assembly.

Well, the first idea that comes to my mind is to use a class defined in the App_Code folder. The class will be recompiled each time there is a change in the source file so this seems as a perfect candidate for a quick test. But there is one problem. The assemblies for the classes in App_Code folder are dynamic and so we don't know what their name is, and because of that we cannot set the right class reference in the configuration file.


A common problem for a .NET project is that after deploying a DLL into the bin folder or as a matter of fact doing any change in the bin folder of a web site all the data for any of the current in process sessions is lost. The same happens if we change the web.config file.

In some cases it makes sense to be so, for example if we store in the session objects that are being changed by the current deployment of a new DLL. But in many other cases it is rather a disturbing frustrating side effect that we want to avoid.


If you need to serialize your business objects into XML you may also need to generate automatically XML Schema so you can check the XML against that schema before try to deserialize it. This is one utility that will do that for you. Now, let’s first see one utility that will do basic XML serialization and deserialization objects.


Very often we have a scale of values that can be generalized and described as a real number within the range of 0 and 1, 0 being the lowest value and 1 being the highest. For example if we are building an airplane with highest possible altitude of 5 miles we can represent the current altitude with a number from 0 to 1, in this case 0 will represent the plane on the ground and 1 on it’s highest altitude of 5 miles. This may be useful in many different situations, for example if you show this value to a person or instrument that is not familiar with the specific value but can understand the idea of minimum and maximum of this value. Another useful scenario would be in you want to represent this value in a diagram, arranging it from 0 to 1 makes it easy to plot on a surface of any size.


Here I want to describe the steps you can use to search for database performance bottlenecks before you deploy your web application to production server.

1. Modify Fiddler Rules

We want to add to Fiddler the option that would allow us to execute a sequence of requests and then tell it to repeat the same sequence N number of times.

First of all if you don’t have Fiddler yet, install the latest version from then start it and go to Rules - Customize Rules…


I would like to present here one tool I have developed recently for visualizing vectors in three dimensions. The tool allowes not only to view vectors but also to share them with others. Check the "link to current vectors" for that.

You can view it only by visiting URL:

The tool is build from scratch and does not use any 3D engine. In fact it includes a very simple light weight 3D engine for drawing lines in 3D. For the platform I chose Silverlight under C# as I find .NET to be the best coding environment.

If you want to dive deeper into the concepts that this tool is based on you can check my Simple Talk article at


Web service proxies for asmx web services are quite annoying. They are supposed to represent the contract between the service and the client and without any doubt there should be such a contract. But in reality they represent not only the contract between the service and the client but also the tool that generates them. And they make you vulnerable to any inefficiencies of that tool. Do you like to be dependant in such a way?

Well, fortunately WCF offers much better approach. The contract between the service and the client is represented by an interface decorated with the right attributes. That is all you need for the contract between the client and the server. There is no third party involved and everything is clear. I like that.

Here is an example of a wrapper around the WCF client.