Posts

Windows welcome screen slow

Image
After I log in to Windows 7 the welcome screen stays on for ages, in the past it was almost instant.  I’ve tried various suggestions from forums and none of them worked, then it struck me what it was! Windows was trying to reconnect network drives after I had logged in, but one of them (a connection to my iMac) was unobtainable because my iMac was off.  I disconnected the mapped network drives and speed is back to normal

Installing Ruby on Rails, RubyMine and MongoDB on Ubuntu Linux

Here are some really basic instructions which should work on a virgin installation of Ubuntu Linux.  I tried following some instructions in a book but they were awful, these are what I ended up with. Install some installation helper tools etc sudo apt-get install build-essential git-core sudo apt-get install curl bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) echo '[[ -s "/home/x/.rvm/scripts/rvm" ]] && source "/home/x/.rvm/scripts/rvm"' >> ~/.bashrc source ~/.bashrc Install JavaScript interpreter sudo apt-get install nodejs Install MongoDB server and clients sudo apt-get install mongodb-server sudo apt-get install mongodb-clients Install Rails sudo apt-get install rails Install Ruby 1.9.3 and set it as the default version to use rvm install 1.9.3 rvm use --default 1.9.3 Install Gems required by Ruby ge...

Decorating Unity extension

First I want to give credit where it is due, the code in this post is based largely on the code I found in this post by Jim Chrisopher. The original code required me to register my decorators before registering the type I wanted to decorate.  I didn't like this because I prefer to register all the low-level services from within their own assemblies and then have the app (website etc) decorate those types at a higher level.  So I changed the code in the following ways It now uses the UnityContainer.Configure<> method to decorate types. The decorators may be registered before or after the registered type, or both, it doesn't matter. It is possible to register both generic and non-generic types, and both will be used if applicable (e.g. ICommand<> and ICommand<string> would apply to Command<string> but only ICommand<> would apply to Command<int>.) It works with child containers. It uses the context.NewBuild method instead of requiring a...

SpinLock SynchronizationLockException - The calling thread does not hold the lock

Here is the code from a console app. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ConsoleApplication48 { class Program { static readonly SpinLock SpinLock = new SpinLock(); static void Main( string [] args) { bool lockTaken = false ; try { SpinLock.Enter( ref lockTaken); if (lockTaken) Console.WriteLine( " Lock taken " ); } finally { if (lockTaken) SpinLock.Exit(); } Console.WriteLine( " Done " ); } } } So why would this single-threaded app tell me that the thread trying to call SpinLock.Exit() doesn’t hold the lock? SpinLock is a value type.  When you mark a field referencing a reference type as readonly you are not only making the field unass...

C# scripting in .NET

Based on a couple of days of experimenting it seems that I now have C# scripting working in my application to a level that I am satisfied.  Because I couldn’t have achieved this without looking at other people’s examples I thought it was only fair that I share what I now have.  Firstly I want to say that my purpose was to give the user the ability to write procedural code rather than object code.  Although it is still possible for the user to write OOP source code my requirement was to let the user define a function which returned a specific return type. public interface ICompiledFunction < T > { T Execute(Dictionary < string , object > variables); } A typical script might look something like this public decimal string Main() { return " Bob Monkhouse " ; } To create an instance of the ICompiledFunction<T> I use ICompilerService, which is defined like so public interface ICompilerService { bool Compile < T > ( strin...