Skip to content

Instantly share code, notes, and snippets.

SELECT idx.relname as table,
idx.indexrelname as index,
pg_relation_size( idx.indexrelname::text ) as bytes,
cls.relpages as pages,
cls.reltuples as tuples,
idx.idx_scan as scanned,
idx.idx_tup_read as read,
idx.idx_tup_fetch as fetched
FROM pg_stat_user_indexes idx,
pg_class cls ,
@sriedel
sriedel / post-checkout
Created October 20, 2010 05:59
Post Commit hook to auto-update submodules
#!/bin/bash
pushd . # save current place in filesystem
until [ -d .git ] || $(pwd) = "/" ; do # look for project root
cd ..
done
if [ -d .git ] ; then # if we found it...
git submodule update
fi
#!/usr/bin/python
### Example usage: $0 {symbolic-host1} {s-h2} ... {s-host12}
from be_setup import *
from wrap_systest_cluster_membership import *
import sys, time
symbolic_hosts = sys.argv[1:]
@sriedel
sriedel / remove_fk_constraints.sql
Created January 13, 2011 07:38
Remove FK constraints from postgres database
select 'ALTER TABLE ' || t.table_name || ' DROP CONSTRAINT ' || t.constraint_name || ';'
from information_schema.table_constraints t
where t.constraint_type = 'FOREIGN KEY';
@sriedel
sriedel / gist:1682210
Created January 26, 2012 10:49
Generate nicknames phonetically
class NicknameGenerator
# Grabbed phoneme and template list from http://www.flipcode.com/archives/misc/NameData.xml
# Based on an idea presented on http://www.flipcode.com/archives/Generating_Names_Phonetically.shtml
# by Jim Adams (jadams@copernus.com), 2000
# (sr 2012-01-26)
PHONEME_LIST = { # consonants
:affricate => %w{ch dg j},
:alveolar => %w{d l n r s t z},
:bilabial => %w{b m p},
:bilabial_stop => %w{b p},
@sriedel
sriedel / gist:3016439
Created June 29, 2012 07:18
copy opt-out-urls from xml feed
file = File.readlines( "20120628T111327_1" )
hash = {}
pairs = file.grep( /extid|opt_out_url/ ).
map { |e| e.gsub( /<.*?>/, '' ) }.
map(&:strip)
pairs.shift
pairs.each_slice( 2 ) { |e| hash[e[0].to_i] = e[1] }
hash.delete(0)
@sriedel
sriedel / ctags.excludes
Created November 5, 2012 08:32
ctags update scripts for git hooks
tmp
log
doc
coverage
app/assets/javascripts/*min.js
@sriedel
sriedel / gist:4032070
Created November 7, 2012 14:56
git lg
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@sriedel
sriedel / rc.lua
Created February 11, 2014 14:53
awesome 3.5 config
-- Standard awesome library
local awful = require("awful")
awful.autofocus = require("awful.autofocus")
awful.rules = require("awful.rules")
-- Theme handling library
local beautiful = require("beautiful")
local gears = require("gears")
-- Notification library
local naughty = require("naughty")
local vicious = require("vicious")