Skip to content

Instantly share code, notes, and snippets.

Zach Gershman zachgersh

Block or report user

Report or block zachgersh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zachgersh
zachgersh / race.txt
Last active Dec 7, 2018
race-gorouter
View race.txt
==================
WARNING: DATA RACE
Read at 0x00c0001ed200 by goroutine 114:
code.cloudfoundry.org/gorouter/route.(*Pool).IsOverloaded()
/Users/pivotal/workspace/routing-release/src/code.cloudfoundry.org/gorouter/route/pool.go:337 +0x1aa
code.cloudfoundry.org/gorouter/handlers.(*lookupHandler).ServeHTTP()
/Users/pivotal/workspace/routing-release/src/code.cloudfoundry.org/gorouter/handlers/lookup.go:45 +0xda
github.com/urfave/negroni.middleware.ServeHTTP()
/Users/pivotal/workspace/routing-release/src/github.com/urfave/negroni/negroni.go:33 +0x116
github.com/urfave/negroni.middleware.ServeHTTP-fm()
View orange_tree.rb
# This is how you define your own custom exception classes
require 'debugger'
class NoOrangesError < StandardError
end
class OrangeTree
# Ages the tree one year
attr_accessor :dead, :oranges, :age, :height
View Ruby_Drill:_Exploring_Scope_solution.rb
# Solution for Challenge: Ruby Drill: Exploring Scope. Started 2013-07-22T18:55:03+00:00
THIS_IS_A_CONSTANT = "constantS"
$global_var = "This is my global variable. Don't Do THIS!!!"
def get_constant
THIS_IS_A_CONSTANT
end
View Ruby_Drill:_The_self_Keyword_solution.rb
# Solution for Challenge: Ruby Drill: The self Keyword. Started 2013-07-22T18:43:38+00:00
# There are two representations of self that one can use at any time:
# 1. When defining a class method, self refers to the current class
# 2. When using an instance of a class, self refers to the current instance
# Self refers to the object you are currently calling a method on
@zachgersh
zachgersh / 99_problems.rb
Created Apr 14, 2013
Simple gist describing a problem I am having with case statements.
View 99_problems.rb
def problems(number)
case number
when number > 99
puts "have a lot of problems"
else
puts "have none"
end
end
problems(100)
View dictionary.rb
class Dictionary
attr_reader :entries
def initialize
@entries = Hash.new
end
def add(add_text)
if add_text.class == Hash
add_text.each do |key, value|
View book.rb
class Book
attr_reader :title
def title=(title)
@title = ""
@dont_capitalize = %w(and or the an of in a)
words = title.split
words.each_with_index do |word, index|
if @dont_capitalize.include?(word) && index != 0
@title += "#{word} "
View pig_latin.rb
def translate(phrase)
parts = phrase.split
final_pigs = []
parts.each do |word|
char = word.split(//)
unless char.at(0).match(/[aeiou]/)
new_string = char
View lottery.rb
class LotteryTicket
NUMERIC_RANGE = 1..25
attr_reader :picks, :purchased
def initialize(*picks)
if picks.length != 3
raise ArgumentError, "You must pick three numbers"
elsif picks.uniq.length != 3
raise ArgumentError, "You must pick three unique numbers"
@zachgersh
zachgersh / usage_shift.rb
Created Feb 27, 2013
The weird wonders of shift
View usage_shift.rb
my_array_hash = [{"foo" => "bar"}, {"bagel" => "chips"}]
my_array_hash.shift["foo"]
returns bar
You can’t perform that action at this time.