Skip to content

Instantly share code, notes, and snippets.

View superalsrk's full-sized avatar
🎯
Focusing

SRK.Lyu superalsrk

🎯
Focusing
  • Beijing China
View GitHub Profile
@superalsrk
superalsrk / maven.xml
Last active December 14, 2015 07:59
pom.xml to install Hibernate & spring3.2.1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>info.superalsrk.maven</groupId>
<artifactId>simple</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>simple</name>
@superalsrk
superalsrk / download captcha
Last active December 14, 2015 07:59 — forked from wilbeibi/gist:5054796
douban CAPTCHA Download
# Grab captcha from douban login page
import urllib
import urllib2
import requests
import re
url = 'http://www.douban.com/accounts/login'
local = '/home/wilbeibi/Dropbox/Papers/Materials/Pool/douban/do'
i = 0
name = ""
@superalsrk
superalsrk / Spring ApplicationContext.xml
Created April 2, 2013 09:26
Spring,hibernate configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
List<Orders> res = hibernateTemplate.executeFind(new HibernateCallback<List<Orders>>() {
public List<Orders> doInHibernate(Session session) throws HibernateException, SQLException {
return session.createQuery(sql.toString()).setInteger(0, status)
.setFirstResult(pageNum)
.setMaxResults(pageSize)
.list();
}
});
@Before
public void setUp() throws Exception {
ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:/spring/applicationContext.xml");
ordersDAO = (OrdersDAO) ctx.getBean("ordersDAO");
userDAO = (UserDAO) ctx.getBean("userDAO");
houseDAO = (HouseDAO) ctx.getBean("houseDAO");
sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
session = SessionFactoryUtils.getSession(sessionFactory, true);
session.setFlushMode(FlushMode.MANUAL);
var Player = {
playList: [{ title: "天空之城", singer: "久石让", URL: ["http://upload20.music.qzone.soso.com/30479511.mp3","http://landodesign.net/sky.mp3"]},
{title: "金鱼的眼泪", singer: "纪佳松", URL: ["http://wma.9ku.com/2011/3/26/1.mp3"]}],//播放列表数据
currentSong: {},//当前播放歌曲
audio: document.getElementById("audio"),//绑定页面相应的Dom,下面几个都是
list: document.getElementById("playlist"),
search: document.getElementById("btn"),
keyword: document.getElementById("search"),
state: document.getElementById("state"),
init: function () {//初始化函数
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Logger;
@superalsrk
superalsrk / twitter4jTest.java
Created July 18, 2013 14:24
twitter4j test appliaton
package OauthTest;
import java.util.Properties;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.RequestToken;
public class TwitterTest {
@superalsrk
superalsrk / Junit4-spring-test.java
Last active December 21, 2015 08:59
spring-test related gists
package com.farmol.model.core.service;
import static org.junit.Assert.fail;
import javax.annotation.Resource;
/**
* notice that you have to include Logger of log4j package ,not other package
*/
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Get current date and set the hour,minute,second,microsceond to zero
*/
Calendar now = Calendar.getInstance();
now.set(Calendar.HOUR_OF_DAY, 0);
now.set(Calendar.MINUTE, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
Date nowdate = now.getTime();