Skip to content

Instantly share code, notes, and snippets.

View severin's full-sized avatar

Severin Schoepke severin

  • Zürich, Switzerland
View GitHub Profile
@severin
severin / gist:114014
Created May 19, 2009 09:44
List of real (defined here) instance methods
def real_instance_methods_of(klass)
klass.instance_methods - ((klass.ancestors - [klass]).map(&:instance_methods).flatten)
end
class Class
def instance_methods_defined_here
real_instance_methods_of self
end
end
@severin
severin / floppy.rb
Created February 8, 2010 22:15 — forked from pjb3/floppy.rb
assigning Procs as methods in Ruby
class Floppy
def method_missing(method, *args)
super unless args.length > 0 && method.to_s[-1..-1] == "="
if args.first.is_a?(Proc)
(class << self; self; end).class_eval do
define_method(method.to_s[0..-2].to_sym, args.first)
end
else
(class << self; self; end).send(:attr_accessor, method.to_s[0...-1])
@severin
severin / lazy_proxy.rb
Created March 17, 2010 13:39
Lazy Proxy
class LazyProxy
# blank slate... (use BasicObject in Ruby 1.9)
instance_methods.each do |method|
undef_method(method) unless method =~ /^__/
end
def initialize(&lazy_proxy_block)
@lazy_proxy_block = lazy_proxy_block
end
@severin
severin / Gemfile
Created March 22, 2010 13:12 — forked from samgranieri/Gemfile
How to set up Bundler in a Rails 2 app
source :gemcutter
gem 'rails', '~> 2.3.5', :require => nil
@severin
severin / clean-rails-logs
Created April 27, 2011 13:57
Rails Log Cleaner
#!/usr/bin/env ruby
logfiles = Dir["#{ENV['HOME']}/**/app/../log/*.log"] # any file with a .log extension in a log directory besides an app directory...
logfiles.each {|file| system "echo '' > #{file}"}
puts "Cleaned #{logfiles.size} logs..."
@severin
severin / gist:4264010c60235a0e29fa32d994579a48
Created November 12, 2020 09:38
Carbon footprint of "materials"?
You always mention carbon footprint of "materials" being by far the biggest chunk of our overall carbon footprint.
However, I have no clue what carbon footprint of "materials" actually is. What does it entail? What exactly causes carbon emissions that fall into this "materials" category? Is it power for some machines? Is it chemical processes that somehow emit carbon dioxide? Is it any kind of transport that happens before a piece of material is in the factory?
(As you maybe can tell I have no clue what actually happens until a shoe is produced)