Skip to content

Instantly share code, notes, and snippets.

gwillem / magento-nginx.conf
Last active May 30, 2022
Battle-tested Nginx configuration for Magento (source:
View magento-nginx.conf
# This is an annotated subset of the Nginx configuration from our Magento production platform @
# See
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/;
events {
View CMakeLists.txt
# CMake configuration
# Please refer to
# You may also refer to for a quick
# introduction to CMake's syntax.
cmake_minimum_required (VERSION 2.8)
# The name of our project is "BLE_HEART_RATE". CMakeLists files in this project can

Devise / Warden Tagged logging

I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin and a User). I tested against Rails 4 and Devise HEAD, but it should work fine in any Rails 3 application.

This solution doesn't use the log_tags configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger is executed, since it happens way down in the middleware chain.

Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:

# application.rb
watsonbox / php_dalli_store.rb
Created Jul 24, 2012
PHP Memcache Session Store Using Dalli
View php_dalli_store.rb
require 'action_dispatch/middleware/session/dalli_store'
# - PHP side is 5.3.6 configured with session.save_handler = memcache
# - Requires php-serialize gem for serialization:
module ActionDispatch
module Session
class PhpDalliStore < ActionDispatch::Session::DalliStore
require 'php_serialize'
class PhpSerializingPoolDecorator < SimpleDelegator
View gist:2307647
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
taras / gist:181654
Created Sep 6, 2009 — forked from anonymous/gist:156623
Scrapy Production/Worker/Dev Setup Fabfile
View gist:181654
Git Repo:
View alternative, using regex
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """)
val matcher = pattern.matcher (input)
while (matcher.find) {
val col1 = (2)
val col2 = (4)
// ...