Skip to content

Instantly share code, notes, and snippets.

View cchamberlain's full-sized avatar

Cole Chamberlain cchamberlain

View GitHub Profile
@cchamberlain
cchamberlain / .zshenv
Last active October 27, 2017 22:45
USR_ZSHENV
#!/usr/bin/env zsh
#
# THIS FILE IS FOR USER SPECIFIC SETTINGS ONLY
export ZDOTDIR="${ZDOTDIR:-"$HOME/.zsh"}"
export GIT_USERNAME="cchamberlain"
export GIT_NPM_ID="npm/npm"
export GIT_ZDOTDIR_ID="cchamberlain/zdotdir"
export GIT_ZPREZTO_ID="cchamberlain/prezto"
@cchamberlain
cchamberlain / conemu-fatal-error
Created July 22, 2015 18:15
ConEmu Error: nNewWidth>0 && nNewHeight>0
## ERROR READS ##
Assertion in C:\Users\ColeChamberlain\local\conemu\ConEmu64.exe
[150716]
nNewWidth>0 && nNewHeight>0
at
RealBuffer.cpp:1796
## PASTE FROM ERROR POPUP ##
Assertion in C:\Users\ColeChamberlain\local\conemu\ConEmu64.exe [150716]
Exception 0x80000003 triggered in CRealConsole::MonitorThreadWorker
@cchamberlain
cchamberlain / ConEmu.xml
Created July 23, 2015 02:47
My ConEmu.xml
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2015-07-22 13:35:19" build="150716">
<value name="ColorTable00" type="dword" data="00362b00"/>
<value name="ColorTable01" type="dword" data="0000bfa8"/>
<value name="ColorTable02" type="dword" data="00009985"/>
<value name="ColorTable03" type="dword" data="0098a12a"/>
<value name="ColorTable04" type="dword" data="00164bcb"/>
<value name="ColorTable05" type="dword" data="00c4716c"/>
@cchamberlain
cchamberlain / AlgorithmExtensions.cs
Last active September 24, 2022 14:27
Extension methods for common algorithms.
/// <summary>
/// Algorithmic extension methods
/// </summary>
public static class AlgorithmExtensions {
private static readonly ThreadLocal<Random> Rng = new ThreadLocal<Random>(() => new Random());
private static readonly ThreadLocal<CryptoRandom> RngCrypto = new ThreadLocal<CryptoRandom>(() => new CryptoRandom());
/// <summary>
/// Shuffle a sequence using Fisher-Yates shuffle algorithm.
@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
@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.
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 / 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>
@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 / 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>