Skip to content

Instantly share code, notes, and snippets.

@ngbrown
ngbrown / AlphanumComparatorFast.cs
Created October 5, 2012 20:07
Alphanumeric compariter using Linq and an EnumerableComparer.
namespace Utilities
{
using System.Collections;
using System.Collections.Generic;
/// <remarks>
/// From http://www.dotnetperls.com/alphanumeric-sorting
/// </remarks>
public class AlphanumComparatorFast : IComparer<string>, IComparer
{
@ngbrown
ngbrown / GenericEqualityComparer.cs
Created January 27, 2016 21:44
Generic IEqualityComparer implementation
using System;
using System.Collections.Generic;
using System.Linq;
namespace Helpers
{
public class GenericEqualityComparer
{
public static IEqualityComparer<T> Create<T>(params Func<T, object>[] Param1)
{
@ngbrown
ngbrown / [WIP] NH-3807 Pull Request.md
Last active August 21, 2016 22:57
NHibernate 5.x Core

This is currently a work in progress. It does compile and I have ran simple programs against it.

A majority of the changes were done to the mainline .NET version so all the mainline tests could be used during development. There are no tests ported to .NET Core yet, and this may be difficult without the dynamic schema support.

By necessity, it includes #241/NH-3431 - Replace System.Data with System.Data.Common and NH-3853 - Switch binary-serialization to an implementation that is supported by CoreClr.

There are a number of compromises that have to take place on .NET Core, chief among them is that there is no GetSchemaTable(). Without this, none of the dynamic schema generation or updates works. The tests, when implemented, will need a static schema c

@ngbrown
ngbrown / BowlingKata.cs
Last active September 15, 2016 17:50
Code to read
namespace BowlingKata02
{
public class Scorer
{
private readonly IList<int> rolls = new List<int>();
private int currentRoll;
private int score;
public int CalculateScore()
{
@ngbrown
ngbrown / AboutFramework.cs
Created October 5, 2016 15:58
Display detailed version information about the .NET framework installed
using System;
using Microsoft.Win32;
namespace AboutFramework
{
class Program
{
static void Main(string[] args)
{
GetVersionFromRegistry();
@ngbrown
ngbrown / utilities.js
Last active November 29, 2016 17:48
redux-little-router utility functions for onClick and onSubmit
import {PUSH, REPLACE} from "redux-little-router";
import defaultCreateLocation from "redux-little-router/lib/util/create-location.js";
// Adapted from https://github.com/FormidableLabs/redux-little-router
// specifically the Link component (https://github.com/FormidableLabs/redux-little-router/blob/master/src/link.js)
const normalizeHref = ({ basename, pathname, search }) =>
`${basename || ''}${pathname}${search || ''}`;
const normalizeLocation = href => {
@ngbrown
ngbrown / typescript-babel-jest.js
Last active July 14, 2017 16:09
Transformer helper for Jest to take Typescript through Babel, with sourcemap support.
"use strict";
/**
*
* This source code is licensed under the BSD-style license.
* Portions of code derived from "babel-jest", copyrighted by
* Facebook, Inc. and released under a BSD-style license.
*
*/
@ngbrown
ngbrown / GridViewSort.cs
Created October 5, 2012 20:26
Wpf helpers.
namespace Extenders
{
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Documents;
/// <summary>
@ngbrown
ngbrown / SQLiteDateRoundTripTests.cs
Created October 13, 2017 23:22
SQLiteDateRoundTripTests
using System;
using System.Globalization;
using NUnit.Framework;
namespace UnitTestProject1
{
[TestFixture]
public class SQLiteDateRoundTripTests
{
private int _optionToStringInSqLite = 1; // Currently implemented in System.Data.SQLite
@ngbrown
ngbrown / JetBrains.ExternalAnnotations.xsd
Created August 13, 2011 01:47
Started to define a basic XSD schema for JetBrains external annotations.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="JetBrains.ExternalAnnotations" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:annotation>
<xs:documentation>
<![CDATA[
Usage: You only need to add the following to the assembly element:
<assembly name="Assembly.Name"
xsi:noNamespaceSchemaLocation="http://jetbrains.com/schema/JetBrains.ExternalAnnotations.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
]]>