Skip to content

Instantly share code, notes, and snippets.

View zachgersh's full-sized avatar
👋

Zach Gershman zachgersh

👋
  • Los Angeles
  • 21:07 (UTC -07:00)
View GitHub Profile
@zachgersh
zachgersh / race.txt
Last active December 7, 2018 23:06
race-gorouter
==================
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()
# 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
# 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
# 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 April 14, 2013 20:18
Simple gist describing a problem I am having with case statements.
def problems(number)
case number
when number > 99
puts "have a lot of problems"
else
puts "have none"
end
end
problems(100)
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|
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} "
def translate(phrase)
parts = phrase.split
final_pigs = []
parts.each do |word|
char = word.split(//)
unless char.at(0).match(/[aeiou]/)
new_string = char
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 February 27, 2013 18:57
The weird wonders of shift
my_array_hash = [{"foo" => "bar"}, {"bagel" => "chips"}]
my_array_hash.shift["foo"]
returns bar