This file contains 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 node | |
'use strict'; | |
// http://www.codewars.com/kata/53db4acb1f1a7dd68700040a/train/javascript | |
function canReach(from, to, movements) { | |
//FIXME: attempt in multiple moves | |
const offset = [ Math.abs(from[0] - to[0]), Math.abs(from[1] - to[1]) ]; | |
const valid_offsets = [ [1, 2], [2, 1] ]; | |
return valid_offsets.some(o => { |
This file contains 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 | |
# DanielFGray 2016 | |
# https://gist.github.com/d47925487840bb445296 | |
err() { | |
local c_red="${esc}[31m" | |
echo -e "${c_red}$1${c_reset}" >&2 | |
} |
This file contains 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
'use strict'; | |
function validISBN10(isbn) { | |
if(! /\d{9}[X0-9]/.test(isbn)) return false; | |
return isbn.split('').reduce((p, c, i) => { | |
return p + ((c == 'X') ? 10 : parseInt(c)) * ++i; | |
}, 0) % 11 == 0; | |
} | |
(function (func, cases, invert) { |
This file contains 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 node | |
'use strict'; | |
const runlength = {}; | |
runlength.decode = function(str) { | |
return str.match(/\d*\w/g) | |
.reduce((prev, curr) => | |
prev + (curr.length > 1 | |
? curr.slice(-1) |
This file contains 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 | |
declare esc=$(printf '\033') | |
declare c_reset="${esc}[0m" | |
declare c_red="${esc}[31m" | |
declare c_green="${esc}[32m" | |
declare c_blue="${esc}[34m" | |
err() { | |
echo -e "${c_red}$@${c_reset}" >&2 |
This file contains 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 node | |
'use strict'; | |
const range = function(start, stop) { | |
return Array.apply(null, { length: 1 + stop - start }) | |
.map((v, i) => start + i); | |
}; | |
const collatz = function(n, len) { | |
let steps = []; |
This file contains 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 | |
declare file="$(date +%F-%s).webm" | |
declare window=false | |
declare region=false | |
declare duration | |
declare delay=0 | |
declare verbose | |
declare -A dimensions |
This file contains 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 | |
has() { | |
command -v $1 &> /dev/null | |
} | |
err() { | |
echo -e "\e[31m$1\e[0m" >&2 | |
} |
This file contains 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! PromptQuit() | |
echo 'close current buffer?' | |
if nr2char(getchar())=~'y' | |
silent execute "normal \<esc>:Sayonara!\<cr>" | |
elseif nr2char(getchar())=~'Y' | |
silent execute "normal \<esc>:Sayonara\<cr>" | |
endif | |
silent! redraw! | |
endfunction | |
nnoremap <silent> Q <Esc>:call PromptQuit()<CR> |
This file contains 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 | |
usage() { | |
cat <<'HELP' | |
-s string to search | |
-t list only text files | |
-c command to execute [defaults to vim] | |
HELP | |
} |