Skip to content

Instantly share code, notes, and snippets.

View efenderbosch's full-sized avatar

Eric Fenderbosch efenderbosch

  • Ohio
  • 21:45 (UTC -04:00)
View GitHub Profile
@efenderbosch
efenderbosch / StriktIsEqualToIgnoring.kt
Last active February 4, 2022 17:34
Fluent equal to ignoring for Strikt
package util
import org.junit.jupiter.api.Test
import strikt.api.Assertion
import strikt.api.expectThat
import strikt.assertions.contentEquals
import strikt.assertions.isEqualTo
import java.beans.Introspector
import java.util.*
import kotlin.reflect.KProperty1
@efenderbosch
efenderbosch / JsonValidated.kt
Last active September 23, 2020 17:18
Jackson Validation
import kotlin.annotation.AnnotationTarget.CLASS
@Target(CLASS)
annotation class JsonValidated
@efenderbosch
efenderbosch / IgnoreExtraWrappedRootJsonParser.java
Created May 21, 2019 15:23
Jackson Ignore Extra Wrapped Root
import java.io.IOException;
public class IgnoreExtraWrappedRootJsonParser extends JsonParserDelegate {
private final String rootName;
public IgnoreExtraWrappedRootJsonParser(JsonParser delegate, JavaType rootType) {
super(delegate);
JsonRootName jsonRootName = rootType.getRawClass().getAnnotation(JsonRootName.class);
rootName = jsonRootName == null ? null : "/" + jsonRootName.value();
public class DatadogApiKeyPrefixEncoder extends EncoderBase<ILoggingEvent> {
private static final byte[] EMPTY = new byte[0];
private final byte[] apiKey;
@SuppressFBWarnings({"EI_EXPOSE_REP2", "WEM_WEAK_EXCEPTION_MESSAGING"})
public DatadogApiKeyPrefixEncoder(byte[] apiKey) {
if (apiKey == null || apiKey.length == 0) {
throw new IllegalArgumentException("DataDog API key must not be empty.");
@efenderbosch
efenderbosch / Dockerfile
Created July 6, 2018 21:00
Installing AWS CAs in Java 10 with Centos 7
FROM centos:7
RUN cd /tmp && \
curl "https://download.java.net/java/GA/jdk10/10.0.1/fb4372174a714e6b8c52526dc134031e/10/openjdk-10.0.1_linux-x64_bin.tar.gz" -o "openjdk-10_bin.tar.gz" -s && \
tar xzf openjdk-10_bin.tar.gz && \
mv jdk-10.0.1 /usr/local/jdk-10 && \
rm /usr/local/jdk-10/lib/src.zip && \
alternatives --install /usr/bin/java java /usr/local/jdk-10/bin/java 1 && \
alternatives --install /usr/bin/javac javac /usr/local/jdk-10/bin/javac 1 && \
alternatives --install /usr/bin/keytool keytool /usr/local/jdk-10/bin/keytool 1 && \
@efenderbosch
efenderbosch / Disabled.java
Created April 10, 2018 14:04
Guice Dynamic Proxy Feature Toggles
@Target(PARAMETER)
@Retention(RUNTIME)
@BindingAnnotation
public @interface Disabled {}
public class PublishingInMemoryFeatureStore extends InMemoryFeatureStore {
@Override
public <T extends VersionedData> void upsert(VersionedDataKind<T> kind, T item) {
String key = item.getKey();
T current = get(kind, key);
super.upsert(kind, item);
T updated = get(kind, key);
if (!Objects.equals(current, updated)) {
// do publish
@efenderbosch
efenderbosch / Disabled.java
Created October 5, 2017 19:56
Feature Toggles w/ LaunchDarkly and Guice
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target(PARAMETER)
@Retention(RUNTIME)
@BindingAnnotation
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.IDynamoDBMapper;
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
import com.amazonaws.services.dynamodbv2.model.GlobalSecondaryIndex;
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
import java.util.Map;
import static com.google.common.base.CaseFormat.*;
import static java.lang.System.out;
webhookListenerCache:
Type: AWS::ElastiCache::CacheCluster
Properties:
ClusterName: ${self:custom.stage}-shopify-wh-listen
CacheNodeType: cache.t2.medium
CacheSubnetGroupName: ${self:custom.stage}
Engine: Redis
EngineVersion: 3.2.4
NumCacheNodes: 1
VpcSecurityGroupIds: ${self:custom.vpc.securityGroupIds}