├── ansible
├── wireguard
│ ├── README.md
│ ├── inventory.yaml
│ └── playbook.yaml
├── k8s
│ ├── k8s.yaml
│ ├── onecloud
│ │ ├── templates
│ │ │ ├── onecloud-cluster.yaml.j2
│ │ │ └── onecloud-operator.yaml.j2
│ │ ├── mariadb.yaml
│ │ ├── inventory.yaml
│ │ └── onecloud.yaml
│ ├── nokmem.yaml
│ ├── README.md
│ ├── inventory.yaml
│ ├── k8s-pkgs.yaml
│ └── docker.yaml
├── ss
│ ├── inventory.yaml
│ └── ss.yaml
├── distrepo
│ ├── nodesource.yaml
│ ├── grafana.yaml
│ └── centos.yaml
└── openwrt
│ └── repos.yaml
├── golang
├── tcpconn
│ ├── .gitignore
│ ├── go.mod
│ ├── go.sum
│ ├── rlimit_linux.go
│ ├── rlimit_darwin.go
│ ├── stats.go
│ └── Makefile
├── tut
│ ├── README.md
│ ├── uuid_test.go
│ ├── unsafe_test.go
│ ├── strings_test.go
│ ├── encoding_json_test.go
│ ├── runtime_test.go
│ ├── net_test.go
│ ├── gorm_test.go
│ ├── syscall_test.go
│ ├── basic_test.go
│ ├── time_test.go
│ └── io_test.go
├── gopkg-nginx.conf
├── pipe_recorder
│ ├── pipe_recorder_test.go
│ └── pipe_recorder.go
├── tcp-simultaneous-open.go
└── ssh-pubkey-fp.go
├── README.md
├── openssl
└── simple-pki
│ ├── .gitignore
│ ├── README.md
│ ├── etc
│ ├── email.conf
│ └── server.conf
│ └── a.sh
├── openwrt
├── defconfig
│ ├── armvirt-mini
│ ├── pexfat
│ ├── hc6361-mini
│ ├── x86_64-mini
│ ├── cb2-mini
│ ├── pqemu
│ ├── debug
│ ├── pshadowsocks-libev
│ ├── povs
│ ├── mos-mini
│ ├── extra-configs
│ ├── zodiac-gx
│ ├── r33
│ ├── wr841v5-yy
│ ├── vocore
│ ├── hc6361-bjb
│ └── malta-mini-be
├── docker
│ ├── docker-build-env
│ ├── README.md
│ └── Dockerfile
├── remote-gdb.md
├── upup
│ ├── files
│ │ ├── upup.init
│ │ ├── upup.config
│ │ └── upup
│ └── Makefile
├── dns-ipset
│ ├── README.md
│ ├── do-dns-ipset.sh
│ └── dns-ipset.txt
├── a.sh
├── hack
│ └── build-tl-wr841n-v5-lede
│ │ ├── zerotier-makefile.patch
│ │ └── build.sh
└── mk
│ └── overlay-pkg-hello.mk
├── stap
├── hello.stp
├── utrace.stp
└── uflame.stp
├── docker
├── mypan
│ ├── docker-build-env
│ ├── root
│ │ └── run.sh
│ └── Dockerfile
├── onedriver
│ ├── docker-build-env
│ ├── README.md
│ └── Dockerfile
├── cuda-bench-tensorflow
│ ├── root
│ │ └── run.sh
│ ├── docker-build-env
│ ├── README.md
│ └── Dockerfile
├── baidunetdisk
│ ├── root
│ │ ├── startapp.sh
│ │ ├── etc
│ │ │ └── openbox
│ │ │ │ └── main-window-selection.xml
│ │ └── baidunetdisk.png
│ ├── README.md
│ ├── docker-build-env
│ └── Dockerfile
├── rarlinux
│ ├── docker-build-env
│ └── Dockerfile
├── nextcloud
│ ├── docker-build-env
│ ├── README.md
│ ├── supervisord.conf
│ └── Dockerfile
├── jupyter
│ ├── docker-build-env
│ ├── README.md
│ └── Dockerfile
├── binwalk
│ ├── docker-build-env
│ └── README.md
├── gocryptfs
│ ├── docker-build-env
│ ├── a.sh
│ └── Dockerfile
└── xfstests
│ └── Dockerfile
├── info
├── meizu-m351
│ ├── META-INF-content.md
│ ├── updater-binary.md
│ ├── factory-test-mode.md
│ ├── updater-binary-and-partitions.md
│ ├── kernel-build-variant.md
│ ├── system.new.dat
│ ├── glossaries-and-staging.md
│ └── boot-and-signature.md
├── skyworth-cm4100-puma5-cable-modem
│ ├── 00-serial-pins.txt
│ └── 00-summary.txt
└── qihoo-c301
│ └── qihoo-c301-firmware-extract.sh
├── nodejs
└── chromeless
│ ├── README.md
│ ├── package.json
│ └── index.js
├── charcodecs
├── gbk
│ ├── go.mod
│ ├── go.sum
│ ├── README.md
│ └── gbk.go
├── README.md
└── c3c2.py
├── qemu
├── distro-on-qemu
│ └── .gitignore
├── osx-on-qemu
│ ├── anti-pirate-song.txt
│ └── smc_read.c
└── qemu-on-osx
│ ├── README.md
│ └── bootpd.plist
├── shell
├── pulse-probe
│ ├── README.md
│ ├── scr-trace.sh
│ ├── scr-ping.sh
│ ├── ping.gnuplot
│ ├── m.sh
│ └── env.sh
├── make-vim-ref-man.sh
├── multif
│ └── multif.spec
├── mail-maintainers.sh
├── vpnguru
│ └── vpnguru.drv
├── tunnels
│ ├── tunnel-gre.sh
│ ├── tunnel-6to4.sh
│ └── tunnel-gretap.sh
├── iptables
│ └── mir.sh
├── ifbps.sh
├── install_grpc.sh
├── circleci.sh
├── spas.sh
├── git-repo.sh
├── build-kernels.sh
├── httpfilter.md
├── lookup-code.sh
├── bondtst.sh
├── labnet.sh
└── zabbix.sh
├── python
├── imp-load_source.py
├── simplehttpserver-no-ptr-query.sh
├── loan
│ └── loan.gnuplot
├── sphinx
│ ├── Makefile
│ └── Dockerfile-latexpdf-extra
├── echoserver
│ ├── Makefile
│ └── README.md
├── timeit-deque-list.py
├── cdist
│ ├── gdns
│ ├── ss
│ ├── params
│ ├── wg
│ ├── strongswan
│ └── init
├── stackframes.py
├── example-traceback.py
├── datetime-epoch.py
├── beanstalk.py
├── iputils.py
├── dis-atomic.py
├── ctypes_inotify_event.py
├── reverse-changelog.py
├── datetime-timezone.py
├── mod-datetime.py
└── apnic-parse.py
├── anki
├── Makefile
├── README.md
├── q.py
├── lookup.c
└── p.py
├── js
├── ctrip.com.js
├── baidu.com.js
└── douban.com.js
├── android
├── install-adb.sh
└── install-apktool.sh
├── c
├── Makefile
├── find_ip_in_range.c
├── pthreads_do.c
├── sockstream.c
├── tuntap.c
└── mdio.c
├── notes
├── mac-input-umlaut.md
└── devices-in-the-field.md
├── .github
└── workflows
│ ├── docker-build-and-push.yaml
│ └── docker-build-and-push.sh
├── collectd
└── wghop.sh
└── libguestfs
└── script.sh
/ansible/wireguard/README.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
--------------------------------------------------------------------------------
/golang/tcpconn/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Repo to replace gist.github.com
2 |
--------------------------------------------------------------------------------
/openssl/simple-pki/.gitignore:
--------------------------------------------------------------------------------
1 | ca/
2 | certs/
3 | crl/
4 |
--------------------------------------------------------------------------------
/openwrt/defconfig/armvirt-mini:
--------------------------------------------------------------------------------
1 | CONFIG_TARGET_armvirt=y
2 |
--------------------------------------------------------------------------------
/stap/hello.stp:
--------------------------------------------------------------------------------
1 | probe begin
2 | {
3 | print("hello\n")
4 | exit()
5 | }
6 |
--------------------------------------------------------------------------------
/docker/mypan/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:mypan
3 | )
4 |
--------------------------------------------------------------------------------
/openwrt/defconfig/pexfat:
--------------------------------------------------------------------------------
1 | CONFIG_BUILD_PATENTED=y
2 | CONFIG_PACKAGE_kmod-fs-exfat=y
3 |
--------------------------------------------------------------------------------
/docker/onedriver/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:onedriver
3 | )
4 |
--------------------------------------------------------------------------------
/info/meizu-m351/META-INF-content.md:
--------------------------------------------------------------------------------
1 | `machine_match imei.dat` to see if "machine not match"
--------------------------------------------------------------------------------
/nodejs/chromeless/README.md:
--------------------------------------------------------------------------------
1 | # Run
2 |
3 | npm install
4 | npm run prep
5 | npm start
6 |
--------------------------------------------------------------------------------
/docker/cuda-bench-tensorflow/root/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | python tf_cnn_benchmarks.py "$@"
4 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/root/startapp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | exec /opt/baidunetdisk/baidunetdisk --no-sandbox
4 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/root/etc/openbox/main-window-selection.xml:
--------------------------------------------------------------------------------
1 | normal
2 | unknown-window-names
3 |
--------------------------------------------------------------------------------
/docker/rarlinux/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:rarlinux-x64-624
3 | yousong/test:rarlinux
4 | )
5 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/root/baidunetdisk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yousong/gists/HEAD/docker/baidunetdisk/root/baidunetdisk.png
--------------------------------------------------------------------------------
/docker/nextcloud/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:nextcloud-31-full
3 | yousong/test:nextcloud-full
4 | )
5 |
--------------------------------------------------------------------------------
/docker/jupyter/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:jupyter-cuda12-2024-11-21
3 | yousong/test:jupyter-cuda12
4 | )
5 |
--------------------------------------------------------------------------------
/charcodecs/gbk/go.mod:
--------------------------------------------------------------------------------
1 | module gbk
2 |
3 | go 1.21.2
4 |
5 | require (
6 | github.com/pkg/errors v0.9.1
7 | golang.org/x/text v0.14.0
8 | )
9 |
--------------------------------------------------------------------------------
/openwrt/defconfig/hc6361-mini:
--------------------------------------------------------------------------------
1 | CONFIG_TARGET_ath79=y
2 | CONFIG_TARGET_ath79_generic=y
3 | CONFIG_TARGET_ath79_generic_DEVICE_hiwifi_hc6361=y
4 |
--------------------------------------------------------------------------------
/docker/binwalk/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:binwalk-2.3.4
3 | yousong/test:binwalk-2.3
4 | yousong/test:binwalk
5 | )
6 |
--------------------------------------------------------------------------------
/docker/binwalk/README.md:
--------------------------------------------------------------------------------
1 | The Dockerfile is a modified version in the [binwalk github repo](https://github.com/ReFirmLabs/binwalk/blob/v2.3.4/Dockerfile)
2 |
--------------------------------------------------------------------------------
/docker/cuda-bench-tensorflow/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:cuda-bench-tensorflow-2.15.0
3 | yousong/test:cuda-bench-tensorflow
4 | )
5 |
--------------------------------------------------------------------------------
/openwrt/defconfig/x86_64-mini:
--------------------------------------------------------------------------------
1 | CONFIG_TARGET_x86=y
2 | CONFIG_TARGET_x86_64=y
3 |
4 | CONFIG_TARGET_KERNEL_PARTSIZE=32
5 | CONFIG_TARGET_ROOTFS_PARTSIZE=128
6 |
--------------------------------------------------------------------------------
/qemu/distro-on-qemu/.gitignore:
--------------------------------------------------------------------------------
1 | *.qcow2
2 | *.iso
3 | *.img
4 | *.xz
5 | *.zip
6 |
7 | qemu_ifup
8 | qemu_ifdown
9 | id_rsa*
10 | qemu-firmware
11 |
12 | config
13 |
--------------------------------------------------------------------------------
/shell/pulse-probe/README.md:
--------------------------------------------------------------------------------
1 | Scripts for probing and analysing bumps of network delays
2 |
3 | See `env.sh` for details about
4 |
5 | - how it works
6 | - how to use it
7 |
--------------------------------------------------------------------------------
/openwrt/defconfig/cb2-mini:
--------------------------------------------------------------------------------
1 | CONFIG_TARGET_sunxi=y
2 | CONFIG_TARGET_BOARD="sunxi"
3 | CONFIG_TARGET_sunxi_DEVICE_sun7i-a20-cubieboard2=y
4 |
5 | CONFIG_TARGET_ROOTFS_PARTSIZE=64
6 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/README.md:
--------------------------------------------------------------------------------
1 | Inspired by https://github.com/gshang2017/docker/tree/master/baidunetdisk
2 |
3 | ports
4 |
5 | TCP/5800 for web browser
6 | TCP/5900 for vnc client
7 |
--------------------------------------------------------------------------------
/docker/gocryptfs/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:gocryptfs-2.4.0
3 | yousong/test:gocryptfs-2.4
4 | yousong/test:gocryptfs-2
5 | yousong/test:gocryptfs
6 | )
7 |
--------------------------------------------------------------------------------
/openssl/simple-pki/README.md:
--------------------------------------------------------------------------------
1 | Imported with
2 |
3 | git clone https://bitbucket.org/stefanholek/pki-example-1
4 |
5 | See https://pki-tutorial.readthedocs.io/en/latest/simple/index.html
6 |
--------------------------------------------------------------------------------
/openwrt/docker/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:openwrt-build-$(date +%Y%m%d%H%M)
3 | yousong/test:openwrt-build-$(date +%Y%m%d)
4 | yousong/test:openwrt-build
5 | )
6 |
--------------------------------------------------------------------------------
/golang/tcpconn/go.mod:
--------------------------------------------------------------------------------
1 | module tcpconn
2 |
3 | go 1.14
4 |
5 | require (
6 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
7 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
8 | )
9 |
--------------------------------------------------------------------------------
/golang/tut/README.md:
--------------------------------------------------------------------------------
1 |
2 | # refs
3 |
4 | - 50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs, http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/index.html
5 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/docker-build-env:
--------------------------------------------------------------------------------
1 | DOCKER_IMAGE_TAGS=(
2 | yousong/test:baidunetdisk-4.17.7
3 | yousong/test:baidunetdisk-4.17
4 | yousong/test:baidunetdisk-4
5 | yousong/test:baidunetdisk
6 | )
7 |
--------------------------------------------------------------------------------
/docker/mypan/root/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if test -f "$RUN_CRONTAB"; then
4 | crontab "$RUN_CRONTAB"
5 | exec /sbin/tini -- /usr/sbin/crond -f -L /dev/stderr "$@"
6 | else
7 | exec mypan "$@"
8 | fi
9 |
--------------------------------------------------------------------------------
/python/imp-load_source.py:
--------------------------------------------------------------------------------
1 | #!python -B
2 | #
3 | # -B Don't write .py[co] files on import. See also PYTHONDONTWRITEBYTECODE.
4 | #
5 | import imp
6 | conf = imp.load_source('modname', '/etc/file.conf')
7 | print conf.enable_xxx
8 |
--------------------------------------------------------------------------------
/docker/jupyter/README.md:
--------------------------------------------------------------------------------
1 | Custom made jupyter container image based on work from Jupyter Docker Stacks
2 |
3 | - Selecting an Jupyter image, https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#jupyter-pytorch-notebook
4 |
--------------------------------------------------------------------------------
/docker/nextcloud/README.md:
--------------------------------------------------------------------------------
1 | Originally copied from https://github.com/nextcloud/docker
2 |
3 | .examples/dockerfiles/full/apache/Dockerfile
4 |
5 | Update instructions: https://github.com/nextcloud/docker?tab=readme-ov-file#update-to-a-newer-version
6 |
--------------------------------------------------------------------------------
/openwrt/remote-gdb.md:
--------------------------------------------------------------------------------
1 | On target board
2 |
3 | gdbserver --attach 192.168.1.1:9000 $(pgrep xl2tpd)
4 |
5 | On OpenWrt/LEDE dev host
6 |
7 | ./scripts/remote-gdb 192.168.1.1:9000 ./staging_dir/target-mipsel_mips32_musl-1.1.10/root-malta/usr/sbin/xl2tpd
8 |
--------------------------------------------------------------------------------
/stap/utrace.stp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Usage:
4 | *
5 | * stap utrace.stp -d /usr/sbin/ovs-vswitchd --ldd /lib64/libofproto-2.10.so.0 do_xlate_actions
6 | *
7 | */
8 |
9 | probe process(@1).function(@2) {
10 | print_ubacktrace()
11 | exit()
12 | }
13 |
--------------------------------------------------------------------------------
/anki/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | @echo read the Makefile!
3 |
4 | lookup.dylib: lookup.c
5 | clang -framework CoreServices -shared -o $@ $?
6 |
7 | anki:
8 | # https://github.com/dae/anki
9 | PYTHONPATH=$(HOME)/Downloads/经济学人词频/p/anki-master \
10 | ./q.py
11 |
--------------------------------------------------------------------------------
/openwrt/defconfig/pqemu:
--------------------------------------------------------------------------------
1 | CONFIG_PACKAGE_qemu-arm-softmmu=y
2 | CONFIG_PACKAGE_qemu-x86_64-softmmu=y
3 | CONFIG_PACKAGE_qemu-bridge-helper=y
4 | CONFIG_PACKAGE_qemu-ga=y
5 | CONFIG_PACKAGE_qemu-img=y
6 | CONFIG_PACKAGE_qemu-nbd=y
7 | CONFIG_PACKAGE_virtio-console-helper=y
8 |
--------------------------------------------------------------------------------
/docker/cuda-bench-tensorflow/README.md:
--------------------------------------------------------------------------------
1 | Example
2 |
3 | docker run --gpus=all --rm -it yousong/test:cuda-bench-tensorflow --model resnet50 --num_gpus=1
4 |
5 | # Credits
6 |
7 | This is based on work by [cemizm/tf-benchmark-gpu](https://github.com/cemizm/tf-benchmark-gpu)
8 |
--------------------------------------------------------------------------------
/openwrt/docker/README.md:
--------------------------------------------------------------------------------
1 | The Dockerfile was initially taken and modified from [mwarning/docker-openwrt-build-env](https://github.com/mwarning/docker-openwrt-build-env/blob/8ef7e34/Dockerfile).
2 |
3 | The docker image built is for building OpenWrt. Check `../a.sh` for an example.
4 |
--------------------------------------------------------------------------------
/shell/pulse-probe/scr-trace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ "$#" -ne 1 ]; then
4 | echo "Usage: $0 " >&2
5 | exit 1
6 | fi
7 |
8 | ip="$1"
9 | while true; do
10 | echo -n '## '
11 | date +%s
12 | tracepath -l 64 -n "$ip"
13 | sleep 1
14 | done >>"tracepath-$ip.txt"
15 |
--------------------------------------------------------------------------------
/js/ctrip.com.js:
--------------------------------------------------------------------------------
1 | // 删除“已取消”火车订单
2 | var els = $('a.hideOrder')
3 | for (var i = 0; i < els.length; i++) {
4 | var el = els[i];
5 | var oid = $(el).attr('rid');
6 | console.log(oid);
7 | ajax.post('http://my.ctrip.com/Home/Ajax/HideOrderHandler.ashx', {'type':'Train', 'orderID':oid})
8 | }
9 |
--------------------------------------------------------------------------------
/js/baidu.com.js:
--------------------------------------------------------------------------------
1 | // 清理关注的贴吧
2 | //
3 | $('div.often_forum a[data-fname]').each(function (i,e) {
4 | var n = $(e).attr('data-fname');
5 | console.log(n);
6 | $.post('http://tieba.baidu.com/i/submit/del_concernforum', {'tbs':'xxx', 'fname':n,'is_like':1,'ie':'utf-8','forum_type':'undefined'})
7 | })
8 |
--------------------------------------------------------------------------------
/python/simplehttpserver-no-ptr-query.sh:
--------------------------------------------------------------------------------
1 | python -c "import socket as s; s.getfqdn=lambda x:x; import sys; sys.argv.append('18080'); import SimpleHTTPServer as u; u.test()"
2 | python -c "import socket as s; s.getfqdn=lambda x:x; import sys; sys.argv.append('13306'); import SimpleHTTPServer as u; u.test()"
3 |
--------------------------------------------------------------------------------
/openwrt/upup/files/upup.init:
--------------------------------------------------------------------------------
1 | #!/bin/sh /etc/rc.common
2 | # Copyright (C) 2006-2015 OpenWrt.org
3 |
4 | START=99
5 | USE_PROCD=1
6 |
7 | BIN=/usr/sbin/upup
8 |
9 | start_service() {
10 | procd_open_instance
11 | procd_set_param command $BIN
12 | procd_set_param respawn
13 | procd_close_instance
14 | }
15 |
--------------------------------------------------------------------------------
/python/loan/loan.gnuplot:
--------------------------------------------------------------------------------
1 | set ytics nomirror
2 | set y2tics
3 |
4 | plot \
5 | "loan.60" using 1 with lines title "60 each", \
6 | "loan.120" using 1 with lines title "120 each", \
7 | "loan.60" using 2 with lines title "60 total" axes x1y2, \
8 | "loan.120" using 2 with lines title "120 total" axes x1y2, \
9 |
--------------------------------------------------------------------------------
/shell/pulse-probe/scr-ping.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ "$#" -ne 1 ]; then
4 | echo "Usage: $0 " >&2
5 | exit 1
6 | fi
7 |
8 | ip="$1"
9 | while true; do
10 | date +%s | tr '\n' ' '
11 | # TODO: add -W for response deadline
12 | ping -c 1 "$ip" | grep 'bytes from'
13 | sleep 1
14 | done >>"ping-$ip.txt"
15 |
--------------------------------------------------------------------------------
/info/skyworth-cm4100-puma5-cable-modem/00-serial-pins.txt:
--------------------------------------------------------------------------------
1 | With the board placed face up and those LEDs near you, the serial pins are at the bottom-right corner, labeled with "RS232".
2 |
3 | LED(red) LED(green) LED(green) LED(green) LED(green) [ o o o o ]
4 |
5 | Pin functions from left to right are: VCC, RX, TX, GND
6 |
--------------------------------------------------------------------------------
/charcodecs/gbk/go.sum:
--------------------------------------------------------------------------------
1 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
2 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
3 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
4 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
5 |
--------------------------------------------------------------------------------
/info/skyworth-cm4100-puma5-cable-modem/00-summary.txt:
--------------------------------------------------------------------------------
1 | CPU: ARM1176, rev 4
2 | Flash: 8MB
3 | RAM: 64MB
4 | Power: 12V, 1A
5 |
6 | 1 RJ45 connector
7 | 1 coaxical cable connector
8 | 5 LEDs
9 | 4 UART serial pins
10 |
11 | LAN address 192.168.100.1
12 | Listened on TCP port 2323 for telnet connection
13 | Root password hash: TQwXqjVn9XBtU
--------------------------------------------------------------------------------
/golang/tut/uuid_test.go:
--------------------------------------------------------------------------------
1 | package tut
2 |
3 | import "testing"
4 | import (
5 | "github.com/satori/go.uuid"
6 | )
7 |
8 | func TestUUID(t *testing.T) {
9 | var id uuid.UUID
10 |
11 | // current time and hardware address
12 | id, _ = uuid.NewV1()
13 | t.Logf("%s", id)
14 |
15 | // randomly generated uuid
16 | id, _ = uuid.NewV4()
17 | t.Logf("%s", id)
18 | }
19 |
--------------------------------------------------------------------------------
/openwrt/defconfig/debug:
--------------------------------------------------------------------------------
1 | CONFIG_DEVEL=y
2 | CONFIG_TOOLCHAINOPTS=y
3 | CONFIG_LIBC="glibc"
4 | CONFIG_LIBC_USE_GLIBC=y
5 | # CONFIG_LIBC_USE_MUSL is not set
6 |
7 | CONFIG_NO_STRIP=y
8 | CONFIG_PACKAGE_valgrind=y
9 | CONFIG_PACKAGE_strace=y
10 | CONFIG_PACKAGE_file=y
11 | CONFIG_PACKAGE_gdbserver=y
12 | CONFIG_PACKAGE_gdb=y
13 |
14 | CONFIG_PACKAGE_kmod-mac80211-hwsim=y
15 |
--------------------------------------------------------------------------------
/openwrt/defconfig/pshadowsocks-libev:
--------------------------------------------------------------------------------
1 | CONFIG_PACKAGE_luci=y
2 | CONFIG_PACKAGE_luci-app-shadowsocks-libev=y
3 | CONFIG_PACKAGE_shadowsocks-libev-config=y
4 | CONFIG_PACKAGE_shadowsocks-libev-ss-local=y
5 | CONFIG_PACKAGE_shadowsocks-libev-ss-redir=y
6 | CONFIG_PACKAGE_shadowsocks-libev-ss-rules=y
7 | CONFIG_PACKAGE_shadowsocks-libev-ss-server=y
8 | CONFIG_PACKAGE_shadowsocks-libev-ss-tunnel=y
9 |
--------------------------------------------------------------------------------
/android/install-adb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | BASEURL="https://github.com/corbindavenport/nexus-tools/raw/master/bin"
4 | PREFIX="$HOME/.usr"
5 |
6 | BINDIR="$PREFIX/bin"
7 |
8 | install_bin() {
9 | local f
10 |
11 | mkdir -p "$PREFIX/bin"
12 | for f in adb fastboot; do
13 | wget -O "$f" -c "$BASEURL/mac-$f"
14 | install -m 0755 "$f" "$BINDIR/$f"
15 | done
16 | }
17 |
18 | "$@"
19 |
--------------------------------------------------------------------------------
/golang/tut/unsafe_test.go:
--------------------------------------------------------------------------------
1 | package tut
2 |
3 | import "testing"
4 | import (
5 | "sync/atomic"
6 | "unsafe"
7 | )
8 |
9 | func TestPointerAtomic(t *testing.T) {
10 | type S struct {
11 | wow string
12 | }
13 | var u = &S{wow: "hello"}
14 |
15 | var p unsafe.Pointer
16 |
17 | t.Logf("%s", (*S)(p))
18 | atomic.StorePointer(&p, unsafe.Pointer(u))
19 | t.Logf("%s", (*S)(p))
20 | }
21 |
--------------------------------------------------------------------------------
/ansible/k8s/k8s.yaml:
--------------------------------------------------------------------------------
1 | - hosts: all
2 | tasks:
3 | - modprobe:
4 | name: br_netfilter
5 | state: present
6 | - sysctl:
7 | name: net.bridge.bridge-nf-call-iptables
8 | value: "1"
9 | reload: yes
10 | state: present
11 | - include_role:
12 | name: geerlingguy.docker
13 | - include_role:
14 | name: geerlingguy.kubernetes
15 |
--------------------------------------------------------------------------------
/c/Makefile:
--------------------------------------------------------------------------------
1 | BINS:=tg pthreads_do mdio
2 |
3 | all: $(BINS)
4 |
5 | # -static requires glibc-static on rhel
6 | tg: tg.c
7 | $(CC) -o $@ -static -Wall $(CFLAGS) $(CPPFLAGS) $^
8 |
9 | pthreads_do: pthreads_do.c
10 | $(CC) -o $@ -Wall -lpthread $(CFLAGS) $(CPPFLAGS) $^
11 |
12 | mdio: mdio.c
13 | $(CC) -o $@ -static -Wall $(CFLAGS) $(CPPFLAGS) $^
14 |
15 | clean:
16 | rm -vf $(BINS)
17 |
18 | .PHONY: clean
19 |
--------------------------------------------------------------------------------
/qemu/osx-on-qemu/anti-pirate-song.txt:
--------------------------------------------------------------------------------
1 | # http://osxdaily.com/2010/03/19/anti-piracy-message-in-mac-os-x-kernel-extension/
2 | #
3 | Your karma check for today:
4 | There once was was a user that whined
5 | his existing OS was so blind,
6 | he’d do better to pirate
7 | an OS that ran great
8 | but found his hardware declined.
9 | Please don’t steal Mac OS!
10 | Really, that’s way uncool.
11 | (C) Apple Computer, Inc.
12 |
13 |
--------------------------------------------------------------------------------
/charcodecs/gbk/README.md:
--------------------------------------------------------------------------------
1 | This program tries to convert dir/file names from being gb18030-encoded to
2 | utf8-encoded.
3 |
4 | This is mostly needed after files were transfered from an old Windows host to
5 | Linux systems.
6 |
7 | The program accepts a single argument, either it be a directory or regular
8 | file. It will recursively operate on all entries in that directory (including
9 | the directory itself) in a depth-first way
10 |
--------------------------------------------------------------------------------
/android/install-apktool.sh:
--------------------------------------------------------------------------------
1 | PREFIX="$HOME/.usr"
2 | BINDIR="$PREFIX/bin"
3 |
4 | # 1. Install jdk7
5 | # 2. Install ia32-libs
6 | # 3. Install apktool
7 | wget -c https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool
8 | wget -c -O apktool.jar https://github.com/iBotPeaches/Apktool/releases/download/2.1.0/apktool_2.1.0.jar
9 |
10 | for f in apktool apktool.jar; do
11 | install -m 0755 "$f" "$BINDIR/$f"
12 | done
--------------------------------------------------------------------------------
/golang/tcpconn/go.sum:
--------------------------------------------------------------------------------
1 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
2 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
3 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
4 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5 |
--------------------------------------------------------------------------------
/docker/gocryptfs/a.sh:
--------------------------------------------------------------------------------
1 | set -x
2 |
3 | i=yousong/test:testing-gocryptfs-2.4.0
4 |
5 | mkdir -p c p
6 | if ! test -s "p/.gocryptfs.reverse.conf"; then
7 | docker run --rm -it -v /dev/fuse:/dev/fuse --privileged -v $PWD/c:/c -v $PWD/p:/p $i -init -reverse /p
8 | fi
9 | docker run --rm -it --device /dev/fuse --cap-add sys_admin -v $PWD/c:/c:shared -v $PWD/p:/p:ro -v $PWD/passfile:/passfile:ro $i -fg -allow_other -nosyslog -reverse -passfile /passfile /p /c
10 |
--------------------------------------------------------------------------------
/python/sphinx/Makefile:
--------------------------------------------------------------------------------
1 | dockerBuildName=yousong/sphinx-latexpdf-extra
2 | dockerBuildTag=0.0.2
3 |
4 | docker-image-build:
5 | docker build \
6 | -t $(dockerBuildName):$(dockerBuildTag) \
7 | -f Dockerfile-latexpdf-extra \
8 | .
9 | docker tag $(dockerBuildName):$(dockerBuildTag) $(dockerBuildName):latest
10 |
11 | docker-image-push:
12 | docker image push $(dockerBuildName):$(dockerBuildTag)
13 | docker image push $(dockerBuildName):latest
14 |
--------------------------------------------------------------------------------
/docker/mypan/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1-alpine3.18 AS builder
2 |
3 | RUN apk add git make
4 | RUN set -x \
5 | && git clone https://github.com/yousong/mypan \
6 | && cd mypan \
7 | && make \
8 | && mv mypan /usr/bin/mypan
9 |
10 | FROM alpine:3.18
11 |
12 | RUN set -ex \
13 | && apk add --no-cache tini \
14 | && true
15 |
16 | COPY --from=builder /usr/bin/mypan /usr/bin/mypan
17 | ADD root/ /
18 | VOLUME ["/root/.mypan"]
19 |
20 | ENV RUN_CRONTAB=
21 | ENTRYPOINT ["/run.sh"]
22 |
--------------------------------------------------------------------------------
/ansible/ss/inventory.yaml:
--------------------------------------------------------------------------------
1 | all:
2 | hosts:
3 | HOST:
4 | #ansible_host: localhost
5 | #ansible_connection: local
6 | ansible_become: yes
7 | shadowsocks_libev_servers: [sss0]
8 | shadowsocks_libev_server_sss0:
9 | server: 0.0.0.0
10 | server_port: 55535
11 | # hexdump -n 16 -e '"%02x"' /dev/urandom
12 | password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
13 | method: chacha20-ietf-poly1305
14 | mode: tcp_and_udp
15 |
--------------------------------------------------------------------------------
/charcodecs/README.md:
--------------------------------------------------------------------------------
1 | # c3c2.py
2 |
3 | This little script tries to restore character strings from byte sequence. The input byte sequenced is expected to be product of applying utf8 encoding on each byte of an already gb18030 encoded byte sequence.
4 |
5 | E.g. "驴", "\xc2\xbf" gb18030 encoded, "\xc3\x82\xc2\xbf" when again utf8 encoded
6 |
7 | UPDATE 2024/02/27: It seems we can achieve the same effect with iconv command
8 |
9 | iconv -f utf8 -t latin1 | iconv -f gb18030 -t utf8
10 |
--------------------------------------------------------------------------------
/docker/cuda-bench-tensorflow/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM tensorflow/tensorflow:2.15.0-gpu
2 |
3 | ENV \
4 | TF_FORCE_GPU_ALLOW_GROWTH=true \
5 | TF_CPP_MIN_LOG_LEVEL=2 \
6 | PYTHONUNBUFFERED=1
7 |
8 | RUN set -ex \
9 | && apt-get update \
10 | && apt-get install -y git \
11 | && cd / \
12 | && git clone --single-branch --branch=master --depth=1 https://github.com/tensorflow/benchmarks.git
13 | WORKDIR /benchmarks/scripts/tf_cnn_benchmarks
14 |
15 | COPY root/ /
16 | ENTRYPOINT ["/run.sh"]
17 |
--------------------------------------------------------------------------------
/ansible/distrepo/nodesource.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all
3 | tasks:
4 | - name: epel
5 | copy:
6 | content: |
7 | [nodesource]
8 | name=NodeJS 12.x Packages for Enterprise Linux $releasever - $basearch
9 | baseurl=https://rpm.nodesource.com/pub_12.x/el/$releasever/$basearch
10 | enabled=1
11 | gpgcheck=0
12 | dest: /etc/yum.repos.d/nodesource.repo
13 | owner: root
14 | group: root
15 | mode: "0644"
16 |
--------------------------------------------------------------------------------
/ansible/wireguard/inventory.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | all:
3 | hosts:
4 | HOSTNAME:
5 | ansible_user: root
6 | ansible_host: x.x.x.x
7 | wireguard_networks:
8 | - wg0
9 | wireguard_wg0_interface:
10 | address: 10.y.y.1/24
11 | private_key: wg genkey | tee /dev/tty | wg pubkey
12 | listen_port: 1111111
13 | wireguard_wg0_peers:
14 | oneplus5t:
15 | public_key: haha
16 | allowed_ips: 10.y.y.2/32
17 | persistent_keepalive: 10
18 |
--------------------------------------------------------------------------------
/docker/gocryptfs/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1-alpine3.18 AS builder
2 | ARG GOCRYPTFS_VERSION=2.4.0
3 |
4 | RUN apk add bash gcc git libc-dev openssl-dev
5 | RUN set -x \
6 | && git clone https://github.com/rfjakob/gocryptfs \
7 | && cd gocryptfs \
8 | && git checkout v$GOCRYPTFS_VERSION
9 | WORKDIR gocryptfs
10 | RUN ./build.bash
11 | RUN mv "$(go env GOPATH)/bin/gocryptfs" /usr/bin/gocryptfs
12 |
13 |
14 | FROM alpine:3.18
15 | COPY --from=builder /usr/bin/gocryptfs /usr/bin/gocryptfs
16 | ENTRYPOINT ["/usr/bin/gocryptfs"]
17 |
--------------------------------------------------------------------------------
/golang/tut/strings_test.go:
--------------------------------------------------------------------------------
1 | package tut
2 |
3 | import "testing"
4 | import (
5 | "strings"
6 | )
7 |
8 | func TestSplit(t *testing.T) {
9 | segs := []string{"", "ips", "uuid-ip", "nics", "uuid-nic"}
10 | url := strings.Join(segs, "/")
11 | segs1 := strings.Split(url, "/")
12 | if len(segs) != len(segs1) {
13 | t.Fatalf("segs length: %d!=%d", len(segs), len(segs1))
14 | }
15 | for i, seg := range segs {
16 | if seg != segs1[i] {
17 | t.Fatalf("seg not equal: %d: %s!=%s", i, seg, segs1[i])
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/python/echoserver/Makefile:
--------------------------------------------------------------------------------
1 | CC:=gcc
2 | CROSS_COMPILE:=$(HOME)/git-repo/lede-project/lede/staging_dir/toolchain-x86_64_gcc-5.4.0_musl/bin/x86_64-openwrt-linux-musl-
3 | CROSS_COMPILE:=
4 |
5 | all: _udpio.so echoserver.tar.gz
6 |
7 | _udpio.so: _udpio.c
8 | $(CROSS_COMPILE)$(CC) -o $@ -D_GNU_SOURCE -shared -fPIC $^
9 |
10 | DEPS_echoserver.tar.gz = echoserver.py udpio.py _udpio.so
11 | echoserver.tar.gz: $(DEPS_echoserver.tar.gz)
12 | tar czf $@ $^
13 |
14 |
15 | clean:
16 | @rm -vf _udpio.so
17 | @rm -vf echoserver.tar.gz
18 |
--------------------------------------------------------------------------------
/openwrt/upup/files/upup.config:
--------------------------------------------------------------------------------
1 | #
2 | # ports_vlan, vlan of the ports
3 | # ports_other, ports of those always part of ports_vlan
4 | # port_bridge, port of the bridge link
5 | # ip_my, ip address to check for connectivity of my wing
6 | # ip_other, same as ip_my, but for the other wing
7 | #
8 | config upup upup
9 | option ports_vlan '1'
10 | option ports_other '0 1 2 3'
11 | option port_bridge '4'
12 | option ip_my '192.168.177.177'
13 | option ip_other '114.114.114.114'
14 | option ip_timeout_my 1
15 | option ip_timeout_other 1
16 |
--------------------------------------------------------------------------------
/notes/mac-input-umlaut.md:
--------------------------------------------------------------------------------
1 | Prefix the first character with `alt` key (or `fn+option`).
2 |
3 | Umlaut and ss
4 |
5 | `, à, grave
6 | e, é, acute
7 | i, î, circumflex
8 | n, ñ, tilde
9 | u, ü, umlaut
10 | s, ß, ss
11 |
12 | CNY, RMB, Yuan, currency
13 |
14 | y, ¥
15 | 3, £
16 | @, €
17 | $, $
18 |
19 | (c), and tm
20 |
21 | g, ©
22 | r, ®
23 | 2, ™
24 |
25 | Bitten Apfel
26 |
27 | K,
28 |
29 | - Apple OS X Keyboards: Typing Diacritics And Special Characters, https://forlang.wsu.edu/help-pages/help-pages-keyboards-os-x/
30 |
--------------------------------------------------------------------------------
/shell/make-vim-ref-man.sh:
--------------------------------------------------------------------------------
1 | #
2 | # A complete VIM REFERENCE MANUAL can be handy when we need to write new or edit existing vimscripts.
3 | #
4 | # If zsh complains "cat: xxx : File name too long", do the following
5 | #
6 | # setopt sh_wordsplit
7 | #
8 | docdir="$HOME/.usr/share/vim/vim74/doc"
9 | refman="vim-ref-man.txt"
10 |
11 | rm -f "$refman"
12 | awk -F '|' '
13 | /^REFERENCE MANUAL/ { p=1 }
14 | $2 ~ /\w+\.txt$/ { if (p) printf "%s\n", $2 }
15 | ' "$docdir/help.txt" \
16 | | while read f; do
17 | cat "$docdir/$f" >>"$refman"
18 | done
19 |
--------------------------------------------------------------------------------
/openwrt/dns-ipset/README.md:
--------------------------------------------------------------------------------
1 | Generate dnsmasq config snippet to
2 |
3 | - resolve selected domains using desired dns server
4 | - add the resolved results to desired ipset
5 |
6 | The genereated config file will be `/etc/dnsmasq.ipset` by default. The output dir can be controlled by environment variable `o_confdir`, e.g.
7 |
8 | ./do-dns-ipset.sh dns-ipset.txt
9 | o_confdir=/tmp/dnsmasq.d ./do-dns-ipset.sh dns-ipset.txt
10 |
11 | To use the generated config file, add the following line to `/etc/dnsmasq.conf`
12 |
13 | conf-file=/etc/dnsmasq.ipset
14 |
--------------------------------------------------------------------------------
/info/meizu-m351/updater-binary.md:
--------------------------------------------------------------------------------
1 | Content of `/proc/uboot_version`, compare and take index0
2 |
3 | eng 0
4 | oversea 1
5 | user 2
6 |
7 | `property_get("ro.meizu.hardware.modem", buf_modem, "wcdma)`, take index1
8 |
9 | wcdma index0
10 | td-scdma index0+3
11 |
12 | So
13 |
14 | eng,wcdma 0
15 | oversea,wcdma 1
16 | user,wcdma 2
17 | eng,td-scdma 3
18 | oversea,td-scdma 4
19 | user,td-scdma 5
20 |
21 | This is also cross-confirmed by contents of bootloader.img
22 |
--------------------------------------------------------------------------------
/ansible/k8s/onecloud/templates/onecloud-cluster.yaml.j2:
--------------------------------------------------------------------------------
1 | apiVersion: "onecloud.yunion.io/v1alpha1"
2 | kind: OnecloudCluster
3 | metadata:
4 | name: "{{ oc_cluster_name }}"
5 | namespace: "{{ oc_namespace }}"
6 | spec:
7 | mysql:
8 | host: "{{ oc_db_host }}"
9 | port: {{ oc_db_port }}
10 | username: "{{ oc_db_user }}"
11 | password: "{{ oc_db_pass }}"
12 | region: "{{ oc_cluster_region }}"
13 | imageRepository: "{{ oc_cluster_image_repo }}"
14 | version: "{{ oc_cluster_version }}"
15 | loadBalancerEndpoint: "{{ oc_cluster_access_addr }}"
16 |
--------------------------------------------------------------------------------
/anki/README.md:
--------------------------------------------------------------------------------
1 | A small set of utilities to
2 |
3 | - Lookup definitions of words and produce them as files of listing
4 | - Import those text files to anki
5 |
6 | Basic facts
7 |
8 | - Depends on the DictionaryServices of Mac OS X
9 | - Anki Python library needs to installed
10 | - Anki is written in Python3
11 | - Python DictionaryServices is only available in Python2
12 |
13 | Files
14 |
15 | - p.py, lookup definitions and produce list
16 | - q.py, import listings to anki
17 | - lookup.c, to be compiled into a c library and used with python through ctypes
18 |
--------------------------------------------------------------------------------
/openwrt/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:buster
2 |
3 | #RUN sed -i -e 's:deb\.debian\.org:mirrors.tuna.tsinghua.edu.cn:' /etc/apt/sources.list
4 | RUN apt-get update &&\
5 | apt-get install -y \
6 | sudo time git-core subversion build-essential g++ bash make \
7 | libssl-dev patch libncurses5 libncurses5-dev zlib1g-dev gawk \
8 | flex gettext wget unzip xz-utils python python-distutils-extra \
9 | python3 python3-distutils-extra rsync curl libsnmp-dev liblzma-dev \
10 | libpam0g-dev cpio rsync gcc-multilib && \
11 | apt-get clean
12 |
--------------------------------------------------------------------------------
/docker/onedriver/README.md:
--------------------------------------------------------------------------------
1 | It provides a variant of [headless onedriver](https://github.com/jstaf/onedriver)
2 |
3 | # How to use it
4 |
5 | Note that `$cacheDir` is actually a parent dir for the per mount point dir
6 | (`/mnt` in the following example)
7 |
8 | ```sh
9 | cacheDir="$HOME/j/c"
10 | mountDir="$HOME/j/m"
11 |
12 | docker run --rm -it \
13 | -v "$cacheDir:/cache" \
14 | -v "$mountDir:/mnt:shared" \
15 | --device /dev/fuse \
16 | --cap-add sys_admin \
17 | r:t \
18 | --cache-dir "/cache" \
19 | --allow-other \
20 | --uid `id -u` \
21 | --gid `id -g` \
22 | /mnt
23 | ```
24 |
--------------------------------------------------------------------------------
/info/meizu-m351/factory-test-mode.md:
--------------------------------------------------------------------------------
1 | Code for factory test mode will not be built for `RECOVERY_KERNEL`.
2 |
3 | `arch/arm/mach-exynos/board-m6x-factory-test.c` provides 2 function pointers: `mx_is_factory_test_mode`, `mx_set_factory_test_led`
4 |
5 | - There is not default implementation for them
6 | - It will not cause memory access error because modules depending on them will also not be built for `RECOVERY_KERNEL`
7 |
8 | There are 4 GPIO pins for factory test mode
9 |
10 | - 1 for factory mode in general
11 | - 1 for bt test mdoe
12 | - 1 for gps test mode
13 | - 1 for driving led of the mode
--------------------------------------------------------------------------------
/python/timeit-deque-list.py:
--------------------------------------------------------------------------------
1 | from collections import deque
2 | from timeit import timeit
3 |
4 | def deque_action(n):
5 | d = deque()
6 | for i in range(n):
7 | d.append(i)
8 | while len(d):
9 | j = d.popleft()
10 |
11 | def list_action(n):
12 | d = []
13 | for i in range(n):
14 | d.append(i)
15 | while len(d):
16 | j = d.pop(0)
17 |
18 | def test(who):
19 | what = '%s_action(100000)' % who
20 | setup = 'from __main__ import %s_action' % who
21 | time = timeit(what, number=1, setup=setup)
22 | print who, time
23 |
24 | test('deque')
25 | test('list')
26 |
--------------------------------------------------------------------------------
/stap/uflame.stp:
--------------------------------------------------------------------------------
1 | /*
2 | * Usage
3 | *
4 | * stap -x `pgrep ovs-vswitchd` -d /usr/sbin/ovs-vswitchd --ldd uflame.stp -o uflame.stp.out
5 | * stackcollapse-stap.pl uflame.stp.out >uflame.stp.out2
6 | * flamegraph.pl uflame.stp.out2 >uflame.stp.svg
7 | *
8 | */
9 |
10 | global stks
11 | global quit = 0
12 |
13 | probe timer.profile {
14 | if (pid() == target()) {
15 | if (quit) {
16 | foreach (stk in stks-) {
17 | print_usyms(stk)
18 | printf("\t%d\n", @count(stks[stk]))
19 | }
20 | exit()
21 | }
22 | stks[ucallers(-1)] <<< 1
23 | }
24 | }
25 |
26 | probe timer.s(5) {
27 | quit = 1
28 | }
29 |
--------------------------------------------------------------------------------
/python/cdist/gdns:
--------------------------------------------------------------------------------
1 | # vi: ft=sh
2 | source "$__manifest/params"
3 |
4 | o_gdns_listen="192.168.175.1:8053"
5 | o_gdns_src="$o_gopath/src/dns-over-https-proxy"
6 |
7 | __git "$o_gdns_src" \
8 | --owner "$o_user" --group "$o_user" \
9 | --source https://github.com/yousong/dns-over-https-proxy
10 |
11 | __daemontools_service gdns \
12 | --servicedir "$o_servicedir"
13 | --runfile - <<-EOF
14 | #!/bin/bash
15 | bin="$o_gopath/bin/dns-over-https-proxy"
16 | if [ ! -x "\$bin" ]; then
17 | cd "$o_gdns_src"
18 | go install || exit 1
19 | fi
20 | exec "$o_gopath/bin/dns-over-https-proxy" -address $o_gdns_listen
21 | EOF
22 |
--------------------------------------------------------------------------------
/notes/devices-in-the-field.md:
--------------------------------------------------------------------------------
1 | 遇到的问题
2 |
3 | 1. 电源断开
4 | 2. 光纤断
5 | 3. DNS无法解析
6 | 4. DNS解析成功但是访问失败(ping超时、端口连接超时)
7 | 5. 解析成功,能连接,但是ping超时
8 | 6. 运营商拨号连接失败
9 | 7. 连接已断,`epoll()`调用调用未有`EPOLLERR`,造成死循环
10 | 8. daemonizer失效,未将客户端重启
11 | 9. dropbear缺少respawn,未重启
12 | 10. xl2tpd named pipe通信设计bug
13 | 11. 内核oops
14 | 12. 可能设备硬件硬件问题,造成非重启无法恢复
15 | 12. 设备外部环境变迁,设备无人照管
16 | 13. 运营商劫持连接,无法通信
17 |
18 | 经验备忘
19 |
20 | - ISP信息,ISP客服联系信息,账号信息等有记录可查
21 | - - 设备信息(设备MAC地址,SN号,地理信息)可查
22 | - - 压缩,头部伪装
23 |
24 | 特征备忘
25 |
26 | - - 普通家用路由器设备
27 | - - 普通家用ISP
28 | - - 服务端的单点问题:域名,IP,机器
29 | - - 接入VPN的单点问题
30 | - - 服务端down掉再up时可能面临的thundering herd问题
31 |
--------------------------------------------------------------------------------
/openwrt/a.sh:
--------------------------------------------------------------------------------
1 | mydir="$(dirname "$(readlink -f "$0")")"
2 |
3 | # run container for openwrt build
4 | runob() {
5 | # Put openwrt source code under $work
6 | local workdir="$mydir/work"
7 | local defcfgdir="$mydir/defconfig"
8 |
9 | local dockerimg="yousong/test:openwrt-build"
10 |
11 | local uid
12 | local gid
13 | local user
14 |
15 | uid="$(id -u)"
16 | gid="$(id -g)"
17 | user="$(id -un)"
18 |
19 | docker run \
20 | --rm \
21 | -it \
22 | --name ob \
23 | -v "$workdir:/work" \
24 | -v "$defcfgdir:/work/defconfig" \
25 | -w "/work" \
26 | --user "$uid:$gid" \
27 | "$dockerimg" \
28 | bash
29 | }
30 |
31 | "$@"
32 |
--------------------------------------------------------------------------------
/charcodecs/c3c2.py:
--------------------------------------------------------------------------------
1 | import codecs
2 | import sys
3 |
4 | def b(bs):
5 | bs1=b''
6 | sz=len(bs)
7 | i=0
8 | while i < sz:
9 | c = bs[i]
10 | if c == 0xc3:
11 | i+=1
12 | bs1 = bs1 + (bs[i]|0x40).to_bytes(length=1, byteorder='big')
13 | elif c == 0xc2:
14 | i+=1
15 | bs1 = bs1 + bs[i].to_bytes(length=1, byteorder='big')
16 | else:
17 | bs1 = bs1 + c.to_bytes(length=1, byteorder='big')
18 | i+=1
19 | return bs1
20 |
21 | bs = sys.stdin.buffer.read()
22 | bs1 = b(bs)
23 | s = codecs.decode(bs1, 'gb18030', errors='ignore')
24 | print(s)
25 |
--------------------------------------------------------------------------------
/openwrt/defconfig/povs:
--------------------------------------------------------------------------------
1 | CONFIG_PACKAGE_kmod-openvswitch=y
2 | CONFIG_PACKAGE_kmod-openvswitch-geneve=y
3 | CONFIG_PACKAGE_kmod-openvswitch-gre=y
4 | CONFIG_PACKAGE_kmod-openvswitch-vxlan=y
5 | CONFIG_PACKAGE_openvswitch=y
6 | CONFIG_PACKAGE_openvswitch-ovn-north=y
7 | CONFIG_PACKAGE_openvswitch-ovn-host=y
8 | CONFIG_PACKAGE_openvswitch-python=y
9 |
10 | #CONFIG_DEVEL=y
11 | #CONFIG_PACKAGE_kmod-openvswitch-intree=y
12 | #CONFIG_PACKAGE_kmod-openvswitch-geneve-intree=y
13 | #CONFIG_PACKAGE_kmod-openvswitch-gre-intree=y
14 | #CONFIG_PACKAGE_kmod-openvswitch-vxlan-intree=y
15 | #CONFIG_PACKAGE_kmod-openvswitch-stt-intree=y
16 | #CONFIG_PACKAGE_kmod-openvswitch-lisp-intree=y
17 |
--------------------------------------------------------------------------------
/docker/onedriver/Dockerfile:
--------------------------------------------------------------------------------
1 | # -*-Dockerfile-*-
2 |
3 | ARG GIT_REPO=https://github.com/yousong/onedriver.git
4 | ARG GIT_BRANCH=yousong
5 |
6 |
7 | FROM golang:1-alpine3.18 AS builder
8 | RUN apk add git
9 |
10 | ARG GIT_REPO
11 | ARG GIT_BRANCH
12 | RUN set -ex \
13 | && mkdir -p /usr/src \
14 | && cd /usr/src \
15 | && git clone "${GIT_REPO}" \
16 | && cd onedriver \
17 | && git checkout "${GIT_BRANCH}"
18 | WORKDIR /usr/src/onedriver
19 |
20 | RUN apk add \
21 | bash \
22 | grep \
23 | make
24 | RUN make onedriver-headless
25 |
26 |
27 | FROM alpine:3.18
28 | COPY --from=builder /usr/src/onedriver/onedriver-headless /usr/bin/
29 | ENTRYPOINT ["/usr/bin/onedriver-headless"]
30 |
--------------------------------------------------------------------------------
/qemu/qemu-on-osx/README.md:
--------------------------------------------------------------------------------
1 | ## refs
2 |
3 | - intel haxm, https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
4 | - qemu 2.9 introduces haxm support, http://wiki.qemu.org/ChangeLog/2.9
5 | - Setup NAT Network for QEMU in Mac OSX, https://blog.san-ss.com.ar/2016/04/setup-nat-network-for-qemu-macosx
6 |
7 | ## steps
8 |
9 | install intel haxm
10 |
11 | tuntap driver
12 |
13 | sudo port install tuntaposx
14 | sudo port load tuntaposx
15 |
16 | create bridge and make it gateway
17 |
18 | sudo ./qemu-osx setup
19 | sudo ./qemu-osx run
20 | sudo ./qemu-osx run2
21 |
22 | ## todo
23 |
24 | - investigate why "-drive if=virtio" does not work
25 |
--------------------------------------------------------------------------------
/ansible/k8s/nokmem.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all
3 | tasks:
4 | - name: check /etc/sysconfig/grub
5 | shell: grep -q '^GRUB_CMDLINE_LINUX=.*cgroup.memory=nokmem' /etc/sysconfig/grub
6 | failed_when: no
7 | changed_when: no
8 | no_log: yes
9 | register: grep
10 | - name: edit /etc/sysconfig/grub
11 | replace:
12 | backup: yes
13 | path: /etc/sysconfig/grub
14 | regexp: '(^GRUB_CMDLINE_LINUX="[^"]+)"'
15 | replace: '\1 cgroup.memory=nokmem"'
16 | when: "grep.rc != 0"
17 | register: edit
18 | - name: generate grub.cfg
19 | shell: grub2-mkconfig -o /boot/grub2/grub.cfg
20 | when: edit is changed
21 |
--------------------------------------------------------------------------------
/nodejs/chromeless/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chromeless",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "dependencies": {
7 | "chromeless": "^1.4.0"
8 | },
9 | "devDependencies": {},
10 | "scripts": {
11 | "prep": "'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --disable-translate --disable-extensions --disable-background-networking --safebrowsing-disable-auto-update --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --remote-debugging-port=9222 --user-data-dir='chromeless-user-data-dir/' --headless about:blank",
12 | "start": "node index.js"
13 | },
14 | "author": "",
15 | "license": "ISC"
16 | }
17 |
--------------------------------------------------------------------------------
/docker/xfstests/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM fedora:34
2 |
3 | RUN dnf install -y \
4 | acl attr automake bc dbench dump e2fsprogs fio \
5 | gawk gcc indent libtool lvm2 make psmisc quota sed \
6 | xfsdump xfsprogs \
7 | libacl-devel libaio-devel libuuid-devel \
8 | xfsprogs-devel btrfs-progs-devel python sqlite liburing-devel \
9 | libcap-devel
10 |
11 | RUN dnf install -y \
12 | hostname \
13 | patch
14 |
15 | COPY ./xfstests-2021-08-16-ae8c30c34c51b5a5c5dd1639ec83ef901a40b3ad.tar.gz /root/xfstests.tar.gz
16 | RUN set -x \
17 | && cd /root \
18 | && find . -type f | xargs -r ls -l \
19 | && tar xzf xfstests.tar.gz \
20 | && mv xfstests-* xfstests \
21 | && cd ./xfstests \
22 | && make -j$(nproc) \
23 | && true
24 |
--------------------------------------------------------------------------------
/docker/jupyter/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM quay.io/jupyter/pytorch-notebook:x86_64-cuda12-2024-11-18
2 |
3 | ENV \
4 | NVIDIA_DRIVER_CAPABILITIES=all
5 |
6 | USER root
7 | RUN set -ex \
8 | && apt-get update \
9 | && apt-get install -y git \
10 | && apt install -y vulkan-tools libegl1 libxext6 \
11 | && apt clean \
12 | && sed -i -e "s:archive\.ubuntu\.com:mirrors.tuna.tsinghua.edu.cn:" /etc/apt/sources.list.d/ubuntu.sources \
13 | && true
14 |
15 | USER jovyan
16 | RUN set -ex \
17 | && mkdir -p $HOME/.pip \
18 | && echo '[global]' >$HOME/.pip/pip.conf \
19 | && echo 'index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple' >>$HOME/.pip/pip.conf \
20 | && echo 'disable-pip-version-check = true' >>$HOME/.pip/pip.conf \
21 | && true
22 |
--------------------------------------------------------------------------------
/docker/nextcloud/supervisord.conf:
--------------------------------------------------------------------------------
1 | [supervisord]
2 | nodaemon=true
3 | logfile=/var/log/supervisord/supervisord.log
4 | pidfile=/var/run/supervisord/supervisord.pid
5 | childlogdir=/var/log/supervisord/
6 | logfile_maxbytes=50MB ; maximum size of logfile before rotation
7 | logfile_backups=10 ; number of backed up logfiles
8 | loglevel=error
9 |
10 | [program:apache2]
11 | stdout_logfile=/dev/stdout
12 | stdout_logfile_maxbytes=0
13 | stderr_logfile=/dev/stderr
14 | stderr_logfile_maxbytes=0
15 | command=apache2-foreground
16 |
17 | [program:cron]
18 | stdout_logfile=/dev/stdout
19 | stdout_logfile_maxbytes=0
20 | stderr_logfile=/dev/stderr
21 | stderr_logfile_maxbytes=0
22 | command=/cron.sh
23 |
--------------------------------------------------------------------------------
/shell/multif/multif.spec:
--------------------------------------------------------------------------------
1 | Name: admnet
2 | Version: 1.0
3 | Release: 1
4 | BuildArch: noarch
5 | Summary: 为云平台主机生成静态网络配置
6 |
7 | Requires: initscripts, iproute
8 |
9 | %description
10 |
11 | 当一台虚机还同时绑定有管理网卡、vpc公共服务网卡时,通过dhcp取得的地址虽然正确,但是路由的配置却不一定符合期望
12 |
13 | 脚本尝试固化此类虚机的网络配置项,实现
14 |
15 | - 所有网卡地址配置正确
16 | - 默认路由走管理网卡
17 | - vpc公共服务相关子网路由设置正确
18 | - 基于网卡源地址的策略路由,例如,FullNAT环境中的NGINX机器,源地址为内网网卡地址、目的地址为公网IP的报文仍从内网网卡出去,而不是通过默认路由走管理网网卡
19 | - 重启机器配置能不变
20 |
21 | %install
22 | mkdir -p %{buildroot}/%{_datadir}/admnet
23 | cp -f $OLDPWD/admnet.sh %{buildroot}/%{_datadir}/admnet
24 |
25 |
26 | %files
27 | %defattr(-,root,root,-)
28 | %{_datadir}/admnet/*
29 |
30 |
31 | %changelog
32 | * Thu Oct 03 2017 Yousong Zhou 1.0
33 | - initial
34 |
--------------------------------------------------------------------------------
/python/stackframes.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import sys
3 | import threading
4 | import traceback
5 | import time
6 |
7 | def print_stacks():
8 | frames = sys._current_frames()
9 | for t in threading.enumerate():
10 | tident = t.ident
11 | tframe = frames.get(tident)
12 | if tframe:
13 | stack = traceback.extract_stack(tframe)
14 | print(stack)
15 |
16 | class T(threading.Thread):
17 | def __init__(self, sem):
18 | super(T, self).__init__()
19 | self.sem = sem
20 |
21 | def run(self):
22 | sem.acquire()
23 |
24 | count = 3
25 | sem = threading.Semaphore(0)
26 | for i in range(count):
27 | T(sem).start()
28 | print_stacks()
29 | for i in range(count):
30 | sem.release()
31 |
--------------------------------------------------------------------------------
/golang/tcpconn/rlimit_linux.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "io/ioutil"
5 | "strconv"
6 | "strings"
7 |
8 | "golang.org/x/sys/unix"
9 |
10 | "github.com/golang/glog"
11 | )
12 |
13 | func sysctlRead(p string) (string, error) {
14 | c, err := ioutil.ReadFile(p)
15 | if err != nil {
16 | return "", err
17 | }
18 | return string(c), nil
19 | }
20 |
21 | func getNofileSysMax() uint64 {
22 | max := uint64(unix.RLIM_INFINITY)
23 |
24 | if s, err := sysctlRead("/proc/sys/fs/nr_open"); err == nil {
25 | s = strings.TrimSpace(s)
26 | n, err := strconv.ParseUint(s, 10, 64)
27 | if err != nil {
28 | glog.Fatalf("bad fs.nr_open (%s): %v", s, err)
29 | }
30 | glog.Infof("fs.nr_open = %d", n)
31 | if max > n {
32 | max = n
33 | }
34 | }
35 |
36 | return max
37 | }
38 |
--------------------------------------------------------------------------------
/openwrt/defconfig/mos-mini:
--------------------------------------------------------------------------------
1 | CONFIG_TARGET_x86=y
2 | CONFIG_TARGET_x86_64=y
3 | CONFIG_TARGET_x86_64_Generic=y
4 | CONFIG_GRUB_TIMEOUT="0"
5 | CONFIG_PACKAGE_qemu-ga=y
6 |
7 | CONFIG_PACKAGE_ip=y
8 | CONFIG_PACKAGE_ip-full=y
9 | CONFIG_PACKAGE_tc=y
10 | CONFIG_PACKAGE_genl=y
11 | CONFIG_PACKAGE_ip-bridge=y
12 | CONFIG_PACKAGE_ss=y
13 |
14 | CONFIG_PACKAGE_python=y
15 | CONFIG_PACKAGE_python-pip=y
16 | CONFIG_PACKAGE_tcpdump=y
17 | CONFIG_PACKAGE_netcat=y
18 | CONFIG_PACKAGE_iputils-arping=y
19 |
20 | CONFIG_DEVEL=y
21 | CONFIG_PACKAGE_python=y
22 | CONFIG_PACKAGE_python-packages=y
23 | CONFIG_PACKAGE_python-packages-list="tornado==4.4.*"
24 | CONFIG_PACKAGE_python-packages-index-url="http://pypi.douban.com/simple"
25 | CONFIG_PACKAGE_python-packages-pip-opts="--trusted-host pypi.douban.com -v"
26 |
--------------------------------------------------------------------------------
/shell/mail-maintainers.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Make --to xx --cc arguments for git-send-email from output of
4 | # get_maintainer.pl script.
5 | #
6 | # send_to_maintainer 133-MIPS-UAPI-Fix-unrecognized-opcode-WSBH-DSBH-DSHD-whe.patch
7 | to_maintainers() {
8 | local f="$1"
9 | local get_maintainer="./scripts/get_maintainer.pl"
10 | local raw
11 | local to cc
12 |
13 | [ -x "$get_maintainer" ] || {
14 | echo "Cannot find executable $get_maintainer" >&2
15 | return 1
16 | }
17 |
18 | raw="$("$get_maintainer" "$f")"
19 | raw="$(echo "$raw" | cut -f1 -d'(')"
20 | to="$(echo "$raw" | head -n 1 | sed 's/^\(.*\)\s\+/--to "\1" /' | tr -d '\n')"
21 | cc="$(echo "$raw" | tail -n +2 | sed 's/^\(.*\)\s\+/--cc "\1" /' | tr -d '\n')"
22 |
23 | echo "$to $cc"
24 | }
25 |
26 | to_maintainers "$@"
27 |
--------------------------------------------------------------------------------
/docker/rarlinux/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3.18 as builder
2 | ARG RARLINUX_TARGZ=rarlinux-x64-624.tar.gz
3 | ARG RARLINUX_TARGZ_MD5SUM=cd34890687cbbc0177fbaf6c9de20449
4 | RUN set -ex \
5 | && cd / \
6 | && wget --no-check-certificate https://www.rarlab.com/rar/$RARLINUX_TARGZ \
7 | && echo "$RARLINUX_TARGZ_MD5SUM $RARLINUX_TARGZ" | md5sum -c \
8 | && tar xzf "$RARLINUX_TARGZ"
9 |
10 | FROM debian:bookworm-slim
11 | ENV \
12 | PATH="/rar:${PATH}" \
13 | LANG="en_US.UTF-8"
14 | COPY --from=builder /rar /rar
15 | RUN set -ex \
16 | && rar \
17 | && apt-get update \
18 | && apt-get install -y --no-install-recommends \
19 | locales \
20 | && rm -rf /var/lib/apt/lists/* \
21 | && sed -i -r -e 's/# (en_US.UTF-8)/\1/' /etc/locale.gen \
22 | && sed -i -r -e 's/# (zh_CN)/\1/' /etc/locale.gen \
23 | && locale-gen
24 |
--------------------------------------------------------------------------------
/openwrt/hack/build-tl-wr841n-v5-lede/zerotier-makefile.patch:
--------------------------------------------------------------------------------
1 | diff --git a/net/zerotier/Makefile b/net/zerotier/Makefile
2 | index e9c1426a1..54ff3c6f0 100644
3 | --- a/net/zerotier/Makefile
4 | +++ b/net/zerotier/Makefile
5 | @@ -6,12 +6,12 @@
6 | include $(TOPDIR)/rules.mk
7 |
8 | PKG_NAME:=zerotier
9 | -PKG_VERSION:=1.12.2
10 | -PKG_RELEASE:=2
11 | +PKG_VERSION:=1.10.6
12 | +PKG_RELEASE:=1
13 |
14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 | PKG_SOURCE_URL:=https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/$(PKG_VERSION)?
16 | -PKG_HASH:=7c6512cfc208374ea9dc9931110e35f71800c34890e0f35991ea485aae66e31c
17 | +PKG_HASH:=3f0b59e0c290b18b93fddee1f7b927209538d84a88343b2f3ac61a6bf3c87910
18 | PKG_BUILD_DIR:=$(BUILD_DIR)/ZeroTierOne-$(PKG_VERSION)
19 |
20 | PKG_MAINTAINER:=Moritz Warning
21 |
--------------------------------------------------------------------------------
/ansible/openwrt/repos.yaml:
--------------------------------------------------------------------------------
1 | # remember to run as
2 | ---
3 | - hosts: all
4 | vars:
5 | git_repo_dir: /home/yousong/git-repo
6 | git_repo_openwrt_dir: "{{ git_repo_dir }}/openwrt"
7 | git_repo_url_base: git://git.openwrt.org
8 | tasks:
9 | - name: Mkdir -p "{{ git_repo_openwrt_dir }}"
10 | file:
11 | path: "{{ git_repo_openwrt_dir }}"
12 | state: directory
13 | - name: Prepare git.openwrt.org repos
14 | git:
15 | repo: "{{ git_repo_url_base }}/{{ item }}.git"
16 | dest: "{{ git_repo_openwrt_dir }}/{{ item | basename }}"
17 | update: no
18 | loop:
19 | - openwrt/openwrt
20 | - project/netifd
21 | - project/firewall3
22 | - project/fstools
23 | - project/libubox
24 | - project/uci
25 | - project/ubus
26 |
--------------------------------------------------------------------------------
/shell/pulse-probe/ping.gnuplot:
--------------------------------------------------------------------------------
1 | # timefmt will only take effect if set xdata is also given
2 | set ydata time
3 | set timefmt "%s"
4 | set format y "%d %H:%M"
5 |
6 | set ytics nomirror
7 |
8 | # date --date='2016-04-21 23:58:00' +%s
9 | # date --date=@1461747768
10 | #stime = 1463121600
11 | #length = 600
12 | #set yrange [stime: stime+length]
13 | set xrange [0: 600]
14 |
15 | #set terminal svg size 8000,4400 dynamic
16 | set terminal svg size 4000,1400 dynamic
17 | set output 'x.svg'
18 |
19 | pingips = system("cat ip.ping.list")
20 | iplist = system("cat ip.list")
21 | set multiplot \
22 | layout 2,4 \
23 | columnsfirst \
24 |
25 | fn(sip, ip) = sprintf('data/%s-ping-%s.out', sip, ip)
26 | do for [ip in pingips] {
27 | plot for [sip in iplist] fn(sip, ip) using 2:1 with lines title fn(sip, ip)
28 | }
29 |
30 | unset multiplot
31 |
--------------------------------------------------------------------------------
/python/cdist/ss:
--------------------------------------------------------------------------------
1 | # vi: ft=sh
2 | source "$__manifest/params"
3 |
4 | o_ss_conf='whattttt'
5 | o_ss_run="
6 | #!/bin/bash
7 | P=/home/$o_user/.usr"'
8 | ss_server="$P/bin/ss-server"
9 | ss_server_conf="$P/etc/shadowsocks-libev/air.conf"
10 | exec "$ss_server" -c "$ss_server_conf"
11 | '
12 |
13 | __config_file "$o_userprefix/etc/shadowsocks-libev/air.conf" \
14 | --owner "$o_user" --group "$o_user" --mode 600 \
15 | --source - \
16 | --state present <<-EOF
17 | $o_ss_conf
18 | EOF
19 | __daemontools_service air0 \
20 | --servicedir "$o_servicedir"
21 | --runfile - <<-EOF
22 | $o_ss_run
23 | EOF
24 | __daemontools_service air1 \
25 | --servicedir "$o_servicedir"
26 | --runfile - <<-EOF
27 | $o_ss_run
28 | EOF
29 |
30 | __line svcss \
31 | --file "/etc/rc.local" \
32 | --regex "$o_userprefix/bin/svscanboot &" \
33 | --state present
34 |
--------------------------------------------------------------------------------
/golang/tut/encoding_json_test.go:
--------------------------------------------------------------------------------
1 | package tut
2 |
3 | import "testing"
4 | import (
5 | "encoding/json"
6 | )
7 |
8 | type OwnerTenantOption struct {
9 | TenantId string `json:"tenant_id"`
10 | UserId string `json:"user_id"`
11 | }
12 |
13 | type VpcOption struct {
14 | Vni int `json:"vni"`
15 | }
16 |
17 | type VpcCreateOption struct {
18 | Owner OwnerTenantOption `json:"owner"`
19 | Vpc VpcOption `json:"vpc"`
20 | }
21 |
22 | func TestNestedJSON(t *testing.T) {
23 | var j = []byte(`{"owner": {"tenant_id": "tenant_me"},"vpc": {"vni": 123}}`)
24 | var opt = &VpcCreateOption{}
25 | var err error
26 | err = json.Unmarshal(j, opt)
27 | if err != nil {
28 | t.Fatalf("unmarshal error: %s", err)
29 | }
30 | if opt.Owner.TenantId != "tenant_me" || opt.Vpc.Vni != 123 {
31 | t.Fatalf("wrong unmarshalled value: %v", opt)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/golang/gopkg-nginx.conf:
--------------------------------------------------------------------------------
1 | # vi: ft=nginx
2 | #
3 | # Export golang packages hosted on GitHub and internal servers with
4 | # orgranization brand names in them
5 | #
6 | # Refs
7 | #
8 | # - https://golang.org/cmd/go/#hdr-Remote_import_paths
9 | # - https://golang.org/doc/go1.4#canonicalimports
10 | # - https://github.com/golang/gddo/wiki/Source-Code-Links
11 | #
12 | map $uri $reporoot {
13 | "~^/x/pubproj(/.*|)$" "https://github.com/org/pubproj";
14 | "~^/x/intproj(/.*|)$" "ssh://git@git.org.io/intproj.git";
15 | }
16 |
17 | map $uri $repoprefix {
18 | "~^/x/pubproj(/.*|)$" "org.io/x/pubproj";
19 | "~^/x/priproj(/.*|)$" "org.io/x/priproj";
20 | }
21 |
22 | server {
23 | location /x/ {
24 | if ($args = "go-get=1") {
25 | add_header Content-Type text/html;
26 | return 200 '';
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/python/sphinx/Dockerfile-latexpdf-extra:
--------------------------------------------------------------------------------
1 | FROM sphinxdoc/sphinx-latexpdf:latest
2 |
3 | MAINTAINER Yousong Zhou
4 |
5 | # fonts-freefont-otf: FreeSerif
6 | # xindy: index generation when latex_engine is xelatex
7 | # texlive-latex-extra: \substitutefont
8 | # texlive-lang-greek: lgrenc.def
9 | RUN true \
10 | && apt-get update \
11 | && apt-get install -y \
12 | fonts-freefont-otf \
13 | xindy \
14 | texlive-latex-extra \
15 | texlive-lang-cyrillic \
16 | texlive-lang-greek \
17 | && true
18 |
19 | # sphinxcontrib-websupport: sphinxcontrib.websupport imported by docs of sphinx itself
20 | RUN true \
21 | && pip install sphinxcontrib-websupport \
22 | && true
23 |
24 | # texlive-plain-generic: listofitems.sty, required by riscv/riscv-isa-manual
25 | RUN true \
26 | && apt-get install -y \
27 | texlive-plain-generic
28 |
29 | # vi: ft=dockerfile
30 |
--------------------------------------------------------------------------------
/shell/vpnguru/vpnguru.drv:
--------------------------------------------------------------------------------
1 | n0() {
2 | export o_ifname=xx
3 | export arg_nft=1
4 | export arg_nft_print_chain=1
5 | sh -e vpnguru
6 | }
7 |
8 | n1() {
9 | export o_ifname=xx
10 | export arg_nft=1
11 | export arg_nft_print_table=1
12 | sh -e vpnguru
13 | }
14 |
15 | i0() {
16 | export o_ifname=xx
17 | export arg_ipt=1
18 | export arg_ipt_print_ipset=1
19 | sh -e vpnguru
20 | }
21 |
22 | i1() {
23 | export o_ifname=xx
24 | export arg_ipt=1
25 | export arg_ipt_print_rule=1
26 | sh -e vpnguru
27 | }
28 |
29 | nftf() {
30 | export o_ifname=xx
31 | export arg_ipt=1
32 | export arg_flush_only=1
33 | sh -e vpnguru
34 | }
35 |
36 | iptf() {
37 | export o_ifname=xx
38 | export arg_ipt=1
39 | export arg_flush_only=1
40 | sh -e vpnguru
41 | }
42 |
43 | # ipt/nft must select one
44 | # ipt print ipset/rule
45 | # nft print table/chain
46 | # ipt/nft flush only
47 |
48 | "$@"
49 |
--------------------------------------------------------------------------------
/ansible/k8s/README.md:
--------------------------------------------------------------------------------
1 | # Try kubespray
2 |
3 | - https://github.com/kubernetes-sigs/kubespray
4 |
5 | # TODO
6 |
7 | - multi-master cluster
8 | - https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/ha-topology/
9 | - https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/high-availability/
10 | - drain and take down
11 |
12 | Kube-proxy IPVS mode
13 |
14 | - https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/#config-file
15 | - role variable: kubernetes_kubeadm_init_extra_opt
16 |
17 | Network other than flannel, e.g. calico
18 |
19 | - https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#pod-network
20 |
21 | # tips
22 |
23 | kubeadm config images list
24 | kubeadm config images pull --help
25 |
26 | # useful on version bump, re-run kubeadm init
27 | rm -vf /etc/kubernetes/admin.conf
28 |
--------------------------------------------------------------------------------
/ansible/ss/ss.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: all
3 | tasks:
4 | - include_role:
5 | name: yousong.shadowsocks-libev
6 | - name: Allow server listen port
7 | firewalld:
8 | zone: public
9 | rich_rule: "rule port port='{{ lookup('vars', 'shadowsocks_libev_server_' + item).server_port }}' protocol='tcp' accept"
10 | permanent: yes
11 | state: enabled
12 | with_items: "{{ shadowsocks_libev_servers }}"
13 | - name: Allow server listen port
14 | firewalld:
15 | zone: public
16 | rich_rule: "rule port port='{{ lookup('vars', 'shadowsocks_libev_server_' + item).server_port }}' protocol='udp' accept"
17 | permanent: yes
18 | state: enabled
19 | with_items: "{{ shadowsocks_libev_servers }}"
20 | - name: Reload firewalld
21 | service:
22 | name: firewalld
23 | state: restarted
24 | enabled: yes
25 |
--------------------------------------------------------------------------------
/anki/q.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import os
3 | import glob
4 |
5 | from anki import Collection
6 | from anki.importing import TextImporter
7 |
8 | def drv(col):
9 | cwd = os.getcwd()
10 | flist = glob.glob('????.txt')
11 | for inf in flist:
12 | textf = 'economist.words.' + inf
13 | deckname = textf.rstrip('.txt')
14 | textf = os.path.join(cwd, textf)
15 | print(textf)
16 | deckid = col.decks.id(deckname)
17 |
18 | ti = TextImporter(col, textf)
19 | ti.model['did'] = deckid
20 | col.decks.select(deckid)
21 |
22 | ti.delimiter = '\t'
23 | ti.initMapping()
24 | ti.run()
25 |
26 | def export(col):
27 | pass
28 |
29 | if __name__ == '__main__':
30 | path_col = '/Users/yousong/Library/Application Support/Anki2/User 1/collection.anki2'
31 | col = Collection(path_col)
32 | drv(col)
33 | col.close()
34 |
--------------------------------------------------------------------------------
/nodejs/chromeless/index.js:
--------------------------------------------------------------------------------
1 | const { Chromeless } = require('chromeless')
2 |
3 | var url
4 | url = 'https://www.douban.com'
5 | url = 'https://www.google.com/culturalinstitute/beta/asset/the-kiss/HQGxUutM_F6ZGg?hl=en'
6 |
7 | useragent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'
8 | longtime = 100000 * 1000;
9 |
10 | async function run() {
11 | const chromeless = new Chromeless({
12 | debug: true,
13 | viewport: {
14 | width: 1440,
15 | height: 900,
16 | }
17 | })
18 |
19 | chromeless.setUserAgent(useragent)
20 | const screenshot = await chromeless
21 | .goto(url)
22 | .wait('div[role="button"] svg path', longtime)
23 | .wait(2000)
24 | .screenshot('html', {
25 | filePath: './pic.jpeg'
26 | })
27 | console.log(screenshot)
28 | await chromeless.end()
29 | }
30 |
31 | run().catch(console.error.bind(console))
32 |
--------------------------------------------------------------------------------
/openwrt/upup/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2017 Yousong Zhou
3 | #
4 | # This is free software, licensed under the GNU General Public License v2.
5 | # See /LICENSE for more information.
6 | #
7 |
8 | include $(TOPDIR)/rules.mk
9 |
10 | PKG_NAME:=upup
11 | PKG_RELEASE:=6
12 |
13 | include $(INCLUDE_DIR)/package.mk
14 |
15 | define Package/upup
16 | SECTION:=net
17 | CATEGORY:=Network
18 | TITLE:=upup managing the bridge link
19 | MAINTAINER:=Yousong Zhou
20 | endef
21 |
22 | define Build/Compile
23 | endef
24 |
25 | define Package/upup/install
26 | $(INSTALL_DIR) $(1)/usr/sbin
27 | $(INSTALL_BIN) ./files/upup $(1)/usr/sbin/
28 | $(INSTALL_DIR) $(1)/etc/init.d
29 | $(INSTALL_BIN) ./files/upup.init $(1)/etc/init.d/upup
30 | $(INSTALL_DIR) $(1)/etc/config
31 | $(INSTALL_BIN) ./files/upup.config $(1)/etc/config/upup
32 | endef
33 |
34 | $(eval $(call BuildPackage,upup))
35 |
--------------------------------------------------------------------------------
/docker/baidunetdisk/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM jlesage/baseimage-gui:debian-11-v4.4
2 |
3 | ENV HOME=/config
4 | ENV TZ=Asia/Shanghai
5 | ENV LC_ALL=C
6 |
7 | ARG BAIDUNETDISK_VERSION=4.17.7
8 |
9 | ADD root/ /
10 |
11 | RUN set -x \
12 | && apt-get update \
13 | && apt-get install -y --no-install-recommends \
14 | ca-certificates \
15 | chromium \
16 | curl \
17 | libasound2 \
18 | libdrm2 \
19 | libgbm1 \
20 | libx11-xcb1 \
21 | ttf-wqy-zenhei \
22 | xdg-utils \
23 | && curl -o baidunetdisk.deb https://issuepcdn.baidupcs.com/issue/netdisk/LinuxGuanjia/${BAIDUNETDISK_VERSION}/baidunetdisk_${BAIDUNETDISK_VERSION}_amd64.deb \
24 | && apt-get install -y --no-install-recommends ./baidunetdisk.deb \
25 | && rm -vf baidunetdisk.deb \
26 | && install_app_icon.sh /baidunetdisk.png \
27 | && set-cont-env APP_NAME "百度网盘" \
28 | && set-cont-env APP_VERSION "$BAIDUNETDISK_VERSION" \
29 | && rm -rf /var/lib/apt/lists/* \
30 | && true
31 |
--------------------------------------------------------------------------------
/python/cdist/params:
--------------------------------------------------------------------------------
1 | # vi: ft=sh
2 | #
3 | # cdist config -v -i init localhost
4 | # # build, then
5 | # cdist config -v -i ss localhost
6 | # cdist config -v -i wg localhost
7 | # cdist config -v -i strongswan localhost
8 | #
9 | o_user=yousong
10 | o_pass='passwordhash' # openssl passwd -crypt -salt fh 3
11 | o_grup=wheel
12 | o_pubk='publickey'
13 | o_pkgs="git mosh sudo zsh"
14 | o_pkgs_dev="make autoconf libtool build-essential cmake pkg-config linux-headers-$(uname -r)" # debian
15 | o_pkgs_dev="make autoconf libtool gcc cmake pkgconfig kernel-headers" # rhel
16 | o_ifname_inet="ens3"
17 |
18 |
19 | #(
20 | # cd "/home/$o_user/git-repo/build-scripts"
21 | # make -j32 \
22 | # shadowsocks-libev/install \
23 | # wireguard/install \
24 | # daemontools/install
25 | #)
26 |
27 |
28 | o_userprefix="/home/$o_user/.usr"
29 | o_userenvprefix="/home/$o_user/.usr.env"
30 | o_servicedir="$o_userprefix/etc/service"
31 | o_gopath="/home/$o_user/gop"
32 |
--------------------------------------------------------------------------------
/info/meizu-m351/updater-binary-and-partitions.md:
--------------------------------------------------------------------------------
1 | `META-INF/com/mx3/android/updater-script`
2 |
3 | Partition and content
4 |
5 | mmcblk0p7 recovery-uboot.img
6 | mmcblk0p6 ramdisk-uboot.img
7 | mmcblk0p5 zImage
8 | mmcblk0boot0 bootloader.img or boot.img
9 | mmcblk0p1 /system
10 | mmcblk0p4 /custom, may delete `/custom/meizu/` if `/custom/simlock.key` does not exist
11 |
12 | See `drivers/mmc/card/block.c:init_extra_partition()` for details.
13 |
14 | Part info from `bootinfo` are added with index 5 as base. That means `PART_REC_PRIV` will be available as `mmcblk0p[5 + PART_KERNEL]`, i.e. `mmcblk0p12`
15 |
16 | In normal mode, `PART_REC_PRIV` is the only partition exported in kernel.
17 |
18 | - bootable/recovery, https://android.googlesource.com/platform/bootable/recovery
19 | - Android notes on OTA, http://www.efalk.org/Docs/Android/ota.html#Edify
20 | - (possibly outdated), https://source.android.com/devices/tech/ota/inside_packages.html
--------------------------------------------------------------------------------
/shell/tunnels/tunnel-gre.sh:
--------------------------------------------------------------------------------
1 | tunnel_setup() {
2 | local name="$1"
3 | local l="${2%%:*}"
4 | local r="${3%%:*}"
5 | local ipl="${2##*:}"
6 | local ipr="${3##*:}"
7 | local dev="$4"
8 |
9 | # also works with ipip tunnel
10 | tunnel_teardown "$name"
11 | sudo ip tunnel add "$name" mode gre local "$l" remote "$r" dev "$dev"
12 | sudo ip addr add local "$ipl" peer "$ipr" dev "$name"
13 | sudo ip link set "$name" up
14 | }
15 |
16 | tunnel_teardown() {
17 | local name="$1"
18 |
19 | sudo ip tunnel del "$name" 2>/dev/null
20 | }
21 |
22 | # value consists of 2 parts
23 | # - ip address for tunnel endpoint
24 | # - ip address to be assigned for the tunnel interface
25 | endlocal="192.168.22.250:1.2.3.3"
26 | endremote="192.168.3.198:1.2.3.4"
27 |
28 | # viewpoint of local host: self
29 | self="$(hostname)"
30 | if [ "$self" = "debian" ]; then
31 | tunnel_setup foo "$endlocal" "$endremote" eth0
32 | else
33 | tunnel_setup foo "$endremote" "$endlocal" eth0
34 | fi
35 |
--------------------------------------------------------------------------------
/python/example-traceback.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # - Internal types, https://docs.python.org/2/reference/datamodel.html#types
3 | # - sys.exc_info(), https://docs.python.org/2/library/sys.html#sys.exc_info
4 |
5 | import sys
6 |
7 | def show_tb():
8 | tb = sys.exc_info()[2]
9 | print '>' * 5
10 | while True:
11 | if tb is None:
12 | break
13 | frame = tb.tb_frame
14 | lineno = tb.tb_lineno
15 | code = frame.f_code
16 | funcname = code.co_name
17 | filename = code.co_filename
18 | print '%s:%d: in function %s' % (filename, lineno, funcname)
19 | tb = tb.tb_next
20 |
21 | def f():
22 | def g():
23 | def h():
24 | raise Exception('hello')
25 | def i():
26 | show_tb()
27 | try:
28 | h()
29 | except:
30 | i()
31 | i()
32 | raise Exception('world')
33 | g()
34 |
35 | try:
36 | f()
37 | except:
38 | show_tb()
39 |
40 |
--------------------------------------------------------------------------------
/python/datetime-epoch.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # encoding: utf-8
3 |
4 | import time
5 | import re
6 | from datetime import datetime
7 |
8 | # https://docs.python.org/2/library/time.html
9 | # https://docs.python.org/2/library/datetime.html
10 |
11 | _s = (
12 | r'^'
13 | r'(?P\d{4})年 (?P\d\d)月 (?P\d\d)日'
14 | r'.*'
15 | r'(?P