Skip to content

Instantly share code, notes, and snippets.

View Emrys-Hong's full-sized avatar
🎯
Focusing

Hong Pengfei Emrys-Hong

🎯
Focusing
  • Singapore University of Technology and Design
  • X @emrys_hong
View GitHub Profile
@Emrys-Hong
Emrys-Hong / TabNineExample.toml
Created July 20, 2020 08:39 — forked from rlisowski/TabNineExample.toml
TabNineExample.toml
[language.rust]
command = "rls"
install = [
["rustup", "update"],
["rustup", "component", "add", "rls", "rust-analysis", "rust-src"],
]
[language.javascript]
command = "flow"
args = ["lsp"]
@Emrys-Hong
Emrys-Hong / mysql_cheat_sheet.md
Last active September 26, 2019 13:03 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@Emrys-Hong
Emrys-Hong / setup.sh
Created September 12, 2019 08:21
setup all my environments
cd
mkdir Github && cd Github
git clone https://github.com/Emrys-Hong/dotfiles .dotfiles
cd .dotfiles && bash setup.sh
@Emrys-Hong
Emrys-Hong / code-server-setup.sh
Last active September 12, 2019 08:19
code server setup
echo "Installing code-server"
cd
mkdir code-server
release=(copy paste the lastest release here)
wget -qO- $release | tar xvz --strip-components=1 -C ~/code-server
echo "alias 'code'='~/code-server/code-server'" >> .bashrc
echo "You need to 'source ~/.bashrc' now!"
echo "Successful installed code server"
@Emrys-Hong
Emrys-Hong / search_hparams.py
Created August 18, 2019 09:27
automatically search hparameters for you, it comes with config.py
"""Peform hyperparemeters search"""
import argparse
import os
from subprocess import check_call
import sys
from multiprocessing import Process
import utils
import torch
@Emrys-Hong
Emrys-Hong / config.py
Created August 18, 2019 09:16
A base config file when doing machine learning and tuning parameters
import argparse
import json
import os
from pathlib import Path
import torch
class NetworkConfig:
def __init__(self, experiment_id, mainfolder):
## Checkpoint
self.id = experiment_id
@Emrys-Hong
Emrys-Hong / callbacks_args.py
Created August 9, 2019 15:40
how to use argparse.ArgumentParser() callbacks
def run_train(args):
# do something with args
return 0
def main():
dynet_args = [
"--dynet-mem",
"--dynet-weight-decay",
"--dynet-autobatch",
@Emrys-Hong
Emrys-Hong / benepar-constituent-parser.py
Created August 9, 2019 13:08
syntactic parse tree parser
import nltk
nltk.download('punkt')
import benepar
benepar.download('benepar_en2')
import benepar
parser = benepar.Parser("benepar_en2")
tree = parser.parse("Short cuts make long delays.")
print(tree)
@Emrys-Hong
Emrys-Hong / elmo-embeddings.py
Created August 7, 2019 08:50
elmo embedding script
from allennlp.modules.elmo import Elmo, batch_to_ids
options_file = "https://allennlp.s3.amazonaws.com/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_options.json"
weight_file = "https://allennlp.s3.amazonaws.com/models/elmo/2x4096_512_2048cnn_2xhighway/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5"
# Compute two different representation for each token.
# Each representation is a linear weighted combination for the
# 3 layers in ELMo (i.e., charcnn, the outputs of the two BiLSTM))
elmo = Elmo(options_file, weight_file, 2, dropout=0)
@Emrys-Hong
Emrys-Hong / tensorboardX-demo.py
Created August 6, 2019 07:15
a basic use method of how to use tensorboardX -- a pytorch visualization tool
import torch
import torchvision.utils as vutils
import numpy as np
import torchvision.models as models
from torchvision import datasets
from tensorboardX import SummaryWriter
resnet18 = models.resnet18(False)
writer = SummaryWriter()
sample_rate = 44100