Blog moved to http://www.andrevdm.com/

Tuesday, 4 August 2009

.net REPL

I often want to test things quickly in .net without creating a new project. There are quite a few options.

REPL

Firstly the read-eval-print-loop options. These are great for quick tests.

Most of the dynamic languages have a REPL. Personally I use booish because I like the boo programming language. IronPython and IronRuby also have REPL. You can even run IronPython in your browser if you want.

The best C# REPL I’ve seen is gsharp from Mono. You can happily run Mono side by side with Microsoft’s .net frameworks. So there is no reason not to try this.


Compiling

For more complex tests a light weigh editor/compiler are useful. By far my favourite in this category is SciTE. SciTE is an incredible editor that will compile .cs files (and many others) out of the box. Just open a .cs, press F7 to compile and F5 to run. It can be configured to edit pretty much anything. Its light weigh, cross platform and it is free. IMO its an editor that every developer should take a look at.

Other options include Snippet Compiler which has a nice IDE and intellisense. Also take a look at Snippy, and the reflector snippy addin.

Wednesday, 15 April 2009

C# T-Tree

I have just created a T-Tree project on github: http://github.com/andrevdm/ttree/tree/master

“A T-tree is a balanced index tree data structure optimized for cases where both the index and the actual data are fully kept in memory, just as a B-tree is an index structure optimized for storage on block oriented external storage devices like hard disks. T-trees seek to gain the performance benefits of in-memory tree structures such as AVL trees while avoiding the large storage space overhead which is common to them.” (from wikipedia)

See also: Tobin J. Lehman and Michael J. Carey, A Study of Index Structures for Main Memory Database Management Systems. VLDB 1986 for a comprehensive discussion of T-Trees

The project is a C# implementation of a T-Tree. There is also a very simple command line profiler and a GUI for visualising inserts and deletes.

There are still a few things outstanding (e.g. Making the class enumerable and supporting the visitor pattern) but all the basics (insert, search and delete) are now working.

I'm sure that more can be done to speed up this implementation but it already performs very well. That coupled with the efficient use of memory makes it quite an attractive data structure.

A quick disclaimer: I have only just gotten the basics working I'm sure there are still some bugs lurking. I'll be doing more testing and adding more unit tests as I have time.

The code is released under the BSD licence.

Please let me know if you find it useful, spot any bugs or can think of way to improve it.

Friday, 27 March 2009

Visual Studio Dot Debugger Visualiser

Graphviz is amazing, I've never found a better or easier to use tool for generating graphs and data visualisation. The dot language is very easy to learn and the documentation is very good indeed. If you are doing any form of visualisation its worth taking a look at.

In the past I've used it for visualising compiler ASTs and data structures. (Which reminds me Jim Idle posted a nice ANTLR to dot conversion sample).

At the moment I'm working on a couple of data structures. Visualising them while developing the structures helps a great deal with spotting obvious errors and checking that things look as expected (yes I have unit tests too :). However it was a little inconvenient to have to keep writing the dot out to disk and generating the images manually.

Luckily Visual Studio supports visualisers and they are easy to write too. So I've just created a dot visualiser. My classes now have a ToDot() method which return a string. Whenever I want to visualise them I simply add a watch and select the dot visualiser. It could not be easier.

image

 

Download

VS 2008 Source code
VS 2008 Binaries

Installing the binaries

  1. Copy the binaries to your visualisers directory (%USERPROFILE%\Documents\Visual Studio 2008\Visualizers)
  2. Edit the config file and set the path to dot.exe

Disclaimer

I’ve not made much effort to make this visualiser robust. It helps me during debugging, that’s all.  works on my machine, starburst


Update: Thanks Riaan for spotting an horribly embarrassing  bug in the code :).

Friday, 13 June 2008

Species Browser

update 2009/01/01

[Warning! Abandonware: I am no longer developing/maintaining this application]


Introduction

Species Browser is a simple application for browsing information saved from the web. Both a desktop PC version and a Windows Mobile version are available. I wrote it for my own use but I'm releasing it here as you might also find it useful.

Species Browser browses information you have saved. It does not come with any of its own data.

Folders

For it to work you need to save your information one folder per species. In the picture below you can see the folder structure on my mobile phone.
Here you can see my plant folders. I have similar folders for fish and 'Other' which contains info on invertebrates etc. Each of these top level folders is referred to as a collection. You can setup whatever folder structure you want. I then have the exact same folder structure on my desktop machine.




Files

In the pic below you can see the files in one of these folders. The images are used for thumbnails. The saved web pages are displayed on the documents tab and the notes file is displayed on the main page.




The Windows Mobile Version


The pic above shows the main screen displaying information on Hygrophilia polysperma.

On the "Docs" tab you can view your saved web pages


The windows mobile version can only view htm and html pages. It can not display mht files. So if you are saving web pages with IE select "Webpage, complete" and not "Web archive".


Setup

Before you can start using the mobile app you need to setup your collections. I.E. you need to tell the app where to look for your files. To do this click on the "Menu", and select "Setup Collections"


You will then see the collection setup page. On this page you can create links to new collections and edit your existing collections.


To add a new collection

  1. Click on the "New Collection"
  2. Enter a name
  3. Click the browse button"..." and browse for the folder containing your collection

Selecting a collection

You can now select a collection from the main menu


Selecting a species

There are two ways to select a species to view. Either select the item from the drop down or click on the "Species" menu item.
If you click on the "Species" menu item you will see this screen



On this screen you can select an item from the listbox or search for items containing a phrase. To search for a phrase type in the edit box at the top of the screen.


Selecting a document

Once you have selected an item from the listbox click the "Select" menu item to load it.

Once you have loaded a species you can view your saved documents by clicking on the "Docs" tab. As with the species page you can either select a document from the drop down or search for it.


Keyboard shortcuts

This pics shows how you can navigate the mobile app without using a stylus





The Windows Desktop Version

I've done a lot less work on the desktop version as I mainly use the mobile version. However it does work...


The PC version is very similar to the mobile version the only difference being that the PC version allows you to edit the notes.

Setup

Click on the "Tools" menu, select "Collection Setup"


Click on "Add" to add a collection. The browse button lets you browse for your collection folder




Download

Both versions are free. I may update them from time to time but I'm not making any promises :)


Prerequisites
To run the windows mobile version you will need to have the Microsoft .Net Compact Framework version 2 installed. If you don't have it you can download it here.

To run the windows desktop version you will need to have the Microsoft .Net Framework version 2 (this is not the same framework as the one above) installed. If you don't have it you can download it here.


Species Browser for Windows Mobile version 1.0.2.3
Download the mobile version's installer here

Species Browser for Windows Desktop machines version 1.0.2.1
Download the desktop version's installer here



Feedback

Let me know if you are using Species Browser by emailing me <dart-software@pobox.com>.