Skip to content

Instantly share code, notes, and snippets.

#simulating a worker running every X
#a user will ahve to receive a msg every Y interval
#user msg is sent sometime between now and now+X
#next_message_time will have to be set to current_time += Y
#Goal: determine if during a time window of a working processing, if a user is receiving fewer messages than it could because of the offset between 0..X
class SendProcess
RUN_INTERVAL = 60.0 #1 minute in seconds
<div class="row">
<div class="col-md-6 col-md-offset-3"></div>
</div>
(12-6)/2
ENV['DISABLE_INITIALIZER_FROM_RAKE'] || Application.model_call_setters
task :environment => :disable_initializer
task :disable_initializer do
ENV['DISABLE_INITIALIZER_FROM_RAKE'] = 'true'
end
class Application < ActiveRecord::Base
def self.model_call_setters
Agency.call_solo_payments
Agency.call_group_payments
Agency.set_sum_payments
Lobbyist.call_team_payments
Lobbyist.call_my_payments
Lobbyist.set_sum_payments
#source https://github.com/rails/rails/issues/10894
module ActiveSupport
module Cache
class FileStore < Store
private
# Patch this so we don't have long paths
def key_file_path(key)
fname = URI.encode_www_form_component(key)
hash = Zlib.adler32(fname)
<% @agency.actions.sort_by { |action| -action.payment }.each do |action| %>
<% cache [action, action.lobbyist_actions, action.lobbyists, action.agency_actions, action.agencies] do %>
<tr>
<td><%= action.purpose %></td>
<td valign="top"> <% action.lobbyists.each do |lobbyist| %>
<%= link_to lobbyist.name, lobbyist_path(lobbyist.slug) %> <br>
<%end%>
</td>
<td valign="top"> <%= link_to action.client.name, client_path(action.client.slug) %> </td>
<td valign="top">$<%= action.payment %></td>
class Store < ActiveRecord::Base
has_many :employees
end
class Employee < ActiveRecord::Base
belongs_to :store, touch: true
end
<% # app/views/stores/show.html.erb %>
<% cache @store do%>
<h1>Store: <%= @store.name %></h1>
<%= render @store.employees %>
<% end %>
<% # app/views/employees/_employee.html.erb %>
<% cache employee do %>
<div class='employee'>