Skip to content

Instantly share code, notes, and snippets.

View zph's full-sized avatar

Zander Hill zph

View GitHub Profile
@zph
zph / ggauto
Created November 23, 2014 00:56
#!/usr/bin/env bash
set -eou pipefail
readonly USERNAME="$1"
if [[ $(grep "$USERNAME" whitelist.txt ) ]];then
echo "Already on list"
exit 2
else
@zph
zph / -
Created November 1, 2014 21:19
ngrok (Ctrl+C to quit)
Tunnel Status online
Version 1.7/1.6
Forwarding http://a5c92a1.ngrok.com -> 127.0.0.1:4567
Forwarding https://a5c92a1.ngrok.com -> 127.0.0.1:4567
Web Interface 127.0.0.1:4040
# Conn 0
Avg Conn Time 0.00ms
@zph
zph / app.rb
Created November 1, 2014 21:14
require 'pp'
require 'sinatra'
get '/' do
key_env = env.dup
useful = key_env.delete_if { |k, v| !k[/^HTTP_/] }.sort
useful.map do |k,v|
"#{k} => #{ v }"
end.join("<br>")
end
# Ruby failing to compile with a 137 exit code & Fail to compile RI Docs?
# Use the --disable-install-doc flag
# Credit: http://stackoverflow.com/a/15502089/1930671
ruby-install ruby 2.1 -- --disable-install-doc
source /usr/local/share/chruby/chruby.sh
# RUBIES+=(~/.rvm/rubies/*)
source /usr/local/share/chruby/auto.sh
# Credit: https://github.com/postmodern/chruby/wiki/Implementing-an-'after-use'-hook
save_function()
{
local ORIG_FUNC="$(declare -f $1)"
local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
eval "$NEWNAME_FUNC"
@zph
zph / cloak.ovpn
Last active August 29, 2015 14:08
client
dev tun
comp-lzo
remote-cert-tls server
server-poll-timeout 10
auth-user-pass
auth-nocache
auth-retry interact
verb 1
remote openvpn.getcloakvpn.com 443 udp
@zph
zph / .vimrc
Created October 21, 2014 18:18
" Hack for speeding up vim load when using rvm
"let g:ruby_path = system('rvm use system')
"" Uses infect.gem to package install all these suckers
"=bundle tpope/vim-pathogen
""=bundle tpope/vim-sensible
source ~/.vim/bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect('bundle/{}')
" Erlang
(ns employee-vs-contractor.core)
(def pct 100)
(defn health-insurance [health-insurance percent]
"Calculates the value of health insurance coverage. Provide percent as [100]"
(let [months 12.0]
(/ (* months health-insurance percent) pct)))
(defn vacation [salary paid-days work-days]
while read -r line
do
echo "$line"
done < <(jobs)
@zph
zph / zshrc.sh
Created September 10, 2014 13:27
Three commands for managing your $PATH
_remove_from_path(){
local item="$1"
cleansed_path=$(echo -n $PATH | tr ':' "\n" | grep -v "^${item}$" | grep -v '^$' | tr "\n" ':')
export PATH=$cleansed_path
}
_add_to_path(){
local item="$1"
export PATH=${item}:$PATH
}