Skip to content

Instantly share code, notes, and snippets.

import com.kenshoo.xlsx2csv.XlsxToCsvConverter;
import java.io.*;
public class Converter {
private final static String SOURCE_FILE_PATH = "/path/example-input.xslx"
private final static String DEST_FILE_NAME = "/path/example-result.csv"
//building a new converter with default parameters
private final XlsxToCsvConverter xlsxToCsvConverter = new XlsxToCsvConverter.Builder().build();
@mosheeshel
mosheeshel / filebeat.config.yml
Last active November 30, 2021 14:53
reference filebeat configuration
############################# Filebeat ######################################
filebeat:
prospectors:
-
paths:
- /var/log/<APP>/app.log
fields:
logzio_codec: plain
token: ${token}
application: app # Custom field and value (can be filtered in logz.io)
@mosheeshel
mosheeshel / ConsumeHeap.java
Last active August 28, 2023 12:20
Function to fill JVM/Java Heap, Java options to automatically create a Heapdump on that event and a companion script to upload resulting files to S3
import java.io.IOException;
import java.util.Vector;
/**
* Created by moshee
* on: 07/06/17
* to compile in place: `javac ConsumeHeap.java`
* Execute: `java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/app-`date +%s`-pid$$.hprof -XX:OnOutOfMemoryError=/opt/app/bin/upload_dump_s3.sh -Xmx2m ConsumeHeap`
* HeapDumpOnOutOfMemoryError specifies to automatically create a dump when OOM occures
* HeapDumpPath supplies a path to put that file
@mosheeshel
mosheeshel / build.gradle
Created February 13, 2017 09:37
outputs std output when gradle test (usually swallowed), if you have logging in tests and test related code which you want to see during the test run, add this to the test block in gradle
test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
@mosheeshel
mosheeshel / build.gradle
Created January 23, 2017 18:15
test task that prints out environment variables and those set for JVM executors that gradle will run and shows how to set specific systemProperty from external value...
apply plugin: 'java' //needs this to have test task defined
test {
println "Host system properties"
System.properties.each { k,v->
println "$k = $v"
}
systemProperty 'db.test.mode', System.getProperty("db.test.mode", "EMBEDDED")
println "Gradle system properties"
systemProperties.each { k,v->
@mosheeshel
mosheeshel / Dockerrun.aws.json
Last active January 1, 2017 10:08
Simplified example of AWS multi-container docker definition for Elastic Beanstalk, including authenticating to external non public docker registry to pull images
{
"AWSEBDockerrunVersion": 2, /* newer multi container format */
"authentication": {
/* if working with non ECR or non public docker registries, this is required, points to file in S3,
that has the correct auth data, this could hold auth for multiple registries,
see here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html#docker-images-private
*/
"bucket": "s3-bucket-name",
"key": "prefix"
},
@mosheeshel
mosheeshel / RabbitIntegrationTest.java
Created October 2, 2014 14:41
Demo Integration test using RabbitDockerContainer @rule
package integration;
import com.kenshoo.trackingfront.configuration.RabbitConfiguration;
import com.kenshoo.trackingfront.rabbitmq.RabbitConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.junit.*;
import org.junit.rules.ExpectedException;
import static org.mockito.Matchers.anyString;
@mosheeshel
mosheeshel / RabbitContainerRule.java
Created October 2, 2014 14:33
JUnit @rule for starting a RabbitMQ container (based on other rule - see comments)
package rules;
import com.google.common.collect.ImmutableMap;
import org.eclipse.jdt.launching.SocketUtil;
import java.util.HashMap;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
@mosheeshel
mosheeshel / DockerContainerRule.java
Created October 2, 2014 14:31
JUnit @rule for starting a docker container from within an Integration test
package rules;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.DockerException;
import com.spotify.docker.client.messages.ContainerConfig;
import com.spotify.docker.client.messages.ContainerCreation;
import com.spotify.docker.client.messages.HostConfig;
@mosheeshel
mosheeshel / gist:8279903
Last active January 2, 2016 08:59
Get App version from package manifest (for fatJar)
protected Integer getBuildNumber() {
try {
final String version = App.class.getPackage().getImplementationVersion();
if (StringUtils.isNotEmpty(version)) {
try {
return Integer.parseInt(version.substring(version.lastIndexOf(".") + 1));
} catch (Exception exp) {
logger.error("Problem parsing buildnumber from package version, returning 0", exp);
}
}