Skip to content

Instantly share code, notes, and snippets.

## gemdoc
if ( which "gem" >/dev/null ) ; then
gemdoc() {
for e in lynx w3m elinks links /usr/bin/open ; do
if ( which $e >/dev/null ) ; then
HTML_OPEN="${e}"
fi
done
$HTML_OPEN `/bin/ls -1t $(gem env gemdir)/doc/$1*/rdoc/index.html | grep "\/$1\-[0-9]" |head -1`
#!/usr/bin/env ruby
require "optparse"
require "tempfile"
require "rubygems"
require "roo"
require "fastercsv"
require "addressable/uri"
OptionParser.new do |opts|
opts.banner = "Usage: [options] <file1> [file2 ...]"
@chorn
chorn / odd rvm fetch
Created November 5, 2010 13:03
System rvm install on a 10.10 linode. ree is already installed.
+__rvm_parse_args:422> [[ -z 4.3.10 ]]
+__rvm_parse_args:578> [[ -z '' && -n 1.9.2 ]]
+__rvm_parse_args:578> rvm_action=use
+__rvm_parse_args:580> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:15> [[ -n fetch ]]
+__rvm_parse_args:17> rvm_token=fetch
+__rvm_parse_args:19> [[ 1 -gt 0 ]]
+__rvm_parse_args:19> next_token=1.9.2
+__rvm_parse_args:19> shift
+__rvm_parse_args:21> case fetch (fetch|version|srcdir|reset|debug|reload|update|monitor|notes|implode|seppuku|question|answer|env)
@chorn
chorn / mysql_check.sh
Created December 23, 2010 15:41
Check all of the databases and tables on a mysql host.
#!/bin/bash
USER="root"
PASS=""
HOST="localhost"
TYPE="QUICK"
usage() {
echo "$0 [--host hostname] [--user username] [--pass password] [--type {valid mysql check table type}]"
echo " [--scan {scans ~/.my.cnf for user & password]"
#!/bin/bash
date_range() {
# Output list of dates from $1 to $2
}
for d in $(date_range 2011-01-01 2011-02-01) ; do
my_command $d
done
export _GNUDATE="date"
if [ "${OSTYPE:0:6}" = "darwin" ] && command -v gdate >/dev/null 2>/dev/null ; then
export _GNUDATE="gdate"
fi
date2stamp() {
$_GNUDATE --utc --date "$1" +%s
}
stamp2date() {
$_GNUDATE --utc --date "1970-01-01 $1 sec" "+%Y-%m-%d %T"
#!/bin/bash
##
# Don't be a dumbass and screw this up.
# If you modify this to be more awesome and don't tell me about it you are an assface.
# - @chorn
##
DB=""
FIELD=""
VALUE=""
TODO=""
@chorn
chorn / homebrew_launchctl.bash
Created November 9, 2011 21:27
I use this in my .bashrc so I can start/stop homebrew installed daemons via a 3 letter prefix. ``start mys'' for mysql. ``stop red'' for redis, etc.
simple_launchctl() {
command=$1
server=$2
for plist in ~/Library/LaunchAgents/*.plist ; do
if [[ `grep -c Cellar "${plist}"` -ne 0 ]] ; then
abbrev=`echo $plist | sed -E -e 's/^.*\///' -e 's/^[[:alnum:]]*\.[[:alnum:]]*\.//' -e 's/\.plist$//' -e 's/([[:alnum:]][[:alnum:]][[:alnum:]]).*/\1/'`
if [[ "$server" == "$abbrev" ]] ; then
launchctl $command -w "${plist}"
return
fi
#!/bin/bash
GZIP="gzip --best --rsyncable --quiet"
for DEST in $* ; do
[ ! -d "${DEST}" ] && exit -1
echo Running \"${GZIP}\" on everything in \"${DEST}\"
TRACKING="/tmp/${RANDOM}_parallel_gzip"
mkdir -p "${TRACKING}"
@chorn
chorn / refresh_git_repos.sh
Created February 28, 2012 19:58
Update the git repos I have cloned in my .* directories, i.e. .vim/bundle
find $HOME/.* -maxdepth 5 -type d -name .git -not -path "*.rvm/*" | while read r ; do echo $r && cd "$r/../" && git pull -q ; done ; cd $HOME