Skip to content

Instantly share code, notes, and snippets.

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

Damon Davison allolex

🏠
Working from home
View GitHub Profile
@allolex
allolex / pr.md
Created May 9, 2016 16:37 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

View hash.md
View class_oop.rb
class Table
# attr_reader :num_legs
# attr_writer :num_legs
attr_accessor :num_legs
def initialize(legs)
@tabletop = []
@num_legs = legs
end
View automobiles.rb
require_relative 'talkative'
class Vehicle
attr_accessor :engine, :tires
end
class Car < Vehicle
def initialize
@tires = 4
end
View tdd_methods.rb
def add_two(number = 0, *rest)
return nil unless number.respond_to? :+
# if number.respond_to? :+
if number.respond_to? :concat
puts "srsly?" if rest.size > 0
if number.respond_to? :push
number.push 2
else
number.concat "2"
View alphabet_testers.rb
module AlphabetTesters
def self.a? letter
letter.downcase == "a"
end
def self.b? letter
letter.downcase == "b"
end
def a? letter
View week1_hw_review.rb
# 1: Remove all hats. All are 0.
# 2: Every 2nd cat is switched to 1. [0, 1, 0, 1]
# 3: Every 3rd cat is switched (toggled). [0, 1, 1, 1]
# 4: [ 0, 1, 1, 0 ]
max = 100
cats = Array.new(max, 1)
p cats