Skip to content

Instantly share code, notes, and snippets.

class ApplicationController < ActionController::Base
before_filter :set_locale_from_remote_addr
private
def set_locale_from_remote_addr
return do_something(session[:locale] if session[:locale]
raise UnknownIPAddessError unless request.remote_addr
geoip = GeoIP.new(Rails.root + "db/GeoLiteCountry.dat").country(request.remote_addr)
#!/usr/bin/env ruby
# please install gnuplot
# sudo apt-get install gnuplot
# crontab
# */15 * * * * /var/www/loadaverage.rb
logname = "/var/www/loadaverage/#{Time.now.strftime('%Y%m%d')}.log"
#! /bin/sh
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro.
#
# Author: Ryan Norbauer <[email protected]>
# Modified: Geoffrey Grosenbach http://topfunky.com
#
# coding: utf-8
puts %w(マジで ヤバい ウケルー).sample while gets != "\n"
require 'openssl'
require 'url_safe_base64'
original = "Hello World"
pem = <<-PEM
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,A6B5D10FFA23D7BC66CE4FB46B754E8C

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
@Epictetus
Epictetus / Gemfile
Created March 15, 2013 19:28 — forked from cblunt/Gemfile
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL
1, this, 17544
2, that, 15950
3, have, 9742
4, with, 9584
5, http, 8688
6, node, 6024
7, should, 5743
8, error, 4285
9, test, 4209
10, work, 4175
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547