Skip to content

Instantly share code, notes, and snippets.

View seamusabshere's full-sized avatar

Seamus Abshere seamusabshere

View GitHub Profile
if File.exists?(File.join(RAILS_ROOT,'tmp', 'passenger_debug.txt'))
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
File.delete(File.join(RAILS_ROOT,'tmp', 'passenger_debug.txt'))
end
(in our app)
class Automobile < ActiveRecord::Base
[...]
include BrighterPlanet::Automobile
end
(in an open source repo/gem)
module BrighterPlanet
require 'net/imap'
require 'tmail'
class ImapChecker
include Singleton
SERVER = 'secure.emailsrvr.com'
USERNAME = 'A'
PASSWORD = 'A'
SEARCH_CRITERIA = %w{ TO offset }
#!/usr/bin/env ruby
require 'rubygems'
require 'daemon_spawn' # currently seamusabshere-daemon-spawn
# BASEDIR = '/var/www/html/offset1'
BASEDIR = '/home/vagrant/offset1'
PID_PATH = "#{BASEDIR}/daemons/offset1_imap_checker.pid"
LOG_PATH = "#{BASEDIR}/log/offset1_imap_checker.log"
TIMEOUT = 60
# SIGNAL = 'INT'
diff --git a/VERSION b/VERSION
index 0c62199..53a75d6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.1
+0.2.6
diff --git a/lib/daemon_spawn.rb b/lib/daemon_spawn.rb
index 2e3d628..f032d55 100644
--- a/lib/daemon_spawn.rb
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = '/data/data1/current'
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require 'rubygems' # do this after changing dirs or else bundler won't be able to find .bundle
gem 'seamusabshere-daemon-spawn', '0.2.6' # otherwise we don't get timeout kill -9
require 'daemon_spawn'
PID_PATH = '/data/data1/shared/pids/delayed_job.pid'
# http://jetpackweb.com/blog/2010/05/19/making-monit-delayed_job-and-bundler-play-nice-together/
check process my_app_delayed_job_1
with pidfile /data/my_app/shared/pids/delayed_job.pid
start program = "/usr/bin/env HOME=/home/deploy PATH=/usr/bin:$PATH RAILS_ENV=production /etc/init.d/delayed_job.sh start" as uid deploy and gid deploy
stop program = "/usr/bin/env HOME=/home/deploy PATH=/usr/bin:$PATH RAILS_ENV=production /etc/init.d/delayed_job.sh stop" as uid deploy and gid deploy with timeout 90 seconds
if totalmem is greater than 256 MB for 10 cycles then restart
group my_app_delayed_job
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = '/data/my_app/current'
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require "rubygems"
require "bundler/setup"
require 'daemon_spawn' # use 0.4.0
PID_PATH = '/data/my_app/shared/pids/delayed_job.pid'
diff --git a/data_miner_test.rb b/data_miner_test.rb
index 69c9cd5..fca902c 100644
--- a/data_miner_test.rb
+++ b/data_miner_test.rb
@@ -4,12 +4,12 @@ class Shop < ActiveRecord::Base
end
class ItemDetail < ActiveRecord::Base
- set_primary_key :id
+ set_primary_key :row_hash
require 'test_helper'
class Shop < ActiveRecord::Base
end
class ItemDetail < ActiveRecord::Base
set_primary_key :row_hash
data_miner do
import 'A csv file with no identifier', :url => 'http://imports.s3.amazonaws.com/products_no_id.csv', :errata => 'http://spreadsheets.google.com/pub?key=tF58sAgqkY214EFBMdYCIUw', :delimiter => ';' do