Skip to content

Instantly share code, notes, and snippets.

@hktonylee
hktonylee / How to auto-start WSL during Windows startup, and run services (e.g. cron) in WSL2?.md
Created October 29, 2021 07:14
How to auto-start WSL during Windows startup, and run services (e.g. cron) in WSL2?
  1. Ran sudo visudo. Add this line:

    ALL ALL= NOPASSWD: /usr/local/etc/start_services.sh
    
  2. Create file /usr/local/etc/start_services.sh

    touch /usr/local/etc/start_services.sh
    chmod go-rwx /usr/local/etc/start_services.sh
    

chown root:root /usr/local/etc/start_services.sh

@hktonylee
hktonylee / main.sh
Last active October 22, 2021 07:02
Install Unison v2.40 in macOS 11+
# Get Unison v2.40.x
git clone https://github.com/bcpierce00/unison.git
cd unison
git checkout 2.40
# Install opam (OCaml verion manager
brew install opam
# Download OCaml v4.06.1
opam init
@hktonylee
hktonylee / backup.prf
Last active October 14, 2021 08:29
2-Phases Backup with Unison
# Unison preferences file (Fast backup)
root = /home/xxxx/your-folder
root = ssh://target.host/your-folder
auto = true
batch = true
prefer = newer
@hktonylee
hktonylee / # qt@5 - 2021-05-24_12-58-54.txt
Created May 24, 2021 20:03
qt@5 on Ubuntu 20.04.2 LTS - Homebrew build logs
Homebrew build logs for qt@5 on Ubuntu 20.04.2 LTS
Build date: 2021-05-24 12:58:54
@hktonylee
hktonylee / manage.py
Last active December 19, 2018 21:41
Flask + manage.py + gunicorn + auto-reload + Flask-Sockets + anything you can do with gunicorn script
#!./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 / interactive-open-url.fish
Created June 15, 2018 20:39
Interactively open URLs
#!/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 March 7, 2018 07:28
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 December 1, 2017 02:12
Run multiple service in one script
#!/usr/bin/env bash
updateRate=1
shutdown() {
updateRate=0.2
for pid in $(jobs -p); do
pkill -TERM -P "$pid"
@hktonylee
hktonylee / index.d.ts
Created November 27, 2016 16:50
Typescript Typing Definition for react-native-fbsdk
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';
@hktonylee
hktonylee / replace_node_modules_buildToolsVersion.sh
Last active April 29, 2017 04:43
Replace buildToolsVersion in all build.gradle in node_modules
#!/usr/bin/env bash
targetVersion="$1"
if [ "$1" == "" ]; then
echo "Usage: $0 <buildToolsVersion>";
else
find \
node_modules \
-type f \