Skip to content

Instantly share code, notes, and snippets.

View andrii's full-sized avatar

Andrii Ponomarov andrii

View GitHub Profile
@csfrancis
csfrancis / gdb_ruby_backtrace.py
Last active June 25, 2024 19:12
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()
class MyApp < Sinatra::Base
# ....
# does nothing other than load the <input type="file"> form...
get '/upload' do
erb(:upload)
end
@vangberg
vangberg / app.rb
Created February 8, 2009 14:34
file upload w/ sinatra
require 'rubygems'
require 'sinatra'
get '/' do
@files = Dir['public/*'].map {|f| File.basename(f) }
erb :index
end
post '/upload' do
filename = params[:file][:filename]