Skip to content

Instantly share code, notes, and snippets.

View zengxs's full-sized avatar

Xiangsong Zeng zengxs

  • Singapore/London
  • 23:36 (UTC +08:00)
View GitHub Profile
@zengxs
zengxs / math.md
Last active March 21, 2018 09:10

logistic regression model

模型

预测函数

loss function

@zengxs
zengxs / [README]aria2-build.md
Last active December 22, 2017 12:08
Aria2 appveyor auto build

Aria2 build

Aria2 auto build scripts with custom patch for appveyor ci with msys2.

#!/usr/bin/env python3
import subprocess
import threading
from queue import Queue
tailq = Queue(maxsize=10)
def tail(filename):
p = subprocess.Popen(
['tail', '-f', filename], # args
@zengxs
zengxs / tex2img.py
Created August 13, 2017 13:22
a script to convert latex formula to png and svg
import os
import subprocess
from hashlib import md5
from tempfile import TemporaryDirectory
TEX_TEMPLATE = r'''
\documentclass{article}
\usepackage[utf8]{inputenc}
@zengxs
zengxs / authorize.py
Last active July 5, 2017 02:35
Let's Encrypt Acme Client Protocol Implementation
import base64
import copy
import hashlib
import json
import logging
import time
from collections import namedtuple
import requests
@zengxs
zengxs / jwk_to_pem.py
Created July 2, 2017 00:50
Convert JWK(JSON Web Key) to Private Key(PEM)
#!/usr/bin/env python3
#
# pip install cryptography, pyjwt
from jwt.utils import (
base64url_decode,
bytes_to_number,
)
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
@zengxs
zengxs / dns-server.c
Last active February 27, 2017 07:26
Sample dns server written in C with libuv
/*
* Licensed under the MIT License <https://opensource.org/licenses/MIT>.
* Copyright (c) 2017 Matsuz <xiangsong.zeng@gmail.com>
*
* 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
* furnished to do so, subject to the following conditions:
@zengxs
zengxs / chromium-fontrender-adjust.css
Last active December 24, 2016 06:43
font render adjust for chromium
* {
text-shadow: 0.01px 0.01px 0.01px #7c7c7c !important;
}
/*
Fonts Setting:
Standard : Microsoft YaHei
Serif : SimSun
San-Serif : Microsoft YaHei
Monospace : Consolas
@zengxs
zengxs / chinadns.service
Created November 24, 2016 12:06
Systemd unit file for chinadns
# Systemd unit file for chinadns
[Unit]
Description=Protect yourself against DNS poisoning in China
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/opt/chinadns/chinadns -b 0.0.0.0 -p 5353 -c /opt/chinadns/chnroute.txt -s "8.8.8.8:53,8.8.4.4:53"
ExecStop=/bin/kill -15 $MAINPID
@zengxs
zengxs / rainy-proxy.go
Last active March 19, 2020 06:42
a simple http-proxy program use goproxy, with basic auth
package main
import (
"log"
"net/http"
"github.com/elazarl/goproxy"
"github.com/elazarl/goproxy/ext/auth"
)