Skip to content

Instantly share code, notes, and snippets.

View zengxs's full-sized avatar

Xiangsong Zeng zengxs

  • Singapore/London
  • 13:11 (UTC +08:00)
View GitHub Profile
@zengxs
zengxs / CharacterCast.java
Created May 9, 2016 06:10
第18章 图形界面 -> 习题4 编写程序,在文本框中输入英文字母,再根据“大写字母按钮”或“小写字母按钮”将输入的内容进行转换, 并将转换后的结果显示在标签上。
import javax.swing.*;
import java.awt.*;
public class CharacterCast {
private JFrame frame;
private JTextField textField;
private JButton lowerButton;
private JButton upperButton;
private JLabel label;
@zengxs
zengxs / openssl.cnf
Created June 5, 2016 12:35
libressl configuration file
[ req ]
#default_bits = 2048
#default_md = sha256
#default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_min = 2
@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 / 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 / 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 / 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}
#!/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 / [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.

@zengxs
zengxs / math.md
Last active March 21, 2018 09:10

logistic regression model

模型

预测函数

loss function

@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