Skip to content

Instantly share code, notes, and snippets.

@satoryu
Last active April 19, 2020 15:18
Show Gist options
  • Save satoryu/d2f0a9c3f2b5f7b910ed9c4bf765bacc to your computer and use it in GitHub Desktop.
Save satoryu/d2f0a9c3f2b5f7b910ed9c4bf765bacc to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
# set_trace_func lambda { |event, file, line, id, binding, klass|
# if binding.receiver.to_s == 'main'
# puts "#{file}:#{line}: #{event} #{id} #{binding.receiver} [#{binding.local_variables.map(&:to_s).join(',')}]"
# end
# }
# trace = TracePoint.new(:call, :c_call) do |tp|
# puts "#{tp.lineno}: #{tp.binding.receiver}##{tp.method_id}"
# # puts "#{tp.lineno}: #{tp.binding.receiver}##{tp.method_id} => #{tp.return_value}"
# end
# trace.enable
END {
exception = $!
return if exception.nil?
require 'cgi'
# https://www.google.com/search?sxsrf=ALeKk00oUZPEnFy5axuDNO3faXCCrDHmPw%3A1587309021240&source=hp&ei=3WmcXrrMC6vYhwP1taWACA&q=system+idle+error&oq=system+idle+error&gs_lcp=CgZwc3ktYWIQAzIGCAAQCBAeOgYIIxAnEBM6BAgjECc6BQgAEIMBOgcIABCDARAEOgQIABBDOgQIABAEOgcIABCDARBDOgIIADoHCCMQ6gIQJzoJCAAQBBBGEP8BOgUIABDLAToECAAQHjoGCAAQBRAeULAdWONOYOVWaARwAHgAgAGuAYgBqhOSAQQxLjE5mAEAoAEBqgEHZ3dzLXdperABCg&sclient=psy-ab&ved=0ahUKEwj6ru3y4vToAhUr7GEKHfVaCYAQ4dUDCAk&uact=5
search_url = "https://www.google.com/search?q=#{CGI.escape(exception.message)}"
system "open '#{search_url}'"
}
class Person
attr_reader :name
def initialize(name)
@name = name
end
end
class Student < Person
attr_reader :grade
def initialize(name, grade)
super(name)
@grade = grade
end
def shout!
raise "OMG!"
end
end
student = Student.new('Nobita Nobi', 4)
# student.shout!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment