Skip to content

Instantly share code, notes, and snippets.

View joshgo's full-sized avatar
🏠
Working from home

Josh joshgo

🏠
Working from home
View GitHub Profile
choco version all
choco upgrade all --noop
choco outdated
@joshgo
joshgo / GIT-CHEATSHEET.txt.md
Last active January 18, 2018 14:47
GITHUB-CHEATSHEET

GIT Cheatsheet

Stage partials/patch

git add --patch

Resolve PR merge conflicts

git fetch origin master
@joshgo
joshgo / config-settings.cs
Created April 4, 2014 15:12
ConfigSettings class for accessing the config file ... a nice clean way. It provides a Require()
public class ConfigSettings : System.Dynamic.DynamicObject
{
private static readonly System.Lazy<ConfigSettings> _settings = new Lazy<ConfigSettings>(() => new ConfigSettings());
private ConfigSettings()
{ }
public static dynamic Instance { get { return _settings.Value; } }
public override bool TryGetMember(System.Dynamic.GetMemberBinder binder, out object result)
@joshgo
joshgo / load-and-init-assembly.cs
Created March 28, 2014 15:04
Dynamically load an assembly, and call the static constructor of a specific class.
private static void LoadAndInit(string assemblyPath, string className)
{
var assembly = System.Reflection.Assembly.LoadFile(assemblyPath);
RuntimeHelpers.RunClassConstructor(assembly.GetType(className).TypeHandle);
}
@joshgo
joshgo / fib-example.go
Created March 28, 2014 14:20
Messing around with Go fibonacci example. Making the function successive forwards and backwards. #golang
package main
import "fmt"
// fib returns a function that returns
// successive Fibonacci numbers.
func fib() func(int) int {
a, b := 0, 1
i := 0
return func(x int) int {
@joshgo
joshgo / linq-expression-get-properties.cs
Created January 16, 2014 20:53
C# Linq Expressions that cache's the get properties
private static Dictionary<Type, Dictionary<string, object>> _propertyAccess = new Dictionary<Type, Dictionary<string, object>>();
private static void CacheProperties<T>()
{
if (_propertyAccess.ContainsKey(typeof(T)))
return;
_propertyAccess.Add(typeof(T), new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase));
foreach (var prop in typeof(T).GetProperties())
@joshgo
joshgo / test-expression-memberinit.cs
Created January 9, 2014 19:11
Playing around with expressions - Create a copy function
private Func<object, object> CreateInitFn(object obj)
{
var keyType = obj.GetType();
if (_initFn.ContainsKey(keyType))
{
return _initFn[keyType];
}
ParameterExpression xTmp = Expression.Variable(obj.GetType(), "tmp");
@joshgo
joshgo / svn-precommit.sh
Created November 20, 2013 17:21
SVN Pre-Commit script
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" > /dev/null
GREP_STATUS=$?
if [ $GREP_STATUS -ne 0 ]
then
@joshgo
joshgo / chocolatey-install-proxy.bat
Created July 29, 2013 14:40
Chocolatey Install Behind Proxy
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$a = new-object net.webclient; $a.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials;$a.DownloadString('https://chocolatey.org/install.ps1') | iex" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
@joshgo
joshgo / disposable-template.cs
Created May 17, 2013 02:38
Disposable Template - Courtesy of http://blog.phatboyg.com/
public class DisposableClass : IDisposable
{
bool _disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}