Skip to content

Instantly share code, notes, and snippets.

su postgres
pg_dropcluster --stop 9.1 main
pg_upgradecluster 8.4 main
Number.prototype.plural = function(){
if(this > 1 || this == 0){
return true;
} else {
return false;
}
}
String.prototype.pluralize_rules = function(){
return [[new RegExp('$', 'gi'), 's']];
@jaywhy13
jaywhy13 / gist:5716329
Created June 5, 2013 19:07
Find database size in PostgreSQL
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
@jaywhy13
jaywhy13 / gist:5783986
Created June 14, 2013 18:06
Change Python Path
The Python PATH can be changed by either editing HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python (if we're on 64-bit) or HKEY_LOCAL_MACHINE\SOFTWARE\Python if we're using a 32-bit machine. This may be necessary in cases of like custom installations.
@jaywhy13
jaywhy13 / customize_byobu_keybindings.sh
Last active January 14, 2016 01:00
Customize Byobu keybindings in Vagrant
#!/bin/bash
# We need to invoke Byobu just so that it'll create the ~/.byobu directory
byobu-tmux new-session -d
byobu kill-server
echo "bind-key -n F1 new-window
bind-key -n F2 previous-window
bind-key -n F3 next-window" > ~/.byobu/keybindings.tmux
@jaywhy13
jaywhy13 / install_virtualenv.sh
Last active January 14, 2016 00:03
Setup Vagrant with Virtualenvwrapper
#!/bin/bash
# Install virtualenvwrapper library
sudo pip install virtualenvwrapper
# Configure .bashrc
echo "export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=/vagrant
source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
@jaywhy13
jaywhy13 / install_rabbit.sh
Last active March 14, 2016 18:20
Install RabbitMQ Server 3.6 on Ubuntu 12.04
#!/bin/bash
echo "deb http://www.rabbitmq.com/debian/ testing main" | tee -a /etc/apt/sources.lst
echo "deb http://packages.erlang-solutions.com/ubuntu precise contrib" | tee -a /etc/apt/sources.lst
# Upgrade Erlang
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
@jaywhy13
jaywhy13 / watchdocs.py
Last active April 27, 2016 11:40
Python script to compile Sphinx documentation
import sys
import time
import logging
import os
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
from watchdog.events import PatternMatchingEventHandler
import subprocess
class DocsCompiler(PatternMatchingEventHandler):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.