Skip to content

Instantly share code, notes, and snippets.

Avatar

Tan Kok Hua spidezad

  • Seagate Technology
View GitHub Profile
@spidezad
spidezad / Sublime text for python IDE
Last active Feb 19, 2020
Sublime text Configure for python IDE
View Sublime text for python IDE
# youtube ref
https://www.youtube.com/watch?v=t2A_4gWzg8c
# terminal in sublime text
https://www.youtube.com/watch?v=sRxpxFDGLXI
# Configure terminus --key binding only work in windows
https://github.com/James231/Terminals-In-Sublime-Text
# command palatte --> install packages --> terminus
View BasicDjangoSimpleProject
## From Django Tutorial
# Create Project
django-admin startproject mysite
# Create Apps
python manage.py startapp polls
# Add app to settings.py
@spidezad
spidezad / django_static_files
Last active Jan 15, 2020
Django static files Notes
View django_static_files
# update settings.py for new app
# create views.py in app
# create urls.py in app
# update urls.py in main
# add in various html template in app_name/templates
# for the html template
{% load static %}
# specifying a static file
<link rel="stylesheet" type="text/css" href="{% static 'appsname/style.css' %}">
View psql commands
# Start PostgreSQL server
pg_ctl -D /usr/local/var/postgres start
# list all database
\l
# help on all commands
\?
# connect to database
View gist:99e889feea264144ccf3317c27c33a6d
#pip suddenly not working (SSL related)
brew reinstall python3
link: https://stackoverflow.com/questions/58280484/ssl-module-in-python-is-not-available-on-osx
# if python2 on os
curl https://bootstrap.pypa.io/get-pip.py | sudo python2
View Git Commands
# git clone and pip install requirements
git clone https://github.com/eleanorstrib/deploying-django.git
pip install -r requirements.txt
View gist:0b94db32fbb40f98b5160dd2e4abd602
Ref: https://medium.com/@Umesh_Kafle/postgresql-and-postgis-installation-in-mac-os-87fa98a6814d
# Remove previous versions of PostgreSQL
brew uninstall --force postgresql
# Delete all Files of Postgres
rm -rf /usr/local/var/postgres
# Install Postgres with Homebrew
brew install postgres
View gist:7bf2a7e6af3392b1e6ee5ea6591b35ce
https://virtualenvwrapper.readthedocs.io/en/latest/
pip install virtualenvwrapper
mkvirtualenv env1
lssitepackages #see new packages
workon env1
echo $VIRTUAL_ENV
# make virtualenv with python3
mkvirtualenv env1 --python=python3
View gist:234ee266abcd1b54ea3d379abbe94c97
sns.heatmap(df.isnull(), yticklabels=False, cbar = False, cmap = 'viridis')
View gist:29ab9555db9238253cc720f33435d94c
from keras.utils import np_utils
from sklearn.preprocessing import LabelEncoder
labelenc = LabelEncoder()
y_enc = labelenc.fit_transform(y)
y_onehot = np_utils.to_categorical(y_enc)
y_onehot