Skip to content

Instantly share code, notes, and snippets.

@jwkfreedom
jwkfreedom / pom.xml
Created February 21, 2014 08:48
[Maven] Add dependecy file to the compiled jar package.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
@jwkfreedom
jwkfreedom / new_gist_file_0
Created February 20, 2014 12:11
A simple Netty Http server sample. Netty是一套高性能的通讯架构,这里我用netty实现http服务器实现信息采集功能。主要是利用他现有的hander处理器,解析出request头,做信息采集使用,重写了他自己的hander.
package io.netty.example.http.snoop;
import static io.netty.handler.codec.http.HttpHeaders.getHost;
import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpHeaders.Names.COOKIE;
import java.util.HashMap;
import java.util.Map;
import redis.clients.jedis.Jedis;
public class TestJedis {
public static void main(String[] args) {
String key = "mostUsedLanguages";
Jedis jedis = new Jedis("localhost");
//Adding a value with score to the set
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};