Skip to content

Instantly share code, notes, and snippets.

@janlay
janlay / backup-bitwarden.sh
Last active Apr 7, 2021
Backup Bitwarden Data
View backup-bitwarden.sh
#!/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 Jun 11, 2020
Open Microsoft Edge with RAMDisk's caching directory
View edge-ramdisk.reg
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 / blocked-domains.txt
Last active Feb 19, 2021
Blocked domain rules for Surge
View blocked-domains.txt
DOMAIN, ads.mopub.com
DOMAIN, cpro.baidu.com
DOMAIN, hm.baidu.com
DOMAIN, hmma.baidu.com
DOMAIN, monitor.uu.qq.com
DOMAIN, graph.facebook.com
DOMAIN, pagead2.googlesyndication.com
DOMAIN, pgdt.gtimg.cn
DOMAIN, pingma.qq.com
DOMAIN, stat.m.jd.com
@janlay
janlay / tput-table
Created Apr 9, 2020
Full preview for tput foreground and background
View tput-table
#!/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 / README.md
Last active Jun 28, 2020
Delete and unfavorite tweets
View README.md

Delete and unfavorite tweets

This util deletes your historical tweets from a downloaded archive file, unfavorites tweets from your public profile.

No guarantee, no support, use it at your own risk.

Preparations

  1. Apply to become a Twitter developer first.
    Once your Twitter developer account application is approved, You can create a new app and get its Consumer API keys and generate Access token. These keys are used to configure tweet.sh.
  2. Obtain archived tweets by requesting to download your Twitter data.
    You can extract tweet.js file from the downloaded .zip file.
@janlay
janlay / msupdate.sh
Last active Dec 20, 2019
MSUpdate - manually update your Microsoft apps on macOS
View msupdate.sh
#!/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 / restore-dotfiles.sh
Created Apr 8, 2019
Restore dotfiles from Dropbox to Home directory
View restore-dotfiles.sh
#!/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 / chinadns-updater.sh
Created Mar 25, 2019
ChinaDNS Updater for OpenWRT
View chinadns-updater.sh
#!/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 / archive-desktop.sh
Created Oct 10, 2016
Archive desktop files into yyyy-mm subdirectory
View archive-desktop.sh
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 / proxy.sh
Last active Mar 2, 2016
Toogle Proxy in command line
View proxy.sh
#!/bin/bash
# 1. source this file or append it to your bash/zsh profile.
# 2. modify https_proxy & http_proxy with your own proxy.
# 3. use `proxy on` to turn on proxy and `proxy off` to turn it off.
export PS1_backup=$PS1
function proxy () {
local prefix