Skip to content

Instantly share code, notes, and snippets.

View chilversc's full-sized avatar

Chris Chilvers chilversc

View GitHub Profile
@chilversc
chilversc / gist:1442357
Created December 7, 2011 10:45
Problem merging changes to file that was renamed
#!/bin/sh
# Create empty repository for testing
mkdir cherrypick
cd cherrypick
git init
# Simulate some initial work
echo bob > a.txt
git add a.txt
@chilversc
chilversc / Output.xml
Created November 11, 2011 17:14
FNH - overiden methods
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class xmlns="urn:nhibernate-mapping-2.2" name="ConsoleApplication1.ItemBase, ConsoleApplication1" table="`ItemBase`">
<id name="Id">
<generator class="identity" />
</id>
<property name="Name" />
<joined-subclass name="ConsoleApplication1.Item, ConsoleApplication1">
<key>
<column name="ItemBase_id" />
</key>
.class interface private abstract auto ansi IBob
{
.method public newslot abstract strict virtual
instance void Foo() cil managed
{
} // end of method IBob::Foo
.method public newslot abstract strict virtual
instance void Bar() cil managed
{
Public Class Class1
Private Delegate Sub AnEventHandler(Of T)(ByVal newValue As T)
Private Event A As AnEventHandler(Of Integer) 'Works
Private Event B As AnEventHandler(Of Guid) 'Works
Private Event C As AnEventHandler(Of Foo) 'Works
Private Event D As AnEventHandler(Of Bar(Of Integer)) 'Works
Private Event E As AnEventHandler(Of Bar(Of Guid)) 'Works
Private Event F As AnEventHandler(Of Bar(Of Foo)) 'Works
@chilversc
chilversc / gist:995589
Created May 27, 2011 16:11
Converts a certificate thumbprint to a string suitable for IIS' adsi SSLCertHash property
function Convert-ToCertificateHash($HashString) {
$pairs = @([regex]::Matches($HashString, '..') | ForEach-Object { $_.Value })
-join @(
for ($x=0; $x -lt $pairs.Length; $x += 2) {
$a, $b = $pairs[$x..($x+1)]
[char] [uint16]::Parse(-join ($b, $a), 'hexnumber')
}
)
}
0 1 2 3 4 5 6 7 hours
|----|----|----|----|----|----|----|
A B C D E F items
When grouping we start with A, this overlaps B so we get (A, B), now do we continue from A and thus include C to get (A, B, C), and then continue from C to end up with (A, B, C, D)?
Thus resulting in (A, B, C, D), (E, F)
@chilversc
chilversc / gablarski
Created March 22, 2011 23:27
Gablarski init.d script
#!/bin/bash
#
# Init file for Gablarski
#
# chkconfig: 345 25 25
#
# pidfile: /var/run/gablarski.pid
# source function library
. /etc/rc.d/init.d/functions
@chilversc
chilversc / Microsoft.PowerShell_profile.ps1
Created February 22, 2011 22:46
PowerShell profile
function Get-HomeLocation {
# Using 'Run as administrator' does not set $Home, so try other variables as well
if ($variable:Home) {
$variable:Home
} elseif ($env:Home) {
$env:Home
} elseif ($env:UserProfile) {
$env:UserProfile
} else {
$null
var eventTypes = subscriber
.GetType ()
.GetInterfaces ()
.Where (x => x.IsGenericType && x.GetGenericTypeDefinition () == typeof (IHandleEvent<>));
@chilversc
chilversc / gist:743723
Created December 16, 2010 17:49
DataGridView pointer bug
/*
* Steps to reproduce:
*
* 1) click the button.
* 2) observe wait cursor displays for whole form.
* 3) hover mouse over data grid view (wait cursor shows).
* 4) click the button.
* 5) observe normal cursor displayed over form.
* 6) hove mouse over data grid view (wait cursor still shows).
*