Skip to content

Instantly share code, notes, and snippets.

@csfrancis
csfrancis / gdb_ruby_backtrace.py
Last active April 24, 2024 05:37
Dump an MRI call stack from gdb
# Updated for Ruby 2.3
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
@tenderlove
tenderlove / terrible.rb
Last active May 16, 2020 13:13
I am a terrible person
require 'fiddle'
module IAmAHorriblePerson
def unset flag
value = _wrap self
flags = 8.times.map { |i| value[i] }.pack('C8').unpack('Q').first
[flags & ~flag].pack('Q').unpack('C8').each_with_index { |n,i|value[i] = n }
end
def class= k
@whilefalse
whilefalse / gist:1019087
Created June 10, 2011 15:42
Bundle install git post-merge hook
#!/bin/bash
if [ ! -z `git diff --name-only HEAD@{1}..HEAD Gemfile` ]
then
echo -e "\033[0;31m*** Gemfile change detected, running bundle install ***\033[0m"
bundle install
fi