Skip to content

Instantly share code, notes, and snippets.

Avatar

Steven Levine slevine

View GitHub Profile
View gist:f92648e120f8c6318e7e
### 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 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
slevine / create-riak-cluster.sh
Last active Dec 13, 2015
Simple script to create a Riak cluster on OSX after installing Riak via Homebrew.
View create-riak-cluster.sh
# 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}"
View tomcat-deploy.md

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 Oct 3, 2012
Simple Ruby Script that starts a WebServer using the current directory as the document root.
View websrv.rb
#!/usr/bin/ruby
require 'rubygems'
require 'webrick'
require 'optparse'
options = {}
# Parse options
optparse = OptionParser.new do|opts|
@slevine
slevine / nosql.md
Created Jan 11, 2012
Comparison between Mongo and Redis
View nosql.md

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 Apr 11, 2011
Tomcat Related Files
View deploy.sh
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
View Evolution of a Ruby Programmer.rb
# 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 Jan 23, 2010
How to fix debugging issues in RubyMine 2.0.1 with Ruby 1.9.
View rubymine-debug-issue.md

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"
    
View Mailer.groovy
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')
])