Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Karmani tmm1

View GitHub Profile
diff --git a/gc.c b/gc.c
index 415cc70..a570ae3 100644
--- a/gc.c
+++ b/gc.c
@@ -6140,7 +6140,7 @@ gc_profile_total_time(VALUE self)
if (objspace->profile.run && objspace->profile.next_index > 0) {
size_t i;
- size_t count = objspace->profile.next_index - 1;
+ size_t count = objspace->profile.next_index;
diff --git a/vm_core.h b/vm_core.h
index 4c6e3c2..c65dcc1 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -389,7 +389,7 @@ typedef struct rb_vm_struct {
/* hook */
rb_hook_list_t event_hooks;
- struct rb_postponed_job_struct *postponed_job;
+ struct rb_postponed_job_struct *postponed_job, *postponed_job_freelist;
@tmm1
tmm1 / sample.rb
Last active December 25, 2015 01:39
require 'pp'
require 'frameprofiler'
class ProfileResult
def initialize(data)
@data = data
end
def frames
@data[:frames].sort_by{ |iseq, stats| -stats[:samples] }
@tmm1
tmm1 / 0-sequential.txt
Created April 24, 2013 04:14
test-queue on github.com test suite
Finished tests in 827.814339s, 10.2281 tests/s, 34.2094 assertions/s.
8467 tests, 28319 assertions, 0 failures, 0 errors, 15 skips
real 14m21.424s
user 11m54.777s
sys 0m28.030s
@tmm1
tmm1 / rails3_mailer.rb
Created March 27, 2013 23:25
rails3 mailer backport
if Rails.version < '3.0'
require 'mail'
require 'active_support/core_ext/module/attr_internal'
class ActionMailer3
class Collector
attr_reader :responses
def initialize(context, &block)
@context = context
@tmm1
tmm1 / ruby19_date_marshal.rb
Created February 6, 2013 06:07
Fix marshal incompatibility between Date/DateTime on 1.8 and 1.9
require 'date'
class Date
if RUBY_VERSION < '1.9'
## accept 1.9 marshaled data on 1.8
## based on ext/date/date_core.c d_lite_marshal_dump_old
def marshal_load(data)
nth, jd, df, sf, of, @sg = data
real_jd =
@tmm1
tmm1 / 1-usage.md
Last active December 10, 2015 07:58
Simple ctags generator for ruby code using melbourne.
$ ruby tags.rb
    5	def	Rubinius.ruby18?
    6	class	SyntaxError
    7	def	SyntaxError.from
   13	class	Rubinius::AST::Node
   14	def	Rubinius::AST::Node#visit
   26	def	Rubinius::AST::Node#full_name
   31	class	Visitor
   32	def	Visitor#initialize
@tmm1
tmm1 / 1-readme.md
Created December 16, 2012 13:06
UTF-8 and ASCII-8BIT (BINARY) compatibility

The patch below fixes the following tests in 1.9:

$ ruby -v binary_test.rb 
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]
Run options: 

# Running tests:

E...E....FF
@tmm1
tmm1 / gist:4109376
Created November 19, 2012 07:12
Improve GC::Profiler.total_time accuracy
diff --git a/gc.c b/gc.c
index e65d0ec..0f14a2f 100644
--- a/gc.c
+++ b/gc.c
@@ -127,7 +127,13 @@ typedef struct gc_profile_record {
static double
getrusage_time(void)
{
-#ifdef RUSAGE_SELF
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
diff --git a/encoding.c b/encoding.c
index b8c5f6d..5863c96 100644
--- a/encoding.c
+++ b/encoding.c
@@ -35,7 +35,7 @@ int rb_encdb_alias(const char *alias, const char *orig);
#pragma GCC visibility pop
#endif
-static ID id_encoding;
+static ID id_encoding, id_handler;