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 | |
TEMP="./tmp" | |
REGEX="img\/[^>]+?(\"|\)|'| )" | |
ROOTPATH="./public" | |
PATH_TO_CLEAN="./public/img" | |
egrep -iowhr "$REGEX" * | rev | cut -c 2-1000 | rev | xargs -I {} sh -c "mkdir -p $TEMP/{} && rm -r $TEMP/{} && cp $ROOTPATH/{} $TEMP/{}" |
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 validateAgainstSchema(array $schema, $data) { | |
$valid = true; | |
$done = false; | |
$path = ""; | |
$current = each($schema); | |
while($valid !== false && $current !== false) { | |
list($key, $value) = $current; |
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
#!/bin/bash | |
# Credit to: http://megakemp.com/2016/08/25/git-undo/ | |
git config --global alias.undo '!f() { \ | |
git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; \ | |
}; f' |
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 typeSizes = { | |
'boolean': () => 4, | |
'number': () => 8, | |
'string': (item) => 2 * item.length, | |
'object': (item) => Object.keys(item).reduce( | |
(sum, key) => sum + sizeOf(key) + sizeOf(item[key]), 0 | |
) | |
}; | |
export default const sizeOf = (value) => typeSizes[typeof value](value); |
NewerOlder