Skip to content

Instantly share code, notes, and snippets.

View mranallo's full-sized avatar

Mark Ranallo mranallo

View GitHub Profile
# How to find out where a method comes from.
# Learned this from Dave Thomas while teaching Advanced Ruby Studio
# Makes the case for separating method definitions into
# modules, especially when enhancing built-in classes.
module Perpetrator
def crime
end
end
class Fixnum
Deploying a Rails App with EC2 + S3 + Ubuntu
============================================
Create EC2 Instance
-------------------
create new instance ami-bf5eb9d6 [http://alestic.com/](http://alestic.com/)
create new elastic ip
attach elastic ip to instance
point dns to elastic ip
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
def flash_helper
[:notice, :warning, :message, :success].collect do |key|
content_tag(:div, flash[key], :class => "#{key}") unless flash[key].blank?
end.join
end
def flash_helper
[:notice, :warning, :message, :success].collect do |key|
content_tag(:div, flash[key], :class => "#{key}") unless flash[key].blank?
end.join
end
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
@mranallo
mranallo / show
Created April 20, 2011 19:34 — forked from tekacs/show
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}
@mranallo
mranallo / emacs.rb
Created July 29, 2011 17:36 — forked from pingles/emacs.rb
Homebrew Emacs for OSX Lion with native full-screen
require 'formula'
class Emacs < Formula
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3.tar.bz2'
md5 'a673c163b4714362b94ff6096e4d784a'
homepage 'http://www.gnu.org/software/emacs/'
if ARGV.include? "--use-git-head"
head 'git://repo.or.cz/emacs.git'
else
@mranallo
mranallo / delete-tags.sh
Created January 24, 2012 21:39 — forked from rgrove/delete-tags.sh
Shell script to delete useless build tags from GitHub forks of YUI 3
#!/bin/bash
# This script will delete *all* local and remote tags from any git repo you run
# it in, unless they begin with "v". Please use it to remove the hundreds of
# build tags from your YUI 3 fork.
#
# This script will not delete branches; just tags.
set -e
@mranallo
mranallo / gist:1760327
Created February 7, 2012 15:46
Mongo Connection Id
module Mongodb
def self.db
config = Rails.configuration.database_configuration["mongodb_#{Rails.env}"]
host = config["host"]
database = config["database"]
username = config["username"]
password = config["password"]
port = config["port"]