Skip to content

Instantly share code, notes, and snippets.

View dblock's full-sized avatar
🐝
Alexa, ask the future of America to be great again! (try it)

Daniel (dB.) Doubrovkine dblock

🐝
Alexa, ask the future of America to be great again! (try it)
View GitHub Profile

Mongoid::CachedJson 1.2.3

Benchmarking 1.2.3 with ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0], Dalli 2.6.0

  • dalli_store:flat => 4.070754
  • dalli_store:manager => 2.670791
  • dalli_store:artwork => 4.310461
  • dalli_store:child_secret => 1.058889
  • dalli_store:child_not_secret => 0.800552
require 'devise/strategies/rememberable'
module Devise
module Strategies
class Rememberable < Authenticatable
private
def remember_key
key = "_app_remember_#{scope}_token"
key += "_#{Rails.env.to_s}" unless Rails.env.production?
key
@dblock
dblock / Gemfile
Last active December 11, 2015 02:59
Infinite loop in bundler?
source "http://rubygems.org"
ruby '1.9.3'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
gem "rails", "~> 3.2"
gem "thin", "1.5.0"
gem "grape", "0.2.6"
@dblock
dblock / timeout.txt
Created January 14, 2013 01:32
heroku slug compilation timeout
[2013-01-13 18:25:27 +0000] git push -f git@heroku.com:gravity-staging.git FETCH_HEAD:master
-----> Deleting 12 files matching .slugignore patterns.
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.0.pre.5
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin
Updating https://github.com/dblock/garner.git
Updating https://github.com/dblock/devise_invitable.git
Updating https://github.com/indirect/haml-rails.git
Updating https://github.com/dblock/carrierwave-mongoid.git
~/source/gravity/master$ git push git@heroku.com:gravity-staging.git staging:master
Counting objects: 37, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (19/19), 2.08 KiB, done.
Total 19 (delta 13), reused 0 (delta 0)
-----> Deleting 12 files matching .slugignore patterns.
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.0.pre.5
@dblock
dblock / config.ru
Created December 11, 2012 23:50
Conditionally disable the proxy forwarding by https://github.com/dblock/heroku-forward using the DISABLE_FORWARD_PROXY environment setting.
require 'rubygems'
require 'bundler'
if ENV['DISABLE_FORWARD_PROXY']
eval File.read(::File.expand_path('../my_app.ru', __FILE__))
else
$stdout.sync = true
@dblock
dblock / app.ru
Created December 11, 2012 15:14
Reverse-proxy setup to beat the Heroku 60 second boot timeout.
$stdout.sync = true
require ::File.expand_path('../config/environment', __FILE__)
run MyApp::Application
@dblock
dblock / api_logger.rb
Created December 10, 2012 01:43
API logger with Grape under Rails
class ApiLogger < Grape::Middleware::Base
def before
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" +
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}"
end
private
def request_log_data
@dblock
dblock / api_new_relic_instrumenter.rb
Created November 29, 2012 17:12
NewRelic Instrumentation for Grape API DSL
class ApiNewRelicInstrumenter < Grape::Middleware::Base
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
def call_with_newrelic(&block)
trace_options = {
:category => :rack,
:path => "#{route_path}\##{route_method}",
:request => request
}
@dblock
dblock / newrelic.yml
Created November 29, 2012 17:11
NewRelic RPM configuration
# Here are the settings that are common to all environments
common: &default_settings
# ============================== LICENSE KEY ===============================
# You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the
# New Relic service.
license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
# Agent Enabled (Rails Only)