Instantly share code, notes, and snippets.

View alk-malloc-test.c
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
#define HISTORY_SIZE (1024*1024)
#define CHUNK_MIN (2*1024*1024)
#define CHUNK_MAX (32*1024*1024)
View gist:7759079
[jamesgolick@kremlin01 cfe-3.3.src]$ make
Makefile:42: ../../Makefile.common: No such file or directory
make: *** No rule to make target `../../Makefile.common'. Stop.
View gist:5645269
searchd[17794]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17795]: segfault at 00002ac7ccca4003 rip 000000000041fe40 rsp 00007fff495156d8 error 4
searchd[17796]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17797]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17798]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17802]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17803]: segfault at 00002ac6fddc4005 rip 000000000041fe40 rsp 00007fff495156d8 error 4
searchd[17804]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17805]: segfault at 0000000000000000 rip 0000000000422662 rsp 00007fff495156e0 error 4
searchd[17809]: segfault at 00002ac74b884001 rip 000000000041fe40 rsp 00007fff495156d8 error 4
View header.c
struct malloc_chunk {
struct malloc_chunk *next; // next pointer on free list
size_t size; // the size of this chunk
unsigned free; // > 0 if this pointer is free - useful for runtime assertions
}
struct malloc_chunk *
header(void *ptr)
{
return (struct malloc_chunk *)ptr - sizeof(malloc_chunk);
View gist:5485837
def self.unicorn_attr(*args)
args.each do |arg|
class << self
define_method(arg) do
@attributes[arg]
end
define_method("#{arg}=") do |value|
@attributes[arg] = value
end
View deep.rb
class A
def hello
puts "Hello, World!"
end
end
class B < A; end
class C < B; end
class D < C; end
class E < D; end
View output
[james@kremlin00 ruby (klasscache)]$./ruby -I . -I lib ./test.rb
method cache invalidations: 18
A
B
method cache invalidations: 18
View gist:5248412
def get(path, params={})
if parms[:memoize]
drivers[path] ||= value
else
driver.sc_object_for_property_path("#{abs_path}.#{Util.to_camel_case(path)}")
end
end
View gc_basic_profile_total_time.c
static VALUE
gc_basic_profile_total_time(VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;
return DBL2NUM(objspace->basic_profile.total_time);
}
View gist:4113248
1.9.3p194 :001 > GC::Profiler.enabled?
=> false
1.9.3p194 :002 > GC::Profiler.enable
=> nil
1.9.3p194 :003 > GC::Profiler.enabled?
=> 0