Skip to content

Instantly share code, notes, and snippets.

@freewind
freewind / mongo-scala-driver-arrayEmbeded
Created March 20, 2011 12:53
This code can't be compiled, and have some errors
package models
import com.mongodb._
import com.osinka.mongodb._, shape._
class Question(val user: User) extends MongoObject with Oid {
var title: String = _
var comments: List[QComment] = Nil
}
@freewind
freewind / Client.java
Created October 23, 2011 13:34
Socket Server and Client
import java.io.InputStream;
import java.net.Socket;
public class Client {
static int PORT = 6666;
public static void main(String[] args) throws Exception {
Socket socket = new Socket("127.0.0.1", PORT);
InputStream input = socket.getInputStream();
@freewind
freewind / Client.java
Created October 25, 2011 17:05
Simple socket server and client, to test the speed of java socket
import java.io.InputStream;
import java.net.Socket;
public class SimpleClient {
public static void main(String[] args) throws Exception {
Socket socket = new Socket("127.0.0.1", 6666);
InputStream input = socket.getInputStream();
long total = 0;
long start = System.currentTimeMillis();
@freewind
freewind / NonfairLock.java
Created November 1, 2011 13:35
Test non-fair and fair mode of ReentrantReadWriteLock
package readwritelock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
public class NonfairLock {
private static long start = System.nanoTime();
package ebb
package snippet
import net.liftweb.http._
import net.liftweb.util._
import net.liftweb.common._
import ebb.model.Models._
import ebb.util.FaqReader
import org.squeryl._
import PrimitiveTypeMode._
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.2 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,
package ebb
package snippet
import net.liftweb.http._
import net.liftweb.util._
import org.squeryl._
import PrimitiveTypeMode._
import net.liftweb.util.Helpers._
import java.util._
import java.text._
/**
* 首页。
*/
public static void index() {
// 用于首页中各列表板块取最新文章
Category categoryMail = Category.getByCode("MAIL"); // 校友来函
Category categoryFengcai = Category.getByCode("FENGCAI"); // 校友风采
Category categoryJuanzeng = Category.getByCode("JUANZENG"); // 校友捐赠(文章)
Category categoryService = Category.getByCode("SERVICE"); // 校友服务
Category categoryNotice = Category.getByCode("NOTICE"); // 通知公告
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Date;
public class TestArr {
public static <T> T[][] createArray(int rows, int cols, T init) {
T[] row = (T[]) Array.newInstance(init.getClass(), cols);
Arrays.fill(row, init);
T[][] result = (T[][]) Array.newInstance(row.getClass(), rows);
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>