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 / ipn-fix-show-list.user.js
Last active March 17, 2017 07:00
以固定顺序显示 ipn.li 首页的节目列表。
// ==UserScript==
// @name IPN - Fixed show list on homepage
// @namespace org.sorz.lab.ipn
// @include https://ipn.li/
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-3.2.0.slim.min.js
// ==/UserScript==
let items = $('.showList > li').toArray();
@sorz
sorz / Transmission-DMHY.user.js
Created March 10, 2017 09:00
Upload a torrent on Transmission Web Interface by pasting URL of thread on share.dmhy.org directly.
// ==UserScript==
// @name Transmission-DMHY
// @namespace org.sorz.lab.transmission-dmhy
// @include https://example.com/transmission/web/*
// @version 1
// @grant GM_xmlhttpRequest
// @require http://code.jquery.com/jquery-3.1.1.slim.min.js
// ==/UserScript==
const ICON = 'https://share.dmhy.org/favicon.ico';

在 Nexus 5X 上使用中国电信(澳门)卡遇到的问题及可能的解决方案

症状

  • 中国电信(澳门)的电话卡插入美版 Nexus 5X 有信号能打电话发短信,但是不能上网。
  • 设置菜单中找不到 APN 相关选项,强行打开 APN 设置页面后提示「没有权限修改设置」。

注:由于手头的 Nexus 5X 已坏,无法对照操作,以下步骤在细节上可能有所出入。

方法一

@sorz
sorz / TweetdeckHDAvatar.user.js
Created February 5, 2017 17:25
Change "normal" size avatar pictures to "bigger" size on Tweetdeck.
// ==UserScript==
// @name HD Avatar for Tweetdeck
// @namespace org.sorz.lab.tweetdeck
// @include https://tweetdeck.twitter.com/
// @version 0.1
// @grant none
// @require https://cdn.rawgit.com/jpillora/xhook/1.3.5/dist/xhook.min.js
// ==/UserScript==
const REGEX_AVATAR_URL = /(\/profile_images\\\/\d+\\\/[\w-]+_)(normal)(\.)/g
@sorz
sorz / adb2dnsmasq.py
Last active January 22, 2017 18:02
Adblock list & domain-only list to dnsmasq's configuration. (NXDOMAIN returned by dnsmasq instead of 127.0.0.1 or sort of thing on hosts-file-based solution.)
#!/usr/bin/env python3
import re
import sys
RE_HOST = r'^\|\|([a-z0-9\.\-]+[a-z]+[a-z0-9\.\-]+)\^$'
def main():
re_host = re.compile(RE_HOST)
for line in sys.stdin:
#!/usr/bin/env python3
import sys
import math
from ipaddress import IPv4Network
def main():
for line in sys.stdin:
if 'CN' not in line or 'ipv4' not in line:
continue
@sorz
sorz / iperf3-cong-test-raw.txt
Last active December 5, 2016 10:11
Vultr SYD to Chinanet FOC (50Mbps), 10 groups, 30s interval between groups. Linux 4.9.0-rc8-mainline.
# 1 - cubic
Connecting to host ***, port 5201
[ 4] local 45.63.*.* port 45594 connected to 110.84.*.* port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 142 KBytes 1.16 Mbits/sec 1 9.84 KBytes
[ 4] 1.00-2.00 sec 23.9 KBytes 196 Kbits/sec 2 16.9 KBytes
[ 4] 2.00-3.00 sec 12.7 KBytes 104 Kbits/sec 4 11.2 KBytes
[ 4] 3.00-4.00 sec 63.3 KBytes 519 Kbits/sec 3 5.62 KBytes
[ 4] 4.00-5.00 sec 0.00 Bytes 0.00 bits/sec 0 7.03 KBytes
[ 4] 5.00-6.00 sec 63.3 KBytes 518 Kbits/sec 1 5.62 KBytes
@sorz
sorz / defer_to_imap.py
Created November 21, 2016 11:17
Script to check postfix's mail queue and forward all deferred mails via IMAP.
#!/usr/bin/env python3
"""
Script to check postfix's mail queue and forward all deferred mails via IMAP.
Forwarded mails will be removed from queue.
Only handle mails in deferred queue and whose's (one of) recipients is EMAIL.
"""
from imaplib import IMAP4_SSL
from subprocess import check_output
import json
@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
import requests
URL = 'http://speedtest-sfo1.digitalocean.com/10mb.test'
headers = {'User-Agent': '-.-'}
resp = requests.get(URL, headers=headers, stream=True)
totalsize = int(resp.headers.get('content-length', '0'))
with open('10mb.test', 'wb') as f:
downsize = 0