Skip to content

Instantly share code, notes, and snippets.

View seancaffery's full-sized avatar

Sean Caffery seancaffery

View GitHub Profile
require "csv"
require "time"
require "file"
res = Hash(String, Array(Int64 | Int32)).new {|hsh, key| hsh[key] = [] of Int32 | Int64 }
stack = [] of Hash(String, Array(String | Int64 | Int32))
CSV.each_row(File.open("trace.csv")) do |line|
begin
type, file, no, time = line
if type == "call"
@seancaffery
seancaffery / prof.rb
Created February 26, 2014 04:51
ruby prof set up
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::WALL_TIME
RubyProf.start
# DO SOME WORK
results = RubyProf.stop
profile_location = 'tmp/zomg_profile.html'
File.open profile_location, 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
end
@seancaffery
seancaffery / post-checkout
Created March 18, 2013 23:58
Generate tags file when changing git branches
#!/bin/sh
old_ref=$1
new_ref=$2
changing_branch=$3
if [[ $changing_branch == 1 && $old_ref != $new_ref ]]
then
/bin/echo -n 'Generating tags file...'
ctags -R 2> /dev/null
@seancaffery
seancaffery / gist:1307265
Created October 23, 2011 11:37
Quick script to gather results from the recent 10KM run, anonymize, and output to CSV.
require 'rubygems'
require 'hpricot'
require 'net/http'
require 'uri'
require 'cgi'
require 'csv'
def do_request(path)
url = URI.parse(path)
req = Net::HTTP::Get.new("#{url.path}?#{url.query}")