Skip to content

Instantly share code, notes, and snippets.


Chris Chilvers chilversc

View GitHub Profile
chilversc / form1.cs
Created Nov 25, 2016
Example showing how blocking the UI thread allows clicks to be received for a 'disabled' button
View form1.cs
using System;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication1
public partial class Form1 : Form
static void Main()
chilversc / SortProject.linq
Created Oct 25, 2016
Sort msbuild project items
View SortProject.linq
<Query Kind="Program" />
static XNamespace ns = "";
static XName ItemGroup = ns + "ItemGroup";
static XName Reference = ns + "Reference";
static XName ProjectReference = ns + "ProjectReference";
static XName Condition = "Condition";
static XName Include = "Include";
static XName OutputType = ns + "OutputType";
static XName Folder = ns + "Folder";
chilversc / bower.json
Created Apr 22, 2016
webpack bootstrap-switch
View bower.json
"private": true,
"name": "temp",
"main": "main.js",
"dependencies": {
"bootstrap": "3.3.6",
"bootstrap-switch": "3.3.2"
chilversc /
Last active Mar 4, 2016
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)
chilversc / DevHost.cs
Last active Feb 5, 2016
Automatically reload topshelf service after build
View DevHost.cs
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 / InstantType.cs
Created Dec 31, 2015
NHibernate NodaTime.OffsetDateTime
View InstantType.cs
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
using NodaTime;
public class InstantType : IUserType
View file.js
addHost() {
var header = { key: this.hostHeaderKey, value: this.hostHeaderValue };
if (!this.hasHeader(header)) {
this.hostHeaderKey = '';
this.hostHeaderValue = '';
hasHeader(header) {
chilversc / target.xml
Last active Jan 21, 2016
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.
View target.xml
<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 /
Created Jul 15, 2015
ASP.Net MVC - Choose method to handle action based upon query string parameters

The scenario is a some external legacy code is accessing the site. In the past the request was handled by an IHttpHandler that dispatched to different private methods to handle the request based upon query string parameters.

The goal is to replace the IHttpHandler with a standard MVC controller.

  • The different requests should go to different methods.
  • We want to retain the standard MVC parameter binding.
  • We do not want one action with lots of parameters, many of which are unrelated.
chilversc / gist:2a1da3e6bc5689f89f9d
Last active Aug 29, 2015
Bootstrap, overriding tables with cascading styles is too verbose
View gist:2a1da3e6bc5689f89f9d
Due to boostrap's high specificity on td styles
I cannot see a shorter method to override this.
.table.vert-align-mid > thead > tr > td,
.table.vert-align-mid > thead > tr > th,
.table.vert-align-mid > tbody > tr > td,
.table.vert-align-mid > tbody > tr > th,
.table.vert-align-mid > tfoot > tr > td,