Skip to content

Instantly share code, notes, and snippets.

View flomotlik's full-sized avatar

Florian Motlik flomotlik

View GitHub Profile
@flomotlik
flomotlik / heroku_run.sh
Last active January 10, 2020 21:40
Heroku run script that exits with the correct error code
#! /bin/bash
array=( $@ )
len=${#array[@]}
app=${array[$len-1]}
args=${array[@]:0:$len-1}
buffer_file=/tmp/last_heroku_run_`date +%N`
/usr/bin/heroku run "$args; echo \$?" --app $app 2>&1 | tee $buffer_file
@flomotlik
flomotlik / Scaler.rb
Created November 15, 2012 15:25
Our scaling logic
if open_jobs < idle_workers.count
scaledown_workers
elsif all_workers_working? && jobs_queued? && (instances_count - workers.count) < open_jobs
scaleup_workers
end
@flomotlik
flomotlik / gitconfig
Created October 12, 2012 09:28
Flo Gitconfig
[alias]
b = branch
a = add
c = commit -sv
cm = commit -svm
ca = commit --amend
co = checkout
cp = cherry-pick
d = diff
f = fetch
@flomotlik
flomotlik / bashrc
Created May 22, 2012 15:06
Efficient Heroku
function h { heroku ${@:1:($#-1)} --app ${@: -1} ; }
function hp { h $@ production_app_name ; }
function hs { h $@ staging_app_name ; }
alias hpc="hp run console"
alias hsc="hs run console"
alias hpl="hp logs -t"
alias hsl="hs logs -t"
@flomotlik
flomotlik / railsonfire.yml
Created May 18, 2012 11:06
Empty Railsonfire for gh-pages
---
test:
commands:
setup:
commands:
@flomotlik
flomotlik / development.rb
Created May 16, 2012 13:29
Testing Cloudfront
config.assets.debug = false
config.action_controller.asset_host = "https://d1qi4917vekr3d.cloudfront.net"
@flomotlik
flomotlik / Gemfile
Created May 14, 2012 15:15
Asset Pipeline Setup
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'yui-compressor'
gem 'compass-rails'
end
@flomotlik
flomotlik / application.rb
Created May 6, 2012 10:23 — forked from Epictetus/heroku_unicorn_logger_fix.rb
Fix Heroku cedar app logging with Rails 3.1 and Unicorn
config.logger = Logger.new(STDOUT)
@flomotlik
flomotlik / Gemfile
Created May 6, 2012 09:46 — forked from leshill/Procfile
Unicorn config for cedar stack on Heroku.
gem 'unicorn'
@flomotlik
flomotlik / unicorn.rb
Created May 6, 2012 09:03
Unicorn config
#Base on https://gist.github.com/1401792
worker_processes 4 # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 30 seconds
preload_app true
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')