Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / fat-logfiles.sh
Last active December 22, 2018 19:56
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@joakimk
joakimk / Example.md
Created November 29, 2012 10:52
More sane backtraces

Example image

@dbi
dbi / time_logger.rb
Created October 3, 2012 13:06
Log duration of method calls
module TimeLogger
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
attr_writer :time_logger
def time_logger
@time_logger ||= Logger.new(File.join(Rails.root, 'log', 'time_logger.log'))
Thread-9jnxc
looping.rb:17:in `block (2 levels) in <main>'
\_ looping.rb:15:in `each'
\_ looping.rb:15:in `block in <main>'
\_ looping.rb:22:in `call'
\_ looping.rb:22:in `condition'
\_ looping.rb:26:in `looping'
\_ looping.rb:31:in `<main>'
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@joakimk
joakimk / script-bootstrap.rb
Created March 31, 2012 10:01
Bootstrap script (script/bootstrap) from a small rails project I'm working on. Designed to be quick to run when nothing changed. Intended to be used in CI builds and on dev machines.
$ time script/bootstrap
Bundler missing, installing.
Fetching: bundler-1.1.3.gem (100%)
Successfully installed bundler-1.1.3
1 gem installed
Gemfile changed, bundling.
Schema changed, updating databases.
real 0m9.163s
user 0m3.762s
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@skojin
skojin / irb_require_without_bundler_hack.rb
Created January 25, 2011 13:33
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib")
end
@ahoward
ahoward / net-http-debug.rb
Created December 10, 2010 20:06
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)