Skip to content

Instantly share code, notes, and snippets.

View janlay's full-sized avatar

Janlay Wu janlay

View GitHub Profile

Keybase proof

I hereby claim:

  • I am janlay on github.
  • I am janlay (https://keybase.io/janlay) on keybase.
  • I have a public key ASAdsgFM0gJM4sbu3Jm2dr4rysHJIdVt4leRb1UI_JGX3wo

To claim this, I am signing this object:

@janlay
janlay / backup-bitwarden.sh
Last active April 7, 2021 08:52
Backup Bitwarden Data
#!/bin/bash
set -e
# Backup db and certs in $BITWARDEN_DIR into $TARGET_DIR/$FILENAME_PREFIX$DATE.tar.gz
BITWARDEN_DIR='/volume1/docker/Bitwarden'
TARGET_DIR='/var/services/dropbox/Backup/Bitwarden'
FILENAME_PREFIX='bw-backup_'
FILENAME_DATE_PATTERN='%m-%d'
@janlay
janlay / edge-ramdisk.reg
Created June 11, 2020 07:10
Open Microsoft Edge with RAMDisk's caching directory
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\MSEdgePDF\shell\open\command]
@="\"C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe\" --disk-cache-dir=R:\\MSEdge -- \"%1\""
[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\open\command]
@="\"C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe\" --disk-cache-dir=R:\\MSEdge -- \"%1\""
[HKEY_CLASSES_ROOT\http\shell\open\command]
@="\"C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe\" --disk-cache-dir=R:\\MSEdge -- \"%1\""
@janlay
janlay / tput-table
Created April 9, 2020 04:06
Full preview for tput foreground and background
#!/bin/bash
# author: janlay@gmail.com
set -e
cols=$(bc <<< "$(tput cols) / 3 - 2")
char=✾
echo -n ' '
for col in $(seq 0 $cols); do
@janlay
janlay / msupdate.sh
Last active December 20, 2019 03:41
MSUpdate - manually update your Microsoft apps on macOS
#!/bin/bash
# author: janlay@gmail.com
set -e
SERVICE_URL="https://officecdn.microsoft.com/pr/C1297A47-86C4-4C1F-97FA-950631F94777/MacAutoupdate"
USER_AGENT='Microsoft%20AU%20Daemon/4.13.19071800 CFNetwork/1098 Darwin/19.0.0 (x86_64)'
MS_APPS=(
"Microsoft AutoUpdate:0409MSau04"
@janlay
janlay / chinadns-updater.sh
Created March 25, 2019 06:13
ChinaDNS Updater for OpenWRT
#!/bin/bash
FILE=/etc/chinadns_chnroute.txt
TEMP_FILE="$FILE.tmp"
TELEGRAM_BOT=/root/scripts/telegram-bot
SOURCE="https://raw.githubusercontent.com/ym/chnroutes2/master/chnroutes.txt"
LOGFILE=/root/scripts/chinadns-updater.log
echo -e "\nChinaDNS Updater started at `date`." >> $LOGFILE
echo "Current routes: `wc -l "$FILE" | cut -d' ' -f1`." >> $LOGFILE
@janlay
janlay / update-repos.sh
Last active April 16, 2019 13:08
Updates all Git repos in directory, defaults to Vim bundles.
#!/bin/bash
# author: janlay@gmail.com
WORKDING_DIR="${1-$HOME/.vim/bundle}"
GIT_DIR_ROOT="$HOME/Workspace/.gitrepo"
echo "Working on $WORKDING_DIR"
for i in `find "$WORKDING_DIR" -mindepth 1 -maxdepth 1 -type d`; do
REPO_NAME="${i##*/}"
export GIT_WORK_TREE="$WORKDING_DIR/$REPO_NAME"
@janlay
janlay / restore-dotfiles.sh
Created April 8, 2019 03:01
Restore dotfiles from Dropbox to Home directory
#!/bin/bash
# author: janlay@gmail.com
# How to use this script:
# 1. To backup your dotfiles, move them to the WORKING_DIR.
# 2. To Restore the dotfiles you previously backed up, run this script.
WORKDING_DIR="$HOME/Dropbox/dotfiles"
echo "Working on $WORKDING_DIR"
@janlay
janlay / archive-desktop.sh
Created October 10, 2016 05:21
Archive desktop files into yyyy-mm subdirectory
filename=`basename "$1"`
[[ "$filename" == "Archive" ]] && exit 1
target=`stat -f '%Sc' -t '%Y-%m' "$1"`
fullpath="$HOME/Desktop/Archive/$target"
mkdir -p "$fullpath"
mv "$1" "$fullpath/"
script="display notification \"$filename -> Archive/$target\" with title \"Desktop file archived\""
osascript -e "$script"
@janlay
janlay / sort.go
Created March 15, 2012 09:40
Tour of Go #43: implement the square root function using Newton's method.
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
for i := 1; i <= 100; i++ {