Robert Reese's Website

Hexagon.js

For some time I have been interested in the new HTML5 features primarily Canvas and WebGL. For this reason I looked at implementing a very simple RPG in HTML5. Five years ago the idea of doing so would have been ludicrous. An HTML implementation would have been clunky, the obvious choice would have been flash. Fortunately most people are using up to date browsers with decent Canvas support.

My initial goal was to implement a hex grid. I looked around to see if anyone had implemented a nice hex grid library but those that did exist did not fit my requirements.

Read more...

Cleaning up Safari Books fonts

For the last several years I have had a subscription to the excellent Safari Books Online site. Safari Books is run by Oriely and is the Netflix of technical books. Most of their catalogue, and a huge swathe of other publishers books is available for a monthly fee.

While Safari is an extremely useful resource it does have two flaws. Firstly some books use a poor choice of fonts which render badly. Secondly if you select text in the book, a small in page popup appears that allows you to highlight or add notes. While that may sound useful, I find myself constantly selecting text (for no purpose) and the box is quite a distraction while reading.

Read more...

Mandelbrot Set

An implementation of the Mandelbrot Set in Javascript using the Canvas element. You can see the full source code at Github

Read more...

Scite

Scite is a free open-source text editor based on the Scintilla source-code editing component. It is extremely powerful, though the documentation isn’t as good as it could be. To help rectify this here are some tutorials and scripts to get you started.

Tutorials

Binding Commands A tutorial on how to bind Lua functions to the tools menu and keyboard shortcuts.

Word Count An introductory by example tutorial on using Lua, concentrating on getting information from the current text field. The completed script is available in the scripts section.

Read more...

ILSpy

For Several years a key tool in .Net developers toolchests has been Reflector. Originally a free tool developed by Lutz Roede, it was bought by Redgate Software in 2008. Redgate had announced that they would try and keep the tool free, but next month free support will end.

ILSpy Screenshot

Those looking for a replacement may be interested in ILSpy. ILSpy has been in development for a few months and already has the major features required by a decompiler. It’s under active development and is open source. It doesn’t yet support languages other then C# and IL, and it would be great if it integrated into Visual Studio, but I think this is a tool with a bright future.

Read more...

Finally my review of the Olympus E-P1

I’ve had the E-P1 in my hands for a few weeks now, long enough to make some conclusions.

Lets start with the bad aspects of this camera.

Weaknesses

Several commentators have lamented the E-P1’s lack of flash. I however haven’t found this to be an issue. I rarely used the flash on my Canon, and the E-P1 is vastly more capable at taking low light shots. A fill flash would be nice, but its lack is more then made up with by the other features on this terrific camera.

Read more...

A look at the Parallel class, .Net 4.0's new functionality to simplify multi-threading.

.Net 4.0 introduces new libraries for handling and greatly simplifying multi-threaded programming. This is a welcome addition to .Net for two reasons. Firstly writing multi-threaded code tends to be complex. There are all sorts of difficulties when working with threads that simply don’t exist for single threaded applications. Add to this an environment where multiple programmers are working on different parts of the code base, or where a maintenance programmer with a weak understanding of the code base needs to make adjustments years later and you have a recipe for difficult to debug code with possible errors making their way into a production environment. But at the same time computers are becoming vastly more parallel. Consumer machines are now multi core, 4 cores are common and over the next couple years we will see 6 and possible 8 core machines in the hands of everyday users. Writing your code in a multi-threaded manner has never been more important.

Read more...

.Net Code Contracts

One of the new features of .Net 4.0 is code contracts. Code contracts are a way for programmers to define how methods and classes should behave in a more complex way then simply their signature. A contract for example could specify that a methods parameters should not be null, or that the value it returns should always be positive.

Code contracts themselves are broken into two parts. The library itself which is included in .Net 4.0 and the Visual Studio addon (downloaded here). The two need to be paired together to do useful work (though no doubt third parties will introduce their own products in the future).

Read more...

Using WiX to install SQL databases and execute SQL scripts

In my last post on wix I described how to set up a simple installation project that installed four files and created a shortcut in the start menu. Today we will look at installing and running SQL against databases during installation. Installing, or configuring a database is not an unusual task during installation especially with programs that roll out with SQL Express.

When we left off we had a wxs file that looked like this:

Read more...

How to use WiX to congiure XML files during installation.

One of WiX’s powerful features is XML interaction. WiX can create and delete elements or change values and attributes inside XML files. To do this we use either the util:XmlFile or util:XmlConfig elements. The two elements differ in subtle ways. util:XmlFile does not let you specify to be run on uninstall though it does allow you set the Permanent flag, which will undo the action on uninstall, while util:XmlConfig only allows you to delete or create an element, not update one.

Read more...

Good photography blogs that I follow.

A colleague of mine asked me what photography blogs I subscribe to. So as follows are the blogs I read regularly relating to photography.

Berlin Guide

Several times a week Grapf posts a photograph from around Berlin. A mixture of architecture and street photography.

link

The Big Picture

The Boston Globe’s website boston.com publishes groups of photographs from the recent new several times a week. One of my favorite photography sites.

Read more...

Installing and Starting Windows Services with WiX

An important part of many application installs is configuring windows services. WiX has the ability to install/uninstall as well as start and stop services during instalation.

The first element we need to set up is the ServiceInstall element. ServiceInstall controls how the service will start and what user and authentication are to be used. Note that the ServiceInstall element does not specify a file. Rather the file that has KeyPath=“yes” set in the same component is considered the executable to use as a service.

Read more...

EP1

EP1

Four and half years ago I bought my second digital camera, the Canon 300d. At this time the 300d was already a year and a half old, and along with the Nikon D70 was one of the first quality, “low cost” entry level DSLRs.

The 300d impressed me greatly, previously I had been using a 4MP point and shoot which I had grown to loath. The SLR brought so much to the table, fast focusing, low light shooting. Paired with my favourite lens the Canon 50mm f1.4 I could shoot in low light environments, and really isolate my subject. Almost everything I loathed about the point and shoot was resolved with the DSLR.

Read more...

Scite Preferences

Scite preferences can be opened and edited by selecting Options->Open Global Options File

Some preferences you may wish to change are:

check.if.already.open=1

This will cause all new files opened to open in the current instance of Scite. If this line is set to equal 0 or it is commented out (#) opening a new file will start a new instance of Scite. Since I often find myself editing tens of files I prefer to keep them in a single instance.

Read more...

Scite: Bold/Italicise Selection

In this tutorial we are going to quickly cover using text selection in our Lua scripts. Our first example will be an italicise-selection command for HTML. Basicly if we select a region of text, we want to be able to hit Ctrl-i and insert at the beginning of the selection and at the end of the selection. This is really easy to do in Scite so let’s get to it.

Read more...

An implementation of a TrackBack listener in ASP.NET MVC.

Please note: this article was written for the original MVC CTP1 preview in 2007 and is horrifically out of date.

Trackbacks are a form of linkback a way of notify a site that your site has made a reference to it. Trackbacks are slowly being deprecated in favor of pingbacks. The spec can be found at Six Apart.

To provide trackback support we need to do 3 things:

Using msiexec to manipulate msi files

As I have mentioned in a previous post, the msi file generated by WiX can either be installed by double clicking them and optionally manipulating a UI or it can be run from the command line.

The Windows installer tool msiexec.ese (located in the System32 folder) can be used to install, modify and uninstall msi packages. Today we are going to look at the common ways of using this tool.

Read more...

Using WiX to create registry values

A common installation requirement is to set registry variables. WiX makes this a simple task. Lets add a RegistryKey element and nested RegistryValue element.

The RegistryKey element defines the specific key that should be created. The Action attribute is an enumeration. The allowable values are specified below:

  • create

  • createKeyAndRemoveKeyOnUninstall

  • none

RegistryKey creates a key if it does not exist or edits it if it already does.

The root attribute is an enumeration for the registry root. Allowable values are:

Read more...

Scite/Lua Word Count Tutorial

In this tutorial we will be creating a Lua script that will count the number of characters, words and lines in the current document.

First up let’s look at some of the functions and strategies we will be using.

editor.Length This property stores the number of chars in the current document. You should be wary as on Windows a newline is stored as \r\n (carriage return, new line) making up two chars, whereas Linux uses only \n and the Mac uses only \r.

Read more...

Canonical urls With ASP.NET MVC

Please note: this article was written for the original MVC CTP1 preview in 2007 and is horrifically out of date.

The Canonical url of a site is the url that search providers consider to be definitive. For example the sites http://www.example.com/ and http://example.com/ are technically different. Since the urls are different, search providers may consider the two sites to be duplicate content.

This issue can be resolved in ASP.NET MVC by using a 301 Moved Permanently HTTP redirect. Using Application_BeginRequest in Global.asax we can catch urls and redirect them as needed.

Read more...

A gentle introduction to the Windows Installer XML toolset.

The WiX 3.0 release candidate has just been released so lets have a look at it. After installing WiX, the linker and compiler are installed along with Visual Studio tools. Create a new WiX Project using the new WiX project type that has been installed.

A new wxs file will be created as below:

The Product section contains all the main elements for the installer, there can only be one product section in a wxs file. The Directory section is where files and other components are defined for installation. WiX doesn’t specify how to install files, rather you define the structure you want, then WiX installs file based on that structure.

Read more...

URL Routing with the ASP.NET MVC Framework

Please note: this article was written for the original MVC CTP1 preview in 2007 and is horrifically out of date.

Unlike standard ASP.NET, MVC does not use a directory and file system for URLs. Rather it maps URLs to controller classes in a RESTfull manner. Routing is defined in the Global.asax file.

Route Mapping

Lets start by looking at the default route created when starting a new MVC project.

RouteCollection.MapRoute() is used to map a route to a controller class. MapRoute() takes a name, a parametrized URL and a parameter object. The parametrized URL represents a pattern. Each URL parameter in the pattern is separated by a constant (in this case ‘/’ though you could use any character or characters).

Read more...

C++ Libraries

Useful C++ libraries.

Boost

Probably the most important set of libraries other then the STL, Boost offers a huge amount of functionality. Libraries featured in Boost may eventually be included in future C++ standards.

Xerces C++

Xerces is a validating XML parser with support for Dom, SAX, XML Namespaces and XML Schemas. This library is provided by the Apache foundation.

Xalan C++

Another library from the Apache foundation, Xalan is an XSLT processor, compatible with Xerces.

Read more...

Binding Keyboard Controls to Functions

In this tutorial we will be looking at how to bind functions to keyboard shortcuts and the tools menu. The following code is used to bind the word count function to Ctrl+W. If these lines are put in the global properties file the word count function will be accessible anywhere. They could be placed in a language specific properties file such as html.properties in which case the function would only be accessible in HTML mode.

Read more...