Skip to content

Instantly share code, notes, and snippets.


Evan Prothro eprothro

View GitHub Profile
eprothro /
Last active Aug 29, 2015
View Heroku Postgres configuration settings


With pg installed, you can run the pg:psql Heroku command to connect to your database and execute commands using the psql interactive terminal:

$ heroku pg:psql
psql (9.3.5, server 9.3.3)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
database-name=> |
eprothro / gist:2b2a89fece090d0a1c43
Created Feb 24, 2015
Simple ruby memory benchmark
View gist:2b2a89fece090d0a1c43
module Benchmark
def memory_usage
`ps -o rss= -p #{}`.to_i
def memory
m0 = memory_usage
memory_usage - m0
def kb
eprothro / gist:dc022de04c58291d5430
Last active Aug 29, 2015
QueryObject as Decorator for relation
View gist:dc022de04c58291d5430
class TestQuery < SimpleDelegator
  def initialize
  module Scopes
    def processed
eprothro / gist:de0cb76631ccfb40b4a9
Last active Aug 29, 2015
Simple Object Oriented JS Example
View gist:de0cb76631ccfb40b4a9

Object Oriented Javascript Example

Consider a simple HTML element that we want to expand and contract by tapping a different target element.

<a href='expandable-element-1' data-expander>
  <!-- some link markup styled using an `expanded` class -->

<!-- unknown number of elements -->
eprothro / PEC Action Required
Created Jan 31, 2012
PEC Clean Water Action
View PEC Action Required
Date: January 30, 2012
R.B. Sloan
Chief Executive Officer
Pedernales Electric Cooperative
P.O. Box 1
Johnson City, TX 78636
Dear PEC Bard Members and PEC Staff:
View gist:2705416
source :rubygems
gem 'rails', '3.1.2'
gem 'asset_sync', '~> 0.4.1'
gem 'awesome_print', '~> 1.0.2'
gem 'authorize-net', '~> 1.5.2'
gem 'cells', '~> 3.8.3'
gem 'countries', '~> 0.8.2'
gem 'dalli', '~> 2.0.4'
View gist:2705420
source :rubygems
gem 'rails', '3.1.2'
gem 'asset_sync', '~> 0.4.1'
gem 'awesome_print', '~> 1.0.2'
gem 'authorize-net', '~> 1.5.2'
gem 'cells', '~> 3.8.3'
gem 'countries', '~> 0.8.2'
gem 'dalli', '~> 2.0.4'
View gist:2773124
tddium suite
Looks like you haven't set up a suite on this computer for youversion-web/mobile...
Enter a repo name or press 'Return'. Using 'youversion-web' by default: 'youversion-web/mobile'
... Detected branch mobile
... Detected ruby ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin11.2.0]
... Detected bundle Bundler version 1.1.3
... Detected gem 1.8.15
>>> Tddium selects tests to run by default (e.g., in CI) by matching against a
list of Ruby glob patterns. Use "," to join multiple globs.
View interaction model

The problem

Exhibit A

class Record < ActiveRecord::Base
  validates_uniqueness_of :name

At some point, we realize we're performing an extra query to check uniqueness every time we validate the object.

View cassandra_migrations and rails

Deadlock with Spring and cassandra_migrations

=> Rack::Timeout set to 1800 in development
Loading development environment (Rails 4.2.4)
[1] pry(main)> CassandraMigrations::Cassandra.client
=> #<Client:0x007ff17f6755e8
 @sessions={:default=>#<Cassandra::Session:0x3ff8bfb3a9a0>, "timebomb_api_development"=>#<Cassandra::Session:0x3ff8bfb42574>}>
You can’t perform that action at this time.