Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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)
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 / gist:7560362c68ac32b1b0b9d74de892b98e
Last active March 8, 2019 19:32
Create AdInsights Report from Facebook and download it into TSV (customize for different stuff easily)
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
@mosheeshel
mosheeshel / gist:b1317e32ed33b0205be9ec4b6d79f804
Last active August 12, 2019 19:44
Quick bash script to start a new GIT branch from master or from any other existing branch
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
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 / LaunchdarlyUserSegmentAPI.java
Last active May 25, 2021 11:36
LaunchDarkly, Create and Add UserSegmentRules with the Java API based on examples given here
package com.moshe.ldclient;
import com.launchdarkly.api.ApiClient;
import com.launchdarkly.api.ApiException;
import com.launchdarkly.api.Configuration;
import com.launchdarkly.api.api.UserSegmentsApi;
import com.launchdarkly.api.auth.ApiKeyAuth;
import com.launchdarkly.api.model.*;
import com.launchdarkly.sdk.LDUser;
import com.launchdarkly.sdk.server.LDClient;