Skip to content

Instantly share code, notes, and snippets.

View taichi's full-sized avatar
😸
shaving...

taichi taichi

😸
shaving...
View GitHub Profile
@taichi
taichi / link.txt
Created April 19, 2011 10:02
link test.
@taichi
taichi / pom.xml
Created April 19, 2011 10:25
current netty build successfull pom
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright 2009 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@taichi
taichi / dependencies.yml
Created April 20, 2011 07:08
twitter/commons dependencies.
flatten : true
destination : ./lib
# https://github.com/twitter/commons/blob/master/build-support/commons/ivy/ivysettings.xml
repositories :
- http://mirrors.ibiblio.org/pub/mirrors/maven2/
- https://repository.apache.org/content/groups/public/
- https://oss.sonatype.org/content/repositories/google-releases/
- http://repository.jboss.org/nexus/content/groups/public/
- http://download.java.net/maven/2/
@taichi
taichi / twitter-commons.txt
Created April 20, 2011 10:40
twitter-commons build step
公開されているライブラリを単に使いたいだけなら、
<repositories>
<repository>
<id>maven.twttr.com</id>
<name>Twitter Maven2 Repository</name>
<url>http://maven.twttr.com/</url>
</repository>
</repositories>
@taichi
taichi / HttpClientPipelineFactory.java
Created April 20, 2011 17:45
Connect to Riak by Netty on the Servlet3.0(Tomcat 7.0.12)
package riak;
import static org.jboss.netty.channel.Channels.pipeline;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.handler.codec.http.HttpClientCodec;
import org.jboss.netty.handler.codec.http.HttpContentDecompressor;
public class HttpClientPipelineFactory implements ChannelPipelineFactory {
@taichi
taichi / ShutdownNow.java
Created April 26, 2011 10:24
Shutdown ExecutorService
static final int MAX_SHUTDOWN_WAIT = 500;
void shutdown(ExecutorService pool) {
pool.shutdown();
try {
for (int wait = 100; (wait < MAX_SHUTDOWN_WAIT)
&& ((pool.isShutdown() == false) || (pool.isTerminated() == false)); wait *= 2) {
if (pool.awaitTermination(wait, TimeUnit.SECONDS)) {
break;
} else {
import java.util.concurrent.TimeUnit;
public class Seconds {
public static void main(String[] args) {
long milis = TimeUnit.SECONDS.toMillis(1303372302L);
long micro = TimeUnit.MICROSECONDS.toMillis(69170L);
System.out.println(micro);
System.out.println(milis);
@taichi
taichi / PbcGetServlet.java
Created May 1, 2011 10:41
example of riak client that uses Protocol Buffers.
package org.handwerkszeug.riak.example.servlet;
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@taichi
taichi / PingPage.java
Created May 16, 2011 12:08
t2 alt-riak on Jetty7
package t2.riak.pages;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.handwerkszeug.riak.RiakAction;
import org.handwerkszeug.riak.model.RiakContentsResponse;
import org.handwerkszeug.riak.model.RiakResponse;
@taichi
taichi / ConcurrentMultiMap.java
Created June 3, 2011 12:04
ConcurrentMultiMap or ConcurrentBag
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author taichi
* @param <K>
* @param <V>
*/
public class ConcurrentMultiMap<K, V, C extends Collection<V>> {