Perhaps these shouldnât be called Easter Eggs - âprogramming noveltiesâ? - but the little additions in projects which donât necessarily need to exist are always satisfying and amusing to me. There are a number of them that my colleagues or I have stumbled upon. Hereâs a little collection I curated.
The headers link to where the code exists in its project. Have any additions? Let me know and Iâll add them to the list!
The âforty_twoâ array accessor in Rails
# 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
The ââšâŻÂ°âĄÂ°â©âŻïž”â»ââ»â method in Sidekiq
Iâm pretty certain this one is my favorite.
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
The âwtf!?!?â method in Pry
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
...
ânyan-catâ, âget-nakedâ, and poems in Pry
From Enrico Genauck (@enricogenauck), Added 5/4/15
The pry gem also includes a dedicated file to Easter Eggs with nyan cat
and a few text snippets from Jermaine Stewart, T.S. Eliot, and Leonard Cohen,
and Fernando Pessoa.
The âisUserAMonkeyâ function in the android.app.ActivityManager package
From Ian Ehlert (@ehlertij)
public static boolean isUserAMonkey () /* Since: API Level 8 */
...
/* Returns "true" if the user interface is currently being messed with by a monkey. */
Iâm not sure if this is all that strange considering the Monkey is a well documented, actual command line tool to stress test your UI. But thatâs part of the much larger joke.
The âI_AM_THE_DESTROYER!â method in Paranoia (acts_as_paranoid rewrite)
From Jason Frey (@Fryguy9)
# 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
The TODO is probably the funniest part, to be honest XD
Honorable Mentions
The âfortnightâ method in Rails
# 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
I donât know if it was really intended to be a novelty or taken seriously, but I find it amusing. And yes, I do actually try and use this - in tests, anyway.
The âseppukuâ command in RVM
Wayne Seguin added this as an alias for implode. The change reads âAdded ârvm seppukuâ in honor
of tsykoduk who canât spell so it saved his life.â
implode|seppuku)
source "$rvm_scripts_path/functions/implode"
__rvm_implode
;;
I especially enjoy the rvm_log "Hai! Removing $rvm_path"
The âquestionâ and âanswerâ commands in RVM
These commands seemed to have been removed since they were added in v0.1.30
answer) __rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything ; result=42 ;;
question) __rvm_ultimate_question ; result=42 ;;
More entertaining is the bugfix for these commands that shortly followed:
Bugfix: ârvm answerâ now uses perl, since the universe is written in Perl. As it is obvious⊠the universe has bugs, and perl is the only language that can have bugs not even god could sort out.