Skip to content

Instantly share code, notes, and snippets.

@davidkeen
davidkeen / pom.xml
Last active January 24, 2024 14:03
Disable doclint for Java 8
<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@davidkeen
davidkeen / env
Last active October 17, 2018 13:16
A systemd unit file for Play Framework
ADDRESS=127.0.0.1
PORT=9000
APPLY_EVOLUTIONS=true
APPLICATION_SECRET=my_secret
@davidkeen
davidkeen / SingleRevisionClassLoaderEvolutionsReader.scala
Created January 4, 2018 13:10
A Play Framework Evolutions reader that reads a single revision from the class path.
import play.api.db.evolutions.{ClassLoaderEvolutionsReader, Evolution}
import play.api.libs.Collections
/***
* Evolutions reader that reads a single revision from the class path.
*
* @param revision the revision number to load
* @param prefix A prefix that gets added to the resource file names
*/
class SingleRevisionClassLoaderEvolutionsReader(val revision: Int, val prefix: String) extends ClassLoaderEvolutionsReader(prefix = prefix) {
@davidkeen
davidkeen / play.conf
Last active July 6, 2016 07:50 — forked from omphe/gist:8302060
Upstart script for Play Framework 2.2.
description "Play Framework Config"
env USER=username
env GROUP=username
env HOME=/your/project/root
env PORT=8080
env ADDRESS=127.0.0.1
env MEM=1024
env PROJECT=your_play_project
@davidkeen
davidkeen / le-renew-webroot
Last active March 4, 2016 14:28 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file=${1:-/usr/local/etc/le-renew-webroot.ini}
le_path='/opt/letsencrypt'
exp_limit=30;
function log {
echo [$(date -u)] $1
@davidkeen
davidkeen / TileLayer.Common.js
Created September 15, 2012 21:17 — forked from mourner/TileLayer.Common.js
Leaflet shortcuts for common tile providers
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {
@davidkeen
davidkeen / bad_referers.conf
Last active August 29, 2015 14:23
Block referer spam in Nginx
map $http_referer $bad_referer {
default 0;
"~semaltmedia\.com" 1;
"~100dollars-seo\.com" 1;
"~buttons-for-your-website\.com" 1;
"~best-seo-offer\.com" 1;
}
# Server block
# if ($bad_referer) {
@davidkeen
davidkeen / mvn-gatling.xml
Created November 28, 2014 10:59
Multiple gatling simulations with maven plugin
<profiles>
<profile>
<id>performance</id>
<build>
<plugins>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>2.0.0-RC4</version>
<configuration>
@davidkeen
davidkeen / jolokia.py
Created October 29, 2014 15:15
Get queue size from jmx
from pyjolokia import Jolokia
import json
# Enter the jolokia url
j4p = Jolokia('http://localhost:8778/jolokia/')
# Put in the type, the mbean, or other options. Check the jolokia users guide for more info
# This then will return back a python dictionary of what happend to the request
data = j4p.request(type = 'read', mbean='org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=sms.in', attribute='QueueSize')
@davidkeen
davidkeen / master_amee_cron
Created October 8, 2014 09:29
AMEE index synchronisation crontab
# Keep the 1 most recent Lucene snapshots every 30 minutes
*/30 * * * * /var/www/apps/amee-platform/current/bin/snapcleaner -N 1 -d /var/www/apps/amee-platform/lucene
# Check the slaves are up to date
0 * * * * /var/www/apps/amee-platform/current/bin/slavecheck -d /var/www/apps/amee-platform/lucene