Skip to content

Instantly share code, notes, and snippets.

View stympy's full-sized avatar

Benjamin Curtis stympy

View GitHub Profile
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
@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.
@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: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 / 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 / session_cookie_dump.rb
Created January 31, 2012 22:06
Rails utility class for manually decoding session cookie values
@stympy
stympy / js.demo.rb
Created September 5, 2012 21:52 — forked from Zapotek/js.demo.rb
V8 interpreter with basic DOM in Ruby using TheRubyRacer and Taka
require 'v8'
require 'open-uri'
require 'pp'
require 'ap'
require 'taka'
require 'ostruct'
#
# Monkey patch all elements to include a 'style' attribute
#
@stympy
stympy / .gitignore
Created December 21, 2012 13:10 — forked from karmi/.gitignore
.DS_Store
Gemfile.lock
*.pem
node.json
tmp/*
!tmp/.gitignore

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@stympy
stympy / solr_side_join.txt
Created December 21, 2015 12:56 — forked from phact/solr_side_join.txt
Solr Side Join to replace collections / dynamic fields
CREATE KEYSPACE IF NOT EXISTS docstore WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE TABLE IF NOT EXISTS docstore.metadata (
userid text,
docid text,
joinkey text,
title text,
body text,
PRIMARY KEY(userid, docid));