Skip to content

Instantly share code, notes, and snippets.

@mmatkinson
mmatkinson / postgres_queries_and_commands.sql
Created June 7, 2018 20:54 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), 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(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
**Convert .ipynb to Slides**
cd "test"
ipython nbconvert "test.ipynb" --to slides --reveal-prefix "http://cdn.jsdelivr.net/reveal.js/2.6.2" --post serve --config slides_config.py
* To print slides add ?print-pdf at the end of the URL and print
**Convert .ipynb to LaTex/PDF**
ipython nbconvert MyFirstNotebook.ipynb --to latex --post PDF
**Convert .ipynb to HTML**
@mmatkinson
mmatkinson / geopandas_tour.ipynb
Created January 16, 2018 17:41 — forked from ocefpaf/geopandas_tour.ipynb
explore shapefile
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.
@mmatkinson
mmatkinson / google_spreadsheets_create_update_example.py
Created November 5, 2016 02:06 — forked from pahaz/google_spreadsheets_create_update_example.py
Python Google spreadsheets v4 API example. Google spreadsheet access management example. Use google drive v3 API for access management
"""Google spreadsheet related.
Packages required: oauth2client, google-api-python-client
* https://gist.github.com/miohtama/f988a5a83a301dd27469
"""
from oauth2client.service_account import ServiceAccountCredentials
from apiclient import discovery
def get_credentials(scopes: list) -> ServiceAccountCredentials:
@mmatkinson
mmatkinson / useful_pandas_snippets.py
Last active April 29, 2016 00:01 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@mmatkinson
mmatkinson / nltk-intro.py
Last active January 28, 2016 15:37 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
import nltk
#python 3.4.0
#nltk==3.0.4
#numpy==1.10.4
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""