Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
class ActionMailer::Base
default 'X-SMTPAPI' => lambda {
{ 'category' => "#{mailer_name}.#{@template}",
'unique_args' => (@unique_args || {})
}.to_json
}
end
rake assets:precompile && git add --all public && git commit -m 'precompile assets'
# See https://www.fededirectory.frb.org/format.cfm
#
# Run this by doing `ruby parser.rb`
require 'rubygems'
require 'json'
require 'sinatra'
$db = {}
@ajsharp
ajsharp / gist:3815488
Created October 2, 2012 00:39
Handling a 409 response when attempting to create a balanced account and a user with that email account already exists
begin
balanced_account = Balanced::Marketplace.my_marketplace.create_merchant(email, merchant_hash, bank_account_uri, name)
rescue Balanced::Error => ex
if ex.response[:status] == 409
# A 409 is returned if the account has already been created.
# Balanced will return the account uri in the error response, so we simply need to
# create an internal account on our end.
decoded_body = ex.response[:body]
uri = decoded_body['extras']['account_uri']
class PostsController
def create
post = Post.new params[:post]
if post.save
render s
# Your standard foreman Procfile
api-server: bundle exec rails s -p 3000
postgres: postgres -D /usr/local/var/postgres
service-runner: ./bin/run-services
/* ...
*= require_self
*= require_tree ./../../../vendor/assets/stylesheets
*= require_tree .
*/
module Rack
class Promiscuity
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
status, headers, body = @app.call(env)
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes