Skip to content

Instantly share code, notes, and snippets.

View michael-pratt's full-sized avatar

Michael Pratt michael-pratt

View GitHub Profile
@michael-pratt
michael-pratt / index.js
Created August 1, 2016 21:05
Custom slack command hosted on Heroku with Node.js
var unirest = require('unirest');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.set('port', (process.env.PORT || 5000));
// Replace these with your own tokens
@michael-pratt
michael-pratt / InetTester.java
Created July 3, 2018 16:30
Java slow DNS resolution test
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.*;
/**
* Test app to show DNS resolution times for IP -> hostname.
*/
public class InetTester
{
@michael-pratt
michael-pratt / SystemHealthIndicator.java
Created July 25, 2018 15:40
Spring Boot System and JVM HealthIndicator
@Configuration
public class SystemHealthIndicator
{
@Bean
public SystemHealthIndicator systemHealthIndicator()
{
return new SystemHealthIndicator();
}
/**
@michael-pratt
michael-pratt / MultipleEurekaInstanceApplication.java
Created August 30, 2018 14:24
Registering multiple instances in Eureka from one application
package com.myorg;
import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
import com.netflix.discovery.DiscoveryClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@michael-pratt
michael-pratt / BootDeployPlugin.groovy
Created October 8, 2018 17:37
Extending Spring Boot bootJar Task
package com.elvtn
import org.gradle.api.Plugin
import org.gradle.api.Project
/**
* Custom plugin that adds a new <code>bootDeploy</code> task for any
* project that depends on the Spring Boot gradle plugin. This new task
* depends on the existing <code>bootJar</code> task, and adds some new
@michael-pratt
michael-pratt / single-event.php
Created February 7, 2019 04:22
customize-events-calendar-popup-single-event-php
<?php
// Define default values to protect against events not having tickets
$additional_data = array();
$additional_data['price'] = "";
$additional_data['stock'] = "";
// Get ticket prices and quantity; this works specifically for WooCommerce
// tickets only and will need to be changed if you use other types such
// as RSVP tickets.
if ( class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main') )
@michael-pratt
michael-pratt / tooltip.php
Created February 7, 2019 04:42
customize-events-calendar-popup-tooltip-php
<?php
/**
* Please see single-event.php in this directory for detailed instructions on how to use and modify these templates.
*
* Override this template in your own theme by creating a file at:
*
* [your-theme]/tribe-events/month/tooltip.php
* @version 4.6.21
*/
?>
@michael-pratt
michael-pratt / RequestAndResponseLoggingFilter.java
Last active March 2, 2024 09:07
Simple Spring Boot Request and Response Logging Filter
// Adapted from https://gist.github.com/int128/e47217bebdb4c402b2ffa7cc199307ba
package com.elvtn.logging;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;