Skip to content

Instantly share code, notes, and snippets.

Find my clj-ttt repository and 'fork' it.
Update the README in this repository to say "Erik was here".
Leave a commit message that says "Adding to README"
Copy the README file to a new file called "README-dup.md", add, then commit this new file with a message saying 'Cloned README'.
Copy the entire 'spec' directory from the repo into a directory called 'spec_clone', add, and commit this.
Submit a pull request to my original repository from a new branch in your repo called 'erik-test'.
module FeatureAccess
def self.features_for_organization(organization_id)
end
def self.feature_on_for_organization(organization_id, feature_name)
end
end
# Example 1
def kind_or_name(data_type)
if data_type.include? :kind
data_type[:kind]
else
data_type[:name]
end
end
# Example 2
@arlandism
arlandism / example.rb
Last active October 27, 2015 16:55
How would you refactor this...
def person(name)
{
:name => name,
:type => :person
}
end
def birthday_person(name, birthday)
{
:name => name,
class LinkedListReversal
def initialize(head)
@head = head
end
def reverse
last_node = nil
node = head
while node.next
module Food
def edible?
true
end
end
class Apple
class << self
include Food
edible? # => NoMethodError: undefined method `edible?' for #<Class:Apple>
module Foo
def edible?
true
end
end
class Apple
class << self
extend Foo
class MinCut
attr_accessor :graph
def initialize(input)
@graph = Graph.new(input)
end
def min_cut
while graph.remaining_vertices.count > 2
2.1.1 :001 > a = [[1, 2], [2,3]]
=> [[1, 2], [2, 3]]
2.1.1 :002 > a.delete(1)
=> nil
2.1.1 :003 > a
=> [[1, 2], [2, 3]]
2.1.1 :004 > a.delete(1)
=> nil
2.1.1 :005 > b = [1, 2]
=> [1, 2]
def handle_source_response(stuff, klazz=StuffDoer)
klazz.new(stuff) if we_have_stuff?
end