Skip to content

Instantly share code, notes, and snippets.

@sorz
sorz / yubioauth_android_for_canokeys_pigeon.patch
Last active Jan 3, 2022
Patch to yubioauth-android (8fbb3b1) for Canokey Pigeon.
View yubioauth_android_for_canokeys_pigeon.patch
diff --git a/app/src/main/java/com/yubico/yubikitold/transport/usb/UsbDeviceManager.java b/app/src/main/java/com/yubico/yubikitold/transport/usb/UsbDeviceManager.java
index 1e5ed82..060b32f 100644
--- a/app/src/main/java/com/yubico/yubikitold/transport/usb/UsbDeviceManager.java
+++ b/app/src/main/java/com/yubico/yubikitold/transport/usb/UsbDeviceManager.java
@@ -29,7 +29,7 @@ public final class UsbDeviceManager {
private transient UsbDevicePredicate deviceFiler = new UsbDevicePredicate() {
@Override
public boolean test(UsbDevice usbDevice) {
- return usbDevice.getVendorId() == 0x1050;
+ return usbDevice.getVendorId() == 0x1050 || usbDevice.getVendorId() == 0x20A0;
@sorz
sorz / README.md
Created Aug 26, 2021
A simple Prometheus export that collect A/C target temperature & load power from Xiaomi Air Conditioning Companion.
View README.md

Prometheus exporter for Xiaomi A/C Companion

A simple Prometheus export that collect A/C target temperature & load power from Xiaomi Air Conditioning Companion.

It serves as a simple demo, you may expand it to other Mi devices & metrics. See python-miio's document.

View ehviewer-fix-comment.patch
diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java
index 27f9a671..1f541301 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java
@@ -73,7 +73,7 @@ public class GalleryDetailParser {
private static final GalleryTagGroup[] EMPTY_GALLERY_TAG_GROUP_ARRAY = new GalleryTagGroup[0];
private static final GalleryCommentList EMPTY_GALLERY_COMMENT_ARRAY = new GalleryCommentList(new GalleryComment[0], false);
- private static final DateFormat WEB_COMMENT_DATE_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm z", Locale.US);
+ private static final DateFormat WEB_COMMENT_DATE_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm", Locale.US);
@sorz
sorz / aqi_tray.pyw
Last active Sep 2, 2020
Simple program that shows AQI on system tray as a colored pie chart.
View aqi_tray.pyw
#!/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 Aug 14, 2020
Lastest update on 2019-10-31. Mocked service may have changed since then. Compatibility issues expected.
View httpdns.py
#!/usr/bin/env python3
import asyncio
import logging
from aiohttp import web
from aiodnsresolver import Resolver, TYPES, DnsRecordDoesNotExist
from des import DesKey
TENCENT_KEYS = {
View e-hentai-prefetch-next-page.user.js
// ==UserScript==
// @name E-Hentai Prefetch Next Page
// @namespace Violentmonkey Scripts
// @match https://e-hentai.org/s/*
// @match https://exhentai.org/s/*
// @grant none
// @version 0.2.0
// @author sorz
// @description Prefetch image file on the next page for faster browsing.
// ==/UserScript==
View wireguard@.service
[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 / check_release.py
Last active May 12, 2018
Sending new release notification (via email) for GitHub repos.
View check_release.py
#!/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
View comment-sender.service
[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 Mar 26, 2018
`curl sorz.org`
View ah.plain.txt
-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`