Skip to content

Instantly share code, notes, and snippets.

View evu's full-sized avatar
🌎
>>> ▌

evu

🌎
>>> ▌
View GitHub Profile
@evu
evu / env.sh
Created October 1, 2020 03:20
env vars
CUDA_LAUNCH_BLOCKING=1
CUDA_VISIBLE_DEVICES=0,1,2,3
@evu
evu / zen.py
Created July 23, 2020 04:00
the zen of python
"""Do not let the zen slip through your fingers."""
import this
zen = "".join([this.d[x] if x.isalnum() else x for x in this.s])
@evu
evu / connect_to_postgres_with_psycopg2_and_pandas.py
Created February 18, 2020 14:56
Read from postgreSQL table into pandas dataframe using psycopg2 / sql query
import pandas as pd
import pandas.io.sql as pdsql
import psycopg2
# Database connection details
creds = {
"dbname": "mydb",
"user": "jsmith",
"password": "hello1234",
@evu
evu / psycopg2_cheatsheet.md
Created January 30, 2020 18:33 — forked from pfigue/psycopg2_cheatsheet.md
psycopg2 Cheatsheet

Connect and Select

connect()

The shortest connect:

from psycopg2 import connect
psql_conn = connect("dbname=XXX user=XXX password=XXX host=localhost sslmode=require")
psql_conn.close()
@evu
evu / snippet.py
Created November 16, 2019 00:59
Pandas DataFrame to tensorflow embedding projector .tsv
word_df.to_csv("words.tsv", sep="\t", header=False, index=False, quoting=csv.QUOTE_NONE, quotechar="", escapechar="\\")
vec_df.to_csv("vectors.tsv", sep="\t", header=False, index=False, quoting=csv.QUOTE_NONE, quotechar="", escapechar="\\")
@evu
evu / saved_model_cli.sh
Last active September 21, 2019 17:01
saved_model_cli example
saved_model_cli show --dir /path/to/saved/model/1521687978/ --all
@evu
evu / add_jupyter_kernel.sh
Created September 14, 2019 15:35
Add jupyter kernel for a virtualenv
#!/bin/bash
#
# Adds a jupyter kernel for a virtualenv
# This makes the virtualenv available for use in a Jupyter notebook
# Run this from the directory containing your virtualenv directory and
# pass it the directory name for your virtualenv.
#
# Usage:
# $ ./add_jupyter_kernel.sh myvenv
#
@evu
evu / the_best_PS1.sh
Created September 12, 2019 17:55
the best PS1
export PS1="\[\e[1;34m\]\W\[\e[m\] \\$ "
@evu
evu / pandas_cheatsheet.py
Created August 13, 2019 20:04
My Fav Pandas 🐼
# Summary statistics for numeric variables
df.describe().transpose()
# Summary statistics for categorical/string variables
df.describe(include=['O']).transpose()
# Info about column names, datatypes, and null values
df.info()
# Get a sample
@evu
evu / jupyter_plotsize_fix.py
Last active August 12, 2019 19:42
Change plot size in Jupyter
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (20,10)