1. 21
    1. 5

      I find Ruby to be a really comfy language to use, both because it’s the first one I learned and so I already know where all the knobs are, and because it’s so malleable that you can easily do silly things like this, and as Gary Bernhardt said this is actually a result of how awesome Ruby is.

    2. 4

      Thanks, it’s exactly as terrible as I was expecting :)

    3. 4

      I’m sorry…

      Original work, public domain, with some help from this:

      require 'cgi'
      require 'shellwords'
      
      module StackOverflow
        def self.method_missing method, ex
          method = method =~ /=$/ ? method.to_s[0..-2] : method.to_s
          search = "[#{method.gsub('_', '-')}] #{ex.class}: #{ex.message}"
          escaped = CGI.escape(search)
          open_browser "https://stackoverflow.com/search?q=#{escaped}"
        end
      
        private
      
        def self.open_browser url
          if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
            system ['start', url].shelljoin
          elsif RbConfig::CONFIG['host_os'] =~ /darwin/
            system ['open', url].shelljoin
          elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
            system ['xdg-open', url].shelljoin
          end
        end
      end
      
      begin
        raise "lol"
      rescue => StackOverflow.ruby
      end
      
      1. 4

        Oh you can do so much worse.

        1. 1

          Oh, good, a way to search for errors when that gem inevitably throws!