Skip to content

Instantly share code, notes, and snippets.

View fertapric's full-sized avatar

Fernando Tapia Rico fertapric

  • Amsterdam, Netherlands
View GitHub Profile
# Minimal example that demonstrates a memory leak in Celluloid.
# Adapted from @debrasetton example: https://github.com/mperham/sidekiq/issues/2107
# Adapted from @grosser example: https://github.com/mperham/sidekiq/blob/master/examples/leak.rb
# Run with LEAK=0 for no memory leak or LEAK=1 for memory leak, like so:
# LEAK=1 ruby ./leak.rb > /dev/null
require 'celluloid/autostart'
Celluloid.logger = nil
$counter = 0
$jobs = 5_000
@awd
awd / migrate_paperclip_to_s3.rake
Created October 1, 2011 23:31
Migrate local paperclip assets to Amazon S3.
##
# Use this behind the scenes to migrate files from your filesystem to Amazon S3
# %: rake paperclip_migration:migrate_to_s3
##
namespace :attachments do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
require 'aws/s3'
@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"