Skip to content

Instantly share code, notes, and snippets.

View acechase's full-sized avatar

Andrew Chase acechase

View GitHub Profile
@acechase
acechase / image optimization instructions
Last active August 29, 2015 13:56
optimize all the jpg's for your (rails or other) application
# This assumes you're using OS X, but should work on any linux-based system
# These two find commands could be run as part of the asset packaging step...
brew install jpegoptim
# checkout disk usage before hand
du -h -d 1 .
# add -n to jpegoptim options to do a dry run
find . -name "*.jpg" -exec jpegoptim --strip-all {} \;
brew install optipng
@acechase
acechase / rails_example_code.rb
Last active December 22, 2015 09:49
Things I want to play with in my next rails app
logger.push_tags and .pop_tags to complement logger.tagged:
class Job
def before
Rails.logger.push_tags :jobs, self.class.name
end
def after
Rails.logger.pop_tags 2
end
@acechase
acechase / .railsrc
Created September 5, 2013 18:40 — forked from janlelis/.railsrc
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers
@acechase
acechase / bunny.log
Created May 18, 2011 22:16
bunny.log output from rabbitmq through the bunny ruby gem (v0.6.0)
Normal flow when declaring an exchange:
#<Qrack::Transport::Method:0x171ae688 @channel=1, @payload=#<Qrack::Protocol::Exchange::Declare:0x171af088 @durable=true, @passive=nil, @nowait=nil, @exchange="test.test_exchange_10", @internal=nil, @type=:fanout, @ticket=1, @auto_delete=nil, @arguments=nil>>
#<Qrack::Transport::Method:0x171ab438 @channel=1, @payload=(
>
The problematic flow:
#<Qrack::Transport::Method:0x171597c8 @channel=1, @payload=#<Qrack::Protocol::Exchange::Declare:0x17159cf0 @durable=nil, @passive=true, @nowait=nil, @exchange="test.test_exchange_201", @internal=nil, @type=:fanout, @ticket=1, @auto_delete=nil, @arguments=nil>>
# Split a single logfile into multiple multiple logfiles based on PID information
# provided in the log lines.
#
# Usage: