This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# bind "tcp://127.0.0.1:5000" | |
# activate_control_app "tcp://127.0.0.1:9293", auth_token: "foo" | |
# | |
# curl -v http://127.0.0.1:5000/ping | |
# curl -v http://127.0.0.1:9293/ping/disable?token=foo | |
# curl -v http://127.0.0.1:9293/ping/enable?token=foo | |
# https://github.com/puma/puma/blob/master/lib/puma/app/status.rb | |
require "puma/app/status" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
REVISION = Rails.root.join('REVISION').exist? ? Rails.root.join('REVISION').read.chomp.strip : nil | |
Rails.application.routes.draw do | |
get 'revision' => proc { |_env| [200, {'Content-Type' => 'text/plain'}, [REVISION.to_s]] } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/application.rb | |
['md5sum', 'convert', 'mogrify', 'identify', 'file'].each do |app| | |
`command -v #{app} > /dev/null 2>&1` | |
next if $?.exitstatus == 0 | |
abort "ERROR: command #{app.inspect} not found" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# config/initializers/torquebox-backstage.rb | |
# WARN: tilt autoloading 'tilt/haml' in a non thread-safe way; explicit require 'tilt/haml' suggested. | |
# WARN: tilt autoloading 'tilt/sass' in a non thread-safe way; explicit require 'tilt/sass' suggested. | |
require "tilt/haml" | |
require "tilt/sass" | |
# https://github.com/rails/rails/issues/15843 | |
Backstage::Application.disable(:sessions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# config/initializers/active_record_disconnect.rb | |
# Disconnect after intialization. | |
# Helpful for TorqueBox keeping connection for each | |
# runtime even when it is not used. | |
# | |
# $ rails c | |
# [1] > ActiveRecord::Base.connection_pool.connections.size | |
# => 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# In JRuby, Tempfile is implemented in Java. We were able to improve the performance substantially, | |
# and avoid the buggy stdlib version in the process. | |
# -- Nick Sieger | |
# http://stackoverflow.com/questions/1466460/jruby-tempfile-rb | |
# JRuby: Tempfile.new('p').path => "/tmp/p.4642.20811" | |
# 1.9.3: Tempfile.new('p').path => "/tmp/p20120426-4327-19gcrqi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# ISSUE: https://github.com/jruby/jruby/issues/405 | |
# In JRuby, FileUtils.remove_entry_secure(dir) crashes when a dir is under | |
# a world-writable directory because it tries to open directory. | |
# Opening directory is not allowed in Java. | |
# -- https://github.com/jruby/jruby/blob/1.7.0/lib/ruby/1.9/tmpdir.rb#L25-L28 | |
#[1] pry(main)> Dir.tmpdir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# https://github.com/mongodb/mongoid/blob/4789bfffd3cbfa065eb7be7f34fbac122278a0ae/lib/mongoid/criteria.rb#L324 | |
require "mongoid/criteria" | |
module Mongoid | |
class Criteria | |
OnlyWhenDefaultScopeError = Class.new(StandardError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
module ImplicitConnectionForbidder | |
def self.forbid_implicit_connections | |
yield | |
end | |
end | |
# http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html#method-i-with_connection | |
# http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html#method-i-release_connection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require "active_record/log_subscriber" | |
require "logger" | |
module ActiveRecord | |
class LogSubscriber | |
NULL_LOGGER = ::Logger.new(nil) | |
def logger |
NewerOlder