Skip to content

Instantly share code, notes, and snippets.

View cchamberlain's full-sized avatar

Cole Chamberlain cchamberlain

View GitHub Profile
@cchamberlain
cchamberlain / rdiff.ps1
Last active May 5, 2024 01:42
Recursively diffs 2 directories (files and contents) using MD5 hashes - Includes validation for paths and optional summary export. Requires PowerShell 3.0 or later.
#########################################################################
### USAGE: rdiff path/to/left,path/to/right [-s path/to/summary/dir] ###
### ADD LOCATION OF THIS SCRIPT TO PATH ###
#########################################################################
[CmdletBinding()]
param (
[parameter(HelpMessage="Stores the execution working directory.")]
[string]$ExecutionDirectory=$PWD,
[parameter(Position=0,HelpMessage="Compare two directories recursively for differences.")]
@cchamberlain
cchamberlain / pod.ps1
Last active July 2, 2017 11:44
PowerShell script for server deployments. Requires PowerShell 3.0 or later.
[CmdletBinding()]
param (
[parameter(HelpMessage="Enable tracing messages.")]
[alias("t")]
[switch]$POD_TRACE,
[parameter(HelpMessage="Enable debugging messages.")]
[alias("d")]
[switch]$POD_DEBUG=$POD_TRACE,
@cchamberlain
cchamberlain / CodeFormatter.sublime-settings
Created September 22, 2015 19:27
CodeFormatter comma-first javascript settings
{
"codeformatter_js_options":
{ "indent_size": 2
, "indent_char": " "
, "eol": "\n"
, "preserve_newlines": true
, "max_preserve_newlines": 3
, "brace_style": "expand"
, "keep_array_indentation": true
, "keep_function_indentation": true
@cchamberlain
cchamberlain / Preferences.sublime-settings
Last active September 22, 2015 18:28
My custom solarized sublime text 3 / VIM setup.
// Sublime Text 3 User Preferences
// Put https://gist.github.com/cchamberlain/e9b1819a7f2a16b9ff73 in Packages\User
// Package Control
// Sodarized, Vintageous, Block Cursor Everywhere, Expand Tabs on Save
{
// https://gist.github.com/cchamberlain/e9b1819a7f2a16b9ff73
"color_scheme": "Packages/User/Solarized (dark).tmTheme",
"ignored_packages":
[
@cchamberlain
cchamberlain / Solarized (dark).tmTheme
Last active January 16, 2017 21:12
Customized version of https://github.com/jrolfs/sodarized modified for better looking block cursor (Vintageous / Block Cursor Everywhere)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Solarized (dark)</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@cchamberlain
cchamberlain / scp-copy-roms.cmd
Created September 20, 2015 03:14
Copy ROMs from local computer to emulationstation via scp
scp -r .\SNES\ pi@192.168.1.18:/home/pi/RetroPie/roms/snes
@cchamberlain
cchamberlain / NuGet.config
Created September 8, 2015 01:24
~/.config/NuGet/NuGet.config (for dnvm)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
</configuration>
public abstract class DapperApiService<TModel, TKey> : DapperService, IApiService<TModel, TKey> {
protected DapperApiService(string connectionString, ICacheProvider cacheProvider = null) : base(connectionString, cacheProvider) {}
protected SqlApiService<TModel, TKey> Sql { get; } = new SqlApiService<TModel, TKey>();
public IEnumerable<TModel> Get(string whereClause, object param = null, int top = 500)
=> Query<TModel>(Sql.Get(whereClause, top));
public IEnumerable<TModel> Get(object param = null, int top = 500)
@cchamberlain
cchamberlain / IApiService.cs
Created August 26, 2015 04:39
API Service Interface
/// <summary>
/// By adhering to this interface, services will align to all the common HTTP methods and will expose sync and async versions.
/// </summary>
/// <typeparam name="TModel">The type of model that the SQL entity will be bound to. Can be decorated.</typeparam>
/// <typeparam name="TKey">The type of primary key of the model (primitive). Can be decorated.</typeparam>
public interface IApiService<TModel, in TKey> : IApiServiceSync<TModel, TKey>, IApiServiceAsync<TModel, TKey> {}
/// <summary>
/// By adhering to this interface, services will align to all the common HTTP methods and expose sync versions.
@cchamberlain
cchamberlain / TryExtensions.cs
Created August 23, 2015 02:27
Generic extension methods for inlining the flow of try-catch-finally blocks. Contains separate implementations for value types and reference types and handles both sync and async.
public static class TryExtensions {
/// <summary>
/// Inline try-catch-finally block for return <typeparamref name="TResult"/> value types. The input is chained through the try, and optionally through the catch and finally blocks. By default, will not throw unless an exception is returned from any of the try-catch-finally blocks.
/// </summary>
/// <typeparam name="T">The type of the input to flow through try-catch-finally.</typeparam>
/// <typeparam name="TResult">The type (value) of the try-catch-finally result.</typeparam>
/// <param name="input">The <typeparamref name="T"/> input to be chained through the try-catch-finally blocks.</param>
/// <param name="tryLogic">The try logic to execute. Receives <typeparamref name="T"/> input and returns <typeparamref name="TResult"/> result or any exception object which will subsequently be thrown.</param>
/// <param name="catchLogic">The catch logic to execute. Runs only when try logic throws. Receives the exception and <typeparamre