Skip to content

Instantly share code, notes, and snippets.

hktonylee

Block or report user

Report or block hktonylee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View interactive-open-url.fish
#!/usr/bin/env fish
function +fzf_open_url
[ -z "$FZF_OPEN_URL_LIST" ]; and echo "Please configure \$FZF_OPEN_URL_LIST first." >&2; and return
set -l result ( \
cat $FZF_OPEN_URL_LIST \
| sort \
| uniq \
| grep -ve '^$' \
@hktonylee
hktonylee / parse_standard_chartered_csv.py
Created Mar 7, 2018
parse_standard_chartered_csv.py
View parse_standard_chartered_csv.py
#!/usr/bin/env python3
import os
import re
import argparse
ACCOUNT_FILE_NAME_EX = re.compile(r'AccountTransactions\d+.csv')
CARD_FILE_NAME_EX = re.compile(r'CardTransactions\d+.csv')
PAYMENT_LINE_EX = re.compile(r'^\d{2}/\d{2}/\d{4},PAYMENT - THANK YOU,')
TRANSACTION_LINE_EX = re.compile(r'^\t\t\t\t\t\t\t\t\t\t\t')
@hktonylee
hktonylee / run-service.sh
Created Dec 1, 2017
Run multiple service in one script
View run-service.sh
#!/usr/bin/env bash
updateRate=1
shutdown() {
updateRate=0.2
for pid in $(jobs -p); do
pkill -TERM -P "$pid"
@hktonylee
hktonylee / manage.py
Last active Dec 19, 2018
Flask + manage.py + gunicorn + auto-reload + Flask-Sockets + anything you can do with gunicorn script
View manage.py
#!./venv/bin/python3
import os
import sys
import subprocess
from flask_migrate import MigrateCommand
from flask_script import Manager, Command, Option
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
@hktonylee
hktonylee / replace_node_modules_buildToolsVersion.sh
Last active Apr 29, 2017
Replace buildToolsVersion in all build.gradle in node_modules
View replace_node_modules_buildToolsVersion.sh
#!/usr/bin/env bash
targetVersion="$1"
if [ "$1" == "" ]; then
echo "Usage: $0 <buildToolsVersion>";
else
find \
node_modules \
-type f \
@hktonylee
hktonylee / index.d.ts
Created Nov 27, 2016
Typescript Typing Definition for react-native-fbsdk
View index.d.ts
declare module "react-native-fbsdk" {
export interface LoginResult {
isCancelled: boolean,
grantedPermissions?: Array<string>,
declinedPermissions?: Array<string>,
}
export type DefaultAudience = 'friends' | 'everyone' | 'only_me';
export type LoginBehaviorIOS = 'native' | 'browser' | 'system_account' | 'web';
View fun.sh
#!/bin/sh
exec scala "$0" "$@"
!#
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world! " + args.toList)
}
}
HelloWorld.main(args)
@hktonylee
hktonylee / spawn.sh
Created Oct 23, 2014
Fork Processes in Shell (With Smart Cleanup)
View spawn.sh
ALL_PIDS=()
on_die() {
for pid in "${ALL_PIDS[@]}"; do
echo "Killing $pid..."
kill -9 $pid
done
}
add() {
@hktonylee
hktonylee / check.py
Created Oct 23, 2014
Check ZeroMQ Version in Python
View check.py
from zmq import zmq_version_info; print zmq_version_info()
@hktonylee
hktonylee / run.sh
Last active Aug 29, 2015
Run task/daemon in the background
View run.sh
#!/bin/bash
# **** You may add `exec` ****
# eg.
# exec python manage.py runserver 0.0.0.0:9000
You can’t perform that action at this time.