Skip to content

Instantly share code, notes, and snippets.

View lukaskonarovsky's full-sized avatar

Lukáš Konarovský lukaskonarovsky

View GitHub Profile
@errordeveloper
errordeveloper / Unicorn_and_Upstart.md
Last active February 9, 2022 09:21
Upstart config for a Rails app using Unicorn HTTP server

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

@ruckus
ruckus / gist:2293434
Created April 3, 2012 16:36
Basic setup of WAL-E for continuous archiving and recovery

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@mperham
mperham / gist:1379464
Created November 19, 2011 22:33
Flexibility without Dependency Injection
class TaxCode
GENERATORS = {
:us => lambda { |id| "US-#{id}" },
:br => lambda { |id| "#{id + 9}-BRA" },
}
def self.generate(code, id)
gen = GENERATORS[code] || raise ArgumentError, "No generator for country #{code}"
gen.call(id)
end
@stefl
stefl / gist:867165
Created March 12, 2011 09:58
Redirect trailing slashes in Sinatra
get %r{(.+)/$} do |r| redirect r; end;
@darwin
darwin / gist:658202
Created November 1, 2010 13:54
Podpora sluzeb CNB pro Google Spreadsheets
// Podpora sluzeb CNB pro Google Spreadsheets
// autor: [email protected]
// ==========================================
//
// =historicalRate(currency, date, zone)
// -------------------------------------
// currency je kod meny (USD, EUR, apod.)
// date je ve formatu d.m.r (pokud neni date zadano, pak se vrati aktualni kurz)
// zone je volitene a uplatni se pro konverzi date na string (pokud neni zadana pouzije se CET)
//
#!/bin/sh
#
# new_server.sh
# Author: Sam Soffes
# Created: 02/25/2010
# Updated: 11/04/2010
#
# See my blog post on this script: http://samsoff.es/posts/new-server-script
#
# This script installs everything needed to run a Ruby on Rails application on