Skip to content

Instantly share code, notes, and snippets.

View mnguyenngo's full-sized avatar

Nguyen Ngo mnguyenngo

View GitHub Profile
@mnguyenngo
mnguyenngo / time_reference.py
Created October 8, 2018 22:34
Working with time in Python
import datetime
import time
# get current date in format yymmdd; useful for naming files
today = datetime.date.today().strftime("%y%m%d")
# get current unix time in seconds as integer
now = int(time.time())
# get time at midnight for current day in seconds as integer
@mnguyenngo
mnguyenngo / cron.txt
Created October 1, 2018 21:01
crontab template
# ┌──────────────── Minute (0 ... 59)
# │ ┌───────────── Hour (0 ... 23)
# │ │ ┌────────── Day (1 ... 31)
# │ │ │ ┌─────── Month (1 ... 12)
# │ │ │ │ ┌──── Weekday (0=Sun ... 6=Sat)
# ┴ ┴ ┴ ┴ ┴
# * * * * *
# run at 1:00 AM everyday from Monday through Friday
0 1 * * 1-6 cd projects/cron_hello_world/ && python hello_world.py
@mnguyenngo
mnguyenngo / using_sqlite3.rst
Last active September 24, 2018 00:30
sqlite3 with Python and in the terminal
@mnguyenngo
mnguyenngo / git_prune.rst
Last active September 20, 2018 22:55
Clean up remote git branches
@mnguyenngo
mnguyenngo / NguyenNgo.md
Created September 17, 2018 05:36
Resume for Microsoft LEAP Program

Nguyen Ngo

808-381-0751 | mnguyenngo@gmail.com | Github | LinkedIn


Software developer with experience in machine learning and data science in the process of making a career transition from structural engineering. I enjoy working on personal projects and collaborating with others as much as possible. In addition to keeping up with the latest machine learning tools, I was driven to understand how to build REST APIs and web applications in order to easily deploy and demonstrate my work to the online community.


@mnguyenngo
mnguyenngo / bins_array.py
Last active September 12, 2018 19:39
Centering histogram bar plots
"""Histogram bars are not centered at their label by default.
The function below returns the bins parameter value for use with matplotlib's
hist() method.
"""
import numpy as np
import pandas as pd
def bin_array(distribution):
"""Returns an array to be used as the parameter value to center the
@mnguyenngo
mnguyenngo / geocoding_quickstart.rst
Created September 3, 2018 22:23
Working with geocoding APIs
@mnguyenngo
mnguyenngo / api.py
Created August 31, 2018 18:51
Sentiment Classifier as REST API
from flask import Flask
from flask_restful import reqparse, abort, Api, Resource
import pickle
import numpy as np
from model import NLPModel
app = Flask(__name__)
api = Api(app)
model = NLPModel()
@mnguyenngo
mnguyenngo / plot.py
Created August 31, 2018 18:06
Center histogram bars on corresponding x-label when plotting from Pandas dataframes
# set bins to the (number of bins + 1) - 0.5 to center the bar on the right x-label
df['col_name'].hist(xrot=90, figsize=(12,6), rwidth=0.5, bins=np.arange(9)-0.5)
@mnguyenngo
mnguyenngo / plac_quickstart.rst
Last active September 20, 2018 22:47
Implementing plac

plac Quickstart

plac makes parsing arguments from the command line easy.

plac Documentation: https://micheles.github.io/plac/

This short guide will only cover the decorator function plac.annotations().