Skip to content

Instantly share code, notes, and snippets.

View jchadwick's full-sized avatar

Jess Chadwick jchadwick

View GitHub Profile
@jchadwick
jchadwick / DynamicSqlDataReader.cs
Created September 20, 2012 13:18
A helper class to read SQL results into a dynamic object
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
public class DynamicSqlDataReader
{
private static dynamic ToExpando(IDataRecord record)
{
@jchadwick
jchadwick / MainWindow.xaml
Created March 7, 2013 03:28
WPF Countdown Timer
<Window x:Class="StoryboardDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock x:Name="CountdownDisplay" FontFamily="Calibri" FontSize="60"/>
</Grid>
</Window>
@jchadwick
jchadwick / Parser.cs
Last active December 19, 2015 07:39
Parser
using System;
using System.Collections.Generic;
using System.Linq;
public static class Parser
{
public static readonly IDictionary<Type, Func<string, object>> Parsers =
new Dictionary<Type, Func<string, object>>
{
{typeof (char), source => char.Parse(source)},
@jchadwick
jchadwick / gist:6393258
Created August 30, 2013 19:08
Entity Framework type conversion
using System.Data;
using System.Data.Entity;
using System.Diagnostics;
public class Animal
{
public long Id { get; set; }
}
public class Dog : Animal
@jchadwick
jchadwick / CsvHelper.cs
Created October 9, 2013 18:37
CSV Reader/Writer
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public abstract class CsvHelper
{
protected internal const string DefaultDelimiter = ",";
protected internal static readonly char[] SpecialChars = new[] { ',', '\n', '\r', '"' };
@jchadwick
jchadwick / InlineEditor.ts
Last active August 29, 2015 13:56
AngularJS Inline Editor (TypesSript)
/// <reference path="../../scripts/typings/angularjs/angular.d.ts" />
/// <reference path="../../Scripts/typings/angularjs/angular-scenario.d.ts" />
module InlineEditor {
'use strict';
function InlineEditor(): ng.IDirective {
function link(scope: ng.IScope, container: ng.IAugmentedJQuery, attrs: ng.IAttributes, ngModel: ng.INgModelController)
: void {
@jchadwick
jchadwick / bootstrap-environment.ps1
Last active August 29, 2015 14:02
Dev Environment Bootstrapper
$toolsDir = "C:\Tools"
$files = @(
# Web Essentials 2013
"http://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361/file/105627/34/WebEssentials2013.vsix"
)
$packages = @(
"Chutzpah",
"Console2",
@jchadwick
jchadwick / AutomatedTestFixture.cs
Created June 17, 2014 04:08
Selenium Extensions
using System;
using System.IO;
using NUnit.Framework;
using Website.Automation.Workflows;
public abstract class AutomatedTestFixture
{
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
@jchadwick
jchadwick / Animal.ts
Created June 19, 2014 06:17
TypeScript demo
declare var log: {
(value): void;
};
interface Food {
name: string;
ingredients?: string[];
}
enum AnimalType {
@jchadwick
jchadwick / TodoServiceProxy.angular.js
Last active September 10, 2015 19:55
Todo Service Proxy
TodosService.$inject = [ '$http' ];
function TodosService($http) {
var baseUrl = "https://jchad-todo.azurewebsites.net/todos";
function getAll() {
return _unwrap($http.get(baseUrl));
}
function getById(todoId) {