- CSS position
- Margin collapsing
- Display types (inline, block, none, table-*, flex) and what they mean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/2450976/2684520 | |
// https://bost.ocks.org/mike/shuffle/ | |
function shuffle(array) { | |
var m = array.length, t, i; | |
// While there remain elements to shuffle… | |
while (m) { | |
// Pick a remaining element… | |
i = Math.floor(Math.random() * m--); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/3955238/2684520 | |
const emptyNode = (el) => { | |
while (el.lastChild) { | |
el.removeChild(el.lastChild); | |
} | |
return el; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = ( | |
f, arr = [] | |
) => (...args) => ( | |
a => a.length === f.length ? | |
f(...a) : | |
curry(f, a) | |
)([...arr, ...args]); | |
// Unbound native-friendly since you can specify arity (typicaly native.length + 1) | |
const curry2 = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delegate(selector, handler) { | |
return (ev) => { | |
const tgt = ev.target; | |
// Check if the event target matches the selector or if it is a descendant | |
// of the selector | |
if (tgt.matches(selector) || tgt.matches(`${selector} ${tgt.nodeName.toLowerCase()}`)) { | |
// Since `ev.target` is the deepest element that triggered the event, it | |
// won't always match the selector for the delegated event, so we add a | |
// custom key to the event object for the delegate event target. | |
handler(Object.assign(ev, { delegateTarget: closest(tgt, selector) })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = true | |
[*] | |
charset = utf-8 | |
indent_style = space | |
indent_size = 4 | |
end_of_line = lf | |
trim_trailing_whitespace = true | |
insert_final_newline = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body.modal-is-visible { | |
/* https://stackoverflow.com/a/43677395/2684520 */ | |
position: fixed; | |
overflow: hidden; | |
width: 100%; | |
height: 100%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateImageFromText(text, width, height) { | |
// TODO Add auto-wrapping logic when text is too wide | |
// TODO Add tiered text scaling (if height > 200: font-size = 36; else if height > 100: font-size = 18; etc) | |
const canvas = document.createElement('canvas'); | |
canvas.width = width; | |
canvas.height = height; | |
const ctx = canvas.getContext('2d'); | |
const fontSize = Math.min(height, 36); | |
ctx.fillStyle = '#212121'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# MIT © Sindre Sorhus - sindresorhus.com | |
# https://gist.github.com/sindresorhus/7996717 | |
# 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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
co = checkout | |
ci = commit | |
st = status | |
br = branch | |
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short | |
type = cat-file -t | |
dump = cat-file -p | |
current-branch = rev-parse --abbrev-ref HEAD | |
cb = rev-parse --abbrev-ref HEAD |