Skip to content

Instantly share code, notes, and snippets.

@wendal
wendal / chain_insert_getid.java
Created September 3, 2012 12:18
Nutz Chain插入后获取主键
Trans.exec(new Atom() {
public void run() {
dao.insert("tp_pet", Chain.make("age", 12));
Sql sql = Sqls.fetchLong("SELECT @@@@IDENTITY");
dao.execute(sql);
long petId = sql.getObject(Long.class);
System.out.println(petId);
}
});
@Test
public void test_cnd_in() {
List<String> list = new ArrayList<String>();
list.add("ab,c");
list.add("game:Announcement:read,update:*");
Cnd cnd = Cnd.where("abc", "in", list).and("zz", "in", new String[]{"asfdsdf,fasdfasdf,asf", "XXXX"});
System.out.println(cnd);
}
@wendal
wendal / TreeNode.java
Created September 5, 2012 13:44
Nutz Json createBy用法示例
package org.nutz.json.meta;
import java.lang.reflect.Type;
import java.util.List;
import org.nutz.json.JsonField;
import org.nutz.lang.util.NutType;
import org.nutz.mapl.Mapl;
public class TreeNode {
@wendal
wendal / gist:3697189
Created September 11, 2012 09:27 — forked from anonymous/gist:3697179
bytecode
package com.salesforce.chatter.provider;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
JdbcExpertConfigFile jdbcConf = new JdbcExpertConfigFile();
Map<String, Object> config = new HashMap<String, Object>();
config.put("pool-home", "~/.nutz/tmp/dao/");
config.put("pool-max", 2000);
config.put("mysql-engine", "InnoDB");
Map<String, Class<? extends JdbcExpert>> experts = new HashMap<String, Class<? extends JdbcExpert>>();
experts.put("h2.*", (Class<? extends JdbcExpert>) Class.forName("org.nutz.dao.impl.jdbc.h2.H2JdbcExpert"));
//...........
jdbcConf.setConfig(config);
@wendal
wendal / test_http.go
Created September 15, 2012 09:28
简单演示go通过http服务静态文件
package main
import (
"log"
"net/http"
)
func main() {
log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/tmp"))))
}
@wendal
wendal / read_mp3_id3.go
Created September 26, 2012 00:31
GOLANG读取MP3文件的ID3信息
//from http://0x55aa.sinaapp.com/%E7%AE%97%E6%B3%95-%E7%BC%96%E7%A8%8B/676.html?1348618006
package main
import (
"fmt"
"os"
"errors"
"strings"
)
//no tag
@wendal
wendal / test_oracle_query.go
Created October 9, 2012 01:52
测试Golang的Oracle驱动的查询性能
package main
import (
"database/sql"
_ "github.com/mattn/go-oci8"
"os"
"log"
"fmt"
)
@wendal
wendal / errors.go
Created October 22, 2012 05:25
扩展golang默认的errors,使其包含堆栈信息
package errors
import (
"fmt"
"path"
"runtime"
)
type Error struct {
@wendal
wendal / exists.go
Last active April 1, 2020 13:05
golang判断文件是否存在
func PathExist(_path string) bool {
_, err := os.Stat(_path)
if err != nil && err.Error() == os.ErrNotExist.Error() {
return false
}
return true
}
// golang新版本的应该
func PathExist(_path string) bool {