Skip to content

Instantly share code, notes, and snippets.

View zengxs's full-sized avatar

Xiangsong Zeng zengxs

  • Singapore/London
  • 07:05 (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 / tomcat.service
Last active August 14, 2022 17:26
tomcat systemd service script
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
@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 / 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"
)
@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 / 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 / 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 / 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}