KeyNode with Node.js and Microsoft Azure

KeyNode is a application to issue and verify software license keys. Technology stack for KeyNode is Node.js, MongoDB and Microsoft Azure. I had built this functionality with (a cloud-based IDE with a built-in source code repository and debugger), mongohq (MongoDB as a service – now part of and appfog (Cloud PAAS built on top of CloudFoundry). It used SMTP/gmail to email license files. That was the version I created a couple of years ago to issue tamper-proof signed xml license files for CodeDemo (a code snippet tool for developers, presenters and instructors). For KeyNode (open source) I switched to a different toolset : Visual Studio Code and Windows Azure, simplified the code to remove signed xml file and open-sourced it on GitHub. Signed […]


Using Powershell with Splunk

Splunk Powershell Resource Kit is a convenient and very capable wrapper over Splunk REST API. You can use the Powershell commandlets exposed by this resource kit to deploy, check and manage splunk services as well as execute splunk searches. In this post, you will be introduced to the Splunk Powershell Resource Kit, you will learn how to use powershell commandlets to connect to a splunk instance and execute searches. 1. First, you will need to download the resource kit from github. 2. Installation is very simple. All you have to do is download and extract the files from the zip archive and double click on install.bat to install the splunk powershell module. 3. Open Windows Powershell console from Windows Start […]

The Site44 Workflow

A light weight development workflow with real-time website deployment. I recently built a sample website to illustrate how clean, semantic html markup can be maintained when using Bootstrap’s grid system. The solution is to use a css pre-processor to incorporate Bootstrap’s LESS based mixins into your own .less files and push the Bootstrap instructions down into your stylesheets. There are two ways to “compile” .less stylesheets – use a stand-alone LESS compiler or use less.js. I found it very convenient to use less.js (note that it is not recommended in production deployment). As I started working on developing the sample code I found it a bit cumbersome to work with an entire web application project in Visual Studio, considering I […]

Understanding and Using System.Transactions

These are some resources to help grasp System.Transactions functionality and use it effectively in your projects: Features Provided by System.Transactions to create transactional applications Implementing an Implicit Transaction using Transaction Scope MSDN Magazine Articles by John Papa: ADO.NET and System.Transactions Revisiting System.Transactions These are specific to TransactionScope (the way to go in most cases): Here is a practical example of Using TransactionScope to handle transactions in .net. This article in MSDN Magazine gets in depth with the way a TransactionScope like functionality can be implemented. Gives you a good understanding of what is happening under the hood when using TransactionScope in some Repository implementations in multi-threaded scenarios. This CodeProject article is another example of implementing a transactional repository. There are […]

Solution to the fetch puzzle

Here is a brute force solution to the fetch problem – Basically, at each step there are three possibilities : 1. You can fill a bucket. 2. You can transfer water from one bucket to the other one. 3. You can dump out the water from a bucket. In this brute force solution, I try each one of these steps and then try all three again after each one of the previous steps. And on and on untill I get the required amount of water in one of the buckets. Check it out. Source code is on my github repo – Here is a brute force solution to the fetch puzzle. Basically, at each step there are three possibilities : […]

Solve puzzle with code

Here is a quite common programming interview puzzle – You have two buckets. A 3 gallon bucket and a 5 gallon bucket. Buckets are not marked or graduated. You are to fetch 4 gallon of water in a single trip to the river. How will you do it? Obviousy, this question is asked by changing the capacities of the two buckets and the amount of water to be fetched. Your mission, should you choose to accept it, is to write a program to solve this puzzle in a generic way. Your program should take 3 inputs – capacities of the two buckets and the amount of water to be fetched. After solving the puzzle, your program must write out the […]

ChildWindow Positioning

Silverlight ChildWindow is centered over the parent control. I have extended ChildWindow to open it at a specific position. Here is a live demo : childwindow-positioning-demo And here is the code : public partial class ChildWindowEx : ChildWindow { Point _pt = new Point(0,0); public ChildWindowEx() { InitializeComponent(); } public ChildWindowEx(Point pt) : this() { _pt = pt; } protected override Size ArrangeOverride(Size finalSize) { Grid grid = Utils.FindChild(this, “ContentRoot”); if (grid != null) { grid.Arrange(new Rect(_pt.X, _pt.Y, grid.DesiredSize.Width, grid.DesiredSize.Height)); return finalSize; } return base.ArrangeOverride(finalSize); } } Visual Studio 2010 Solution : download

Using Model-View-ViewModel in WPF Applications

I am presenting at SoCalCodeCamp this weekend (January 30th, 2010) – Advanced WPF – Using Model-View-ViewModel in WPF Applications. Agenda : 1. Roles of the M-V-VM triad 2. Why use M-V-VM ? 3. Characteristics of the ViewModel 4. Build a Sample WPF Application using M-V-VM Resources : MSDN Magazine Article and Sample Application Download Martin Fowler’s description of the ‘Presentation Model ‘ Jeremy Miller’s ‘Build Your Own CAB’ series

ReSharper vs CodeRush + Refactor Pro

I have been playing with JetBrains ReSharper (version 4.1) and DevExpress CodeRush + Refactor! Pro (version 3.2.2) lately. I wanted to decide on which one to go with. Here are some notes – R# = ReSharper CodeRush = CodeRush + Refactor! Pro R# seems to be better for refactoring, because it does not assume that I follow a rigid work flow when writing code. For example, I don’t always decide on the class hierarchies upfront. I do discover them as I write code. So, when I discover that I need to extract a base class from the class I am working on, I can do so with R#. I couldn’t find a way to do extract a base/super class with CodeRush. […]

Using NHibernate With SQLite in DbUpdater

DbUpdater (version 1.3 onwards) can be used with sqlite3. Review the files included in 1. DbUpdater.exe.config must be modified. Note changes to the following keys – exe-file, exe-args, dialect, driver_class, connetion_string. 2. SchemaVersion.hbm.xml must be modified. The ‘class’ attributes value for the ‘generator’ of ‘id’ must be changed to ‘identity’. No other changes are needed here. 3. \SqlScripts\schema-version-table.sql is modified. Note that the datatypes of all columns are changed to TEXT, except for SchemaChangeId, which is changed to integer primary key. integer primary key is used for auto-incremented columns in sqlite. 4. \SqlScripts\baseline.sql is modified. Note the use of current_timestamp function. The actual sql syntax in this file must conform to sqlite dialect. 5. All other .sql scripts in […]

Dial Gauge is a ProgressBar

I am not just being philosophical here. In WPF, ControlTemplates allow you to transform a control’s appearance. This is not the same as applying stylesheets. This is an entirely new level of customization. What you see in the screenshot below looks like a Dial but is actually a simple ProgressBar control wearing a “Dial” template. The Dial template was created using Microsoft Expression Blend . Include the ControlTemplate as a Window.Resource and then assign it to ProgressBar element’s Template attribute : Of course that is not all. The ControlTemplate must define some named elements of FrameworkElement type. Charles Petzold has explained it in detail : MSDN Magazine Article. So, I will not repeat it here. The sample code can be […]

PostSharp with SharpDevelop

SharpDevelop3.0 uses MSBuild. Including PostSharp in your build process is transparent if you are doing a global install using PostSharp installer. If you are doing a per-project installation using “Binary – No Installer” download, you will need to import the PostSharp targets into your .csproj file – True C:\code\PostSharp-\ For more details, read the install instructions included in the PostSharp download and under-the-hood-of-msbuild-integration. To use local PostSharp binaries (relative to your project) , modify your .csproj file as follows – True $(MSBuildProjectDirectory)\PostSharp\ $(MSBuildProjectDirectory) is the directory containing your .csproj file. \PostSharp\ is the directory containing local PostSharp binaries. 2. You will need to exclude the Aspect class itself from being woven. If you are following the getting-started sample, see the […]

Using Custom Converter in XAML

In my previous post : WPF-LINQ To SQL Sample, I had to resort to modifying .dbml file to get the images stored as varbinary into the WPF ListView control. I had to change the Type of image fields to System.Byte[], instead of using System.Data.Linq.Binary. A better way to do this is to use a custom converter. WPF allows you to specify custom converter as part of the Binding in .xaml, like this – <Image Grid.Row=”2″ Source=”{Binding Path=ThumbNailPhoto , Converter={StaticResource imageConverter}}”></Image> The custom converter is declared in the same .xaml file as a resource – <Window.Resources> <local:ImageDataConverter x:Key=”imageConverter” /> </Window.Resources> ImageDataConverter is implemented in .xaml.cs file – public class ImageDataConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, […]

WPF – LINQ to SQL Sample

This exercise in binding a WPF ListView control with LINQ to SQL was a lot of fun ! The following image shows data from AdventureWorks sample database displayed in the ListView control. The end result is very admirable, even in this very basic demo. Feeling a complete sense of freedom is unavoidable when working with WPF. This sample demonstrates : LINQ to SQL mapping. WPF ListView Control DataBinding. Displaying images stored in database as varbinary in WPF control. The sample code can be downloaded here : WPF-LINQ to SQL Sample License : Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Customize log4net Output Path

The default log4net output path is relative to the startup directory of your executable. To customize the output path, you can override the base Appender’s File property in your own Appender class. The following example describes how to route the log files relative to the temp folder : public class MyOwnAppender : log4net.Appender.RollingFileAppender { public override string File { get { return base.File; } set { if (Path.IsPathRooted(value)) { base.File = value; } else { base.File = Path.Combine(Path.GetTempPath(), value); } } } } Your log4net config file must be modified so that log4net can locate and use your custom Appender. If MyOwnAppender is in MyNamespace and you have implemented it in MyLoggerLib.dll :

Leveraging XPATH Axes

XPATH axes come in very handy when nodes need to be selected based on (attribute’s or child element’s) values that must match those of other nodes elsewhere in the xml tree. Consider the following log4net configuration file : <?xml version=”1.0″?> <configuration> <configSections> <section name=”nhibernate” type=”System.Configuration.NameValueSectionHandler, System, Version=,Culture=neutral, PublicKeyToken=b77a5c561934e089″ /> <section name=”log4net” type=”log4net.Config.Log4NetConfigurationSectionHandler,log4net” /> </configSections> <nhibernate> <add key=”hibernate.connection.provider” value=”NHibernate.Connection.DriverConnectionProvider” /> <add key=”hibernate.connection.driver_class” value=”NHibernate.Driver.SqlClientDriver” /> <add key=”hibernate.connection.connection_string” value=”Server=servername; Database=dbname; User=username; Password=secret;” /> <add key=”hibernate.connection.isolation” value=”ReadCommitted” /> <add key=”hibernate.dialect” value=”NHibernate.Dialect.MsSql2000Dialect” /> </nhibernate> <log4net> <appender name=”NHibernateFileLog” type=”log4net.Appender.RollingFileAppender”> <file value=”Logs/nhibernate.txt” /> <appendToFile value=”true” /> <rollingStyle value=”Size” /> <maxSizeRollBackups value=”10″ /> <maximumFileSize value=”100KB” /> <staticLogFileName value=”true” /> <layout type=”log4net.Layout.PatternLayout”> <conversionPattern value=”%d{HH:mm:ss.fff} [%t] %-5p %c – %m%n” /> </layout> </appender> <appender name=”GeneralLog” type=”log4net.Appender.RollingFileAppender”> <file value=”Logs/general.txt” /> <appendToFile […]