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
// tested on Groovy 1.8.9. | |
enum GreetEnum { | |
MORNING("Good Morning"), | |
AFTERNOON("Good Afternoon"), | |
EVENING("Good Evening"); | |
static { | |
MORNING.metaClass.greeting = { String you -> | |
return delegate.emphasize() + " " + you + ", I'm sleeping..." | |
} |
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
@Grab(group='com.github.plecong', module='hogan-groovy', version='3.0') | |
import com.github.plecong.hogan.Hogan | |
def expected = '' | |
def template = null | |
def data = [:] | |
def template_s = '' | |
// {{{ basic compile() |
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 gjt3; | |
public class Singleton { | |
private static Singleton instance = null; | |
private String myarg; | |
private Singleton(String arg) { | |
myarg = arg; | |
} | |
public synchronized static Singleton getInstance(String arg) { | |
if (Singleton.instance == null) { |
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 gjt1; | |
public class Calc1 { | |
int v1; | |
int v2; | |
def Calc1(int a, int b) { | |
v1 = a; | |
v2 = b; | |
} | |
int calc() { |
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 gjt2; | |
public class Calc { | |
private int v1; | |
private int v2; | |
public Calc(int a, int b) { | |
v1 = a; | |
v2 = b; | |
} | |
public int calc() { |
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
import sun.net.InetAddressCachePolicy; | |
// see: https://docs.oracle.com/javase/jp/8/api/java/net/InetAddress.html | |
// see: https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/net/InetAddressCachePolicy.java | |
// for (Open/Oralce) JRE 7-8 | |
// "networkaddress.cache.ttl" | |
println InetAddressCachePolicy.cachePolicy | |
// "networkaddress.cache.negative.ttl" | |
println InetAddressCachePolicy.negativeCachePolicy | |
println InetAddressCachePolicy.propertySet |
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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>HTML5 history API exercise</title> | |
</head> | |
<script> | |
/* | |
HTML5 history API exercise 1. |
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
javascript:void(function(){if (window.location.href.match(new RegExp("file/d/(\\w+)/edit"))) { var n = "http://drive.google.com/uc?export=view&id=" + RegExp.$1; prompt("url", n); } else { prompt("not google drive image edit url. see:", "http://googlesystem.blogspot.jp/2013/02/permalinks-for-google-drive-images.html"); }}()) |
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
for (int i in 0..0xFF) { | |
System.out.write(i); | |
System.out.flush(); | |
} |
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
/* | |
* (no copyright, license-free, AS-IS, for any commercial or oss or free source code) | |
*/ | |
String host = args[0] | |
int port = args[1].toInteger() | |
int to_connect = 10 * 1000 // connect timeout in milli secs | |
int to_read = 10 * 1000 // read timeout in milli secs | |
SocketAddress sa_local = null // bind to system default address and port. | |
SocketAddress sa_remote = new InetSocketAddress(host, port) |