Skip to content

Instantly share code, notes, and snippets.

View alvaropinot's full-sized avatar
🤘
Metal this

Alvaro Pinot @alvaropinot alvaropinot

🤘
Metal this
View GitHub Profile
@alvaropinot
alvaropinot / color1.svg
Created July 27, 2016 18:37
svg color gradients
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alvaropinot
alvaropinot / prepare-commit-msg.sh
Created July 18, 2016 11:50 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
# Type(<scope>): <subject>
# <body>
# <footer>
# Type should be one of the following:
# * feat (new feature)
# * fix (bug fix)
# * docs (changes to documentation)
@alvaropinot
alvaropinot / get.js
Last active June 21, 2016 09:59
get.js
function _get(property, defaultValue) {
var path = property.split(/[\.\["'\]]+/);
return function(obj) {
return typeof obj === 'object' ? path.reduce(function (acc, key) {
var value = acc && acc[key];
// should allow null and falsy values.
return (value || (value !== undefined)) ?
value :
defaultValue;
}, obj) :
@alvaropinot
alvaropinot / defaults-overrides.md
Created May 9, 2016 12:27 — forked from ericelliott/defaults-overrides.md
ES6 defaults / overrides pattern

ES6 Defaults / Overrides Pattern

Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.

function foo ({
    bar = 'no',
    baz = 'works!'
  } = {}) {
//from https://github.com/achohq/acho/blob/0a57c8450e781ca69c248103f48a24818dca695b/lib/Constants.coffee
'use strict'
figure =
false:
info : 'ℹ'
success : '✔'
warning : '⚠'
error : '✖'
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@alvaropinot
alvaropinot / args.js
Last active August 29, 2015 14:15
simple url arguments reader
//remove the starting '?' and split options
location.search.slice(1).split("&").forEach(function(opt) {
opt = opt.split('=');
console.log(opt); // ['arg1','val1'] ['arg2','val2']
});