Skip to content

Instantly share code, notes, and snippets.

var fs = require('fs');
fs.readFile('package.json', 'utf8', function(err, data){
console.log("reading package.json");
if (err) throw err;
obj = JSON.parse(data);
if (obj.devDependencies) {
var fs = require('fs');
fs.readFile('package.json', 'utf8', function(err, data){
console.log("reading package.json");
if (err) throw err;
obj = JSON.parse(data);
if (obj.devDependencies) {
public int ExecuteSql(string sql, object parameters = null)
{
int result;
using (var connection = ConnectToDb())
using (var command = new SqlCommand(sql, connection))
{
Log.Info(sql);
if (parameters != null)
@crmckenzie
crmckenzie / xd2md.cs
Created February 19, 2016 21:19 — forked from formix/xd2md.cs
Generates Markdown From VisualSturio XML documentation files
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program
function Install-Java7JRE()
{
# 7.0.79
$url = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=106369"
$filename = "jre-7u79-windows-x64.exe"
$downloadedFile = Join-Path $env:TEMP $filename
$javaHome = Join-Path $env:ProgramFiles "Java\jre7"
$jreForPathVariable = Join-Path $javaHome 'bin'
@crmckenzie
crmckenzie / ConfigureToUseSqlite
Last active December 17, 2015 02:19
How I setup my NHibernate configuration to use Sqlite for unit tests.
public static void ConfigureToUseSqlite(this IKernel kernel)
{
var nHibernateConfiguration = Substitute.For<INHibernateConfiguration>(); // custom interface
var msSqlConfiguration = SQLiteConfiguration.Standard
.InMemory()
.ShowSql()
;
nHibernateConfiguration.GetPersistenceConfiguration().Returns(msSqlConfiguration);
@crmckenzie
crmckenzie / gist:5338433
Last active December 15, 2015 23:09
Get registered bindings from Ninject.
public class InjectionBinding
{
public Type RegistrationKey { get; set; }
public IList<object> Implementations { get; set; }
public Type[] GetImplementationTypes()
{
return Implementations.Select(row => row.GetType()).ToArray();
}
}
@crmckenzie
crmckenzie / gist:4736254
Created February 8, 2013 02:53
Demo of a fluent api implementation for mapping one object to another. The unit test does not actually exercise the implementation, but it does demonstrate how the api will look to the consumer.
[Test]
public void ApiDocumentation()
{
// Arrange
var builder = Substitute.For<IBuilder>();
builder.Create<string>().From(5.0m).Returns("Five");
// Act
var result = builder.Create<string>().From(5.0m);
public interface ICommand<in TRequest, out TResponse> : IDisposable
{
TResponse Execute(TRequest request);
}
/// <summary>
/// Use Request.Empty when the command doesn't need any arguments.
/// </summary>
public class Request
{
@crmckenzie
crmckenzie / gist:4632765
Last active December 11, 2015 17:09
Recursive Mocks Sample
public interface IMapper
{
IMapperLink From<TInput>(TInput input);
}
public interface IMapperLink
{
TOutput To<TOutput>();
}