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
@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 / 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 / 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 / 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 / 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
choco version all
choco upgrade all --noop
choco outdated
choco install googlechrome
choco install git
choco install TortoiseGit
choco install 7zip
choco install sysinternals
choco install HeidiSQL
choco install winscp
choco install putty
choco install sublimetext3
choco install notepadplusplus
@joshgo
joshgo / longest-increasing-subsequence.cpp
Last active June 13, 2016 03:57
Find longest increasing subsequence
int longest_increasing_subsequence(vector<int>& nums)
{
map<int, int> table;
int tmax = 0;
for(int i = 0; i < nums.size(); i++)
{
int pmax = 0;
for(map<int, int>::iterator itr = table.begin(); itr != table.end() && itr->first < nums[i]; itr++)
@joshgo
joshgo / longest-increasing-subsequence.cpp
Created June 13, 2016 03:40
Find longest increasing subsequence:
int longest_increasing_subsequence(vector<int>& nums)
{
map<int, int> table;
int tmax = 0;
for(int i = 0; i < nums.size(); i++)
{
int pmax = 0;
for(map<int, int>::iterator itr = table.begin(); itr != table.end() && itr->first < nums[i]; itr++)
@joshgo
joshgo / longest_increasing_subsequence_v2.cpp
Created June 13, 2016 04:00
A faster version of my original longest_increasing_subsequence solution. Could be faster still.
int longest_increasing_subsequence_v2(vector<int>& nums)
{
map<int, set<int>> table;
int tmax = 0;
for(int i = 0; i < nums.size(); i++)
{
int pmax = 1;
for(map<int, set<int>>::reverse_iterator itr = table.rbegin(); itr != table.rend(); itr++)