Skip to content

Instantly share code, notes, and snippets.

View therrick's full-sized avatar

Tom Herrick therrick

  • duobit.io
  • 11:19 (UTC -04:00)
View GitHub Profile
@therrick
therrick / gist:11cce78cc13b3cfe0301d94e2901e223
Last active August 19, 2016 14:38
Rails 4.2.4 + Paranoia issue for with_deleted on belongs_to
# I've been troubleshooting an issue that cropped up in our app when we upgraded from
# rails 4.1 to 4.2. We make heavy use of the 'paranoia' gem to allow for soft-deleting
# records via a deleted_at attribute. The gem uses default scopes that exclude
# `deleted_at: nil` records from default queries.
#
# In our join tables, we unscope the belongs_to relation because once the app has found
# its way to a record in the join table, it expects to be able to see the joined
# records, even if those records have been deleted.
#
# Starting with Rails 4.2.4, it appears that this unscope on the belongs_to unexpectedly
@therrick
therrick / gist:4f8c4dc34411bf0bbdf2
Created December 19, 2015 12:15
stacktrace for rspec hangs
# from https://github.com/rspec/rspec-rails/issues/1353
# put this in spec/initializers/debug_hangs.rb, then use 'kill -USR1 <rspec-pid>' when rspec hangs
puts "rspec pid: #{Process.pid}"
trap 'USR1' do
threads = Thread.list
puts
puts '=' * 80
@therrick
therrick / gist:8090767
Last active January 1, 2016 04:19
/etc/init.d/nginx
#!/bin/sh
#
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.