Skip to content

Instantly share code, notes, and snippets.

@gliviu
gliviu / KafkaMultiConsumer.java
Last active November 19, 2018 11:34
Consume and print message from all topics in a kafka server
import java.time.Duration;
import java.time.Instant;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import asyncio
import sys
import time
import re
cmd_regexp = re.compile('^([a-zA-Z0-9_-]+?)(\\((.*)\\))?$')
async def read_command(loop):
line = await loop.run_in_executor(None, sys.stdin.readline)
line = line.rstrip() # remove new line
cmd = None
package activemq.publisher;
import java.io.File;
import java.util.Arrays;
import java.util.stream.Collectors;
import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
'use strict';
var fs = require('fs');
/**
* Limits the number of concurrent file handlers.
* Use it as a wrapper over fs.open() and fs.close().
* Example:
* var fdQueue = new FileDescriptorQueue(8);
* fdQueue.open(path, flags, (err, fd) =>{
@gliviu
gliviu / HelloSoapClient.java
Created January 27, 2016 09:29
Java soap client
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPException;
@gliviu
gliviu / StandaloneHelloSoapService.java
Last active March 12, 2019 22:53
Java standalone soap service
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
// http://localhost:8080/helloService?wsdl
// Credits: http://hofmanndavid.blogspot.ro/2008/11/easiest-way-to-publish-java-web.html
@WebService(targetNamespace="namespace")
public class StandaloneHelloSoapService {
public String hello(String name) {
return "Hello " + name + " !";
}
@gliviu
gliviu / ParseHeaderByteRange.java
Created September 25, 2015 04:43
Java Http header byte range decoder
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Http header byte range decoder.
* According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
*/
public class ParseHeaderByteRange {
public static void main(final String[] args) {