Skip to content

Instantly share code, notes, and snippets.

View cshirley's full-sized avatar

Clive Shirley cshirley

View GitHub Profile

Keybase proof

I hereby claim:

  • I am cshirley on github.
  • I am cshirley (https://keybase.io/cshirley) on keybase.
  • I have a public key ASBqu7KPXWOjRV6TRDnxrT6xXc-zW1iBj2aoZD3LQsVO-Qo

To claim this, I am signing this object:

@cshirley
cshirley / export.rb
Last active May 20, 2019 18:35
HTML Parse and export
require 'nokogiri'
require 'json'
require 'byebug'
require 'fileutils'
def export_html(filename)
doc = Nokogiri::HTML(File.read(filename))
@body = doc.css('div.light')
@cshirley
cshirley / gist:8a0f8d5dd9fc030b3c4d7914f7ec8028
Created November 29, 2018 17:56
OptionParser for Rake task
task :add_args do
args = ARGV[2..-1]
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: rake test:check_args [options]"
opts.on("-o", "--one ARG", Integer) { |num1| options[:num1] = num1 }
opts.on("-t", "--two ARG", Integer) { |num2| options[:num2] = num2 }
end.parse!(args)
puts options[:num1].to_i + options[:num2].to_i
exit
def trace_method(filter)
trace = TracePoint.trace(:call) do |tp|
p [tp.event, Time.now.to_f, "#{tp.path}:#{tp.lineno}", tp.defined_class.name, tp.method_id] if tp.path =~ /#{filter}/i
end
trace.enable
yield
trace.disable
end