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
# Type(<scope>): <subject>
# <body>
# <footer>
# Type should be one of the following:
# * feat (new feature)
# * fix (bug fix)
# * docs (changes to documentation)
@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##*/}"
@alvaropinot
alvaropinot / color1.svg
Created July 27, 2016 18:37
svg color gradients
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alvaropinot
alvaropinot / fun-hacks.js
Created September 14, 2016 18:17
fun hacks
const randomColor = '#' + ((1 << 24) * Math.random() | 0).toString(16);
@alvaropinot
alvaropinot / curry.js
Last active May 31, 2017 08:02
curry and pipe playground
const pipe = (...functions) => startingValue => functions.reduce((actualValue, fn) => fn(actualValue), startingValue)
const sumTwo = (a) => a + 2
const mult = (a) => a + 2
const repeat = times => fn => Array(times).fill(fn)
const doTimes = times => fn => x => pipe(...repeat(times)(fn))(x)
const sumTwo4Times = doTimes(4)(sumTwo)
@alvaropinot
alvaropinot / groupArrayEach.js
Created June 7, 2017 08:32
group two elements each `n` elements with a nice offset :)
const transformIndex = (index, groupEach, offset) =>
offset + (index - offset - Math.ceil((index - offset) / groupEach))
const transformIndexEachThreeWithOneOffset = (index) => transformIndex(index, 3, 1)
function groupArrayEach(arr, groupEach=3, offset=0) {
return arr.reduce(function(acc, e, index) {
const newIndex = transformIndex(index, groupEach, offset)
acc[newIndex] = acc[newIndex] || []
acc[newIndex].push(e)
return acc
@alvaropinot
alvaropinot / map-to-object.js
Created October 3, 2017 17:58
"FUNctional" 😜 Map 🗺 to object 🔑
const obj = { a: 1, c: 3, b: 2 }
// Map from object.
const myMap = new Map(Object.entries(obj))
// Map to Object.
// NOTE: Keys will be cast to strings by `.toString`, so any "complex" key like for example `[1, 2]` will become `1,2`
const newObj = [...myMap.entries()]
.reduce((acc, [key, value]) => (Object.assign(acc, { [key]: value })), {})
@alvaropinot
alvaropinot / README.markdown
Created April 15, 2018 16:02 — forked from FranklinYu/README.markdown
links for old versions of Docker for Mac (inspired by docker/for-mac#1120)

links for old versions of Docker for Mac

Deprecated

Docker provides download links in release note. They promised that

(we) will also include download links in release notes for future releases.

Note:

@alvaropinot
alvaropinot / .vault
Created May 1, 2018 07:54 — forked from steve-jansen/.vault
HashiCorp Vault Token Helper using the OS X Keychain
token_helper = "/Users/me/.vault-helper"
@alvaropinot
alvaropinot / .vault
Created May 1, 2018 07:54 — forked from steve-jansen/.vault
HashiCorp Vault Token Helper using the OS X Keychain
token_helper = "/Users/me/.vault-helper"