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 sys | |
import time | |
import math | |
import re | |
import telnetlib | |
import random | |
from collections import namedtuple, defaultdict |
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
[Unit] | |
Description=High-performance, schema-free document-oriented database | |
After=syslog.target network.target | |
[Service] | |
Type=forking | |
User=mongod | |
PIDFile=/var/run/mongod/mongod.pid | |
EnvironmentFile=/etc/sysconfig/mongod | |
ExecStart=/usr/bin/mongod -f /etc/mongod.conf run |
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
from itertools import chain, tee, izip | |
# A | |
def pairwise(iterable): | |
"s -> (s0,s1), (s1,s2), (s2, s3), ..." | |
a, b = tee(iterable) | |
next(b, None) | |
return izip(a, b) | |
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
def convert(ordinal): | |
"""Convert Excel Date type""" | |
sd = datetime.date(1899, 12, 31) - datetime.timedelta(days=1) | |
return datetime.datetime.fromordinal(int(ordinal) + sd.toordinal()) |
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
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -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
// In task configuration, use `expand: true` and `rename: stripVersion` | |
var stripVersion = function (dest, src) { | |
var path = require('path'); | |
return path.join(dest, src.replace(/-\d+\.\d+\.\d+(\.min)?/, '')) | |
} |
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
function getAstro(m, d) { | |
return "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(m*2-(d<"102123444543".charAt(m-1)- -19)*2,2); | |
} |
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
import unicodedata | |
import re | |
chars = (unichr(i) for i in xrange(0x110000)) | |
cc = ''.join(c for c in chars if unicodedata.category(c) == 'Cc') | |
# or equivalently and much more efficiently | |
cc = ''.join(map(unichr, range(0,32) + range(127,160))) | |
cc_re = re.compile('[%s]' % re.escape(cc)) |
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
# Firewall configuration written by system-config-firewall | |
# Manual customization of this file is not recommended. | |
*nat | |
:PREROUTING ACCEPT [10:532] | |
:INPUT ACCEPT [0:0] | |
:OUTPUT ACCEPT [0:0] | |
:POSTROUTING ACCEPT [0:0] | |
# PPTP | |
-A POSTROUTING -s 10.18.1.0/24 -o eth0 -j MASQUERADE |
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 | |
MEM=$(cat /proc/meminfo | ack 'MemFree: +(\d+)' --output "\$1" | bc) | |
CAC=$(cat /proc/meminfo | ack '^Cached: +(\d+)' --output "\$1" | bc) | |
FREE=$(echo "$MEM + $CAC" | bc) | |
THRESHOLD=1048576 | |
echo "Free Memory: $MEM kb" |