Skip to content

Instantly share code, notes, and snippets.

View Naive HoneyComb OpenTelemetry Exporter WIP
package com.kenshoo.teddy.infra;
import com.google.inject.Singleton;
import io.honeycomb.libhoney.Event;
import io.honeycomb.libhoney.HoneyClient;
import io.honeycomb.libhoney.builders.HoneyClientBuilder;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.trace.SpanId;
@mosheeshel
mosheeshel / gist:b1317e32ed33b0205be9ec4b6d79f804
Last active Aug 12, 2019
Quick bash script to start a new GIT branch from master or from any other existing branch
View gist:b1317e32ed33b0205be9ec4b6d79f804
create_branch() {
local ORIGIN_BRANCH="origin/master"
if [ -z "$1" ] ; then
echo "branch name is required"
else
if [ ! -z "$2" ] ; then
local ORIGIN_BRANCH="$2"
fi
git checkout -b $1 $ORIGIN_BRANCH
git push -u origin $1:$1
@mosheeshel
mosheeshel / gist:7560362c68ac32b1b0b9d74de892b98e
Last active Mar 8, 2019
Create AdInsights Report from Facebook and download it into TSV (customize for different stuff easily)
View gist:7560362c68ac32b1b0b9d74de892b98e
import time, datetime
import csv
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.adobjects.adreportrun import AdReportRun
from facebook_business.adobjects.campaign import Campaign
import boto3
View ConvertXlsxToCsvExample.java
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 Jul 5, 2017
reference filebeat configuration
View filebeat.config.yml
############################# 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 Apr 11, 2021
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
View ConsumeHeap.java
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 Feb 13, 2017
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
View build.gradle
test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
@mosheeshel
mosheeshel / build.gradle
Created Jan 23, 2017
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...
View build.gradle
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 Jan 1, 2017
Simplified example of AWS multi-container docker definition for Elastic Beanstalk, including authenticating to external non public docker registry to pull images
View Dockerrun.aws.json
{
"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 Oct 2, 2014
Demo Integration test using RabbitDockerContainer @rule
View RabbitIntegrationTest.java
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;