Skip to content

Instantly share code, notes, and snippets.

View sorz's full-sized avatar
😱
AAHHH

Shell Chen sorz

😱
AAHHH
View GitHub Profile
@sorz
sorz / aqi_tray.pyw
Last active September 2, 2020 05:32
Simple program that shows AQI on system tray as a colored pie chart.
#!/usr/bin/env python3
"""Simple program that shows AQI on system tray as a colored pie chart.
It fetches PM_2.5 data via Graphite's HTTP API every minutes.
Required Python packages:
requests, pystray, Pillow
"""
import time
import webbrowser
@sorz
sorz / httpdns.py
Created August 14, 2020 08:32
Lastest update on 2019-10-31. Mocked service may have changed since then. Compatibility issues expected.
#!/usr/bin/env python3
import asyncio
import logging
from aiohttp import web
from aiodnsresolver import Resolver, TYPES, DnsRecordDoesNotExist
from des import DesKey
TENCENT_KEYS = {
@sorz
sorz / DS1307.py
Last active September 5, 2019 19:48
Read and wite datetime on DS1307 via I2C by Python.
#!/usr/bin/env python
#encoding: utf-8
# Copyright (C) 2013 @XiErCh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
[Unit]
Description=Setup WireGuard link
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
@sorz
sorz / paheal-downloader.py
Last active August 6, 2018 07:12
Download all images from rule34.paheal.net, with multithreading, existing files ignored.
#!/usr/bin/env python3
from threading import Thread
from urllib.parse import unquote
from pathlib import Path
from queue import Queue
import requests
import os.path
import sys
import re
@sorz
sorz / paste.conf
Last active July 8, 2018 08:11
Source code of paste.sorz.org
server {
server_name example.com;
charset utf-8;
location ~ "/t/([^/]+)(/[^/]+)?$" {
alias /srv/http/paste/data/$1;
gunzip on;
gzip_static always;
default_type text/plain;
@sorz
sorz / check_release.py
Last active May 12, 2018 13:57
Sending new release notification (via email) for GitHub repos.
#!/usr/bin/env python3
"""GitHub New Release Checker
./check_release.py path/to/releases.ini
It fetches release tag from GitHub, then comparing it with the
old one in ini file. If tag changed, send a email to configured
address.
"""
import re
[Unit]
Description=Comment sender for example.com
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=/usr/bin/python3 /opt/comment-sender/sender.py
PrivateDevices=True
@sorz
sorz / ah.plain.txt
Last active March 26, 2018 15:10
`curl sorz.org`
-oooooooooooo- -::::::::::::::::::::-
.---------. oMMMMMMMMMMMM+ dMMMMMMMMMMMMMMMMMMMMM.
.NMMMMMMMMMN` oMMN:...-yMMM: /+++++++++++++yMMMo+++`
.NMMhyyydMMN` oMMN. `mMMd /MMN`
.NMM/ oMMN` oMMN. +MMN: /MMN`
.NMM/ oMMN` oMMN. `dMMs /MMN`
.NMM/ oMMN` oMMN. /MMN. -hhhhhhhhhh/ /MMN`
.NMM/ oMMN` oMMN. dMMo :MMMNmmmNMMs /MMN`
.NMM/ oMMN` oMMN. +MMN. :MMN.```yMMs /MMN`
@sorz
sorz / matriahix.sh
Created March 10, 2018 07:24
Copy from http://bruxy.regnet.cz/web/linux/EN/matrix-sh/, just change random chars to 啊.
#!/bin/bash
echo -e "\033[2J\033[?25l"; R=`tput lines` C=`tput cols`;: $[R--] ; while true
do ( e=echo\ -e s=sleep j=$[RANDOM%C] d=$[RANDOM%R];for i in `eval $e {1..$R}`;
do c=`printf '啊'` # fork from http://bruxy.regnet.cz/web/linux/EN/matrix-sh/ #
$e "\033[$[i-1];${j}H\033[32m$c\033[$i;${j}H\033[37m"$c; $s 0.1;if [ $i -ge $d ]
then $e "\033[$[i-d];${j}H ";fi;done;for i in `eval $e {$[i-d]..$R}`; #[mat!rix]
do echo -e "\033[$i;${j}f ";$s 0.1;done)& sleep 0.05;done #(c) 2011 -- [ BruXy ]