Skip to content

Instantly share code, notes, and snippets.

View jsmestad's full-sized avatar
👾

Justin Smestad jsmestad

👾
View GitHub Profile
portal: bundle exec rails s -p 3000
sidekiq: bundle exec sidekiq
redis: redis-server
tsa_server: sh -c 'cd ../tsa/ && exec rails s -p 3001'
@jsmestad
jsmestad / postgresql_patch.rb
Last active December 29, 2015 03:08
PG patch for StatementInvalid when using UUIDs or non-standard primary keys (PK)
# config/initializers/postgresql_patch.rb
#
class ActiveRecord::ConnectionAdapters::AbstractAdapter
def translate_exception(exception, message)
if exception.is_a?(PG::InvalidTextRepresentation)
raise ActiveRecord::RecordNotFound
else
# override in derived class
ActiveRecord::StatementInvalid.new(message, exception)
end
# config/initializers/database_connection.rb
# Uncomment line below to only enable fix in affected environments.
#
# if Rails.env.production? or Rails.env.staging?
require 'active_record/connection_adapters/postgresql_adapter'
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
def active?
@connection.query 'SELECT 1'
SituationRoom.provision(@account, :secure_regime)
FactoryGirl.{build,create,attributes_for}(:factory_name, {override/extra attrs})
FactoryBoy.create_asset_with_failing
SituationRoom::Situations::Asset
SituationRoom::Situations::FailingViolations
defaults: &defaults
fog_provider: 'AWS'
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] || '' %>
aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] || '' %>
fog_directory: assets.cafewell.com
# You may need to specify what region your storage bucket is in
# fog_region: "eu-west-1"
existing_remote_files: keep
# To delete existing remote files.
# existing_remote_files: delete
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'xxx', # required
:aws_secret_access_key => 'yyy', # required
:region => 'eu-west-1' # optional, defaults to 'us-east-1'
}
config.fog_directory = 'name_of_directory' # required
config.fog_host = 'https://assets.example.com' # optional, defaults to nil
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
require File.expand_path('../exceptions', __FILE__)
# Supports the following matchers:
#
# describe '/api/account.json' do
# subject { json_response }
# before { get '/api/account.json' }
# it { should have_json(:email).of_type(String) }
# it { should have_json(:posts).of_type(Array).inside_of('account') }
# it { should have_json(:review).of_type(Hash).inside_of('account/profile') }
module ResponseMatchers
# test for a 201 response
def be_successfully_created
ResponseStatusMatcher.new "201 Created"
end
# test for a 422 response
def be_unprocessable
ResponseStatusMatcher.new "422 Unprocessable Entity"
end
require 'formula'
class TmuxForIterm2 < Formula
url 'http://iterm2.googlecode.com/files/tmux-for-iTerm2-20120108.tar.gz'
md5 'f15d9f567b9b029482bb7b3227ee7ac3'
homepage 'http://code.google.com/p/iterm2/downloads/detail?' +
'name=tmux-for-iTerm2-20120108.tar.gz'
depends_on 'libevent'