This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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[''] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# borrowed from https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit | |
import os | |
import sys | |
import re | |
import subprocess | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some problem tobe solved! | |
# ========================= | |
# 1. Can you setup the whole system? | |
# 2. Is the benchmark good enough? | |
# 3. Can this auth by user/password? | |
user=$1 | |
GRAPHITE_ROOT=/opt/graphite | |
# mkdir -p /opt/graphite/data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QueryProcessor(): | |
FILTER_DICT = { | |
# f ==> field; v ==> value; | |
'contains' : lambda f, v: f.contains(v), | |
'~contains' : lambda f, v: ~f.contains(v), | |
'ilike' : lambda f, v: f.ilike(u'%{}%'.format(v)), | |
'~ilike' : lambda f, v: ~f.ilike(u'%{}%'.format(v)), | |
'like' : lambda f, v: f.like(u'%{}%'.format(v)), | |
'~like' : lambda f, v: ~f.like(u'%{}%'.format(v)), | |
'in' : lambda f, v: f.in_(v), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: supervisord | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Example initscript | |
# Description: This file should be used to construct scripts to be | |
# placed in /etc/init.d. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import os | |
import sys | |
import json | |
import uuid | |
import tempfile | |
from flask import Flask, request, Response, g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding: utf-8 | |
import sys | |
import time | |
from datetime import datetime | |
from flask import Flask | |
from flask.ext.cache import Cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func worker(linkChan chan string, wg *sync.WaitGroup) { | |
// Decreasing internal counter for wait-group as soon as goroutine finishes | |
defer wg.Done() | |
for url := range linkChan { | |
// Analyze value and do the job here | |
} | |
} | |
func main() { |