My Profile Photo

Chris Arcand


Principal Engineer building Terraform at IBM / HashiCorp đŸ‘šâ€đŸ’» Formerly: Red Hat, NBC SportsEngine, RubyMN organizer. Once played the clarinet for a living, now making a living to play hockey. I make pointless connections to Minnesota as a Minnesotan does.

St. Paul, MN


Programming Easter Eggs

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.

<- Back