Skip to content

Instantly share code, notes, and snippets.

View Gowee's full-sized avatar
🙂

Hung-I Wang Gowee

🙂
View GitHub Profile
@Gowee
Gowee / getRawPostData.php
Created November 12, 2015 12:43
alternative for file_get_contents("php://input");
<?php
function getRawPostData(){
$eol = "\r\n";
$BOUNDARY = substr(ltrim(explode(";", $_SERVER["CONTENT_TYPE"])[1]), strlen("boundary="));
$postData = "";
foreach($_POST as $name => $value){
$postData .= "--" . $BOUNDARY . $eol;
$postData .= 'Content-Disposition: form-data; name="' . $name . '"' . $eol . $eol;
$postData .= $value . $eol;
}
@Gowee
Gowee / pptpclient@.service
Last active December 3, 2016 05:07
systemd service script for pptpclient
# Modified from OpenVPN systemd service script.
[Unit]
Description=PPTP Client connection to %I
After=syslog.target network.target network-online.target
[Service]
PrivateTmp=true
Type=forking
ExecStart=/usr/bin/pon %i persist
PIDFile=/run/ppp0.pid
@Gowee
Gowee / README.md
Last active September 20, 2018 02:43
To help detect being added into unknown groups on Telegram.

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 / telegram_reborn.py
Created December 24, 2018 07:14
"Reborn" in groups on Telegram (
#!/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)
#!/usr/bin/env python3
import urllib.request
import re
from collections import namedtuple
from math import log
def ip2num(ip_address: str) -> int:
a, b, c, d = map(int, ip_address.split("."))
return (a << 24) + (b << 16) + (c << 8) + d
@Gowee
Gowee / cnmooc.py
Created March 1, 2019 17:22
Get video links from chinesemooc.org
#!/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 January 19, 2019 03:59
openwrt /etc/init.d/relayd
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 / README.md
Last active July 26, 2019 15:10
tinc split-tunnel with ipset

left emtpy

@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')
@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