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 / README
Created November 12, 2009 02:04
Applescript used to change application preferences and application geometry based upon a screen resolution.
Overview
--------
This file is invoked when switching from a standalone Macbook Pro display to a Apple Cinema display.
Originally, the only problem I was trying to solve was to move my dock from the side of the screen to
the bottom (which it does), but then after diving deeper in to the Applescript API's, it became obvious
to me that there was no limit to what I can configure.
Details
-------
The flow of the script is as follows:
@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')
])
@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"
    
# 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 / 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
@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 / 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 / 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}"
@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" }