Skip to content

Instantly share code, notes, and snippets.

View swyoon's full-sized avatar

Sangwoong Yoon swyoon

View GitHub Profile
@swyoon
swyoon / gist:0c0e62d7a705fd92a8a2c3873062ad54
Created August 25, 2020 07:03 — forked from amrakm/gist:be4c89555ef5318aa6827905eb887d3f
Dynamically update plots in Jupyter lab
# source: https://stackoverflow.com/a/52672859/5554394
from IPython.display import clear_output
from matplotlib import pyplot as plt
import collections
%matplotlib inline
def live_plot(data_dict, figsize=(7,5), title=''):
clear_output(wait=True)
plt.figure(figsize=figsize)
@swyoon
swyoon / download_files_from_googledrive.py
Created July 4, 2020 14:51
A script for downloading all files in a Google Drive folder.
"""
A Python script for downloading all files under a folder in Google Drive.
Downloaded files will be saved at the current working directory.
This script uses the official Google Drive API (https://developers.google.com/drive).
As the examples in the official doc are not very clear to me,
so I thought sharing this script would be helpful for someone.
To use this script, you should first follow the instruction
in Quickstart section in the official doc (https://developers.google.com/drive/api/v3/quickstart/python):
@swyoon
swyoon / gist:e7cba35b569a79377fc1eb67e4f8d2ea
Created February 4, 2018 09:11
Install Vim 8 with Python, Python 3, Ruby and Lua support on Ubuntu 16.04
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev
#Optional: so vim can be uninstalled again via `dpkg -r vim`
sudo apt-get install checkinstall
sudo rm -rf /usr/local/share/vim /usr/bin/vim
cd ~
@swyoon
swyoon / np_to_tfrecords.py
Last active November 29, 2022 06:39
From numpy ndarray to tfrecords
import numpy as np
import tensorflow as tf
__author__ = "Sangwoong Yoon"
def np_to_tfrecords(X, Y, file_path_prefix, verbose=True):
"""
Converts a Numpy array (or two Numpy arrays) into a tfrecord file.
For supervised learning, feed training inputs to X and training labels to Y.
For unsupervised learning, only feed training inputs to X, and feed None to Y.