Skip to content

Instantly share code, notes, and snippets.

View terrbear's full-sized avatar

terry heath terrbear

View GitHub Profile
free_grades = %w(1st 2nd 3rd 4th 5th).map{|g| Grade.find_by_name(g).id}
(Application.processed + Application.submitted).reject{|a| free_grades.include?(a.child_apply_grade) || ((a.child_financial_aid_requested == 'true') rescue false)}.select{|a| a.order.nil?}.map{|a| [a.id, a.child_first_name, a.child_last_name, (a.parent1_email rescue nil)]}
template_names = %w(standing_dismissal_instructions medical_emergency_authorization medical_authorization_form preschool_trips student_information_update lower_school_trips)
incomplete = []
Contact.children.all.each do |c|
forms = c.get_ad_hoc_arr
template_names.each do |tn|
forms.detect{|f| f[:template_canonical_name] == tn} || (incomplete << c.id)
end
end
incomplete.uniq!
regex = /canonical_text:([\w\s)]+)($|[^\w+\:()])/
query.gsub(regex) do |match|
val = $1
boundary = $2
if val.gsub!(/\)/, '')
"canonical_text:\"#{val}\")#{boundary}"
else
"canonical_text:\"#{val}\"#{boundary}"
end
end
drop table if exists cdub;
create temporary table cdub
select cw.* from contract_workflows cw
inner join contacts c on cw.contact_id=c.id
where cw.id != (select id from contract_workflows ccw where ccw.contact_id=c.id limit 1);
delete cw
from contract_workflows cw
Capistrano::Configuration.instance.load do
#[terry] http://rails-bestpractices.com/posts/51-dry-bundler-in-capistrano
#says not to do this anymore, but i couldn't get the pre-loaded bundler tasks
#to work, so i'm just doing it by hand.
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
Capistrano::Configuration.instance.load do
namespace :gems do
desc "Install gems"
task :install, :roles => :app do
run "cd #{current_path} && #{sudo} rake RAILS_ENV=#{rails_env} gems:install"
end
end
after 'deploy:update_code', 'gems:install'
end
GEM_INSTALLS = {
'demo' => 'pre-bundler',
'production' => 'pre-bundler',
'qe' => 'pre-bundler',
'staging' => 'bundler'
}
require File.join(File.dirname(__FILE__), '..', 'support', 'deploy', GEM_INSTALLS[rails_env])
ALLEY ALY ALY. ALLY ALLEE. ALLY. ALLEE
ANNEX ANX ANX. ANNX ANEX. ANNX. ANEX
ARCADE ARC ARC.
AVENUE AVE AVE. AVEN AVENU AVN AVNUE AV. AVEN. AVENU. AVN. AVNUE. AV
BAYOO BYU BYU. BAYOU. BAYOU
BEACH BCH BCH.
BEND BND BND.
BLUFF BLF BLF. BLUF. BLUF
BLUFFS BLFS BLFS.
BOTTOM BOT BTM BOTTM BOT. BTM. BOTTM.
def forked!
ActiveRecord::Base.connection.reconnect!
Rails.cache.instance_variable_get(:@data).reset
Mongoid.config.master.connection.close
load File.join(RAILS_ROOT, 'config/initializers/mongoid.rb')
end
def run(job)
runtime = Benchmark.realtime do
fork do
input = <<EOL
machine6 0 1 2 3 4 5 6 7 8 9 .
S1 null null null null null null null null null null null
S2 null null null null null null null null null null null
S3 null null null null null null null null null null null
S4 null null null null null null null null null null null
S5$ null null null null null null null null null null null
S6! null null null null null null null null null null null
EOL