Skip to content

Instantly share code, notes, and snippets.

View sorz's full-sized avatar
😱
AAHHH

Shell Chen sorz

😱
AAHHH
View GitHub Profile
vm.panic_on_oom=1
kernel.panic=10
# protect against tcp time-wait assassination hazards
net.ipv4.tcp_rfc1337 = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.ip_forward = 1
net.ipv4.tcp_fastopen = 3
public class MultiTable {
public static void printMulti(int row, int col) {
if (row == 0 && col == 0)
System.out.printf(" * ");
else if (col == 0)
System.out.printf("%4d ", row);
else if (row == 0)
System.out.printf("%4d ", col);
else
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
@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 / 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 / hw_smsd.py
Last active December 23, 2016 12:17
Forward SMS to E-mail via Huawei datacard. See https://blog.sorz.org/p/sms2email/ for detial.
#!/usr/bin/env python
#encoding: utf-8
# Copyright (C) 2013 @XiErCh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@sorz
sorz / ddns-hosts.json
Last active January 3, 2017 04:39
DDNS HTTP API
{
"host": "password",
"sorz": "hWUVw79k"
}
#!/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 / 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:
@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