Skip to content

Instantly share code, notes, and snippets.

View chilversc's full-sized avatar

Chris Chilvers chilversc

View GitHub Profile
colorscheme ir_dark
if has("gui_macvim")
set fuoptions=maxvert,maxhorz
set guifont=Monaco:h14
set guioptions-=T
set stal=2
end
set anti
@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
@chilversc
chilversc / gist:b085ec9885221edb8692
Created January 13, 2015 17:31
T-SQL nesting transactions for stored procedures
DECLARE @mark CHAR(32) = replace(newid(), '-', '');
DECLARE @trans INT = @@TRANCOUNT;
IF @trans = 0
BEGIN TRANSACTION @mark;
ELSE
SAVE TRANSACTION @mark;
BEGIN TRY
-- do work here
@chilversc
chilversc / target.xml
Last active January 21, 2016 12:28
Target to remove old typescript output files after msbuild. This will remove all javascript files found in the typescript output directory that were not generated by typescript.
<Target Name="TypeScriptCleanOldOutput" DependsOnTargets="PreComputeCompileTypeScript" AfterTargets="Clean;Build" Condition=" '$(TypeScriptOutDir)' != '' ">
<!--
Assumes the TypeScriptOutDir only contains generated code.
If a TypeScript file is deleted from the project the old js file
will remain in the output folder.
Find JS files in the output folder that were not generated by
TypeScript and delete them.
-->
@chilversc
chilversc / InstantType.cs
Created December 31, 2015 08:59
NHibernate NodaTime.OffsetDateTime
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
using NodaTime;
[Serializable]
public class InstantType : IUserType
{
@chilversc
chilversc / DevHost.cs
Last active February 5, 2016 19:49
Automatically reload topshelf service after build
using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
class Program
{
const string exe = "Server.exe";
const string config = exe + ".config";
@chilversc
chilversc / test.py
Last active March 4, 2016 16:46
Sphinx - generate reStructuredText table from directive
from docutils import nodes, core, io
from docutils.parsers.rst import Directive
def setup(app):
app.add_directive('test', TestDirective)
return {'version': '0.1'}
class TestDirective(Directive):
def run(self):
table = nodes.table(cols=2)