Skip to content

Instantly share code, notes, and snippets.

@dmorgantini
dmorgantini / DropWizardAdminResource.java
Last active August 13, 2020 20:09
Dropwizard App with Admin Resource
public class TemplateApplication extends Application<ServiceConfiguration> {
public static void main(String[] args) throws Exception {
new TemplateApplication().run(args);
}
@Override
public void run(ServiceConfiguration configuration, Environment environment) throws Exception {
@dmorgantini
dmorgantini / AddNumbersService.java
Created August 13, 2012 14:37
Use SOAP with dropwizard
package com.example.helloworld.resources;
import javax.jws.WebMethod;
@javax.jws.WebService(
name = "AddNumbersPortType",
serviceName = "AddNumbersService",
targetNamespace = "http://duke.example.org")
@javax.jws.soap.SOAPBinding(
style = javax.jws.soap.SOAPBinding.Style.DOCUMENT,
@dmorgantini
dmorgantini / DateTimeDeserializer.java
Created November 20, 2012 11:02
Joda Datetime with dropwizard (0.6.0-SNAPSHOT)
public class DateTimeDeserializer extends JsonDeserializer<DateTime> {
@Override
public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
if (jp.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) {
return new DateTime(jp.getLongValue());
}
throw ctxt.mappingException("Expected JSON Number");
}
@dmorgantini
dmorgantini / monitor_network.sh
Last active January 19, 2016 13:25
Execute this to ensure that your macbook pro resets the DHCP lease each time your macbook pro decides to drop the wifi connection.
#!/bin/bash
FAIL_COUNT=0
TIME=1
while true; do
ping -c 1 -t 1 google.com > /dev/null
if [ $? -ne 0 ]; then