Skip to content

Commit

Permalink
Initial commit after blowing away repo (to hide its nefarious history…
Browse files Browse the repository at this point in the history
… from github)
  • Loading branch information
dbrady committed Jan 4, 2009
0 parents commit f327b34
Show file tree
Hide file tree
Showing 37 changed files with 2,879 additions and 0 deletions.
2,266 changes: 2,266 additions & 0 deletions ack

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions ansicolors
@@ -0,0 +1,31 @@
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
# Author: Giles Orr
# URL: http://gilesorr.com/bashprompt/howto/c350.html
# License: GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation;
# http://gilesorr.com/bashprompt/howto/a1004.html


T='gYw' # The test text

echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";

for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
16 changes: 16 additions & 0 deletions bloop
@@ -0,0 +1,16 @@
#!/bin/sh
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
echo BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP BLOOP
3 changes: 3 additions & 0 deletions cak
@@ -0,0 +1,3 @@
#!/bin/sh
echo 'Heh. You cacked.'
ack $*
5 changes: 5 additions & 0 deletions cdgem
@@ -0,0 +1,5 @@
#!/bin/sh
# Script to run cd, but given a custom name. Bind this
# particular command to search the folders in the rubygems folder in
# .bash_completions.
cd $*
31 changes: 31 additions & 0 deletions csvpeek
@@ -0,0 +1,31 @@
#!/usr/bin/env ruby
# Script to "peek" into a CSV file. Reads the header row, then dumps
# the csv file as blocks. Slice and dice the csv file beforehand using
# head and tail if needed. Usefel when trying to debug data imports
# from big csv's.
#
# TODO: If you tail a csv file, you lose the header rows. Fix this?
require 'csv'

# csvpeek filename.csv [file2.csv] [file3.csv] [...]

@headers = nil
@h2c = nil

@filename = nil

CSV::Reader.parse($<) do |row|
if @headers && @filename == $<.filename
@headers.each do |col|
puts "#{col}: #{row[@h2c[col]]}"
end
else
@filename = $<.filename
@headers = row.dup
@h2c = {}
row.each_with_index do |item, i|
@h2c[item] = i
end
end
puts '-' * 80
end
32 changes: 32 additions & 0 deletions custom_field_cache.rb
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby
# tablecounts.rb - Show all the tables from a database, including the count(*) from each table
require 'rubygems'
require 'mysql'

database=ARGV[0] || 'leadgen_development'

def max(a,b)
a>b ? a : b
end

begin
# connect to the MySQL server
dbh = Mysql.real_connect("localhost", "root", "", database)

res = dbh.query("SELECT * FROM custom_fields")
row_count = 0
while row = res.fetch_row do
puts "Passing #{row_count}..." if row_count%1000==0
row_count += 1 # stupid, but you get the idea
end
res.free
puts "All done. Counted #{row_count} rows."
rescue Mysql::Error => e
puts "Error code: #{e.errno}"
puts "Error message: #{e.error}"
puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
ensure
# disconnect from server
dbh.close if dbh
end

4 changes: 4 additions & 0 deletions davail
@@ -0,0 +1,4 @@
#!/bin/sh
# davail - Domain available?
# davail <domain.com>
whois $1 | grep -E '^No match for ' > /dev/null && echo "$1 is available" || echo "$1 is taken"
10 changes: 10 additions & 0 deletions decrypt
@@ -0,0 +1,10 @@
#!/bin/sh
#
# Decrypt a file with gpg, deleting the encrypted file. See also
# encrypt: I can never remember the correct syntax to encrypt a file
# using gpg. The command to decrypt a file is actually quite easy:
# "gpg -d file.txt.gpg $file.txt". This script exists only for
# completeness--if you've got encrypt, you gotta have decrypt.
#
# See also encrypt, decrypt_cat.
gpg -d $1 > $(basename $1 .gpg) && rm $1
9 changes: 9 additions & 0 deletions decrypt_cat
@@ -0,0 +1,9 @@
#!/bin/sh
#
# decrypt_cat -- decrypt file and cat it to screen. Mainly because I
# can't be bothered to remember gpg's options. (I know, this one looks
# really simple, but it's the only one that's simple and I can't be
# bothered to remember that THIS one is simple either. So nyeah.)
#
# See also encrypt, decrypt
gpg -d $1
3 changes: 3 additions & 0 deletions deke_pass
@@ -0,0 +1,3 @@
#!/bin/sh
# deke_pass -- decrypt file $1 and dump the info for topic $2
gpg -d $1 | grep -iEA 20 "^$2" | ruby -ne '$<.each_line {|line| puts line; break if line.strip == "" }'
15 changes: 15 additions & 0 deletions dhist
@@ -0,0 +1,15 @@
#!/bin/bash
# dhist <database> <table> <column> - Show a histogram of a column in a table
#
# E.g.
# dhist corpsales_production sales_statuses status
# +-----------------+----------+
# | status | COUNT(*) |
# +-----------------+----------+
# | pending | 2665 |
# | discounted | 14874 |
# | appointment | 69393 |
# | rejected | 157212 |
# +-----------------+----------+

mysql -D $1 -e "SELECT DISTINCT($3), COUNT(*) FROM $2 GROUP BY 1 ORDER BY 2"
74 changes: 74 additions & 0 deletions emalias
@@ -0,0 +1,74 @@
#!/usr/bin/env ruby -w
#
# emalias - create email aliases.
#
# TODO:
#
# - Enhance this with a universally decodable mechanism. If box_ is
# followed by a digit, we know to use simple base-36 encoding. If
# box_ is followed by a letter, however, we can use a different
# encoding scheme, something a little less obviously breakable. A
# simple first example would be a simple substitution cipher
# (perhaps even just rot13), and a simple second example would be a
# combination of both.
#
# - Hmm, composable encodings? This means that assembly of an email
# address should be kept separate from the encoding/decoding step,
# so that multiple encodings can be applied sequentially.

# (This is all still TODO):
# Encoded Format:
# <prefix><separator><encoding_id><separator><code>@<domain>
#
# Example:
# box.0.macheist@shinybit.com
#
# (The "0" encode is "no encode")

PREFIX = 'box_'
DOMAIN = 'shinybit.com'

def encode_address(addr)
if $DEBUG
puts "-" * 80
puts "addr: #{addr}"
end
"#{PREFIX}#{addr.to_i(36)}@#{DOMAIN}"
end

def decode_address(addr)
addr = addr.gsub(/^#{PREFIX}/, "")
addr = addr.gsub(/@.*$/, "")
addr.to_i.to_s(36)
end

def usage
puts str = <<EOT
emalias - encode_address and decode_address email address
usage:
emalias (options) <address>
options: One of the following MUST be specified
-d, --decode: decode address
-e, --encode: encode address
-h, -?, --help: this help message
EOT
end

if $0 == __FILE__
if $DEBUG
ARGV.each_with_index do |a,i|
puts "ARGV[#{i}]: #{ARGV[i]}"
end
end

# puts ARGV[1]
# puts encode_address(ARGV[1])

case ARGV[0]
when '-d', '--decode_address': puts "#{ARGV[1]} => #{decode_address(ARGV[1])}"
when '-e', '--encode_address': puts "#{ARGV[1]} => #{encode_address(ARGV[1])}"
when '-?', '-h', '--help': usage
end
end
10 changes: 10 additions & 0 deletions encrypt
@@ -0,0 +1,10 @@
#!/bin/sh
#
# Because I can never remember the command to encrypt a file using my
# own gpg keys.
#
# See also decrypt and decrypt_cat.
#
# TODO: If you are not me, change your name to "David Brady" so the
# following hardcode will work.
gpg -r "David Brady" -e $1 && rm $1
15 changes: 15 additions & 0 deletions fhish
@@ -0,0 +1,15 @@
#!/bin/sh
echo '**********************************************************************************'
echo '**********************************************************************************'
echo '**********************************************************************************'
echo '**************************** ****************************'
echo '**************************** IT REALLY IS EASY TO ****************************'
echo '**************************** TYPE fhish WHEN YOU ****************************'
echo '**************************** MEAN fhist, INNIT ****************************'
echo '**************************** ****************************'
echo '**************************** LEARN TO TYPE, DUMMY ****************************'
echo '**************************** ****************************'
echo '**********************************************************************************'
echo '**********************************************************************************'
echo '**********************************************************************************'
fhist $*
14 changes: 14 additions & 0 deletions fhist
@@ -0,0 +1,14 @@
#!/bin/sh

# fhist - file histogram.
#
# greps files recursively and displays the frequency of occurrence in each
# This is just a compound bash statement find -> grep -c -> awk -> sort; all
# arguments are passed to grep.
#
# myproject/app$ fhist -i program | tail -n 3
# 54 ./controllers/distribution_controller.rb
# 68 ./models/category.rb
# 70 ./institutions/yale.rb

find . -print0 | xargs -0 grep -c $* | awk -F ':' '{ print $2 " " $1 }' | sort -n | grep -vE '^0'
2 changes: 2 additions & 0 deletions gci
@@ -0,0 +1,2 @@
#!/bin/sh
git-commit $*
2 changes: 2 additions & 0 deletions gco
@@ -0,0 +1,2 @@
#!/bin/sh
git-checkout $*
2 changes: 2 additions & 0 deletions git-currentbranch
@@ -0,0 +1,2 @@
#!/bin/sh
git branch | grep '*' | awk '{print $2}'
6 changes: 6 additions & 0 deletions git-pooll
@@ -0,0 +1,6 @@
#!/bin/sh
# Pulls the current branch from the remote server (default origin)
branch=$(git branch 2>/dev/null | grep ^\* | sed -e s/^\*[[:space:]]// )
[ x$1 != x ] && remote=$1 || remote=origin
echo "git pull ${remote} ${branch}"
git pull ${remote} ${branch}
6 changes: 6 additions & 0 deletions git-poosh
@@ -0,0 +1,6 @@
#!/bin/sh
# Pushes the current branch to the remote server (default origin)
branch=$(git branch 2>/dev/null | grep ^\* | sed -e s/^\*[[:space:]]// )
[ x$1 != x ] && remote=$1 || remote=origin
echo "git push ${remote} ${branch}"
git push ${remote} ${branch}
15 changes: 15 additions & 0 deletions git-pull-all
@@ -0,0 +1,15 @@
#!/bin/sh
curbranch=$(git-currentbranch)
echo "Pulling updates into all local branches"
echo "You are in $curbranch"

for b in $(git branch|sed -e 's/\*//'); do
echo "checking out $b..."
git checkout $b
echo "pulling updates from $b..."
git pull
done

echo "Returning to $curbranch"
git checkout $curbranch

13 changes: 13 additions & 0 deletions git-track
@@ -0,0 +1,13 @@
#!/bin/sh
#
# I stole this one off the internet when somebody tweeted about it.
# It's pretty brilliant. Can't remember the author. Contact me if you
# recognize this code, and I'll give credit where it is due.

branch=$(git branch 2>/dev/null | grep ^\*)
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}

git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking

echo "tracking origin/$tracking"
2 changes: 2 additions & 0 deletions gst
@@ -0,0 +1,2 @@
#!/bin/sh
git-status $*
21 changes: 21 additions & 0 deletions headers
@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
#
# headers - program to read and output email headers. Point it at an
# email file (such as in vpopmail's domains/user/cur folder) to see
# the headers for that message.

if ARGV[0] == '-m'
opts[:multiline] = true
ARGV.pop
end

ARGV.each do |file|
File.open(file).each("") do |chunk|
if opts[:multiline]
puts chunk.rstrip
else
chunk.each_line {|line| puts line unless line =~ /^\s/}
end
break
end
end
27 changes: 27 additions & 0 deletions mknewrepo
@@ -0,0 +1,27 @@
#!/bin/sh
#
# Create a new git repository on monkey, turn the current folder into
# a git repo, and push it to monkey.
#
# Usage:
# ~/foobar $ mknewrepo foobar.git

echo ssh git@monkey mkdir repos/$1
ssh git@monkey mkdir repos/$1

echo ssh git@monkey "cd repos/$1 && git --bare init"
ssh git@monkey "cd repos/$1 && git --bare init"

echo git add remote monkey git@monkey:repos/$1
git remote add monkey git@monkey:repos/$1

echo git add .
git add .

echo git commit -m "Initial commit"
git commit -m "Initial commit"

echo git push monkey master
git push monkey master


0 comments on commit f327b34

Please sign in to comment.