Skip to content

Instantly share code, notes, and snippets.

View RedFred7's full-sized avatar

Fred Heath RedFred7

View GitHub Profile
@iboard
iboard / ruby-destructor-example.rb
Last active March 21, 2025 09:32
Ruby 'Destructor' example.
class Foo
attr_reader :bar
def initialize
@bar = 123
ObjectSpace.define_finalizer( self, self.class.finalize(bar) )
end
def self.finalize(bar)
proc { puts "DESTROY OBJECT #{bar}" }
end
@DevL
DevL / sequel_migrations.rake
Created December 12, 2012 10:11
Sequel migration rake tasks based on https://gist.github.com/1409152
namespace :db do
require 'sequel'
namespace :migrate do
Sequel.extension :migration
task :connect do
if ENV['DATABASE_URL']
DB = Sequel.connect(ENV['DATABASE_URL'])
else
puts 'ABORTING: You must set the DATABASE_URL environment variable!'
@chetan
chetan / yardoc_cheatsheet.md
Last active July 22, 2025 02:26
YARD cheatsheet
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end