Skip to content

Instantly share code, notes, and snippets.

View OutlawAndy's full-sized avatar
🏠
Working from home

Andy Cohen OutlawAndy

🏠
Working from home
View GitHub Profile
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@OutlawAndy
OutlawAndy / prettify_json.rb
Created October 5, 2012 15:20 — forked from tilo/prettify_json.rb
Ruby script to pretty print JSON on the command line (comes with Ruby's json Gem)
#!/usr/bin/env ruby
require 'json'
require 'fileutils'
include FileUtils
# Parses the argument array _args_, according to the pattern _s_, to
# retrieve the single character command line options from it. If _s_ is
# 'xy:' an option '-x' without an option argument is searched, and an
# option '-y foo' with an option argument ('foo').
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@OutlawAndy
OutlawAndy / clockwork-init.sh
Created November 5, 2012 17:38 — forked from tomykaira/clockwork-init.sh
Create a new project with clockwork for heroku.
#!/bin/sh
# Licence: MIT
# Created by tomykaira, 2011-10-25
if [ $# -ne 1 ]; then
echo "Give me your new project name (only)"
exit 1
fi
@OutlawAndy
OutlawAndy / eventmachine.rb
Created November 15, 2012 02:44 — forked from jaigouk/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {
@OutlawAndy
OutlawAndy / 0-readme.md
Created December 1, 2012 18:59 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@OutlawAndy
OutlawAndy / serve
Last active December 19, 2015 10:19
a tiny wrapper around a ruby command to make serving a local directory with ruby's builtin web server even simpler
#!/usr/bin/env ruby
require 'optparse'
options = {}
simple_server = OptionParser.new do |opt|
opt.banner = "Usage: serve [DIRECTORY] [OPTIONS]"
opt.separator ''
opt.separator 'OPTIONS'
ActionView::Template.register_template_handler(:rb, :source.to_proc)
@OutlawAndy
OutlawAndy / states-hash.rb
Created July 27, 2013 23:51
a hash constant to help in converting state names to abbreviations
STATES_HASH = {
"alabama" => "AL",
"alaska" => "AK",
"arizona" => "AZ",
"arkansas" => "AR",
"california" => "CA",
"colorado" => "CO",
"connecticut" => "CT",
"delaware" => "DE",
"florida" => "FL",
@OutlawAndy
OutlawAndy / core-extensions.rb
Created July 28, 2013 00:04
a bunch of ruby core class extensions that I commonly use
Float.class_eval do
def to_money
ActionController::Base.helpers.number_to_currency self
end
alias money to_money
def to_dollar
try(:/,100)
end