Skip to content

Instantly share code, notes, and snippets.

View dpmccabe's full-sized avatar

Devin McCabe dpmccabe

  • Broad Institute of MIT and Harvard
  • Cambridge, MA
View GitHub Profile
# == Schema Information
#
# Table name: billings
#
# id :integer not null, primary key
# user_id :integer
# bt_cc_token :string(255)
# bt_cust_id :string(255)
# bt_cc_expiration :string(255)
# bt_cc_last4 :string(255)
class Billing < OtherClass
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
attr_accessor :save_my_billing
attr_reader :result
cattr_reader :rate
@dpmccabe
dpmccabe / user.rb
Last active December 23, 2015 22:49
a really bad model
class User < ActiveRecord::Base
MAILCHIMP_API_KEY ='m23lm092m3'
MAILCHIMP_LIST_ID ='h439cds'
has_many :orders
before_save :assign_referral_code
after_create :schedule_welcome_email
class @VideoProgressTracker
constructor: (@video) ->
@played_five_seconds = 0
@checkpoints = [0, 25, 50, 75, 95]
track: ->
@played_five_seconds += 1
@triggerCheckpoints(500 * @played_five_seconds / @duration)
start: ->
jQuery ->
$.ajax
url: "//connect.facebook.net/en_US/all.js"
dataType: 'script'
cache: true
$('a.requires-fb').click (e) ->
e.preventDefault()
return_to = $(this).attr('href')
ask_for_fb(return_to)
@dpmccabe
dpmccabe / unicorn.rb
Last active December 15, 2015 09:29
timeout backtraces
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1147:in `translate_exception'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:284:in `rescue in log'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/instrumentation/active_record.rb:32:in `block in log_with_newrelic_instrumentation'
vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.3.25/lib/new_relic/agent/instrumentation/active_record.rb:29:in `log_with_newrelic_instrumentation'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection
@dpmccabe
dpmccabe / gist:5171731
Created March 15, 2013 17:53
extra sublime layouts
[{
"id": "view",
"children": [{
"id": "layout",
"children": [{
"command": "set_layout",
"caption" : "1-2 Grid",
"keys": ["super+alt+shift+5"],
"args":
{
Process: org.eyebeam.SelfControl [26418]
Path: /Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl
Identifier: org.eyebeam.SelfControl
Version: ???
Code Type: X86-64 (Native)
Parent Process: SelfControl [26414]
User ID: 0
Date/Time: 2013-03-04 11:11:41.694 -0600
OS Version: Mac OS X 10.8.2 (12C3104)
production_app_name="getafive"
pg_dev_db="gaf_development"
function LastBackupName() {
heroku pgbackups --app="$production_app_name" | grep '(DATABASE_URL)' | tail -n 1 | cut -d " " -f 1
}
# delete last manual backup and create new one
old_backup=$(LastBackupName)
heroku pgbackups:destroy $old_backup --app="$production_app_name"
app/views/credits/new.html.haml:22:in `block in _app_views_credits_new_html_haml___2861429593078620750_74935680'
vendor/bundle/ruby/1.9.1/gems/haml-3.2.0.rc.1/lib/haml/helpers/action_view_mods.rb:133:in `call'
vendor/bundle/ruby/1.9.1/gems/haml-3.2.0.rc.1/lib/haml/helpers/action_view_mods.rb:133:in `block (2 levels) in form_for_with_haml'
vendor/bundle/ruby/1.9.1/gems/haml-3.2.0.rc.1/lib/haml/helpers.rb:278:in `with_tabs'
vendor/bundle/ruby/1.9.1/gems/haml-3.2.0.rc.1/lib/haml/helpers/action_view_mods.rb:133:in `block in form_for_with_haml'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
vendor/bundle/ruby/1.9.1/gems/haml-3.2.0.rc.1/lib/haml/helpers/xss_mods.rb:110:in `with_output_buffer_with_haml_xss'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_view/helpers/capture_helper.rb:40:in `capture'
vendor/bundle/ruby/1.9.1/