Skip to content

Instantly share code, notes, and snippets.

View davidmerrick's full-sized avatar

David Merrick davidmerrick

View GitHub Profile
@davidmerrick
davidmerrick / caviarMe.js
Last active July 19, 2019 00:15
CaviarMe bookmarklet
// Converts a Caviar group order link to a shareable link
function copyText(a){
var b=document.createElement("textarea");
c=document.getSelection();
b.textContent=a;
document.body.appendChild(b);
c.removeAllRanges();
b.select();
document.execCommand("copy");
@davidmerrick
davidmerrick / build.gradle
Created July 16, 2019 15:32
Gradle force dependency version
configurations.all {
resolutionStrategy {
force "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
}
}
@davidmerrick
davidmerrick / throwables.java
Created July 11, 2019 22:06
Get root cause of an exception with Throwables
import com.google.common.base.Throwables;
try {
// Try a thing
} catch (Exception e) {
Throwable rootCause = Throwables.getRootCause(e);
}
@davidmerrick
davidmerrick / gist:11d0dbf2b98e74cddc337990881bd098
Last active June 7, 2019 00:48
Migrating to Gradle Kotlin DSL

Kotlin DSL for Gradle Intro

Why use this?

  • Build scripts and tooling written in Groovy are often hard to configure, hard to refactor, and non-idiomatic.
  • Type-safe build logic
    • IDE support
      • Code completion
      • Documentation
  • Refactoring
@davidmerrick
davidmerrick / kinesisIterate.sh
Last active October 23, 2020 04:32
Iterate over a Kinesis stream
#!/bin/bash -eux
# This script iterates over a Kinesis stream and dumps out the records.
# I used it to test whether items were getting pushed to my stream.
# Requires jq.
AWS_PROFILE=dev
AWS_REGION=us-east-1
SHARD_ID=myShard
STREAM_NAME=myStream
@davidmerrick
davidmerrick / redis.sh
Last active April 12, 2019 21:57
Docker Redis
# Run Redis locally, with restarts enabled, and forward default ports to it
docker run -p 6379:6379 --restart=always -d redis redis-server --appendonly yes
@davidmerrick
davidmerrick / cloneAll.sh
Last active January 15, 2022 23:26
Clone all github repos in an org
#!/bin/bash
# Note: This script requires that you have $GITHUB_TOKEN set.
# Get one here: https://github.com/settings/tokens
ORG=yourOrg
HAS_NEXT=true
i=1
while $HAS_NEXT
@davidmerrick
davidmerrick / travis.sh
Created March 11, 2019 06:54
Run travis CI client in docker
docker run -ti -v $PWD:/app ruby /bin/bash
# Then `gem install travis` and you'll be good to go.
@davidmerrick
davidmerrick / assertEquals.md
Created March 9, 2019 00:50
Ordering of TestNG's assertEquals

In TestNG's assertEquals method, it's easy to confuse which parameter represents the expected value, and which one represents the actual value.

@Test(groups = INTEGRATION_GROUP)
public void assertEqualsTest(){
    String expected = "expected";
    String actual = "actual";

    assertEquals(actual, expected);
}
@davidmerrick
davidmerrick / visible.java
Created September 27, 2018 22:38
Using @VisibleForTesting inside Lombok annotation
@Wither(onMethod = @__({@VisibleForTesting}))
private String myString;