This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include this in your ~/.zshrc or ~/.bashrc | |
pconsole () { | |
if [[ $1 == production ]]; | |
then RAILS_ENV=production bundle exec pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers; | |
elif [[ $1 == test ]]; | |
then RAILS_ENV=test pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers; | |
else bundle exec pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers; | |
fi } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bigdecimal' | |
require 'csv' | |
require 'pp' | |
class Stats | |
include Enumerable | |
def initialize(array) | |
standardize_array(array) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'csv' | |
require 'pp' | |
class CodeSearch | |
def initialize(csv) | |
@file_path = csv | |
parse | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Two tips: | |
# Initialize a Hash with a default value of Array. | |
hash = Hash.new {|hash,key| hash[key] = []} | |
hash["some-key"] << "some-string value" | |
pp hash | |
# => {"some-key"=>["some-string value"]} | |
---------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
require 'pp' | |
# -------------------------------------------------------------- | |
# CONWAY'S GAME OF LIFE! | |
# | |
# Any live cell with fewer than two live neighbours dies, as if caused by under-population. | |
# Any live cell with two or three live neighbours lives on to the next generation. | |
# Any live cell with more than three live neighbours dies, as if by overcrowding. | |
# Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mysql2' | |
require 'faker' | |
require 'pry' | |
class SampleData | |
attr_reader :connection | |
def initialize(size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sass::Script::Functions | |
def insert_grid(columns, width_string) | |
assert_type columns, :Number | |
assert_type width_string, :String | |
width = width_string.match(/\A(\d+)(\w+)\z/)[1] | |
type = width_string.match(/\A(\d+)(\w+)\z/)[2] | |
raise StandardError, "You must set width_string with unit ie '960px'. " unless ["px","em", "pt", "%"].include?(type) | |
grid, grid_segment_width = "", 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Mammal(species, defining_characteristic) { | |
this.species = species; | |
this.defining_characteristic = defining_characteristic; | |
} | |
Mammal.prototype.print = function(){ | |
return "Hello I'm a " + this.species + ". " + | |
"I have " + this.defining_characteristic + "." | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'hippo' | |
ts = Hippo::TransactionSets::HIPAA_835::Base.new | |
ts.ST do |st| | |
st.TransactionSetControlNumber = '0021' | |
st.ImplementationConventionReference = '1234random1241' | |
end | |
puts ts.to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authors: Robert Jackson, Jonathan Jackson | |
# the formatting of this file has been altered in | |
# order to fit on this website. Check out | |
# https://gist.github.com/1233581 if you care | |
require 'chunky_png' #or 'oily_png' | |
class Hough | |
def initialize(image_path, options={}) | |
@image = ChunkyPNG::Image.from_file(image_path) | |
@image_path = image_path |