IdleLock – a utility to lock your PC after X minutes of idle time

IdleLockIconIf you want your Windows PC to lock (i.e. require you to enter your password to use it) after a period of user inactivity, you can go to the screen saver setting and check “On resume, display logon screen”. But what if you want the screensaver to be activated after e.g. 10 minutes, but you don’t want the PC to lock until after 20 minutes? In Windows XP, you could resort to the ScreenSaverGracePeriod registry hack. However, in Windows 7 and later, the PC will be locked no later than 60 seconds after the screensaver kicks in, no matter what ScreenSaverGracePeriod value you have specified. To remedy this flaw, I whipped up IdleLock, a small utility that locks your PC after a selectable time of user inactivity. Read more

ConcurrencyMode unit tests for Entity Framework EDMX files

When using Microsoft’s Entity Framework, the ConcurrencyMode attribute for properties mapped to rowversion (a.k.a. timestamp) database columns, should be set to ConcurrencyMode.Fixed, to enable optimistic concurrency.

Unfortunately, due to a bug in the Entity Framework tools, you have to do this manually. The NuGet package EFConcurrencyModeTest makes it easy to write the unit tests needed to make sure that you have done so.

Read more

MissingMethodException when migrating from F# 3.0 to F# 3.1

If you retarget an F# 3.0 project to F# 3.1 in Visual Studio 2013, you might end up with a System.MissingMethodException when you rebuild and run your project. This is because you need to manually update the App.config file after you retarget to F# 3.1.

Read more

Links from my talk at Prevas

Here are the links I was referring to at the end of my talk at Prevas:

Videos

Luca Bologneses presentation from 2008. Don’t be deterred by the age of it, it’s still a great talk and the most enjoyable F# talk out there. The link is to the WMV file, which is better than the online stream.

Type Providers intro and demo by Tomas Petricek.

3 part introduction to F# by Don Syme.

Online interactive tutorial

http://www.tryfsharp.org/.

 

Google Drive – 15GB of unreliability

The better part of a year has passed since I last gave up on Google Drive because of its unreliability, which is akin to that of a Lucas automotive electrical system. In mid May, Google announced that they tripled the storage space, giving you a total of 15GB for free, if you were brave enough to submit your files to the bug ridden mess that is Google Drive. Surely, this must be an indication that they finally sorted out their problems and that Google Drive at last was ready for serious use? A couple of weeks ago, I thought it was time to find out.

Read more

Adding binding options to Morozov’s WPF MVC framework

Inspired by Dmitry Morozov’s MVC series (among the best F# articles I’ve ever seen!), I wanted to extend his data binding DSL to allow the setting of binding properties individually for each model property. The end result I was after, was to be able to write binding expression quotations like

<@
  view.Control.LastName.Text <- model.LastName |> UpdateSourceOnChange
  view.Control.Bitness.Text  <- model.Bitness |> string |> Mode BindingMode.OneTime
@>

Read more

Simple F# producer-consumer pattern

The producer-consumer pattern allows a producer thread to generate data (e.g loaded from disk or read from a web site) and put in a queue, concurrently with a thread that consumes the data from the queue.

A typical application of this is the processing of multiple disk files. When done in a single threaded, sequential manner, the CPU mostly sits idle while waiting for the disk during file load. The disk, in turn, doesn’t do anything useful while waiting for the CPU to finish processing a file before the next one is loaded. Using the producer-consumer pattern, the files are loaded from the disk and queued while the CPU processes files already in the queue, speeding up the processing of the second and all subsequent files. To boot, you get the possibility of running multiple producers and multiple consumers concurrently, as well as the smug feeling that goes with it. Read more

International Caps Lock Day – and VS2012 Menus

Today, the 28th of June, is INTERNATIONAL CAPS LOCK DAY. Someone at Microsoft seems to be a big Caps Lock fan, as MENUS AND WINDOW TITLES ARE ALL CAPS in Visual Studio 2012. With good reason, this is universally disliked. Fortunately, MS took note and provided a way to switch off the caps, so I’d like to celebrate INTERNATIONAL CAPS LOCK DAY with this link to the cure for VS2012′s menu uglyfication.

Happy CAPS LOCK DAY!

Detecting the CPU architecture in F#

If you google for methods of detecting the cpu architecture, you’ll find lots of pages about how to use WMI and ManagementObjectSearcher. This is an immensely slow operation which takes more than a second to complete (at least when I’ve timed it on a 2.8 GHz 4 core machine), so don’t use it. A quicker method is to use PInvoke to call the GetNativeSystemInfo function of the Windows API directly.

Read more

Compatibility between 32-bit, 64-bit and “Any CPU” .NET assemblies

I couldn’t find any decent .NET platform target compatibility chart, so I made one:

.NET platform compatibility charts

Read more