Skip to content

Instantly share code, notes, and snippets.

View Gowee's full-sized avatar
🙂

Hung-I Wang Gowee

🙂
View GitHub Profile
# -*- coding: utf8 -*-
# To be deployed to Tecent SCF
# https://console.cloud.tencent.com/scf/
import json
def main_handler(event, context):
srcip = event['requestContext']['sourceIp']
dest_url = "https://water-meter.bamboo.workers.dev/callback?ip=" + srcip
resp = {
"isBase64Encoded": False,
@Gowee
Gowee / openingsourceorg.iv
Last active September 30, 2021 08:21
The Telegram InstantView template rule for OpeningSource.org
# Maintained by: Hung-I WANG <whygowe@gmail.com>
~version: "2.1"
# e.g. `/1234`, `/1234/zh-tw`
?path: /\d+/(\w+/)?
# # The Telegram IV parser treats the webpage incorrectly, which results in mal-structured HTML/XML. Here try to fix it by rewrapping <meta> into <head> and moving them to the front of <body>.
# @prepend("<head>"): /html
# @prepend_to($@): //meta
@Gowee
Gowee / tomato-renew-tls-cert.sh
Created June 25, 2021 01:20
Shell script for renewing the TLS cert of the WebUI of AdvancedTomato
#!/bin/sh
# The script is simply adapted from:
# https://codeinsecurity.wordpress.com/2020/03/08/setting-a-custom-https-certificate-in-tomato-or-advancedtomato/
# The script is expected to work with uacme with a hook script:
# https://gist.github.com/Gowee/e756f925cfcbd5ab32d564ee3c795786
set -eu
FQDN="foobar.example.org" # TO BE FILLED
UACME_HOOK=/path/to/uacme-hook.sh # TO BE FILLED
@Gowee
Gowee / uacme-cloudflare-hook.sh
Last active April 23, 2025 11:21
DNS-01 challenge hook script of uacme for Cloudflare
#!/bin/sh
# Copyright (C) 2020 Michel Stam <michel@reverze.net>
# Copyright (C) 2021 Hung-I Wang <whygowe@gmail.com>
#
# The script is adatped from:
# https://github.com/ndilieto/uacme/blob/5edec0eea1bcf6f454ec1787297c2408c2f2e97a/nsupdate.sh
#
# Licensed under the the GNU General Public License <http://www.gnu.org/licenses/>.
# The script is meant to be used as a hook script of uacme to update TXT records for acme challenges.
@Gowee
Gowee / nlc-getbook.js
Last active August 16, 2024 06:06
Download PDF from read.nlc.cn
async function downloadBook(aid, bid) {
const [title, myreader, kime, fime] = await getBookKey(aid, bid)
const r = await fetch(`http://read.nlc.cn/menhu/OutOpenBook/getReader?aid=${aid}&bid=${bid}&kime=${kime}&fime=${fime}`, { method: "POST", headers: { myreader: myreader }})
const d = await r.arrayBuffer()
saveByteArray(title + ".pdf", d)
}
async function getBookKey(aid, bid) {
const r = await fetch(`http://read.nlc.cn/OutOpenBook/OpenObjectBook?aid=${aid}&bid=${bid}`)
@Gowee
Gowee / cipher.java
Last active October 11, 2020 07:51
对360的绿光浏览器(Tuber同款)的RE(未完成)
// import com.coloros.mcssdk.c.a;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
//import org.json.JSONObject;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println("Hello world!");
String key1 = key.substring(16, 32);
async function run() {
const contest = 169;
const pages = [...Array(25).keys()].map(v => v + 1);
const question_id = 1429;
const is_cheating = function(code) {
const words = [/*"MONEY", "POINT",*/ "HOPE", "SATURN", "SEIS", "GEMINI", "ELM", "YOUVE", "PLANETS", "PEOPLE", "EHGEEE", "CANCER", "FBCDE", "TWENTY", "TREES", "EUROPE", "ABCDE", "NOVENTA", "EAII", "FUNNY", "ADICG", "FALSE", "TRUE", "EEIE", "THREE", "DHCF", "DHBADI", "INDEED"];
let score = 0;
for (const word of words) {
if (code.indexOf(word) != -1) {
score += 1;
@Gowee
Gowee / cfapi-ddns-worker.js
Last active April 10, 2026 15:03
A DDNS-friendly wrapper/proxy for Cloudflare API with fine-grained permission control, deployed on Cloudflare Workers
// CloudFlare API token
// for zone: example.com (Edit)
const CLOUDFLARE_API_TOKEN = "TO_BE_FILLED";
// Currently, there seems not to be a way to get zone ids with tokens. So hardcode it here.
// https://community.cloudflare.com/t/bug-in-list-zones-endpoint-when-using-api-token/115048
// Trailing dots CANNOT BE OMITTED.
const ZONES = {
"example.org.": {
id: "TO_BE_FILLED"
},
@Gowee
Gowee / proxy_checker.py
Created September 25, 2019 15:09
A python script to validate HTTP proxies with aiohttp, a side project of https://github.com/Gowee/NEMUserCrawler
#!/usr/bin/env python3
import asyncio
import aiohttp
import re
import sys
import time
from collections import namedtuple
from functools import wraps
@Gowee
Gowee / WSExport-zh.js
Created August 22, 2019 12:00
適用于中文維基文庫的 WSExport 小工具(以 common.js 導入)
// WSExport [[mul:Wikisource:WSexport]]
// > WSexport is a tool for exporting Wikisource's texts in EPUB, PDF and other file formats. It was created by user Tpt for French Wikisource, but it's also available for the other Wikisource subdomains.
// Copied from https://en.wikisource.org/w/load.php?lang=en&modules=ext.gadget.Easy_LST%2CPurgeTab%2CWSexport%2Ccharinsert%2CcollapsibleTables%2CdynamicLayoutOverrides&skin=vector&version=01fx33l
// and modified slightly to adapt to Chinese WikiSource by Gowee@Github.
if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 114]) !== -1) {
$(function() {
mw.util.addPortletLink('p-electronpdfservice-sidebar-portlet-heading', '//tools.wmflabs.org/wsexport/tool/book.php?' + $.param({
lang: 'zh',
format: 'epub-3',
page: mw.config.get('wgPageName')