Skip to content

Instantly share code, notes, and snippets.

View chilversc's full-sized avatar

Chris Chilvers chilversc

View GitHub Profile
@chilversc
chilversc / RowVersionType.cs
Created December 8, 2010 16:50
NHibernate IUserVersionType for MSSQL rowversion columns
public class RowVersionType : IUserVersionType
{
public object Seed(ISessionImplementor session)
{
return 0ul;
}
public object Next(object current, ISessionImplementor session)
{
return current;
@chilversc
chilversc / Grinder.psm1
Created September 28, 2010 10:13
Grinder Powershell module
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
$script:GrinderPath = Resolve-Path (Join-Path $PSScriptRoot ../engine/grinder-3.4)
$script:ClassPath = (Join-Path $script:GrinderPath lib/grinder.jar) + ";$env:classpath"
$script:JavaHome = $env:java_home
colorscheme ir_dark
if has("gui_macvim")
set fuoptions=maxvert,maxhorz
set guifont=Monaco:h14
set guioptions-=T
set stal=2
end
set anti
o (master)
\ /--W (release-10.19-x)
\ o---o (release-10.19)
\ /
A---o---o---o---M---o---o (develop)
\ /
B---C---E (bug-2248)
M - Merge branch 'bug-2248' into develop
@chilversc
chilversc / test1.ps1
Created May 7, 2010 13:00
Powershell positional parameters
param (
[Parameter()] $foo,
[Parameter()] $bar
)
$foo
$bar
#output:
#> .\test1.ps1 0 1
@chilversc
chilversc / gist:357546
Created April 6, 2010 12:41
Very odd, but it works
void Main()
{
var f = new Foo ();
f.Inc ();
f.Inc ();
f.X.Dump ();
}
struct Foo {
public readonly int X;
@chilversc
chilversc / gist:342750
Created March 24, 2010 20:30
Rough implementation to find a concrete list type from an interface
Sub Main
Dim type = GetType(List(Of String))
FindExplicitListType(type).Dump()
End Sub
Function FindExplicitListType(type As Type) As Type
If type.IsClass Then
'TODO: Should check if type implements IList or IList(Of)
Return type
ElseIf IsGenericList(type)
@chilversc
chilversc / Range spec
Created March 12, 2010 20:03
Range spec
Range:
Min/Max rather than Start/End, better naming when dealing with non-contiguous ranges.
Start and end values are inclusive.
How enumeration works for stepping, etc is left to the class to decide, provide a static class with some standard implementations that use Math<T>.
Assumption is the main IRange<T> can be either contiguous or non-contiguous
Assumptions for SubRanges():
No two sub-ranges overlap.
Each sub-range is atomic (ie contiguous).
@chilversc
chilversc / gist:291827
Created February 1, 2010 17:13
Verify SSL thumbprint
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
namespace SslTest
{
internal class Program
@chilversc
chilversc / output.sql
Created January 25, 2010 14:28
NHibernate one-to-one problem
-- statement #1
begin transaction with isolation level: Unspecified
-- statement #2
SELECT bar_.Foo,
bar_.Rate as Rate1_,
bar_.Value as Value1_
FROM [Bar] bar_
WHERE bar_.Foo = '2b76e14d-c48e-490d-9d1c-9d0900ee14ec' /* @p0 */