Skip to content

Instantly share code, notes, and snippets.

View TheWaWaR's full-sized avatar
🌀
Focusing

LingFeng TheWaWaR

🌀
Focusing
View GitHub Profile
@TheWaWaR
TheWaWaR / gen_cert.sh
Last active July 7, 2017 01:41
Shell script to generate SSL/TLS certificate in macOS.
########################################
# $ tree $HOME/local/etc/TLS
# .
# |-- CA
# | |-- index.txt
# | |-- index.txt.attr
# | |-- newcerts
# | | |-- 01.pem
# | | `-- 02.pem
# | |-- private
extern crate threadpool;
extern crate futures;
extern crate tokio_core;
use std::env;
use std::thread;
use std::net::SocketAddr;
use futures::Sink;
use futures::sync::mpsc::{channel, Receiver};
extern crate libc;
extern crate threadpool;
extern crate futures;
extern crate tokio_core;
use std::env;
use std::net::SocketAddr;
// use std::sync::mpsc::{channel, Receiver};
@TheWaWaR
TheWaWaR / prometheus-grafana.json
Created December 7, 2016 07:12
Grafana prometheus configuration
{
"id": 29,
"title": "Prometheus - Demo Dashboard",
"tags": [
"prometheus",
"node",
"misc"
],
"style": "dark",
"timezone": "browser",
@TheWaWaR
TheWaWaR / agent.py
Created December 7, 2016 07:10
Statsd host metrics (python psutil)
#!/usr/bin/env python
# coding: utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os
import time
# Example YAML to get you started quickly.
# Be aware that YAML has indentation based scoping.
# Code completion support is available so start typing for available options.
swagger: '2.0'
# This is your document metadata
info:
version: "0.0.0"
title: <enter your title>
@TheWaWaR
TheWaWaR / mini-termcolor.py
Created July 22, 2016 06:59
Mini termcolor
# coding: utf-8
"""ANSII Color formatting for output in terminal. (termcolor-1.1.0)"""
import os
ATTRIBUTES = dict(list(zip(['bold', 'dark', '', 'underline',
'blink', '', 'reverse', 'concealed'],
list(range(1, 9)))))
del ATTRIBUTES['']
@TheWaWaR
TheWaWaR / apscheduler-test.py
Last active May 16, 2021 09:14
<Advanced Python Scheduler> date trigger example
# coding: utf-8
import os
import time
from datetime import datetime, timedelta
from pytz import utc, timezone
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.executors.pool import ThreadPoolExecutor
@TheWaWaR
TheWaWaR / gist:373250e00f004d551872ba73556f84c8
Created May 17, 2016 07:55 — forked from danaspiegel/gist:3105761
Git pre-commit hook to check pep8 and pyflakes
#!/usr/bin/python
# borrowed from https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit
import os
import sys
import re
import subprocess
@TheWaWaR
TheWaWaR / chinese-html-diff.py
Last active April 21, 2016 06:18
HTML diff (支持中文断句)
#coding: utf-8
## 支持中文断句
punctuation = u'\uff02\uff03\uff04\uff05\uff06\uff07\uff08\uff09\uff0a\uff0b\uff0c\uff0d\uff0f\uff1a\uff1b\uff1c\uff1d\uff1e\uff20\uff3b\uff3c\uff3d\uff3e\uff3f\uff40\uff5b\uff5c\uff5d\uff5e\uff5f\uff60\uff62\uff63\uff64\u3000\u3001\u3003\u3008\u3009\u300a\u300b\u300c\u300d\u300e\u300f\u3010\u3011\u3014\u3015\u3016\u3017\u3018\u3019\u301a\u301b\u301c\u301d\u301e\u301f\u3030\u303e\u303f\u2013\u2014\u2018\u2019\u201b\u201c\u201d\u201e\u201f\u2026\u2027\ufe4f\ufe51\ufe54\xb7\uff01\uff1f\uff61\u3002'
import re
from lxml.html import diff
diff.split_words_re = re.compile(r'[^\s%(p)s]+(?:[\s%(p)s]+|$)' % dict(p=punctuation), re.U)