Skip to content

Instantly share code, notes, and snippets.

View denmarkin's full-sized avatar

Den Markin denmarkin

  • Rev.com, Inc
  • Carlsbad, CA
View GitHub Profile
@denmarkin
denmarkin / devise.en.yml
Created May 4, 2011 18:50
Custom overwrite for Device::SessionsController
sessions:
signed_in: 'Signed in successfully.'
signed_in_first_time: "MY CUSTOM WELCOME GREETING. DO NOT FORGET TO READ OUR GUIDELINE!"
signed_out: 'Signed out successfully.'
@denmarkin
denmarkin / resque.rake
Created September 20, 2011 11:02
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@denmarkin
denmarkin / common_steps.rb
Created November 2, 2011 17:15
Cucumber + Capybara HTML table comparison from http://railscasts.com/episodes/186-pickle-with-cucumber
Then(/^I should see (.+) table$/) do |table_id, expected_table|
html_table = table_at("##{table_id.parameterize.tableize}").to_a
html_table.map! { |r| r.map! { |c| c.gsub(/<.+?>/, '').gsub(/[\n\t\r]/, '') } }
expected_table.diff!(html_table)
end
@denmarkin
denmarkin / delayed_job.monitrc
Created March 11, 2011 19:31
real-world monit recipes
# See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611
check process delayed_job with pidfile /full/path/to/app/shared/pids/delayed_job.pid
start program = "/bin/su - deploy_username -c 'cd /full/path/to/app/current/; RAILS_ENV=production script/delayed_job start'"
stop program = "/bin/su - deploy_username -c 'cd /full/path/to/app/current/; RAILS_ENV=production script/delayed_job stop'"
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"

Keybase proof

I hereby claim:

  • I am denmarkin on github.
  • I am denmarkin (https://keybase.io/denmarkin) on keybase.
  • I have a public key ASCpGeeJGVUX_VHJR-x-QXpS-IOj0NY-aqqjU8_n0oYkcwo

To claim this, I am signing this object:

@denmarkin
denmarkin / will_paginate_array_helper.rb
Created February 8, 2011 21:48
How to extend array to support .paginate with will_paginate
# See http://rubydoc.info/gems/will_paginate/2.3.15/WillPaginate/Collection.create
# See https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/array.rb
# Do in application_helper.rb or application_controller.rb (or somewhere else application-wide)
require 'will_paginate/collection'
Array.class_eval do
def paginate(options = {})
raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options
WillPaginate::Collection.create(
options[:page] || 1,
@denmarkin
denmarkin / read_uncommitted.sql
Created November 16, 2012 19:09
Allow read from locked MSSQL table during debug of test inside transactions
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
@denmarkin
denmarkin / wd_world.log
Created October 20, 2011 14:43
My Book World (White Light) firmware 01.02.12 icompatibility of Berkeley DB lib from OSX Lion
10/20 13:43:40 MyBookWorld daemon.err afpd[4173]: Can't open volume "/DataVolume/.timemachine" CNID backend "cdb"
10/20 13:43:40 MyBookWorld daemon.err afpd[4173]: Cannot open CNID db at [/DataVolume/.timemachine].
10/20 13:43:40 MyBookWorld daemon.err afpd[4173]: cnid_open: dbenv->open of /DataVolume/.timemachine/.AppleDB failed: DB_VERSION_MISMATCH: Database environment version mismatch
10/20 13:43:40 MyBookWorld daemon.err afpd[4173]: cnid_open: dbenv->open (rw) of /DataVolume/.timemachine/.AppleDB failed: DB_VERSION_MISMATCH: Database environment version mismatch
10/20 13:43:39 MyBookWorld daemon.notice afpd[4173]: AFP3.3 Login by WD_Backup
10/20 13:38:24 MyBookWorld daemon.info wixEvent[3626]: Network IP Address - NIC 1 use static IP address 192.168.1.60
10/20 13:38:23 MyBookWorld daemon.warn wixEvent[3626]: Volume Used - Volume 'DataVolume' had reached 80% capacity.
10/20 13:38:06 MyBookWorld daemon.info wixEvent[3626]: Network Link - NIC 1 link is up 100 Mbps full duplex.
10/20 13:36:2
@denmarkin
denmarkin / application_helper.rb
Created October 14, 2011 08:17
Shared errors for multiple targets (when you need render errors for a form containing nested or unlinked )
def collect_shared_error_messages(target)
targets = []
error_messages = []
if target.kind_of?(Array)
target.collect {|t| targets << t}
else
targets << target
end
targets.each do |target|
target.errors.full_messages.collect {|msg| error_messages << msg} if target.errors.any?