Last active
November 3, 2016 02:27
-
-
Save chrisarcand/9da0dee4fab8d34173036b7416098744 to your computer and use it in GitHub Desktop.
Code snippets for "Programming Easter Eggs" - http://chrisarcand.com/programming-easter-eggs/
This file contains 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
public static boolean isUserAMonkey () /* Since: API Level 8 */ | |
... | |
/* Returns "true" if the user interface is currently being messed with by a monkey. */ |
This file contains 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
# Please do not use this method in production. | |
# Pretty please. | |
def self.I_AM_THE_DESTROYER! | |
# TODO: actually implement spelling error fixes | |
puts %Q{ | |
Sharon: "There should be a method called I_AM_THE_DESTROYER!" | |
Ryan: "What should this method do?" | |
Sharon: "It should fix all the spelling errors on the page!" | |
} | |
end |
This file contains 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 Pry | |
class Command::Wtf < Pry::ClassCommand | |
match(/wtf([?!]*)/) | |
group 'Context' | |
description 'Show the backtrace of the most recent exception.' | |
options :listing => 'wtf?' | |
banner <<-'BANNER' | |
Usage: wtf[?|!] | |
Show's a few lines of the backtrace of the most recent exception (also available | |
as `_ex_.backtrace`). If you want to see more lines, add more question marks or | |
exclamation marks. | |
wtf? | |
wtf?!???!?!? | |
# To see the entire backtrace, pass the `-v` or `--verbose` flag. | |
wtf -v | |
BANNER | |
... |
This file contains 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
# Returns a Duration instance matching the number of fortnights provided. | |
# | |
# 2.fortnights # => 28 days | |
def fortnights | |
ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]]) | |
end | |
alias :fortnight :fortnights |
This file contains 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
# Equal to <tt>self[41]</tt>. Also known as accessing "the reddit". | |
# | |
# (1..42).to_a.forty_two # => 42 | |
def forty_two | |
self[41] | |
end |
This file contains 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
implode|seppuku) | |
source "$rvm_scripts_path/functions/implode" | |
__rvm_implode | |
;; |
This file contains 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
answer) __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything ; result=42 ;; | |
question) __rvm_ultimate_question ; result=42 ;; |
This file contains 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 self.❨╯°□°❩╯︵┻━┻ | |
puts "Calm down, bro" | |
end | |
describe "❨╯°□°❩╯︵┻━┻" do | |
before { $stdout = StringIO.new } | |
after { $stdout = STDOUT } | |
it "allows angry developers to express their emotional constitution and remedies it" do | |
Sidekiq.❨╯°□°❩╯︵┻━┻ | |
assert_equal "Calm down, bro\n", $stdout.string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment