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 time | |
class Timer(object): | |
def __init__(self, verbose=False): | |
self.verbose = verbose | |
def __enter__(self): | |
self.start = time.time() | |
return self |
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 sys | |
from functools import wraps | |
class TraceCalls(object): | |
""" Use as a decorator on functions that should be traced. Several | |
functions can be decorated - they will all be indented according | |
to their call depth. | |
""" | |
def __init__(self, stream=sys.stdout, indent_step=2, show_ret=False): | |
self.stream = stream |
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
; Sample supervisor config file. | |
[unix_http_server] | |
file=/tmp/supervisor.sock ; (the path to the socket file) | |
;chmod=0700 ; sockef file mode (default 0700) | |
;chown=nobody:nogroup ; socket file uid:gid owner | |
;username=user ; (default is no username (open server)) | |
;password=123 ; (default is no password (open server)) | |
;[inet_http_server] ; inet (TCP) server disabled by default |
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 | |
# happyhouse is my home wifi name | |
happyhouse=`airport -s | grep happyhouse | wc -l` | |
if [ "${happyhouse//[[:space:]]}" = '1' ]; then | |
networksetup -setmanual wi-fi 192.168.2.129 255.255.255.0 192.168.2.1 | |
networksetup -setdnsservers wi-fi 192.168.2.1 | |
fi |
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
###### | |
# 本归档每周末收录当周的Tips | |
###### | |
# 以root身份执行上一条命令 | |
$ sudo!! | |
# 返回用户主目录 | |
$ cd |
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 struct | |
from mutagen.easyid3 import EasyID3 | |
def decode_gbk_from_unicode(s): | |
l, f = [], [] |
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 jobs.celeryapp import celery | |
@celery.task(name="crons.spider.add") | |
def add(x, y): | |
try: | |
raise Exception('This is a Exception') | |
return x + y | |
except Exception, exc: | |
raise add.retry(exc=exc, countdown=5, max_retries=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
<#ftl strip_whitespace=true> | |
<#import "spring.ftl" as spring /> | |
<#-- This file contains form-related macros for use in the other Freemarker template files. | |
The generated HTML is intended for use with Twitter Bootstrap based forms. --> | |
<#-- | |
* radioButtons | |
* | |
* @param path the name of the field to bind to |
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
repositories { | |
mavenCentral() | |
mavenLocal() | |
maven { | |
url = mavenRepoPublicUrl | |
} | |
} |
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
2016-09-29 15:51:15,463 main DEBUG Initializing configuration XmlConfiguration[location=/Users/pat/Software/skywalking/installer/config/log4j2.xml] | |
2016-09-29 15:51:15,465 main DEBUG PluginManager 'Core' found 77 plugins | |
2016-09-29 15:51:15,465 main DEBUG PluginManager 'Level' found 0 plugins | |
2016-09-29 15:51:15,466 main DEBUG PluginManager 'Lookup' found 13 plugins | |
2016-09-29 15:51:15,468 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. Searching for builder factory method... | |
2016-09-29 15:51:15,470 main DEBUG Found builder factory method [newBuilder]: public static org.apache.logging.log4j.core.layout.PatternLayout$Builder org.apache.logging.log4j.core.layout.PatternLayout.newBuilder(). | |
2016-09-29 15:51:15,481 main DEBUG TypeConverterRegistry initializing. | |
2016-09-29 15:51:15,481 main DEBUG PluginManager 'TypeConverter' found 21 plugins | |
2016-09-29 15:51:15,495 main DEBUG Calling build() on class class org.apache.logging.log4j.core.layout.PatternLayout$Builde |