Skip to content

Instantly share code, notes, and snippets.

Janlay Wu janlay

Block or report user

Report or block janlay

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
@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
@janlay
janlay / update-repos.sh
Last active Apr 16, 2019
Updates all Git repos in directory, defaults to Vim bundles.
View update-repos.sh
#!/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 / README.md
Last active Aug 3, 2019
Yet another config for Surge.app
View README.md

Install

  1. Modify index.txt with your output path and proxy info
  2. Use Text Builder to build configuration for Surge: $ text-builder -index /path/to/index.txt Or run $ sh build-all to build all your index files.
  3. Import configuration via AirDrop/iTunes/Dropbox/iCloud

本人不提供任何保证和技术支持,使用者自负风险。
There are no guarantees, no any support. Use it at your own risk.

@janlay
janlay / wubi86.custom.yaml
Last active Mar 31, 2016
My custom Squirrel config especially created for Wubi86 users.
View wubi86.custom.yaml
patch:
switches:
- name: ascii_mode
reset: 0
states: [中文, 英文]
- name: full_shape
states: [半角, 全角]
- name: extended_charset
states: [通用, GBK]
- name: simplification
@janlay
janlay / whitelist.pac
Last active Apr 16, 2018
A white-list based PAC.
View whitelist.pac
/*
* A white-list based PAC without regexp, by @janlay
* It's just simple and fast.
* Last update: Oct 20, 2015
* Special thanks to @Paveo
*/
function FindProxyForURL(url, host) {
// REPLACE PROXY WITH YOUR OWN'S
var PROXY = "SOCKS 127.0.0.1:8801;SOCKS5 127.0.0.1:8801;PROXY 127.0.0.1:8800";
var BLACKHOLE = "127.0.0.2";
@janlay
janlay / sort.go
Created Mar 15, 2012
Tour of Go #43: implement the square root function using Newton's method.
View sort.go
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
for i := 1; i <= 100; i++ {
You can’t perform that action at this time.