Example usage:
old_accounts = Account.where("created_at < ?", 1.month.ago)
old_abandoned_trials = AbandonedTrialQuery.new(old_accounts)
old_abandoned_trials.find_each do |account|
account.send_offer_for_support
# Usage: in develoopment.rb | |
# | |
# config.middleware.insert_before Rails::Rack::Logger, PeacefulAssetsLogger | |
# | |
class PeacefulAssetsLogger | |
def initialize(app) | |
unless ENV[ 'LOG_ASSETS' ] | |
puts 'For more peaceful logs we have silenced the asset logs.' | |
puts 'To see asset requests in the logs, set LOG_ASSETS=true env variable.' | |
Rails.application.assets.logger = Logger.new('/dev/null') |
select fund_sums.total, fund_products.name | |
from ( | |
select sum(allocation_amount) total, fund_product_id | |
from transactions | |
where transactions.investor_id = 490 | |
group by fund_product_id | |
) fund_sums | |
left join fund_products on fund_sums.fund_product_id = fund_products.id |
class Foo < Struct.new(:bar); end | |
puts Foo.ancestors #=> [Foo, #<Class:0x007fae624e79e8>, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject] | |
Bar = Struct.new(:foo) | |
puts Bar.ancestors #=> [Bar, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject] | |
# The first way adds an extra, unnecessary, anonymous module in the ancestors chain. |
me:
Is it possible to send a signal to a worker/process?
I realize the platform sends SIGTERM
and SIGKILL
when restarting a dyno, but I need to send a USR1
to one of my workers to tell it to stop picking up new jobs. Normally this is achieved via kill -USR1 <pid>
, but on the Heroku platform not only do we not know know the pid, we also don't run one-off commands on the same dyno.
Caio (heroku support):
We had this feature experimentally at some point but it was never productized. I recommend you find other ways to signal your processes, like setting a database flag.
me:
module ServiceKeys | |
def self.brewery_db | |
ENV['BREWERY_DB_API_KEY'] | |
end | |
end |
class AdaptBreweryDBWebhook | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
adapt_action_param(env) | |
@app.call(env) | |
end |
module World | |
module USA | |
class Directory | |
def move_to(a_state) | |
state = a_state.class.name.split('::').last #=> 'Georgia' | |
# fails | |
self.class.const_get(state) #=> Want World::USA::Georgia | |
# but this would work |
Cloudsheet::Map.new( | |
1 => { month: Date }, | |
2 => { income: Curreny }, | |
3 => { other: -> (raw) { some_custom_transform(raw) } } | |
) |
/ In app/views/shared/ | |
#dev-badge | |
span= Rails.env | |
span It ain't production! |