Skip to content

Instantly share code, notes, and snippets.

View andyzhuangyy's full-sized avatar

Zhuang Yongyao andyzhuangyy

View GitHub Profile
@andyzhuangyy
andyzhuangyy / dereference_template.cc
Last active August 29, 2015 14:17
dereference template
struct Dereference {
template<typename T>
const T& operator()(const T* ptr) const
{
return *ptr;
}
};
@andyzhuangyy
andyzhuangyy / MethodCounter.java
Created April 29, 2016 03:39
aop, use aspectj calculate count of method called
@Aspect
public final class MethodCounter {
private static final InternalLogger LOG = InternalLoggerFactory.getInstance(MethodCounter.class);
public MethodCounter() {
}
@Around(
// @checkstyle StringLiteralsConcatenation (2 lines)
"(execution(* *(..)) || initialization(*.new(..)))"
@andyzhuangyy
andyzhuangyy / AnnoCounter.java
Created April 29, 2016 03:41
the annotation of counter with aspectj
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface AnnoCounter {
String name() default "";
}
@andyzhuangyy
andyzhuangyy / log_utils.py
Created May 5, 2016 16:22
decorator of log
def log_start(logger):
"""
Debug functions
"""
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
logger.debug('Calling: %s with: args: %s, kwargs:%s' %
(func.__name__, args, kwargs))