Skip to content

Instantly share code, notes, and snippets.

" don't bother with vi compatibility
set nocompatible
" enable syntax highlighting
syntax enable
" configure Vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
import com.alibaba.fastjson.JSON;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ser.StdSerializerProvider;
import org.codehaus.jackson.type.TypeReference;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public ModelAndView gotoManageAccount(HttpServletRequest req, HttpServletResponse res) throws BusinessException, IOException {
Map resultMap = new HashMap();
Date testdate = new Date(System.currentTimeMillis());
if(testdate.getHours()>16&&testdate.getHours()<=24){
resultMap.put("above5", "yes");
}
StringBuffer sb = req.getRequestURL();
String domain = "vip";
try{domain = sb.toString().replace("http://", "").split("\\.")[0];}catch(Exception e){}
@moistrot
moistrot / gist:3304983
Created August 9, 2012 15:05
SCIP 1.3
(define (sum-max x y z)
(+ (max x y)
(max (min x y) z)
)
)
(sum-max 1 10 20)
(sum-max 1 20 10)
(sum-max 10 1 20)
(sum-max 10 20 1)
(sum-max 20 1 10)
if(StringUtils.isBlank(script)) {
String jsPath = "http://cdn.tanx.com/t/tanxclick.js";
script = "<script type=\"text/javascript\" src=\"" + jsPath + "\"></script>";
}
velocityContext.put("extra_html", script);
static public AdList get_list(Injector injector, Request r, String backend, Context context) {
ThriftClient client = injector.getInstance(ThriftClient.class);
if (client == null) {
return null;
}
try {
client.setThriftTimeout(1000); // debug interface, 1s timeout
client.init(backend, 0); // ignore port
context.put("backendHost",backend);
if (client != null) {
@moistrot
moistrot / gist:1513415
Created December 23, 2011 06:51
AdmemberHandlerTest
public class AdmemberHandlerTest {
private AdmemberHandler admemberHandler;
private DailyAccountService dailyAccountService;
private AdmemberService admemberService;
private int admemberId;
@moistrot
moistrot / gist:1513411
Created December 23, 2011 06:50
AdmemberHandler
@Service("admemberHandler")
public class AdmemberHandler {
@Resource
private AdmemberService admemberService;
@Resource
private DailyAccountService dailyAccountService;
public void setDailyAccountService(DailyAccountService dailyAccountService) {
@moistrot
moistrot / gist:1479791
Created December 15, 2011 04:04
jsonp
@RequestMapping("/jsonp")
public void jsonp(HttpServletResponse response, HttpServletRequest request) throws IOException {
String name = getStringValue(request, "name");
int age = getIntValue(request, "age");
// do anything you want
// foo(name, age)
logger.info("name:" + name + " age:" + age);
response.setContentType("application/javascript;charset=utf-8");
app.all('/setAttrPrice/:adgroupid/:attrid/:price', function(req, res) {
var adgroup_id = req.params.adgroupid;
var attr_id = req.params.attrid;
var price = req.params.price;
if (price < 10000) {
send(res, 'price must greater than 10000');
return;
}
if(adgroup_id <=0) {
send(res, 'adgroup id must greater than 0');