Skip to content

Instantly share code, notes, and snippets.

@prakashpp
prakashpp / drop-postgres-db-in-bulk.py
Last active August 29, 2015 14:04
Remove postgres databases in bulk!
"""How to run:
POSTGRES_DATABASE_URI="postgresql://postgres:postgres@localhost/postgres" python remove-postgres.py
"""
import urlparse
import os
import psycopg2
from psycopg2.extensions import AsIs
result = urlparse.urlparse(os.environ['POSTGRES_DATABASE_URI'])
@prakashpp
prakashpp / keybase.md
Created June 17, 2015 11:33
keybase.md

Keybase proof

I hereby claim:

  • I am prakashpp on github.
  • I am prakashpandey (https://keybase.io/prakashpandey) on keybase.
  • I have a public key whose fingerprint is F383 E183 ACAF 56DA 33B7 F7AE 630F 74FE F11B 1198

To claim this, I am signing this object:

@prakashpp
prakashpp / kill_connection.sql
Created August 30, 2015 06:49
Postgres all connections except one IP
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
client_addr <> '172.31.1.200'
AND datname = 'staging'
@prakashpp
prakashpp / uninstall_tryton_module.py
Last active February 13, 2016 02:01
Uninstall tryton modules
# -*- coding: utf-8 -*-
import os
import sys
import psycopg2
# Connect to tryton database with database uri.
#
# Example: postgres://tryton:tryton@localhost/production
conn = psycopg2.connect(os.environ.get('TRYTOND_DATABASE_URI'))
@prakashpp
prakashpp / push_stats.py
Created March 28, 2016 07:49
Script to push github commit stats to slack
import os
from datetime import datetime
from slacker import Slacker
from dateutil.relativedelta import relativedelta
import requests
from requests.auth import HTTPBasicAuth
USERNAME = "prakashpp"
GITHUB_TOKEN = os.environ['GITHUB_ACCESS_TOKEN']