Skip to content

Instantly share code, notes, and snippets.


Chris Chilvers chilversc

View GitHub Profile
chilversc / monodoc-style.css
Created Dec 31, 2009
Style for editing monodoc xml using tools such as oxygen
View monodoc-style.css
AssemblyInfo, TypeParameters, Base, MemberType, Parameters, ReturnValue
display: none;
TypeSignature {
display: block;
padding: 1em;
margin: 1em;
content: attr(Value);
View gist:274651
create table Foo (data1 bit, data2 bit, data3 bit, seq int not null)
insert into Foo (data1, data2, data3, seq)
values (NULL, 0, 1, 1), (1, NULL, 0, 2), (0, 1, NULL, 3)
with unpivoted as (
select seq, value, col
from (select seq, data1, data2, data3 from Foo) a
View gist:278414
void Main()
int x = System.Net.IPAddress.HostToNetworkOrder((127 << 24) | 1);
var y = new System.Net.IPAddress(x);
chilversc / Fob.hbm.xml
Created Jan 25, 2010
NHibernate insert/update problem
View Fob.hbm.xml
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="ValueMapping.Fob, ValueMapping, Version=, Culture=neutral, PublicKeyToken=null" table="`Fob`">
<id type="System.Int32, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="id" />
<generator class="native" />
<property name="Something" type="System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Something" />
chilversc / output.sql
Created Jan 25, 2010
NHibernate one-to-one problem
View output.sql
-- 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 */
chilversc / gist:291827
Created Feb 1, 2010
Verify SSL thumbprint
View gist:291827
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
View Range spec
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 / gist:342750
Created Mar 24, 2010
Rough implementation to find a concrete list type from an interface
View gist:342750
Sub Main
Dim type = GetType(List(Of String))
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 / gist:357546
Created Apr 6, 2010
Very odd, but it works
View gist:357546
void Main()
var f = new Foo ();
f.Inc ();
f.Inc ();
f.X.Dump ();
struct Foo {
public readonly int X;
chilversc / test1.ps1
Created May 7, 2010
Powershell positional parameters
View test1.ps1
param (
[Parameter()] $foo,
[Parameter()] $bar
#> .\test1.ps1 0 1