Skip to content

Instantly share code, notes, and snippets.

View ceshine's full-sized avatar

CeShine Lee ceshine

View GitHub Profile
@ceshine
ceshine / spacy_sentencizer.ipynb
Created August 14, 2019 04:46
Customizing Spacy's Statistical Sentence Segmenter with Custom Rules
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ceshine
ceshine / convert.py
Created July 17, 2019 05:03
A simple script to convert markdown image specification to hugo shortcode (result is automatically copied to clipboard)
from subprocess import Popen, PIPE
def image_markdown_conversion():
try:
while True:
text = input("Input:").strip()
brackets, split_point = 1, 0
description = ""
assert len(text) > 5, "wrong format!"
@ceshine
ceshine / detector.py
Last active April 22, 2020 05:57
A Simple CJK Language Detector
import re
def cjk_detect(texts):
# korean
if re.search("[\uac00-\ud7a3]", texts):
return "ko"
# japanese
if re.search("[\u3040-\u30ff]", texts):
return "ja"
@ceshine
ceshine / zip_and_base64encode.py
Created November 19, 2018 09:59
Useful script for importing your own packages into Kaggle Kernels
from zipfile import ZipFile
import zipfile
from pathlib import Path
import base64
import sys
import io
def write_folder(zfile: ZipFile, dir_path: Path, prefix: str = ""):
assert dir_path.is_dir()
@ceshine
ceshine / extract.py
Last active October 29, 2018 04:01
Scripts to scrape and extract data from the Tourism Bureau of Taiwan
# WARNING: this script is out-dated since the last update of the Tourism Bureau website.
from pathlib import Path
import pandas as pd
SCHEMAS = [
(201201, "schema/residence-2012-01.csv"),
(201101, "schema/residence-2011-01.csv")
]
DATA_FILE_PATTERN = "raw_data/{year}-{month}.xls"
@ceshine
ceshine / plotting.R
Created October 8, 2018 10:33
Plotting Script for the TPU blog psot
library(ggplot2)
library(ggthemes)
dat <- data.frame(
name = c("CPU", "GPU", "TPU"),
time = c(3 * 3600 + 6 * 60 + 4, 3 * 60 + 16, 1 * 60 + 42)
)
dat$log_time = log(dat$time)
ggplot(data=dat, aes(x=name, y=log_time)) +
@ceshine
ceshine / keras-fashion-mnist-tpu.ipynb
Created October 8, 2018 08:53
Keras Fashion MNIST - TPU
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ceshine
ceshine / keras-fashion-mnist-gpu.ipynb
Created October 8, 2018 08:53
Keras Fashion MNIST - GPU
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ceshine
ceshine / keras-fashion-mnist-cpu.ipynb
Created October 8, 2018 08:48
Keras Fashion MNIST - CPU
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.