Skip to content

Instantly share code, notes, and snippets.

Avatar
🙂

Hung-I Wang Gowee

🙂
View GitHub Profile
@Gowee
Gowee / cfapi-ddns-worker.js
Last active Sep 27, 2021
A DDNS-friendly wrapper/proxy for Cloudflare API with fine-grained permission control, deployed on Cloudflare Workers
View cfapi-ddns-worker.js
// 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 Sep 25, 2019
A python script to validate HTTP proxies with aiohttp, a side project of https://github.com/Gowee/NEMUserCrawler
View proxy_checker.py
#!/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 Aug 22, 2019
適用于中文維基文庫的 WSExport 小工具(以 common.js 導入)
View WSExport-zh.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')
@Gowee
Gowee / README.md
Last active Jul 26, 2019
tinc split-tunnel with ipset
View README.md

left emtpy

@Gowee
Gowee / cnmooc.py
Created Mar 1, 2019
Get video links from chinesemooc.org
View cnmooc.py
#!/usr/bin/env python3
from time import sleep
from collections import namedtuple
import json, re, os, csv
from urllib.parse import parse_qsl, urljoin, urlparse, urlencode
from requests import Session
from requests.cookies import create_cookie
parse_qs = lambda *args, **kwargs: dict(parse_qsl(*args, **kwargs))
Info = namedtuple("CourseInfo", ["name", "teacher"])
@Gowee
Gowee / relayd.patch
Created Jan 19, 2019
openwrt /etc/init.d/relayd
View relayd.patch
3a4,5
> . $IPKG_INSTROOT/lib/functions/network.sh
>
45a48
> local dhcp_ipaddr
47a51,64
> config_get proto "$net" proto
> [ "$proto" = "dhcp" ] && {
> local addrs
> network_get_ipaddr addrs "$net"
@Gowee
Gowee / telegram_reborn.py
Created Dec 24, 2018
"Reborn" in groups on Telegram (
View telegram_reborn.py
#!/usr/bin/env python3
import sys
import json
from functools import partial
from pyrogram import Client, Error
from pyrogram.client.types.user_and_chats.dialog import Dialog
from pyrogram.client.types.user_and_chats.chat import Chat
from pyrogram.api.functions.channels import InviteToChannel
eprint = partial(print, file=sys.stderr)
@Gowee
Gowee / README.md
Last active Sep 20, 2018
To help detect being added into unknown groups on Telegram.
View README.md

A script to help detect being added to new groups on Telegram. When detected, logs are sent to Saved Message with a corresponding tag to facilitate locating.

Usage:

Setup Pyrogram (MTProto) at first: https://docs.pyrogram.ml/start/ProjectSetup.

chmod +x baugd.py
./baugd.py
@Gowee
Gowee / README.md
Created Jun 24, 2018
Rotate the avatar of Telegram based on the time in a day using Pyrogram(MTProto).
View README.md
@Gowee
Gowee / get-cert-issuer.sh
Created Nov 7, 2016
One-line Bash script to fetch the issuer CA certificate of an x509-specified certificate via id-ad-caIssuers of x509.v3 Authority Information Access extension.
View get-cert-issuer.sh
#!/bin/bash
# Maintainer: Gowe Wang<i@gowe.wang>
# Reference: https://tools.ietf.org/html/rfc5280#section-4.2.2.1
# Notice: Just available in most cases.
curl -s $(openssl x509 -in $1 -noout -text | grep -Po "((?<=CA Issuers - URI:)http://.*)$") | openssl x509 -inform DER -outform PEM