This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package netty.sample | |
import io.netty.channel.ChannelHandlerContext | |
import io.netty.channel.ChannelInboundHandlerAdapter | |
import io.netty.buffer.ByteBuf | |
import io.netty.bootstrap.ServerBootstrap | |
import io.netty.channel.ChannelOption | |
import io.netty.channel.ChannelOption._ | |
import io.netty.channel.ChannelFuture | |
import io.netty.channel.ChannelInitializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package squtest | |
import org.squeryl.PrimitiveTypeMode._ | |
import org.squeryl.Schema | |
import org.squeryl.annotations.Column | |
import org.squeryl.SessionFactory | |
import org.squeryl.Session | |
import org.squeryl.KeyedEntity | |
import org.squeryl.adapters.H2Adapter | |
import java.util.Date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test2 { | |
//Also: def callFn(a: Int, f: (Int) => Int) = { | |
def callFn(a: Int, f: Int => Int) = { | |
a + f(a) | |
} | |
// 2 parameters | |
def callFnMult(a: Int, f: (Int, Int) => Int) = { | |
a + f(a, a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `s' and `b' are both implicit parameters | |
def implFn(i: Int)(implicit s: String, b: Int) = { | |
println(s) | |
i + b | |
} | |
def main(args: Array[String]) { | |
// otherS will match parameter `s' by type, **not by name** | |
implicit val otherS = "hello" | |
// error, two variables with the same type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo off | |
REM | |
REM Usage: put jars into lib/ext directory, put config file in ext directory | |
REM gen_runjar.bat | |
REM Kevin Lynx 09/24/2013 | |
REM | |
if "%1"=="" goto usage | |
if not "%1"=="clear" goto dist | |
del /Q ext\*.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
char find(const char *str) { | |
int cnt = 1; | |
char c = *str++; | |
for ( ; *str; ++str) { | |
c = cnt == 0 ? *str : c; | |
cnt = cnt + (*str == c ? 1 : (cnt - 1 < 0 ? -cnt : -1)); | |
} | |
return cnt > 0 ? c : 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
typedef unsigned __int64 uint64; | |
typedef unsigned char byte; | |
void setBit(byte *data, int pos) { | |
byte bits[] = { | |
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 | |
}; | |
/* note the position starts from 1, not 0 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test.cpp : 定义控制台应用程序的入口点。 | |
// | |
#include <stdio.h> | |
#include <vector> | |
#include <string> | |
#include <assert.h> | |
struct OpCode { | |
/* 0: indicate `*' operator, 1: string match */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Entity { | |
public: | |
enum { CLIENT, SERVER }; | |
Entity(const CGUID &id, int type, const std::string &brief); | |
// send text to this entity, this function will preprocess `text` | |
bool Send(const std::string &text); | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string> | |
#include <map> | |
#include <vector> | |
#include <list> | |
void ds_str_i(void *p) { | |
char **raw = (char**)p; | |
char *s = *raw; | |
size_t len = *(size_t*)(s - sizeof(size_t) * 3); |