Skip to content

Instantly share code, notes, and snippets.

View JasonCust's full-sized avatar
🍺
Hold my beer…

Jason Cust JasonCust

🍺
Hold my beer…
View GitHub Profile
@JasonCust
JasonCust / clone.js
Last active August 29, 2015 14:00
Collection of simple helper functions.
function clone(object) {
switch (getObjectType(object)){
case 'Object':
object = Object.keys(object).reduce(function(obj, key) {
obj[key] = clone(object[key]);
return obj;
}, {});
break;
case 'Array':
@JasonCust
JasonCust / Logger.js
Created June 10, 2015 18:27
Simple Express logger
function log(req, res, next) {
var start = process.hrtime();
var write = res.write;
var end = res.end;
var chunks = [];
res.write = function newWrite(chunk) {
chunks.push(chunk);
write.apply(res, arguments);
var Person = {
first: undefined,
last: undefined,
personMethod: function personMethod() {
console.log( this.first, this.last);
}
};
var Employee = Object.create(Person);
Employee.position = undefined;
@JasonCust
JasonCust / .gitconfig
Last active April 25, 2016 17:04
Git config file showcasing an advanced alias for lazily getting an author's commits for standup meetings.
[alias]
# Sample uses (defaults for Tues-Sat: from "yesterday AM" to "now", for Sun-Mon: from "last friday AM" to "now"):
# $ git standup
# $ git standup "last week"
# $ git standup "3 days ago"
# $ git standup "last monday" "last friday"
# $ git standup --stat
# $ git standup "last thursday AM" "last thursday PM" --pretty --date=short
# For date formats: https://github.com/git/git/blob/master/date.c
standup = "!f() { : git log ; \
@JasonCust
JasonCust / post-merge
Last active May 20, 2016 18:31 — forked from sindresorhus/post-merge
A git hook to run checks and commands automatically after `git pull`
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)
check_run() {
echo "${changed_files}" | grep --quiet "$1" && eval "$2"

Keybase proof

I hereby claim:

  • I am jasoncust on github.
  • I am jasoncust (https://keybase.io/jasoncust) on keybase.
  • I have a public key whose fingerprint is F68A C9EB 2D17 7F4D 684F 6BD8 FB33 77BC 278E 81B5

To claim this, I am signing this object:

@JasonCust
JasonCust / objects-basic.js
Last active January 22, 2017 05:05
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment
/* ES5 equivalent
var obj = { one: 1, two: 2, three: 3 };
var one = obj.one;
var two = obj.two;
*/
let obj = { one: 1, two: 2, three: 3 };
let {one, two} = obj; // <-- Destructuring Assignment
console.log({one, two}); // output: { one: 1, two: 2 }
@JasonCust
JasonCust / arrays-basic.js
Last active January 22, 2017 05:05
ES2015 Destructuring Assignment Example -- Basic array destructuring assignment
/* ES5 equivalent
var arr = [1, 2, 3];
var one = arr[0];
var two = arr[1];
*/
let arr = [1, 2, 3];
let [one, , three] = arr; // <-- Destructuring Assignment
console.log({one, three}); // output: { one: 1, three: 3 }
@JasonCust
JasonCust / arrays-defaults-basic.js
Last active January 22, 2017 05:26
ES2015 Destructuring Assignment Example -- Basic array destructuring assignment with default value
/* ES5 equivalent (ignoring assignment of intended falsy values)
var arr = [];
var one = arr[0] || 1;
var two = arr[1];
*/
let arr = [];
let [one = 1, two] = arr;
console.log({one, two}); // output: { one: 1, two: undefined }
@JasonCust
JasonCust / arguments-basic-defaults.js
Created January 17, 2017 01:57
ES2015 Destructuring Assignment Example -- Basic function argument destructuring assignment with default value
/* ES5 equivalent (ignoring assignment of intended falsy values)
function foo(one, two) {
one = one || 1;
console.log({one, two});
}
*/
function foo(one = 1, two) {
console.log({one, two});
}