Skip to content

Instantly share code, notes, and snippets.

View janlay's full-sized avatar

Janlay Wu janlay

View GitHub Profile
@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++ {
@janlay
janlay / whitelist.pac
Last active February 29, 2024 20:23
A white-list based 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 / wubi86.custom.yaml
Last active March 31, 2016 18:26
My custom Squirrel config especially created for Wubi86 users.
patch:
switches:
- name: ascii_mode
reset: 0
states: [中文, 英文]
- name: full_shape
states: [半角, 全角]
- name: extended_charset
states: [通用, GBK]
- name: simplification
@janlay
janlay / README.md
Last active May 11, 2024 03:22
Yet another config for Surge.app

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 / 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 / proxy.sh
Last active September 29, 2021 03:45
Toogle Proxy in command line
#!/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 / 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 / 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 / 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 / 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"