Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 778 Bytes

README.md

File metadata and controls

41 lines (27 loc) · 778 Bytes

require_so

Copying code from StackOverflow? In my DRY codebase? Not if I can help it!

Code snippet from a StackOverflow answer

$ cat dry.rb
require "require_so"
require_so "https://stackoverflow.com/a/61879644"

puts fast_next_smaller(907)
$ ruby dry.rb
790

Usage

  1. Require require_so
require "require_so"
  1. Copy the share link below your StackOverflow answer

Share button location

  1. 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
  1. Achieve DRYness