Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
# date: 2017-2-28
[[ $(id -u) = 0 ]] || {
echo "Please run this script as root !"
exit -1
}
#!/bin/bash
# author: nanpuyue <nanpuyue@gmail.com>, https://blog.nanpuyue.com
# license: GPL 3.0, https://www.gnu.org/licenses/gpl-3.0.html
[ $(id -u) = 0 ] || {
echo "must run as root!" && exit 1
}
x11vnc -storepasswd || {
@nanpuyue
nanpuyue / start_thunder.sh
Last active September 14, 2017 03:33
CrossOver 迅雷极速版启动脚本,用于修复残留窗口遮挡屏幕
#!/bin/bash
# filename: start_thunder.sh
# date: 2017-03-11
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
EXIT_TIME=$(( $(date +%s) + 15 ))
exec "/opt/cxoffice/bin/wine" --bottle "迅雷极速版" --check --wait-children --start "C:/users/Public/Start Menu/Programs/迅雷软件/迅雷极速版/启动迅雷极速版.lnk" "$@" &
@nanpuyue
nanpuyue / network_switcher.sh
Last active April 17, 2018 14:50
多网络配置切换管理器
#!/bin/bash
# date: 2017-04-23
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
CONF_FILE=~/.config/network_switcher.conf
RESERVED_UUID="defa5e5c-16c4-426d-83ea-aa187f6e2ea6"
read_conf(){
if [[ ! -f "$CONF_FILE" ]]; then
touch "$CONF_FILE"
#!/bin/bash
# date: 2017-11-17
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
echo 'install: ~/.mozilla/native-messaging-hosts/hide_titlebar.json'
[[ -d ~/.mozilla/native-messaging-hosts ]] || mkdir -p ~/.mozilla/native-messaging-hosts
cat > ~/.mozilla/native-messaging-hosts/hide_titlebar.json << EOF
{
"name": "hide_titlebar",
@nanpuyue
nanpuyue / minecraft-input.sh
Last active August 5, 2018 07:23
Linux 下的 Minecraft 中文输入脚本
#!/bin/bash
# file: minecraft-input.sh
# date: 2017-12-01
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
#
# 依赖:zenity xdotool xclip
#
# 使用方法:
# 将脚本绑定快捷键,不带参数的用于聊天,带-i参数的用于书写告示牌, 例如:
@nanpuyue
nanpuyue / openwrt-hc5611.patch
Created January 26, 2018 15:38
Add support for HiWiFi HC5611 for OpenWrt
diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index 37630cde66..f90ed13d12 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -205,6 +205,9 @@ hc5661a)
ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "eth0.2"
set_wifi_led "$boardname:blue:wlan2g"
;;
+hc5611)
+ ucidef_set_led_default "system" "system" "$boardname:green:system" "1"

Keybase proof

I hereby claim:

  • I am nanpuyue on github.
  • I am nanpuyue (https://keybase.io/nanpuyue) on keybase.
  • I have a public key whose fingerprint is 794A 6269 E8A1 8C2E C09C 4454 8EED CF60 4CFE 0321

To claim this, I am signing this object:

@nanpuyue
nanpuyue / prefix_to_mask.sh
Last active September 15, 2018 03:04
将前缀长度转换为子网掩码
#!/bin/bash
# date: 2018-03-03
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
num=$((4294967296 - 2**(32-$1)))
for i in {3..0};do
echo -n $((num / 256**i))
num=$((num % 256**i))
(($i == 0)) && echo || echo -n .
@nanpuyue
nanpuyue / mask_to_prefix.sh
Last active September 15, 2018 04:13
将子网掩码转换为前缀长度
#!/bin/bash
# date: 2018-09-15
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
n=0;b=3
for i in ${1//./ };do
if ((0 <= i < 256));then
let n+=$((2**(b*8) * i))
let b--