Skip to content

Instantly share code, notes, and snippets.

@okeydoke
okeydoke / gist:2957957
Last active August 1, 2021 22:38
git aliases
via http://coderwall.com/p/euwpig?i=3&p=1&t=git
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.df "diff -U --color"
git config --global alias.st "status -sb"
#new branch
git config --global alias.nb "checkout -b"
@okeydoke
okeydoke / gist:a2ac8b5ebfc757e3dd14
Last active August 29, 2015 14:16
JS Object properties
function getAllMethods(object) {
return Object.getOwnPropertyNames(object).filter(function(property) {
return typeof object[property] == 'function';
});
}
console.log(getAllMethods(String).sort());
@okeydoke
okeydoke / functional-utils.js
Last active September 16, 2015 23:16 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@okeydoke
okeydoke / async-css.js
Created January 14, 2016 19:42
Async css loading
//http://stackoverflow.com/questions/5186638/how-to-asynchronously-load-css-using-jquery/32614409#32614409
var stylesheet = document.createElement('link');
stylesheet.href = '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css';
stylesheet.rel = 'stylesheet';
stylesheet.type = 'text/css';
// temporarily set media to something inapplicable to ensure it'll fetch without blocking render
stylesheet.media = 'only x';
// set the media back when the stylesheet loads
stylesheet.onload = function() {stylesheet.media = 'all'}
@okeydoke
okeydoke / start-ssh-agent.sh
Created February 1, 2016 03:01
auto start ssh-agent
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
agent_is_running() {
ssh-keygen -t rsa -b 4096 -C "jesse@okeydoke.net"
ssh-add ~/.ssh/id_rsa
eval "$(ssh-agent -s)" (windows)
clip < ~/.ssh/id_rsa.pub
https://github.com/settings/ssh
@okeydoke
okeydoke / gist:17d07643dd451b4cfd6a
Created March 3, 2016 00:50
Closure memory leak
Any objects that are scope acessible to a closure is scope acessible to all closures of that same scope level
@okeydoke
okeydoke / gist:435fc1306af55ab5b53d5952b80a03f3
Last active June 15, 2016 16:38
Windows 10 Bash node/npm
# Get root up in here
sudo su
# Update and begin installing some utility tools
apt-get -y update
#install git
apt-get install git-all
# Get latest version of node
idx = (p, o) => p.replace(/\[/g,'.').replace(/\]/g, '').split('.').reduce((xs, x) => (typeof xs !== 'undefined' && typeof xs[x] !== 'undefined') ? xs[x] : undefined, o)
// Taken from regex at bottom of this section https://html.spec.whatwg.org/#e-mail-state-(type=email)
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;