Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Gupta Karmani tmm1

View GitHub Profile
@tmm1
tmm1 / flamegraph.html
Last active August 29, 2015 13:56
flamegraph viewer
<html>
<head>
<title>flamegraph</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Monaco, "Liberation Mono", Courier, monospace;
font-size: 10pt;
}
require 'rubygems'
require 'mq'
EM.run do
def log(*args)
p args
end
amq = MQ.new
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'mq'
EM.run do
# open a channel on the AMQP connection
channel = MQ.new
# declare a queue on the channel
queue = MQ::Queue.new(channel, 'queue name')
#require 'rubygems'
require 'amqp/lib/mq'
EM.run do
def log(*args)
p args
end
# AMQP.logging = true
require 'thread'
Thread.abort_on_exception = true
require 'rubygems'
require 'eventmachine'
class AsyncTime
def self.now
EM.add_timer(2){ yield(Time.now) }
end
end
require File.dirname(__FILE__) + '/fiber18'
require 'bacon'
class Bacon::Context
unless method_defined? :_it
alias :_it :it
def it *args
_it(*args){ if block_given? then yield; Fiber.yield end }
end
def ConstSetter(opts)
(@@__const_setter__modules ||= {})[opts] ||= Module.new do |m|
def m.included c
@@__const_setter__modules.index(self).each do |key, val|
c.const_set(key, val)
end
end
end
end
@tmm1
tmm1 / gist:6716
Created August 22, 2008 01:57
Patch to MRI signal.c to prevent unnecessary sigprocmask syscalls
--- signal.c.orig 2008-08-21 18:42:46.000000000 -0700
+++ signal.c 2008-08-21 18:55:42.000000000 -0700
@@ -23,6 +23,7 @@
#if defined HAVE_SIGPROCMASK || defined HAVE_SIGSETMASK
#define USE_TRAP_MASK 1
+static int restore_signals = 0;
#else
#define USE_TRAP_MASK 0
#endif
require 'rubygems'
require 'rev'
require 'pp'
class Google < Rev::HttpClient
def self.connect loop = Rev::Loop.default
g = super('google.com')
g.attach(loop) if loop
g
end