Skip to content

Instantly share code, notes, and snippets.


Steven Levine slevine

View GitHub Profile
View gist:f92648e120f8c6318e7e
### Keybase proof
I hereby claim:
* I am slevine on github.
* I am stevelevine ( on keybase.
* I have a public key whose fingerprint is A4D5 89E2 503C 5061 913D 3599 2670 0D7B F029 5495
To claim this, I am signing this object:
slevine / Default (OSX).sublime-keymap
Last active Dec 31, 2015 — forked from uberbuilder/Default (OSX).sublime-keymap
Simple Sublime Plugin to Add ### Date to a Markdown document
View Default (OSX).sublime-keymap
{ "keys": ["command+alt+1"], "command": "add_date_stamp" }
slevine /
Last active Dec 13, 2015
Simple script to create a Riak cluster on OSX after installing Riak via Homebrew.
# Script taken from:
# Thanks Otto Pöllath!
CWD=$(cd $(dirname $0); pwd)
echo "Creating dev directory ${BASE_DIR}"
mkdir "${BASE_DIR}"

There are four different ways one can deploy a webapp to Tomcat.
If $TOMCAT_HOME is the Tomcat top-level directory:

  • Copy the war file foo.war or exploded war directory to $TOMCAT_HOME/webapps
  • Create a context file context.xml in the webapp’s META-INF/ directory that contains a fragment that describes the webapp deployment
  • Add a <Context> element to the <Host> element in Tomcat’s server.xml that describes the webapp deployment, including docBase. docBase is a attribute that locates the war file or exploded war directory in the filesystem.
  • Create a context file foo.xml in $TOMCAT_HOME/conf/Catalina/localhost/foo.xml that contains a fragment that describes the webapp deployment, including docBase.

Sample $TOMCAT_HOME/conf/Catalina/localhost/foo.xml

slevine / websrv.rb
Created Oct 3, 2012
Simple Ruby Script that starts a WebServer using the current directory as the document root.
View websrv.rb
require 'rubygems'
require 'webrick'
require 'optparse'
options = {}
# Parse options
optparse = do|opts|
slevine /
Created Jan 11, 2012
Comparison between Mongo and Redis

NoSQL Discussion Points


  • Master/Slave - Main Goal Data Redundancy
  • Automated Failover - High Availability
  • Good for D/R


  • All Data is Versioned
slevine /
Created Apr 11, 2011
Tomcat Related Files
export CATALINA_HOME=/Developer/Java/Servers/apache-tomcat-7.0.2
export APP_NAME=pizzashop
export WAR_NAME=pizzashop-0.1.0.BUILD-SNAPSHOT.war
$CATALINA_HOME/bin/ stop
rm -rf $APP_NAME
unzip $WAR_NAME -d $APP_NAME
$CATALINA_HOME/bin/ start
View Evolution of a Ruby Programmer.rb
# Newbie Programmer
def factorial(x)
if x == 0
return 1
return x * factorial(x - 1)
puts factorial(6)
puts factorial(0)
slevine /
Created Jan 23, 2010
How to fix debugging issues in RubyMine 2.0.1 with Ruby 1.9.

If you are trying to debug Ruby code in RubyMine IDE, but are having difficulties such as, the IDE freezes after you try to step in, step over, or step next and are wondering if your configuration is wrong? It is not, if you happen to have installed the ruby-debug-ide19 gem from the command line (not from IDE), you need to patch the actual gem code to get things working nicely.

  1. Open the following file with your favorite text editor (part of ruby-debug-ide19 gem)

  2. Add the following code at line ~120 (look below for full code location):

    return "" if str == "$FILENAME"
View Mailer.groovy
import javax.mail.Session
import javax.mail.Message
import javax.mail.internet.MimeMessage
import javax.mail.internet.InternetAddress
@Grab(group = 'javax.activation', module = 'activation', version = '1.1'),
@Grab(group = 'javax.mail', module = 'mail', version = '1.4')