View pgstore.rb
require 'pg' | |
PGDB = PG.connect(host: '/tmp', dbname: 'mydb') | |
PGDB.type_map_for_results = PG::BasicTypeMapForResults.new(PGDB) | |
class Hash | |
def symbolize_keys | |
inject({}) { |m, kv| v = kv[1]; | |
m[kv[0].to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v; m } | |
end | |
end |
View gist:8105846
#!/bin/bash | |
D=`ruby -e 'puts File.dirname(File.realpath(File.expand_path("'${BASH_SOURCE[0]}'")))'` | |
pushd "${D}" >/dev/null | |
# ... Do stuff ... | |
popd >/dev/null |
View new_bashrc.sh
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |
View gist:2884332
#!/bin/bash | |
# Put's the script's directory in the $BS variable. | |
# Follows symlinks, works on mac-os as well as linux etc. | |
# Move final popd to the end of your script if you want to run your script with the script's directory as the working directory. | |
BS="${BASH_SOURCE[0]}";RL="readlink";([[ `uname -s`=='Darwin' ]] || RL="$RL -f") | |
while([ -h "${BS}" ]) do BS=`$RL "${BS}"`; done | |
N="/dev/null";pushd .>$N;cd `dirname ${BS}`>$N;BS=`pwd`;popd>$N | |
# ... rest of the script ... use ${BS} when referring to this script's directory |