$ cat Envfile
your-heroku-app-name:
LANG: ja_JP.UTF-8
$ heroku config -a your-heroku-app-name
=== your-heroku-app-name Config Vars
LANG: en_US.UTF-8
$ ruby path/to/heroku_config.rb # dry run
I, [2015-09-04T19:13:17.972419 #14090] INFO -- : your-heroku-app-name
I, [2015-09-04T19:13:17.972511 #14090] INFO -- : C LANG=ja_JP.UTF-8
This file contains 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
class Sample | |
DUMMY_IMPL = proc { |*| } | |
def self.only(method_name) | |
return unless const_get(:FLAG, false) | |
singleton_class.__send__ :remove_method, method_name | |
singleton_class.__send__ :define_method, method_name, DUMMY_IMPL | |
end | |
end | |
class SampleA < Sample |
This file contains 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
# Luhnアルゴリズム | |
# https://ja.wikipedia.org/wiki/Luhn%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0 | |
def luhn(digits) | |
raise if digits.to_s =~ /[^\d]/ | |
sum = digits.each_char.map(&:to_i).reverse_each.with_index.reduce(0) do |r, (digit, idx)| | |
if idx.odd? | |
n = digit * 2 | |
n = n > 10 ? n - 10 + 1 : n | |
else | |
n = digit |
This file contains 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 'mongo/functional/logging' | |
module Mongo | |
module QueryTracer | |
CLEANER = ActiveSupport::BacktraceCleaner.new.tap do |cleaner| | |
cleaner.add_silencer { |line| line !~ /\A#{Regexp.escape Rails.root.to_s}/ } | |
end | |
DEPTH = (0...ENV.fetch('MONGO_QUERY_TRACE_DEPTH', 3).to_i) | |
def log_operation(name, payload, duration) |
This file contains 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
var a = (function (txt) { | |
var R = /(?:https?:\/\/)?(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z]+[a-z0-9#%&+,-./;=?_~]*/i; | |
var P = function(txt, ary) { | |
var m = R.exec(txt); | |
if (m) { | |
ary.push(txt.substr(0, m.index)); | |
ary.push(m[0]); | |
return P(txt.substr(m.index + m[0].length), ary); | |
} else { | |
ary.push(txt); |
This file contains 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
module Sprockets | |
module Cache | |
class Local | |
def initialize(original) | |
@object = {} | |
@client = Dalli::Client.new(nil, namespace: "#{::Rails.env}/cache", compress: true) | |
@original = original | |
end | |
# Lookup value in cache |
This file contains 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 'spec_helper' | |
class Doc | |
include MongoMapper::Document | |
one :em_doc | |
timestamps! | |
ensure_index [['em_doc.foo', Mongo::ASCENDING]] | |
end |
This file contains 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
Thu, 08 Jan 2015 00:00:00 EST -05:00 : Thu, 08 Jan 2015 05:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 01:00:00 EST -05:00 : Thu, 08 Jan 2015 06:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 02:00:00 EST -05:00 : Thu, 08 Jan 2015 07:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 03:00:00 EST -05:00 : Thu, 08 Jan 2015 08:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 04:00:00 EST -05:00 : Thu, 08 Jan 2015 09:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 05:00:00 EST -05:00 : Thu, 08 Jan 2015 10:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 06:00:00 EST -05:00 : Thu, 08 Jan 2015 11:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 07:00:00 EST -05:00 : Thu, 08 Jan 2015 12:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 08:00:00 EST -05:00 : Thu, 08 Jan 2015 13:00:00 UTC +00:00 | |
Thu, 08 Jan 2015 09:00:00 EST -05:00 : Thu, 08 Jan 2015 14:00:00 UTC +00:00 |
This file contains 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
module Stripe | |
module APIOperations | |
module List | |
module ClassMethods | |
def find_each(filters={}, api_key=nil, &block) | |
loop do | |
list = all(filters, api_key).tap { |e| e.each(&block) } | |
break unless list.has_more | |
filters = filters.merge(starting_after: list.data.last.id) | |
end |
This file contains 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
Backbone.localForage = {} | |
Backbone.localForage.sync = (prefix) -> | |
(method, model, options) -> | |
options.success ?= -> | |
options.error ?= -> | |
save = (key, options) -> | |
localforage.setItem key, model.toJSON(), (err, val) -> | |
if err | |
options.error err | |
else |