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
@dblock
dblock / mongoid_collection.rb
Created October 29, 2012 16:52
A monkey patch for detecing nil IDs.
require 'mongoid/collection'
module Mongoid
class Collection
alias_method :_update, :update
def update(selector, document, options = {})
document.deep_fetch("_id").each do |value|
if value.nil?
Rails.logger.error "Invalid nil _id in #{document}."
@dblock
dblock / mongoid.yml
Created November 9, 2012 14:24
MongoHQ configuration for Mongoid 3.x
development:
sessions:
default:
database: mydb_development
hosts:
- localhost:27017
options:
safe: true
test:
@dblock
dblock / mongoid_slug_unique_slug.rb
Created November 22, 2012 15:39
Monkey-patch mongoid-slug to allow slug = _id
module Mongoid
module Slug
class UniqueSlug
alias_method :_find_unique, :find_unique
# by default Mongoid::Slug returns id-1 if you try to get a slug from the model's ID
def find_unique attempt = nil
if ! attempt
candidate = url_builder.call(model)
@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)
@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 / 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 / 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
~/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 / 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
@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"