Skip to content

Instantly share code, notes, and snippets.

Wendal Chen wendal

Block or report user

Report or block wendal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wendal
wendal / PojoForQQ.java
Last active Mar 15, 2017
测试nutz json 处理getter/setter的情况
View PojoForQQ.java
package org.nutz.json.meta;
import org.nutz.json.Json;
import org.nutz.json.JsonField;
public class PojoForQQ {
private int id;
private String code;
@JsonField
@wendal
wendal / jedis_key_expired.java
Created Mar 14, 2017
Jedis订阅key过期事件的示例代码
View jedis_key_expired.java
public static void main(String[] args) {
Jedis jedis = new Jedis();
jedis.setex("abc", 15, "hi");
System.out.println("time now = " + System.currentTimeMillis());
jedis.psubscribe(new JedisPubSub() {
@Override
public void onPMessage(String pattern, String channel, String message) {
System.out.println("time now = " + System.currentTimeMillis());
@wendal
wendal / test.java
Created Sep 10, 2015
演示如何得到NutDao生成的Sql语句
View test.java
@Test
public void test_get_sql() throws Throwable {
NutDao dao = new NutDao(ioc.get(javax.sql.DataSource.class));
final List<String> sqls = new ArrayList<String>();
final Method m = NutStatement.class.getDeclaredMethod("toStatement", Object[][].class, String.class);
m.setAccessible(true);
dao.setExecutor(new DaoExecutor() {
public void exec(Connection conn, DaoStatement st) {
String psql = st.toPreparedStatement();
sqls.add(psql);
@wendal
wendal / Daos_tableName.java
Created Sep 7, 2015
示例获取一个动态表名
View Daos_tableName.java
public static String getTableName(Dao dao, Class<?> klass, Object t) {
final Entity<?> en = dao.getEntity(klass);
final String[] name = new String[1];
TableName.run(t, new Runnable() {
public void run() {
name[0] = en.getTableName();
}
});
return name[0];
}
@wendal
wendal / BaseNutTest.java
Last active Sep 7, 2015
Nutz测试基类,供参考
View BaseNutTest.java
package org.nutz.test;
import java.lang.reflect.Field;
import org.junit.After;
import org.junit.Before;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.IocLoader;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.annotation.Inject;
@wendal
wendal / 0_reuse_code.js
Last active Aug 31, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wendal
wendal / BeetlViewMaker.java
Created Jun 16, 2015
改造版BeetlViewMaker,把方法的返回值放进req里面
View BeetlViewMaker.java
package org.beetl.ext.nutz;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.resource.WebAppResourceLoader;
@wendal
wendal / DaoHelper.java
Last active Nov 2, 2017
nutz中实现saveOrUpdate封装(供参考)
View DaoHelper.java
@SuppressWarnings("unchecked")
public static <T> T insertOrUpdate(Dao dao, T obj) {
if (obj == null)
return null;
Entity<T> en = (Entity<T>) dao.getEntity(obj.getClass());
if (en.getPkType() == PkType.UNKNOWN)
throw new IllegalArgumentException("no support , without pks");
boolean doInsert = false;
switch (en.getPkType()) {
case ID:
@wendal
wendal / ddns.go
Created Jan 22, 2015
golang的dns缓存, 含流量统计
View ddns.go
package ddns
import (
"log"
"net"
"sync"
)
var (
dnsLock = &sync.Mutex{}
@wendal
wendal / IotUser.java
Created Jan 3, 2015
基于XML配置NutDao的Entity, 未测试代码, 正式代码会出现在nutz主库或nutzmore项目.
View IotUser.java
package org.nutz.dao.impl.entity.xml;
public class IotUser {
private long id;
private String name;
private int age;
public int getAge() {
return age;
}
You can’t perform that action at this time.