Skip to content

Instantly share code, notes, and snippets.

@mckamey
mckamey / AcceptFilter.java
Created March 10, 2011 23:58
Servlet Filter for JAX-RS content negotiation which fixes WebKit Accept header and adds extension support
package org.example.www.filters;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Modifies Accept headers and allows URL extensions to improve JAX-RS content negotiation
* Adds "Vary: accept" header to response
@brikis98
brikis98 / PlayAsyncIOCallback.java
Created July 6, 2011 01:18
Play framework async I/O with callbacks
public class AsyncTest extends Controller
{
public static void callback()
{
F.Promise<WS.HttpResponse> remoteCall1 = WS.url("http://www.remote-service.com/data/1").getAsync();
F.Promise<WS.HttpResponse> remoteCall2 = WS.url("http://www.remote-service.com/data/2").getAsync();
F.Promise<WS.HttpResponse> remoteCall3 = WS.url("http://www.remote-service.com/data/3").getAsync();
F.Promise<List<WS.HttpResponse>> promises = F.Promise.waitAll(remoteCall1, remoteCall2, remoteCall3);
@dav-rob
dav-rob / ElasticSearch Bulk Indexing
Created October 19, 2011 09:52
ElasticSearch Bulk Indexing from JDBC Input
package ****.elasticsearch.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.logging.Log;
@dgorissen
dgorissen / jquery.bootstrap.confirm.popover.js
Created November 3, 2011 13:15
Confirmation dialog using jQuery and Bootstrap
/*
Copyright (c) 2011 Damien Antipa, http://www.nethead.at/, http://damien.antipa.at
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@akhawaja
akhawaja / Application.java
Created December 29, 2011 19:59
Play! Framework 1.2.x Pagination (this is a variation and modification of the version found on https://gist.github.com/1379217)
package controllers;
import controllers.Constants;
import play.mvc.Controller;
import utils.PaginationInfo;
import java.util.List;
/**
* Sample controller.
*/
@rakeshpai
rakeshpai / errorception-loader.html
Created January 11, 2012 14:33
Errorception's async loader
<script>
// <snip>
(function (window, document) {
var loader = function () {
var script = document.createElement("script"), tag = document.getElementsByTagName("script")[0];
script.src = "http://errorception.com/projects/" + _errs[0] + "/beacon.js";
tag.parentNode.insertBefore(script, tag);
};
// Wait until window.onload before downloading any more code.
@codahale
codahale / pom.xml
Last active April 20, 2024 01:38
Take this and save it as pom.xml in your project directory.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- none yet -->
@shantanusingh
shantanusingh / gist:2272004
Created April 1, 2012 06:33 — forked from bihe/init.d play
init.d script to launch Play framework under Ubuntu
#!/bin/sh
### BEGIN INIT INFO
## END INIT INFO
# Path to play install folder
PLAY_HOME=/usr/share/play
PLAY=$PLAY_HOME/play
# Path to the JVM
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
.fc {
direction: ltr;
text-align: left; }
.fc table {
border-collapse: collapse;
border-spacing: 0; }
.fc .btn {
line-height: 1.2em; }
html .fc {
@juddflamm
juddflamm / gist:5391938
Last active July 13, 2018 01:08
Enabling 2 Way SSL Client Service Calls from within Dropwizard. To do so, you need to load your keystore and truststore and configure HttpClient to us them for HTTPS calls. In this case, my keystore and truststore are the same file with the same password. (Thanks to Coda Hale for an initial solution)
//First create the httpClient in Dropwizard's run method as documented
final HttpClient httpClient = new HttpClientBuilder().using(configuration.getHttpClient()).build();
try {
//Create KeyStore obejcts for both the keystore and truststore
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore truststore = KeyStore.getInstance(KeyStore.getDefaultType());
//Then load the actual keystore/truststore file(s), they are the same file in my case
keystore.load(new FileInputStream(configuration.getKeyStore()), configuration.getKeyStorePassword().toCharArray());