Skip to content

Instantly share code, notes, and snippets.

View simon-liu's full-sized avatar
🏠
Working from home

Zenglu Liu simon-liu

🏠
Working from home
View GitHub Profile
@simon-liu
simon-liu / sendmail-cmd.sh
Last active August 16, 2017 01:10
sendmail command
mail.py -s "mail subject" liuzl@yxt.com < mail-content.txt
@simon-liu
simon-liu / doc2dash.sh
Created August 3, 2017 05:28
readthedocs to Docset
doc2dash -A selenium-python-latest
@simon-liu
simon-liu / empty-file.py
Created August 1, 2017 01:33
empty file using python
open(filename, 'w').close()
@simon-liu
simon-liu / firewalld-deny-host.sh
Created July 5, 2017 06:07
firewalld deny host
firewall-cmd --add-rich-rule='rule family="ipv4" service name="mysql" source address="1.2.3.4" drop'
@simon-liu
simon-liu / py-format-date.py
Created July 3, 2017 03:25
python format date
from datetime import *
datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')
@simon-liu
simon-liu / py-set-log-level.py
Created June 29, 2017 07:18
python set log level
logging.getLogger('requests').setLevel(logging.ERROR)
@simon-liu
simon-liu / signal.py
Created June 21, 2017 05:31
python signals
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_DFL)
@simon-liu
simon-liu / mysql-create-db-utf8.sql
Created June 21, 2017 04:35
mysql create db utf8
CREATE DATABASE IF NOT EXISTS octopus DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
git clone --mirror https://github.com/raveren/kint
cd kint.git
git remote add gitlab http://gitlab.example.com/raveren/kint.git
git push gitlab --mirror
git remote remove origin
git remote add origin http://gitlab.example.com/raveren/kint.git
git fetch --all
@simon-liu
simon-liu / watermark.py
Last active August 3, 2017 17:08
python watermark
import os
from PIL import Image, ImageEnhance, ImageDraw, ImageFont
def text2img(text, font_color="Black", font_size=30):
"""生成内容为 TEXT 的水印"""
font = ImageFont.truetype('/Users/liuzenglu/Documents/yahei.ttf', font_size)
# 多行文字处理
text = text.split('\n')