Skip to content

Instantly share code, notes, and snippets.

Avatar

Den Markin denmarkin

  • Rev.com, Inc
  • Carlsbad, CA
View GitHub Profile
View keybase.md

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 / read_uncommitted.sql
Created Nov 16, 2012
Allow read from locked MSSQL table during debug of test inside transactions
View read_uncommitted.sql
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
View common_steps.rb
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 / wd_world.log
Created Oct 20, 2011
My Book World (White Light) firmware 01.02.12 icompatibility of Berkeley DB lib from OSX Lion
View wd_world.log
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 Oct 14, 2011
Shared errors for multiple targets (when you need render errors for a form containing nested or unlinked )
View application_helper.rb
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?
@denmarkin
denmarkin / nginx
Created Oct 6, 2011 — forked from mdominiak/nginx
nginx start up script for ubuntu
View nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
View config_initializers_sass.rb
Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
load_paths << "#{Rails.root}/app/assets/stylesheets"
load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
load_paths << "#{Gem.loaded_specs['html5-boilerplate'].full_gem_path}/stylesheets"
load_paths << "#{Gem.loaded_specs['fancy-buttons'].full_gem_path}/lib/stylesheets"
end
@denmarkin
denmarkin / resque.rake
Created Sep 20, 2011
My rake task for clearing Resque queues and stats
View resque.rake
# 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 / monit_rake.sh
Created Jun 22, 2011
monit + resque management (from @Mindwork)
View monit_rake.sh
#!/bin/sh
# wrapper to daemonize rake tasks: see also http://mmonit.com/wiki/Monit/FAQ#pidfile
usage() {
echo "usage: ${0} [start|stop] name target [arguments]"
echo "\tname is used to create or read the log and pid file names"
echo "\tfor start: target and arguments are passed to rake"
echo "\tfor stop: target and arguments are passed to kill (e.g.: -n 3)"
exit 1
}
[ $# -lt 2 ] && usage
@denmarkin
denmarkin / payments_controller.rb
Created May 29, 2011
Example of ActiveMerchant Express Checkout request construction
View payments_controller.rb
amount = thing.build_payment.price_in_cents
response = EXPRESS_GATEWAY.setup_authorization(amount,
:ip => request.remote_ip,
:return_url => new_payment_url,
:cancel_return_url => new_order_url,
:no_shipping => true,
:items => [{:name => "#{thing.title}", :amount => amount}]
)