Skip to content

Instantly share code, notes, and snippets.

View DavidRagone's full-sized avatar

David Ragone DavidRagone

View GitHub Profile
@DavidRagone
DavidRagone / .pryrc
Created October 1, 2016 04:22 — forked from manno/.pryrc
pry command for graphing AASM models with graphviz
# see https://github.com/ivantsepp/aasm_graph/blob/master/bin/aasm_graph
Pry::Commands.helpers {
def dot_template(edges)
<<-DOT
digraph cronjob {
rankdir=LR; /* This should be configurable */
node [shape = circle];
#{edges}
}
DOT
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@DavidRagone
DavidRagone / gist:4242337
Created December 8, 2012 22:43 — forked from markbates/gist:4240848
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@DavidRagone
DavidRagone / gist:4100458
Created November 17, 2012 21:30
Setup PostgreSQL for Rails development in Mac OS 10.7.x (aka Lion)
# Clean a previous install
brew uninstall postgre
rm -rf /usr/local/var/postgres/
# Install the database with brew package manager
brew install postgres
brew info postgresql
# Initialize the database
initdb /usr/local/var/postgres
@DavidRagone
DavidRagone / card.rb
Created October 21, 2012 19:07 — forked from dbc-challenges/card.rb
FlashCardinator
class Card
def initialize(term, definition)
@term = term
@definition = definition.chomp
end
attr_reader :term, :definition
def to_s
"Term: '#{term}', Definition: '#{definition}'"
@DavidRagone
DavidRagone / binary_vs_linear_searching.rb
Created October 6, 2012 05:44
binary vs linear searching
require 'benchmark'
require_relative "linear_search"
require_relative 'binary_search'
one_thousand = (1..1000).to_a
ten_thousand = (1..10_000).to_a
one_million = (1..1_000_000).to_a
test_cases = {1000 => one_thousand, 10000 => ten_thousand, 1000000 => one_million}
test_cases.each do |int, test_array|
# Put your answers here!
rvm rubies
ruby-1.8.7-p370 [ i686 ]
ruby-1.9.3-p125 [ x86_64 ]
=* ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default