Skip to content

Instantly share code, notes, and snippets.

@filipwodnicki
filipwodnicki / conda_cheatsheet.sh
Last active July 9, 2019 10:38
Conda cheatsheet
# Conda cheatsheet
# Conda create new environment
conda create -n myenvname python=3.7
# Add conda environment to jupyter
python -m ipykernel install --user --name myenvname --display-name "Python (myenvname)"
# Conda create new environment and install datascience packages
conda create -n myenvname python=3.7 jupyter ipykernel nb_conda pandas geopandas shapely numpy scipy
@filipwodnicki
filipwodnicki / how_to_named_tuple.py
Last active June 13, 2019 16:32
How to use Named Tuples in Python
# source: https://pymotw.com/2/collections/namedtuple.html
# doc: https://docs.python.org/3.7/library/collections.html#collections.namedtuple
import collections
Person = collections.namedtuple('Person', field_names=['name', 'age', 'gender'])
filip = Person(name='Filip', age=101, gender='undisclosed')
print(filip.name)
@filipwodnicki
filipwodnicki / install_macos.sh
Created June 10, 2019 18:30
install libpostal mac
# install libpostal v1.1-alpha. Environment: MacOS 10.14 Python 3.6
# libpostal library instructions didn't work for me, got error:
# ERR Error loading transliteration module, dir=(null) at libpostal_setup_datadir (libpostal.c:266) errno: No such file or directory
# Here is a workaround:
git clone https://github.com/openvenues/libpostal
cd libpostal
./bootstrap.sh
@filipwodnicki
filipwodnicki / heroku-dump-pg-restore.sh
Last active June 10, 2019 14:06
use heroku database dump to populate local database
# Download heroku database dump and run pg restore on it to populate local db
## Source: https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e
## link: https://data.heroku.com/datastores/
# prep: download the heroku dump from heroku > Databases > durability
psql
postgres=# drop database if exists replace_this_with_your_database_name;
postgres=# create database replace_this_with_your_database_name;
pip install --upgrade pip
pip install jupyter
@filipwodnicki
filipwodnicki / binomial-distribution.r
Created August 30, 2017 16:44
R Tutorial For Beginners
# Here we view that many random trials result in a Gaussian Distribution.
# first we create random vector and resize it be a matrix
d2 <- runif(4000,-1,2)
dim(d2) <- c(100,40)
#wanna see my d2?
head(d2)
#now we bind the a new column rowsum to the original matrix (Column 41!)