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 | |
# Source: https://gist.github.com/kml/da4f7cf70008986b3ba5 | |
# Issue: https://github.com/solnic/coercible/issues/16 | |
require "virtus/attribute/coercer" | |
# Coercible::Coercer::Object#to_string doesn't know how to coerce nil | |
# https://github.com/solnic/virtus/blob/master/lib/virtus/attribute/coercer.rb#L31 |
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
# Custom proxy cache server for assets speedup in *development* environment. | |
# | |
# Usage: | |
# Foreground (for tests): | |
# nginx -c $(pwd)/assets-nginx.conf -g 'daemon off; error_log stderr;' | |
# | |
# Background: | |
# nginx -c $(pwd)/assets-nginx.conf | |
# nginx -c $(pwd)/assets-nginx.conf -s <SIGNAL> | |
# signals: stop, quit, reopen, reload |
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
2.3.1 |
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
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
require 'bundler/setup' | |
require "rails/commands/server" | |
Rails::Server.class_eval do | |
def default_options | |
super.merge(Port: 3000, Host: "127.0.0.1") | |
end | |
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
# Example usage: | |
# I18n.t("application.hello") | |
# I18n.t("hello", scope: "application") | |
# Application.t("hello") | |
# | |
# Application.t("missing") | |
# Error: translation missing: pl.application.missing | |
# | |
# I18n.locale = "ru" | |
# Application.t("hello") |
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
# This file is used by Rack-based servers to start the application. | |
require ::File.expand_path('../config/environment', __FILE__) | |
app = Rack::Builder.new do | |
map "/ping" do | |
run lambda { |_env| [200, {'Content-Type' => 'text/plain'}, ['pong']] } | |
end | |
map "/" do |
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
# https://github.com/rest-client/rest-client/blob/ac388df8b904b0ff839ac73496af5b75ab683076/lib/restclient/request.rb#L575 | |
# RestClient logs messages using RestClient.log << "message" | |
# that ignores default logger formatter | |
class RestClientLogAdapter | |
def initialize(logger: Logger.new(nil), level: :info) | |
@logger = logger | |
@level = level | |
end | |
def <<(message) |
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
# ByteBuf#getInt64 should return Fixnum not Bignum | |
# Issue: https://jira.mongodb.org/browse/RUBY-1189 | |
# Example: http://pastie.org/10978801#1,14,17,19,25 | |
# Gist: https://gist.github.com/kml/4c76c22df26a1fa372c97aff93e873ab | |
require "bson" | |
unless BSON::ByteBuffer.new(2200000227.to_bson.to_s).get_int64.is_a?(Bignum) | |
abort "#{__FILE__}: BSON::ByteBuffer#get_int64 already fixed! Remove this patch." | |
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
require "pry" | |
def pp(value) | |
pager = Pry::Pager::NullPager.new(STDOUT) | |
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1) | |
end | |
alias ap pp |
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/initializers/apartment.rb | |
require "apartment/reloader" | |
# skip Apartment::Reloader for assets | |
# (Apartment::Reloader is used only in development) | |
# https://github.com/influitive/apartment/blob/development/lib/apartment/railtie.rb#L43 | |
# https://github.com/influitive/apartment/blob/development/lib/apartment/reloader.rb | |
Apartment::Reloader.prepend(Module.new do | |
def call(env) |