Skip to content

Instantly share code, notes, and snippets.

View wenzhihong2003's full-sized avatar

tom.wen wenzhihong2003

View GitHub Profile
@wenzhihong2003
wenzhihong2003 / caller_name.py
Created September 24, 2015 00:57 — forked from techtonik/caller_name.py
Python - inspect - Get full caller name (package.module.function)
# Public Domain, i.e. feel free to copy/paste
# Considered a hack in Python 2
import inspect
def caller_name(skip=2):
"""Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
package xxx;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
package xxx;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
# Application dependencies
require:
- com.gelinsoft -> app-base 1.4.7
- com.gelinsoft -> play-excel 1.2.3
- com.gelinsoft -> config 1.2.2
- com.gelinsoft -> betterlogs 1.2i
- com.gelinsoft -> aaa 1.7d
- com.gelinsoft -> play-rythm 1.0-b5e
- com.gelinsoft -> morphia 1.2.14
package util.transaction;
import play.Logger;
import play.db.jpa.JPA;
public class TransactionRetryUtil {
private static final int MAX_TRIED_TIMES = 15;
public static <T> T run(TransactionCallback<T> callback) {
for (int i = 0; i < MAX_TRIED_TIMES; i++) {
try {
@wenzhihong2003
wenzhihong2003 / AA.md
Created July 17, 2012 01:16 — forked from sadache/AA.md
Is socket.push(bytes) all you need to program Realtime Web apps?

Is socket.push(bytes) all you need to program Realtime Web apps?

One of the goals of Play2 architecture is to provide a programming model for what is called Realtime Web Applications.

Realtime Web Applications

Realtime Web Applications are applications that make use of Websockets, Server Sent Events, Comet or other protocols offering/simulating an open socket between the browser and the server for continuous communication. Basically, these applications let users work with information as it is published - without having to periodically ping the service.

There are quite a few web frameworks that target the development of this type of application: but usually the solution is to simply provide an API that allows developers to push/receive messages from/to an open channel, something like:

@wenzhihong2003
wenzhihong2003 / gist:3126298
Created July 17, 2012 01:15 — forked from sadache/gist:3026886
Bits'bout Play2 Architecture

Bits'bout Play2 Architecture

Play2 Simple HTTP API

Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.

The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.

Basically, Play2 is an API that abstractly have the folllowing type

@wenzhihong2003
wenzhihong2003 / MethodParamNamesScaner.java
Created July 13, 2012 02:56 — forked from wendal/MethodParamNamesScaner.java
获得方法形参名称列表(Java)
package org.nutz.lang.util;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
# Application dependencies
require:
- com.gelinsoft -> app-base 1.3.2
- com.gelinsoft -> config 1.2.2
- com.gelinsoft -> betterlogs 1.2i
- com.gelinsoft -> aaa 1.2j
# - play -> rythm 1.0.0-RC6
- com.gelinsoft -> rythm 1.0.0-20120615
#- play -> morphia 1.2.8-RC1