Skip to content

Instantly share code, notes, and snippets.

@dlutcat
dlutcat / Timer.py
Created July 30, 2012 09:53
Python execute timer
import time
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
@dlutcat
dlutcat / gist:3487991
Created August 27, 2012 12:25
trace calls
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
@dlutcat
dlutcat / supervisord-example.conf
Created September 3, 2012 02:54 — forked from didip/supervisord-example.conf
Example for supervisord conf file
; 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
@dlutcat
dlutcat / netswitch.sh
Created September 18, 2012 13:17
Auto switch network config between home and office.
#!/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
@dlutcat
dlutcat / linux_tips.sh
Last active December 12, 2015 07:48
LinuxTips历史发布归档
######
# 本归档每周末收录当周的Tips
######
# 以root身份执行上一条命令
$ sudo!!
# 返回用户主目录
$ cd
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import struct
from mutagen.easyid3 import EasyID3
def decode_gbk_from_unicode(s):
l, f = [], []
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)
<#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
@dlutcat
dlutcat / groovy
Created July 30, 2014 13:46
init.gradle
repositories {
mavenCentral()
mavenLocal()
maven {
url = mavenRepoPublicUrl
}
}
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