Skip to content

Instantly share code, notes, and snippets.

View chenzhuoyu's full-sized avatar

Oxygen chenzhuoyu

View GitHub Profile
@chenzhuoyu
chenzhuoyu / resize.py
Created August 9, 2022 12:00
`resize` tool without installing `xterm`
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import os
import sys
import tty
import fcntl
import struct
import termios
@chenzhuoyu
chenzhuoyu / uartmon.py
Created June 13, 2022 13:32
UART Line Monitor
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import urwid
import signal
import string
import asyncio
import serial_asyncio
@chenzhuoyu
chenzhuoyu / Schneider SPM & SPRM Series UPS Support for Synology DSM 7.md
Last active June 21, 2024 11:40
Schneider SPM & SPRM Series UPS Support for Synology DSM 7

Schneider SPM/SPRM Series UPS Support for Synology DSM 7

Step 1: Connect your UPS and NAS with USB cable

You should see a NEW serial port (like /dev/ttyUSB0) been added to /dev. Remember that for the later steps.

If not, please refer to this GitHub repo for building and installing the driver for CH341 USB to Serial Converter chips.

Step 2: Test the connection

With full reinstall (recommended)

  1. Boot into recovery using ⌘R during reboot, wipe the harddrive using Disk Utility, and select reinstall macOS

  2. Initial installation will run for approximately 1 hour, and reboot once

  3. It will then show a remaining time of about 10-15 minutes

  4. When it reboots again, be sure to press ⌘R to boot into recovery and continue with Main procedure

Keyboard Matrix
A B C D E F G H
1 N M 7 6 J H Y U
2 Num Del NP1 SP NP4 NP7
3 NP/ Ins NP2 NP0 NP5 NP8
4 F12 F10 F9 | F11 BKSP
5 , 8 + K F6 ] I
6 Fn . 9 F8 L F7 O
7 C 3 F2 D F4 F3 E
@chenzhuoyu
chenzhuoyu / http_proxy.py
Created May 11, 2018 08:32
Simple HTTP proxy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import logging
from gevent import socket
from gevent import Greenlet
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
@chenzhuoyu
chenzhuoyu / get_pixiv.py
Created January 26, 2018 18:00
Pixiv downloader without login, requires BeautifulSoup4 and requests to work properly
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import bs4
import sys
import requests
if len(sys.argv) != 2:
print >> sys.stderr, 'usage: ./get_pixiv.py <illustration_url>'
@chenzhuoyu
chenzhuoyu / pf_get_orig_dst.py
Created August 15, 2017 08:40
Get original dest addr for FreeBSD pf
import os
import fcntl
import ctypes
import socket
import struct
PF_OUT = 2
DIOCNATLOOK = 0xc04c4417
class pf_addr(ctypes.Structure):