Skip to content

Instantly share code, notes, and snippets.

View jessedearing's full-sized avatar

Jesse Dearing jessedearing

View GitHub Profile
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4n/M/hGnsDZgrJ6acSstQ0+HuhF/iZziU/nXR35vZn4tWFU/3UgDS2/7kQM1KMFVdkbzUv2VmoHPEI3XWGIBn6a8aBDwoJvXDfuepXvBnhERkRair/53uD8qseG9djxpbkudO2eJPSyR9678aTjb5jkzErM1cwFdT126JnrzlnYpl79lscTMfbzjY1gGtW/2UC5qgqS4+nQHgVFi9d9EmWFnUM4hPQV3SQtqsA76uqtChjrTCGFJ/FqSg2fO+SWpqE8BKoROa1Ad0CVPSBqpO7UdDNadIyzR3G0ZTyLLqb7E25qDs9eGg1ZyaARmZmtsOAEKQUVy6Hdy7wcYDy+9kw== jesse.dearing@gmail.com
postgres: /usr/local/Cellar/postgresql/9.0.4/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
mongo: mongod -f /usr/local/Cellar/mongodb/1.8.3-x86_64/mongod.conf
module Foo
class Bar
# stuff here...
end
end
# vs.
class Foo::Bar
# stuff here...
task 'create_hstore' do
sql = <<-HSTORE_SQL
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.11 2009/06/11 18:30:03 tgl Exp $ */
-- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE TYPE hstore;
CREATE OR REPLACE FUNCTION hstore_in(cstring)
@jessedearing
jessedearing / cleanup.sh
Created April 12, 2012 17:48 — forked from mdp/cleanup.sh
Git branch cleanup
#!/bin/bash
# This must be run from master
git checkout master
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
git branch --merged master | grep -v 'master$' | xargs git branch -d
# Show remote fully merged branches
@jessedearing
jessedearing / gist:2351836
Created April 10, 2012 14:44 — forked from twoism-dev/gist:1183437
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
class Classifier
def initialize
@docs = Hash.new(0)
@words = {}
end
def train(words,tag)
@docs[tag] += 1
@words[tag] ||= Hash.new(1)
words.each{|w| @words[tag][w] += 1 }
@jessedearing
jessedearing / best.rb
Created December 7, 2011 01:17
Best and Worst code of 2011 for Dallas.rb
def has_balanced_transfer_amounts
return if transfers.empty?
unless transfers.nil?
transfer_invalid = transfers.map(&:amount).reduce(:+) != 0
if transfer_invalid
errors.add(:transfers, "Transfer amounts do not balance")
end
end
end
@jessedearing
jessedearing / vim cheatsheet.md
Last active April 1, 2022 18:05
Vim Cheatsheet

#Vim Cheat Sheet

  • gqip - Reformats paragraph to textwidth
  • gq - Reformats selection
  • :Tab /= - Equally spaces based on the = symbol (requires Tabular vim plugin)
  • :setf language - Changes current language
  • :set language=language - Changes current language
  • <C-a> - Increments the number under the cursor
  • <C-x> - Decrements the number under the cursor
  • ~ - Toggles case and moves to next character in normal mode