Skip to content

Instantly share code, notes, and snippets.

View smullins7's full-sized avatar

Stephen Mullins smullins7

View GitHub Profile
@smullins7
smullins7 / php-hash
Created July 22, 2014 19:44
php sha512 hash command line
<?php
echo "Enter your password:\n";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
echo "HashedPassword:\n" . hash("sha512", trim($line)) . "\n";
?>
@smullins7
smullins7 / bash-for-loop-function
Created May 7, 2014 16:01
bash for.loop function, so I don't have to remember the for loop syntax...
function for.loop {
if [ $# -eq 0 ]
then
echo "Usage: for.loop <num-of-iterations> <command>"
return
fi
local iterations=${1}
local cmd=${@:2}
for i in $(seq 1 ${iterations}); do ${cmd}; done
}
@smullins7
smullins7 / vimrc-highlight-search-results
Created May 1, 2014 00:25
Vim highlighted search results
"toggle highlighting search results with space bar"
set hlsearch
noremap <silent> <Space> :silent noh<Bar>echo<CR>
@smullins7
smullins7 / bash-milliseconds-functions
Last active December 30, 2015 22:59
Bash functions to convert to and from milliseconds since epoch UTC. Requires moment (http://momentjs.com/docs/) to be installed.
function millis {
nvm use v0.10.12 > /dev/null && node -e "var m = require('moment'); console.log(+m.utc('${1}', ['MM/DD/YY', 'YYYYMMDDTHH:mm:ss']))"
}
function fmillis {
nvm use v0.10.12 > /dev/null && node -e "var m = require('moment'); console.log(m(${1}).utc().format())"
}