Skip to content

Instantly share code, notes, and snippets.

View wonglkd's full-sized avatar

Daniel Wong wonglkd

View GitHub Profile
@wonglkd
wonglkd / NRIC checksum Excel formula
Last active June 13, 2020 11:09
NRIC checksum letter calculator for Excel
=MID(
IF(OR(LEFT(C2,1)="S", LEFT(C2,1)="T"),
"JZIHGFEDCBA",
"XWUTRQPNMLK"),
MOD(
MID(C2,2,1)*2+
MID(C2,3,1)*7+
MID(C2,4,1)*6+
MID(C2,5,1)*5+
MID(C2,6,1)*4+
@wonglkd
wonglkd / pssh.py
Last active November 1, 2019 00:49
pssh.py
#!/usr/bin/python
import argparse
import subprocess
def pssh(servers, cmd):
ps = [subprocess.Popen(['ssh', srv, cmd], stdout=subprocess.PIPE)
for srv in servers]
outputs = []
for srv, p in zip(servers, ps):
@wonglkd
wonglkd / cluster.md
Last active August 30, 2018 14:53
Tool Chain
  • Brooce for managing jobs
  • Secure Pipes for managing SSH tunnels (great when you have Bastions)
  • ?? for monitoring
  • tmux on bastion for session management
@wonglkd
wonglkd / spell_check.sh
Last active February 7, 2018 04:40
spell_check.sh
#!/bin/bash
# usage: bash ../utils/spell-check.sh
# setup:
# brew install hunspell
# wget https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/en-US/index.dic -O ~/Library/Spelling/en_US.dic
# wget https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/en-US/index.aff -O ~/Library/Spelling/en_US.aff
#
hunspell -l -t *.tex | sort | uniq > ../utils/misspelled.tmp
sort ../utils/dictionary -o ../utils/dictionary
comm -23 ../utils/misspelled.tmp ../utils/dictionary
scikit-learn==0.18.1
pandas==0.20.1
Keras>=2.0.4
numpy>=1.12.1
scipy>=0.19.0
tensorflow>=1.1.0
spacy>=1.8.2
# sacred==0.7.0
git+https://github.com/IDSIA/sacred.git@5a823657d824103cbbe09177a3aaf706c557ce55#egg=sacred
pymongo>=3.4.0
import pdb, sys, traceback
def info(type, value, tb):
traceback.print_exception(type, value, tb)
pdb.pm()
sys.excepthook = info
import pdb, sys, traceback
def info(type, value, tb):
traceback.print_exception(type, value, tb)
pdb.pm()
sys.excepthook = info
@wonglkd
wonglkd / model.py
Created January 5, 2017 14:03
Bypass sample weights
# Implement REINFORCE rule by using crossentropy
# + (reward - baseline) as sample_weight.
self.model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=self.lr))
# Adapted from model.compile: redo the computation of loss.
loss_functions = [objectives.get('categorical_crossentropy')]
total_loss = None
for i in range(len(self.model.outputs)):
@wonglkd
wonglkd / portopen.sh
Created November 25, 2016 05:05
Test if port is open
# on server
# tips: -u for UDP,
nc -l <port>
# on client
nc <ip> <port>