Skip to content

Instantly share code, notes, and snippets.

@stuntgoat
stuntgoat / stop_queries.sql
Last active August 29, 2015 14:03
Check long running queries and stop them if you want.
;; Show long running queries.
SELECT pid, state, query_start, query FROM pg_stat_activity;
;; Kill a long running query.
SELECT pg_cancel_backend(<pid of the query from previous query>);
@stuntgoat
stuntgoat / pandas_notes.py
Last active March 8, 2016 01:45
notes on using Pandas
# read csv
df = pd.read_csv("<filename>")
# show duplicates; returns series of bools
dup_indexes = r.duplicated(cols=("colname1", "colname2"))
# remove duplicates; in place
df.drop_duplicates("colname1", "colname2", inplace=True)
# drop a column
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 14, 2024 09:13
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@c4milo
c4milo / yourservice.conf
Created April 25, 2011 18:05
upstart example script
# Ubuntu upstart file at /etc/init/yourservice.conf
pre-start script
mkdir -p /var/log/yourcompany/
end script
respawn
respawn limit 15 5
start on runlevel [2345]
@gpiancastelli
gpiancastelli / goodreads-oauth-example.py
Created August 19, 2010 13:50
A Python example of how to use OAuth on GoodReads
import oauth2 as oauth
import urlparse
url = 'http://www.goodreads.com'
request_token_url = '%s/oauth/request_token/' % url
authorize_url = '%s/oauth/authorize/' % url
access_token_url = '%s/oauth/access_token/' % url
consumer = oauth.Consumer(key='Your-GoodReads-Key',
secret='Your-GoodReads-Secret')