Skip to content

Instantly share code, notes, and snippets.

View scottwb's full-sized avatar

Scott W. Bradley scottwb

View GitHub Profile
@scottwb
scottwb / config_hierarchy_classes.rb
Created November 30, 2009 00:49
Ruby Config Hierarchy Class
#!/usr/bin/env ruby
# This file demonstrates a simple experiment to make a hierarchy of config classes
# where each class can simply define a hash of config values which augment/override
# those of it's parent class. Each class uses class methods to access the config
# values by name. In addition to the config hash, each class can define custom
# class methods that combine/format config values, even if those values are actually
# defined in an ancestor or descendant class.
class BaseConfig
@scottwb
scottwb / bash_string_var_replacement.sh
Created December 1, 2009 09:13
String replacement in a string var in bash.
#!/bin/sh
# Shows how to do replacment in a string variable in bash.
SRC_STRING=/Applications/something
REPLACED_STRING=${SRC_STRING//\//\\/}
echo "Source String is: $SRC_STRING"
echo "Replaced String is: $REPLACED_STRING"
@scottwb
scottwb / drop_all_tables.rb
Created December 1, 2009 10:09
Ruby script to drop all tables in a MySQL database.
#!/usr/bin/env ruby
#
# Drops all the tables in a MySQL database, without dropping the databse.
#
###############################################################################
# Usage
###############################################################################
usage=<<EOT
@scottwb
scottwb / kill_server.rb
Created December 1, 2009 10:28
Script to kill Rails script/server processes.
#!/usr/bin/env ruby
#
# Quick-and-dirty script to kill rogue script/server processes.
#
###############################################################################
# Configuration
###############################################################################
# The command you use to run your Rails server.
@scottwb
scottwb / findstr.rb
Created December 1, 2009 11:45
Find a string in configured set of dirs and files.
#!/usr/bin/env ruby
#
# Script to search for a string in a set of configured dirs. The main
# value of this is to provide:
#
# * Easy configuration for a common set of directories you like to
# grep through, and the file patterns to match per directory.
#
# * Easy configuration for the common grep options you like to use.
#
@scottwb
scottwb / makepem.sh
Created December 23, 2009 11:01
Create .pem certificate.
#!/bin/sh
#
# Script to create an SSL .pem certificate.
#
# Adapted from Fedora's /etc/pki/tls/certs/Makefile. Only tested on
# Mac OS X 10.5.
#
PEMFILE=$1
@scottwb
scottwb / check_nfs.sh
Created February 24, 2010 22:41
Checks if NFS mount is wedged.
#!/bin/sh
#
# Checks to see if an NFS-mounted dir is wedged.
#
# Sometimes the NFS mount goes down. Other tactics like rpcinfo didn't
# pan out, so this hack is just based on trying to ls the mounted dir
# and timing that out if it doesn't respond quickly.
#
# Usage: check_nfs.sh <dirpath>
#
@scottwb
scottwb / gist:350738
Created March 31, 2010 19:14 — forked from jnunemaker/gist:350680
Alias file stolen from jnunemaker
alias reload='. ~/.bashrc'
alias ea="$EDITOR ~/bin/dotfiles/bash/aliases && reload"
alias ee="$EDITOR ~/bin/dotfiles/bash/env && reload"
alias eh="$EDITOR ~/bin/dotfiles/bash/heroku && reload"
# Processes
alias tu='top -o cpu'
alias tm='top -o vsize'
# Projects
@scottwb
scottwb / gist:357446
Created April 6, 2010 10:29
Previews a markdown file in the browser.
#!/usr/bin/env ruby
#
# Previews a markdown file in the browser.
#
# Usage: markdown <filename>
#
# Requires: gem install maruku
#
infile = ARGV[0]
= Ruby Packaging Standard
The aim of this document is to specify a common structure of how a
Ruby package distributed as source (that is, but not limited to,
development directories, version-controlled repositories, .tar.gz,
Gems, ...) should conform to.
(See RFC 2119 for use of MUST, SHOULD, SHALL.)
== Library files