Skip to content

Instantly share code, notes, and snippets.

View stympy's full-sized avatar

Benjamin Curtis stympy

View GitHub Profile
@stympy
stympy / gist:1502891
Created December 20, 2011 19:37 — forked from qrush/gist:296921
stats tracking in redis
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@stympy
stympy / gist:1501816
Created December 20, 2011 14:51 — forked from bretthoerner/gist:839193
redis config from disqus
activerehashing yes
appendfsync everysec
appendonly no
bind 0.0.0.0
daemonize yes
databases 1
dbfilename dump_1.rdb
dir /var/redis/
glueoutputbuf yes
hash-max-zipmap-entries 512
@stympy
stympy / descriptive_sql_load_log.rb
Created July 23, 2011 17:15 — forked from JackDanger/descriptive_sql_load_log.rb
Let Rails display file names and line numbers for log activity.
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
protected
# Turn:
# User Load (6.3ms) SELECT * FROM "users"
# Into:
# User Load /app/views/_partial.erb:27 (6.3ms) in `_app_views_partial_erb` SELECT * FROM "users"
@stympy
stympy / gist:948168
Created April 29, 2011 11:00 — forked from therealadam/gist:731944
Trace slow queries in Rails
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 5
THRESHOLD = 300 # In ms
def sql(event)
return unless event.duration > THRESHOLD
callers = Rails.
backtrace_cleaner.
class ActiveRecord::Base
@@cache_store = nil
def self.cache_store
@@cache_store ||= ActionController::Base.cache_store
end
def self.caches(method_name, key = nil, options = {}, &block)
if key.is_a?(Hash)
options = key
key = nil