Skip to content

Instantly share code, notes, and snippets.

View jprante's full-sized avatar
💤
Dormant

Jörg Prante jprante

💤
Dormant
View GitHub Profile
@jprante
jprante / OpenAlexAwsClientTest.java
Last active January 31, 2024 09:47
Download all works from OpenAlex S3 with AWS Java SDK
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@jprante
jprante / MultiplexCodecCleartextHttp2Test.java
Created March 11, 2018 13:43
Http2MultiplexCodec demo for cleartext HTTP/2 between a server and a client (Netty 4.1.22)
package org.xbib.netty.http.server.test.simple;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
@jprante
jprante / SimpleHttp1Test.java
Last active March 8, 2018 15:15
Netty ObjectCleanerThread leak?
package org.xbib.netty.http.client.test.simple;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
@jprante
jprante / gist:3f167c34d81e1ccf3053a339c385057e
Last active January 4, 2017 08:32
javac StackOverflowError
java -version
openjdk version "1.8.0_112"
OpenJDK Runtime Environment (Zulu 8.19.0.1-linux64) (build 1.8.0_112-b16)
OpenJDK 64-Bit Server VM (Zulu 8.19.0.1-linux64) (build 25.112-b16, mixed mode)
Looks a bit like https://bugs.openjdk.java.net/browse/JDK-8143898 but it's another issue: there is no safety mechanism
(or a failing mechanism) in the Java compiler to guard against massive nested method calls like a.add(b).add(c)...
on tight thread stack size. It happened on a Linux 40 core CPU machine with 64 GB RAM when >700 nested method calls
are parsed by javac. Default on Linux is -J-Xss1m which is exceeded, -J-Xss2m works. Also smaller machines (laptops)
with lower CPU core count and lower RAM size are exempted from this error. javac reads the total amount of RAM
@jprante
jprante / DocDate.groovy
Created December 10, 2016 22:38
Dates in Elasticsearch 5 with Groovy/Java
@Grab(group='org.elasticsearch.client', module='transport', version='5.0.2')
@Grab(group='org.apache.logging.log4j', module='log4j-core', version='2.6.2')
@Grab(group='org.apache.logging.log4j', module='log4j-api', version='2.6.2')
import org.elasticsearch.action.admin.indices.create.CreateIndexAction
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder
import org.elasticsearch.action.index.IndexAction
import org.elasticsearch.action.index.IndexRequestBuilder
import org.elasticsearch.action.search.SearchResponse
import org.elasticsearch.action.support.WriteRequest
@jprante
jprante / gist:35041580b6d4a31d2041df54812e1461
Last active October 4, 2016 07:55
Build of Elasticsearch 2.3.5 from source
uname -a
Darwin Jorg-Prantes-MacBook-Pro.local 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64
java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
env | grep JAVA
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
DELETE /myindex
PUT /myindex/
{
"mappings": {
"error" : {
"_parent" : {
"type" : "activitytype"
}
}
@jprante
jprante / NetworkInterfaceTester.java
Last active April 18, 2016 20:55
Test network interfaces with java
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Collections;
import java.util.Enumeration;
public class NetworkInterfaceTester {
public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
@jprante
jprante / arabic.txt
Created April 10, 2016 20:14
Arabic text with Elasticsearch
DELETE /test
PUT /test
POST /test/doc/_mapping
{
"properties": {
"message": {
"type": "string", "analyzer" : "simple"
}
@jprante
jprante / ilovees2.txt
Created March 7, 2016 16:25
I love ES Pt. 2
DELETE /test
PUT /test/
{
"settings": {
"analysis": {
"filter" : {
"heart" : {
"type" : "synonym",
"synonyms" : [