Skip navigation

Category Archives: .NET

I have an Ardunio lying around, currently they are not really doing anything (waiting for me to get off ass and order robotic goodness:) ).

As nice as it is to code them in the Ardunio IDE, it would be fun to code them in C#, so I could plug the sketches into other interesting things (currently I am intrested in using Touchless to control mobility robotics)

As it turns out there is a couple of things that allow me to do this:

Firmata.NET is a .NET implementation of the Firmata protocol.

Sharpdunio looks to be a slightly more verbose .NET implementation of the Firmata protocol.

PS: If you are in NZ and are looking to buy some Ardunio goodness for yourself, I would highly recommend Mindkits.

Yesterday I uploaded a project of mine that I have been using a while on various image manipulation projects and the like.

Basicly what it is a class libary with a couple handy things such as the RectangleHelpers class, this class allows one todo some handy things with rectangles, such as creating a system.drawing.rectangle class from two points.

The logical operators class does Boolean operations on images, I should point out that the code in that class is not mine, I can’t remember where I found it, I do remember it was in a article of code-project or similar.

the rest of the classes are fairly self descriptive.

Work continues on ItemDB(at a slowish speed, damned RL…), I have finally settled on a persitance mechanism that I am relitivly happy with (JSON based, More on that in a couple of posts).

While I was talking to roman about it the other day, I realised that I could be increadibly lazy and create a simple version of itemDB powered by SQL Server and LINQ2SQL, but for reasons of speed and wanting todo it right I have decided aganst it for now.

Of course if anybody is willing to lend a hand please flick me an email or something, this will be open source.

For a current project involving large amounts of unstructured and structured data, I needed a Key/Value style DB.

So after looking around at the current options nothing really suited my needs (.NET based, relatively small footprint, simple as pie) I decided to write one, it is [imaginatively] titled ItemDB and is sort of modeled after the way freebase store’s its data and my own views.

With ItemDB (currently in early stages of development) there are three main concepts to think about; Item, Fact, Relationship.

An Item is the main storage item in ItemDB (as an example let’s create an Item called Josh), with ItemDB this is the main thing we need to worry about.

A Fact is a bit of knowledge about the Item that its contained in (let’s add a Fact to the Item we created previously called age, we will set it to 21), Facts generally live in a FactCollection witch is the subject of a later post

A Relationship is well, a relationship between one fact and another (let’s add a relationship between Josh and Coke with a relationship type as FavoriteCaffineatedBeverage)

These three concepts should allow for incredibly complex capability

This would usually be the bit with a link to the current build of ItemDB or something along those line, but there is a problem with that, It’s not quite ready for its public showing (current lack of  persistence being a large part of that). Stay tuned

As per usual, Any questions leave a comment.

So in my effort to set free some of my useful code, today I am releasing a class called JHarris.RegexCollectioner.

I created this because I needed a class to check multiple regexs on a single string (its really increadibly trivial todo)

the code should be pritty self explanitory, but if you have any questions, feel free to ask

so heres the code:

using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace JHarris
public class RegexCollectioner
/// <summary>
/// Internal dictonary that holds the regexs
/// </summary>
Dictionary<string, string> m_RegexCollection = new Dictionary<string, string>();

/// <summary>
/// Adds a Regex to the collection
/// </summary>
/// <param name=”name”>the name of the regex</param>
/// <param name=”regex”>the regex</param>
public void addRegex(string name, string regex)
m_RegexCollection.Add(name, regex);

/// <summary>
/// Tests if a string matches a regex in the collection
/// </summary>
/// <param name=”input”>the string to test</param>
/// <returns>the name of the regex that works, if no regex is found to be a match, this function will return string.empty</returns>
public string FindRegex(string input)
string name = string.Empty;

foreach (KeyValuePair<string,string> rgx in m_RegexCollection)
if (Regex.IsMatch(input,rgx.Value))
name = rgx.Key;

return name;


So, Josh has been a bad blogger. And some things have popped up with a member of the family having terminal cancer, so yeah.

Anyways, on with the letting my code fly.

Today I am gonna get free a tool I created a while ago called Image ripper. The basic idea behind it is that somebody is having lunch or something with a client, and they start diagramming something on a napkin or other non suitable bit of paper and would like to get that into Visio or Word or something like that without redoing the diagram.

It’s a command line program, written in c#, full source is included (should be rather easy to understand).

The way you use it is (from the command line and in the directory the program is) ImageRipper.exe templatefilepath checkfilepath outputfilepath.

The first thing is the path to what I call the template image (I.E If the diagram is on a napkin, the template file would be a blank napkin).

The second argument is the path to the file to check (I.E the napkin or whatever that your diagram is on).

The last argument is the file that you want to be the output file, it will create it if the location doesn’t exist

so as an example ImageRipper.exe c:\images\templatefile.jpg c:\images\checkfile.jpg c:\images\output.jpg

The way it works is that It loads both images into separate System.Drawing.Bitmap classes and then comparing the images pixel-by-pixel, if the current check image pixel is different than the template image pixel, then it will add a pixel to the output images bitmap

Obviously this works best with scanned images.

Any Questions, feel free to leave a comment and I’ll get back to you as soon as I can.

Here’s the link.

As with all my apps that I set free, feel free to-do whatever you want with this, I’d like a email if you do anything cool with it commercially. If you blow up or have vomiting and nausea or anything else bad while using my software, I’m not responsible, so there mmmkay?

I Repeat: Do Not Listen to Your Users:  An interesting post from Jeff Atwood on users, nothing new but interesting none the less.

ASP.NET MVC Framework Scaffold Generator: Scaffolding for ASP.NET MVC!!

Alligator Tags: Like but for ASP.NET

Sriram Krishnan: Cacheman – a fast distributed hashtable for Windows
I’m gonna have to keep an eye on this. It looks seriously awesome.

Blogged with Flock

Tags: , , ,

Today, as I was coding away at one of my projects, I found myself writing the same code as I had written before, the code in question was producing a couple of html pages.

So I decided to turn it into a .NET  library, 20 minutes later [the imaginatively named] HTMLTools was born.

As with most of my personal projects, It has no XML documentation, it should be easy enough to understand and work with. To produce a simple web page with a heading, this is what you would write:

using Josh.HTMLTools.HTMLGeneration;

class Program
static void Main(string[] args)
List<IHtmlElement> elements = new List<IHtmlElement>();

elements.Add(new GenericHtmlElement(“h1”, “Hello world”));

HtmlPage page = new HtmlPage(“test”, elements);


This will also save the page as Test.html in your program’s working directory.

here is the download link.

(yes I do realise that SingleTagElementType is completely random and has no use, I was planning to implement a feature that I decided to leave out for this release, after I uploaded it to Assembla)

as with most of my programs, you are free to do whatever with it, just give me some credit if possible.

If you have any questions or anything, feel free to leave a comment or send me an email (jhektor %at% gmail _dot com)

Yesterday for some unknown reason I decided to have a play with the planet software (this is the software that I sort of ported to the .net stack with JRN).

For my Install I used the Venus build (download here), I did this because Venus uses a flat file db system that works better on Windows.

After around 10 minutes of playing around with the config file I was able to start it with a simple command (python Josh/config.ini for those playing at home).

And the I suddenly realized how planet manages to be so fast, it generates static HTML pages and outputs them into a folder (I know it said that on the planet homepage but old age is starting to get me…)

So after a bit of consideration, for the next 6-10 months I have decided to not do any development on JRN in order to get some new ideas and finish some of my [incredibly large amount of] unfinished projects and to also try and get planet working with IronPython.

Blogged with Flock

Tags: , ,