西维蜀黍

【macOS】移除默认输入法

  • 关闭 macOS 的 SIP

  • 将输入法切换为系统自带的 ABC 输入法,然后打开终端输入以下命令:

    $ sudo open ~/Library/Preferences/com.apple.HIToolbox.plist
    
  • 以打开 com.apple.HIToolbox.plist 文件(打开 .plist 文件需要安装有如 Xcode

  • 依次点开 Root - AppleEnabledInputSources ,会看到一列 item ,找到其中 KeyboardLayout NameABC 的那一列,将整列 item 删掉,然后 command + S 保存。

  • 接着重启电脑,打开键盘设置,就可以看到系统自带的 ABC 输入法已经被删掉了。

  ...


【Network】NAT

  ...


【VMware】安装 VMware ESXi 7.0.3

Download

ISO

https://customerconnect.vmware.com/en/downloads/details?downloadGroup=ESXI70U3C&productId=974&rPId=84824 下载 VMware ESXi

  ...


【OpenWrt】查看 CPU 温度

$ cut -c1-2 /sys/class/thermal/thermal_zone0/temp
  ...


【Network】tcpdump 抓包

OpenWrt安装

$ opkg update && opkg install tcpdump

Usage

默认启动

$ tcpdump

普通情况下,直接启动tcpdump将监视第一个网络接口上所有流过的数据包。

# get list of interfaces
$ ifconfig

# do tcpdump on lan interface 'br-lan'
$ tcpdump -i br-lan -n

# dump for http traffic
$ tcpdump -i br-lan port 80

# dump for ssh traffic on wan, but do not show self
$ tcpdump -i eth0 port 22 and not host 192.168.1.7
  ...


【Linux】修改 MAC 地址

Linux

获取mac地址

$ ip link show
enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
 link/ether 08:xx:xx:xx:xx:x1 brd ff:ff:ff:ff:ff:ff

或者:

$ ifconfig | grep HWaddr
enp0s3    Link encap:Ethernet  HWaddr 08:xx:xx:xx:xx:x1
  ...


【OpenWrt】macOS 下小米红米路由器 AC2100 (Xiaomi Redmi Router AC2100) 刷 OpenWrt

Preparation

相关工具安装

$ brew install netcat
$ pip3 install scapy

下载 busybox 和固件

$ wget https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-mipsel -o busybox-mipsel

$ wget https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-ramips-mt7621-xiaomi_redmi-router-ac2100-squashfs-kernel1.bin -o openwrt-ramips-mt7621-xiaomi_redmi-router-ac2100-squashfs-kernel1.bin
$ wget https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-ramips-mt7621-xiaomi_redmi-router-ac2100-squashfs-rootfs0.bin -o openwrt-ramips-mt7621-xiaomi_redmi-router-ac2100-squashfs-rootfs0.bin

# download the latest version from https://downloads.openwrt.org/releases/, e.g., https://downloads.openwrt.org/releases/23.05.2/targets/ramips/mt7621/
  ...


【Golang】Golang 遍历 map 时 key 随机化问题(Interation Order)

Context

package main

import (
	"fmt"
)

func main() {
	x := make(map[int]int)
	for i := 0; i < 30; i++ {
		x[i] = i
	}

	for i := 0; i < 10; i++ {
		for k, v := range x {
			fmt.Println(k, v)
			break
		}
	}
}

// output 
18 18
29 29
2 2
2 2
2 2
16 16
28 28
1 1
0 0
4 4

可以看到,我们进行10次遍历 map,每次遍历都只print 出第一对key-value pair,而每次遍历 print 的结果都不同。

  ...


【hexo】使用 node 14 运行 hexo 报错

Situation

$ hexo g
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received an instance of Object
    at copyFile (fs.js:1895:10)
    at tryCatcher (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/util.js:16:23)
    at ret (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
    at /SW/myBlog/node_modules/hexo-deployer-git/node_modules/hexo-fs/lib/fs.js:144:39
    at tryCatcher (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at /SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/nodeback.js:42:21
    at FSReqCallback.oncomplete (fs.js:163:23)
  ...


【Linux】Oh-my-zsh 启动慢

升级

$ upgrade_oh_my_zsh

启动测速

$ time /bin/zsh -i -c exit

$ for i in $(seq 1 10); do /usr/bin/time $SHELL -i -c exit; done
  ...