This file contains hidden or 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
class PropertyObserverExample | |
def number | |
@number ||= 0 | |
end | |
def number=(new_number) | |
old_number = @number | |
puts "About to change to #{new_number}" | |
@number = new_number | |
puts "Just changed from #{old_number} to #{new_number}!" |
This file contains hidden or 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
# http://selenium-python.readthedocs.org/en/latest/api.html?highlight=cookie#selenium.webdriver.remote.webdriver.WebDriver.get_cookie | |
cookie = driver.get_cookie("cookie_name") | |
subprocess.check_call(["curl", "--cookie", "cookie_name=%" % cookie["value"], url, "-o", "destination_filename") |
This file contains hidden or 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
class Observable(object): | |
"""Mixin for use cases that can fire events to be handled by observers""" | |
def __init__(self): | |
self._observers = [] | |
def attach_observer(self, observer): | |
self._observers.append(observer) | |
def notify_observers(self, event, *args, **kwargs): |
This file contains hidden or 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
def test_subdirectory_gets_linked_to_parent(self): | |
# When a Site with ResourceDirectories is serialized and passed in for | |
# duplication, we have to re-link the parent child hierarchy since | |
# primary keys have changed. | |
... |
This file contains hidden or 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
jblake@sauron:~$ man help | |
No manual entry for help | |
jblake@sauron:~$ help man | |
-bash: help: no help topics match `man'. Try `help help' or `man -k man' or `info man'. |
This file contains hidden or 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
def test_returns_2_when_x_is_1_and_y_is_1(self): | |
self.assertEqual(2, sum(1, 2)) | |
def test_returns_1_when_x_is_2_and_y_is_neg1(self): | |
self.assertEqual(1, sum(2, -1)) | |
# etc.... | |
# versus: |
This file contains hidden or 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
“Go placidly amid the noise and haste, and remember what peace there may be in silence. As far as possible without surrender be on good terms with all persons. Speak your truth quietly and clearly; and listen to others, even the dull and the ignorant; they too have their story. Avoid loud and aggressive persons, they are vexations to the spirit. If you compare yourself with others, you may become vain and bitter; for always there will be greater and lesser persons than yourself. Enjoy your achievements as well as your plans. Keep interested in your own career, however humble; it is a real possession in the changing fortunes of time. Exercise caution in your business affairs; for the world is full of trickery. But let this not blind you to what virtue there is; many persons strive for high ideals; and everywhere life is full of heroism. Be yourself. Especially, do not feign affection. Neither be cynical about love; for in the face of all aridity and disenchantment it is as perennial as the grass. Take kindly t |
This file contains hidden or 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
1.9.3p484 :008 > require 'set' | |
=> true | |
1.9.3p484 :009 > Set.new([1, 2, 3]) ^ Set.new([2, 3, 4]) | |
=> #<Set: {4, 1}> |
This file contains hidden or 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
Judge each day by the seeds you plant, not the harvest you reap. You don't improve when you win. You improve when you practice. Judge yourself by how hard you train, not how well you perform. |
This file contains hidden or 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
class Chef | |
class Provider | |
alias_method :old_converge_by, :converge_by | |
def converge_by(descriptions, &block) | |
if descriptions.kind_of? String | |
run_context.descriptions << descriptions | |
descriptions = "X #{descriptions}" | |
elsif descriptions.kind_of? Array | |
run_context.descriptions.concat(descriptions) | |
end |