This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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>); |