Skip to content

Instantly share code, notes, and snippets.

View horiga's full-sized avatar

Hiroyuki Horigami horiga

View GitHub Profile
@horiga
horiga / java.xml
Last active May 31, 2017 10:48
IntelliJ snippets
<!--
Install.
* MacOS : ~/Library/Preferences/IntelliJIdea/templates, (~/Library/Preferences/IntelliJIdea2017.1/templates)
-->
<templateSet group="java">
<template name="j-po" value="protected $END$&#10;" description="" toReformat="true" toShortenFQNames="true">
<context>
<option name="HTML" value="true" />
<option name="JAVA_CODE" value="true" />
<option name="JSP" value="true" />
@horiga
horiga / HttpTimeoutTest.java
Last active March 8, 2017 13:37
How to HTTP timeout testing
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@horiga
horiga / httpserver_check.sh
Last active June 1, 2016 13:25
bash script for http status check
#!/bin/bash
# endpoint URI
endpoint=$1
# http execution timeout [sec]
timeout=1
successful_http_code=${2:-200}
execution_fail_code="000"
max_attempts=${3:-5}
@horiga
horiga / CallableWithCallbackHandlerListenableFutureExcample.java
Created May 22, 2014 01:05
Google-guava library ListeningExecutorService examples
package org.horiga.study.googleguava.examples.concurrent;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.math.RandomUtils;
@horiga
horiga / EventMessage.java
Created December 7, 2013 11:49
Google guava EventBus example.
public class EventMessage {
final int msgcode;
final String msg;
public EventMessage(int msgcode, String msg) {
this.msgcode = msgcode;
this.msg = msg;
}
@horiga
horiga / GuavaCacheTest.java
Created September 11, 2013 10:38
A simple java cache. use the 'guava-libraries'
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
public class GuavaCacheTest {
@horiga
horiga / A.java
Created June 14, 2013 00:56
multi files test
public class A {
public void execute() {
System.out.println("This is A");
}
}
public class Test {
public static void main(String[] args) {
System.out.println("hello");
}
}