Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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
@davidkeen
davidkeen / amee
Created October 8, 2014 08:59
AMEE init script
#!/bin/bash
export RUN_AS_USER=amee
AMEE_HOME=/var/www/apps/amee-platform/current
sh $AMEE_HOME/bin/amee-platform $1
@davidkeen
davidkeen / amee
Last active August 29, 2015 14:07
AMEE nginx vhost (http)
upstream amee-platform {
server 127.0.0.1:8888;
}
upstream amee-platform-secure {
server 127.0.0.1:8889;
}
server {
listen 80;