Skip to content

Instantly share code, notes, and snippets.

@finghine
finghine / build_openvpn.sh
Created June 9, 2017 03:37
用docker创建openvpn脚本
#!/bin/bash
# 配置文件所在目录
CONFIG_DIR='/home/ff/ovpn-data-example'
# 服务器ip
# SERVER_DOMAIN_IP='192.168.2.133'
SERVER_DOMAIN_IP=`curl -s ipinfo.io/ip`
# 暴露的 UDP 端口
EXPORT_PORT='1194'
# 客户端名字
@finghine
finghine / anyconnect_run_docker.sh
Created May 22, 2017 10:31
docker 运行anyconnect
#!/bin/bash
sudo apt-get install Docker.io
sudo docker run -d --privileged -p 8123:443 --name anyconnect -v $HOME/certs:/certs treelite/anyconnect
@finghine
finghine / anyconnect_build_cert.sh
Last active April 30, 2020 17:57
创建anyconnect证书脚本
#!/bin/bash
sudo apt-get install gnutls-bin -y
if [ ! -d "~/certs" ]; then
mkdir ~/certs
fi
cd ~/certs
# 获取本地ip
MYIP=`curl -s ipinfo.io/ip`
# 生成ca模版
echo -e "cn = \"${USER}\"\norganization = \"${USER}\"\nserial = 1\nexpiration_days = 3650\nca\nsigning_key\ncert_signing_key\ncrl_signing_key" > ca.tmpl
@finghine
finghine / hexo_build_blog.sh
Created May 21, 2017 13:12
用hexo 创建 blog 脚本
#!/bin/bash
# 用hexo 创建 blog 脚本
sudo apt-get update
sudo apt-get install npm nodejs-legacy git -y
sudo npm install hexo-cli -g
# 初始化
hexo init ~/blog
cd ~/blog
npm install
@finghine
finghine / watchdog.py
Last active June 15, 2017 14:55
监视文件变化 watchdog
from watchdog.observers import Observer
from watchdog.events import *
import time
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
class FileEventHandler(FileSystemEventHandler):
def __init__(self):
@finghine
finghine / 0_reuse_code.js
Created June 8, 2016 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@finghine
finghine / multithread.py
Last active June 8, 2016 13:58
python multihread example
#encoding:utf-8
# multithread
import threading
import Queue
import time
# 实现initQuenue
# 实现testfun
# 修改线程数
MAX_QUEUE_SIZE = 10001
@finghine
finghine / pythonloguse.py
Last active May 28, 2016 03:19
python log use
#encoding:utf-8
import logging
# 创建一个logger
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG)
# 创建一个handler,用于写入日志文件
fh = logging.FileHandler('test.log')
@finghine
finghine / gencert.py
Created May 13, 2016 01:23 — forked from toolness/gencert.py
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@finghine
finghine / m2crypto-certificates.py
Created May 12, 2016 11:26 — forked from eskil/m2crypto-certificates.py
Example of generating CA certs and CA signed certs using python m2crypto.
"""
Tools for creating a CA cert and signed server certs.
Divined from http://svn.osafoundation.org/m2crypto/trunk/tests/test_x509.py
The mk_temporary_xxx calls return a NamedTemporaryFile with certs.
Usage ;
# Create a temporary CA cert and it's private key
cacert, cakey = mk_temporary_cacert()