Skip to content

Instantly share code, notes, and snippets.

@dnault
dnault / JsonFieldEraser.java
Created July 14, 2023 23:32
Quick way to remove top-level fields from a byte array containing a JSON object.
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.json.JsonMapper;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
/*
* Copyright 2018 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dnault
dnault / es-clear.sh
Created January 25, 2018 20:19
Delete all documents from an Elasticsearch index
#!/bin/sh
INDEX=$1
# optionally limit the deletion to a specific type
TYPE=$2
BASE_URL=http://localhost:9200
if [ "$#" -eq 1 ]; then
@dnault
dnault / gmvn.sh
Created July 14, 2016 19:17
Wrapper script for Maven that sends a notification to the Mac OS X notification center when execution completes.
#!/bin/bash
#
# USAGE: gmvn <parameters and goals>
#
# Invoke maven with the supplied parameters and goals.
#
# When the build is complete, send a message to the notification center indicating if the build was successful, and
# the directory in which it was run (in case there are multiple builds running concurrently).
@dnault
dnault / JsonSchemaExample.java
Last active August 8, 2022 13:26
Jackson 2.5+ sample code for generating JSON schemas that always use schema references instead of inline schemas
package com.github.therapi.apidoc;
import java.util.List;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import com.fasterxml.jackson.module.jsonSchema.factories.VisitorContext;
@dnault
dnault / gist:425c144cc6a2ac4b3ef9
Created February 17, 2015 07:27
Bash function for killing stubborn a stubborn Tomcat process
function kill-tomcat {
ps xu | grep tomcat | grep -v grep | awk '{ print $2 }' | xargs kill -9
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.netflix.nebula:nebula-publishing-plugin:2.0.1"
classpath "com.netflix.nebula:gradle-extra-configurations-plugin:2.0.1"
}
}