Copying code from StackOverflow? In my DRY codebase? Not if I can help it!
$ cat dry.rb
require "require_so"
require_so "https://stackoverflow.com/a/61879644"
puts fast_next_smaller(907)
$ ruby dry.rb
790
- Require
require_so
require "require_so"
- Copy the share link below your StackOverflow answer
- Paste it into your code
require_so "https://stackoverflow.com/a/61877826"
You can also specify the index of the snippet you want to require
require_so "https://stackoverflow.com/a/61877826", 1 # will require the 2nd code snippet in the post
- Achieve DRYness