Skip to content

Instantly share code, notes, and snippets.

View slevine's full-sized avatar

Steven Levine slevine

View GitHub Profile
### Keybase proof
I hereby claim:
* I am slevine on github.
* I am stevelevine (https://keybase.io/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
slevine / Default (OSX).sublime-keymap
Last active December 31, 2015 02:49 — forked from uberbuilder/Default (OSX).sublime-keymap
Simple Sublime Plugin to Add ### Date to a Markdown document
{ "keys": ["command+alt+1"], "command": "add_date_stamp" }
@slevine
slevine / create-riak-cluster.sh
Last active December 13, 2015 17:38
Simple script to create a Riak cluster on OSX after installing Riak via Homebrew.
# Script taken from: http://ottopoellath.github.com/blog/2012/04/08/running-a-three-node-riak-cluster-using-a-homebrew-installation
# Thanks Otto Pöllath!
#!/bin/bash
CWD=$(cd $(dirname $0); pwd)
BASE_DIR="${CWD}/dev"
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
slevine / websrv.rb
Created October 3, 2012 12:20
Simple Ruby Script that starts a WebServer using the current directory as the document root.
#!/usr/bin/ruby
require 'rubygems'
require 'webrick'
require 'optparse'
options = {}
# Parse options
optparse = OptionParser.new do|opts|
@slevine
slevine / nosql.md
Created January 11, 2012 17:59
Comparison between Mongo and Redis

NoSQL Discussion Points

Failover

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

Mongo

  • All Data is Versioned
@slevine
slevine / deploy.sh
Created April 11, 2011 18:40
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/catalina.sh stop
rm -rf $APP_NAME
unzip $WAR_NAME -d $APP_NAME
$CATALINA_HOME/bin/catalina.sh start
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@slevine
slevine / rubymine-debug-issue.md
Created January 23, 2010 20:23
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)

    $GEM_HOME/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb
    
  2. Add the following code at line ~120 (look below for full code location):

    return "" if str == "$FILENAME"
    
@slevine
slevine / Mailer.groovy
Created December 24, 2009 19:29
Groovy Mailer
import javax.mail.Session
import javax.mail.Message
import javax.mail.internet.MimeMessage
import javax.mail.internet.InternetAddress
@Grapes([
@Grab(group = 'javax.activation', module = 'activation', version = '1.1'),
@Grab(group = 'javax.mail', module = 'mail', version = '1.4')
])