Skip to content

Instantly share code, notes, and snippets.

@mcantrell
mcantrell / tomcat.sh
Last active December 15, 2015 08:39
Tomcat init.d script slightly tweaked from here: https://gist.github.com/valotas/1000094
#!/bin/bash
#
# tomcat7 This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@mcantrell
mcantrell / launchd.conf
Last active December 14, 2015 18:29
Mac Laptop Configuration
# Set environment variables here so they are available globally to all apps
# (and Terminal), including those launched via Spotlight.
#
# After editing this file run the following command from the terminal to update
# environment variables globally without needing to reboot.
# NOTE: You will still need to restart the relevant application (including
# Terminal) to pick up the changes!
# grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
#
# See http://www.digitaledgesw.com/node/31
@mcantrell
mcantrell / tcpsettings.bat
Created March 5, 2013 21:21
TCP Offload Fix for VMWare and Windows Server 2008 r2
Netsh int tcp set global RSS=Disable
Netsh int tcp set global chimney=Disabled
Netsh int tcp set global autotuninglevel=Disabled
Netsh int tcp set global congestionprovider=None
Netsh int tcp set global ecncapability=Disabled
Netsh int ip set global taskoffload=disabled
Netsh int tcp set global timestamps=Disabled
@mcantrell
mcantrell / catalina.properties
Last active December 13, 2015 21:49
Clustered tomcat config
package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
server.loader=
shared.loader=
tomcat.util.buf.StringCache.byte.enabled=true
http.port=8080
shutdown.port=8005
@mcantrell
mcantrell / crypto-spike-tests.js
Last active December 10, 2015 13:18
Node.js cryptography spike (Mocha Test) in order to get it talking with Java PBE which uses PBKDF1 instead of the more popular (and secure) PBKDF2. This is not pretty and uses an insecure algorithm (DES and MD5) but it illustrates the point. I'll work on refactoring it into a real lib for Zuul at some point.
var should = require('should'),
crypto = require('crypto');
describe('Crypto Spike Tests', function () {
var password = new Buffer('test', 'utf8');
var KDF = function(password, salt, iterations) {
var key = Buffer.concat([password, salt]);
for (var i = 0; i < iterations; i++) {
key = crypto.createHash("md5").update(key).digest();
}
@mcantrell
mcantrell / iptables-http-forward.sh
Created December 22, 2012 20:55
IP tables command to allow local, non-root applications to be accessed via port 80 without a proxy
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
@mcantrell
mcantrell / displaytag.properties
Created November 17, 2012 22:37
Bootstrap Pagination with DisplayTag
paging.banner.placement=top
paging.banner.all_items_found=
paging.banner.some_items_found=
paging.banner.one_item_found=
paging.banner.no_items_found=
paging.banner.onepage=
paging.banner.first=<div class="pagination pagination-right"><ul><li class="disabled"><span>First</span></li>{0}<li><a href="{4}">Last</a></li></ul></div>
paging.banner.full=<div class="pagination pagination-right"><ul><li><a href="{1}">First</a></li>{0}<li><a href="{4}">Last</a></li></ul></div>
paging.banner.last=<div class="pagination pagination-right"><ul><li><a href="{1}">First</a></li>{0}<li class="disabled"><span>Last</span></li></ul></div>
paging.banner.page.link=<li><a href="{1}">{0}</a></li>
@mcantrell
mcantrell / pom.xml
Created September 14, 2012 15:34
Custom Groovy Version with GMaven - Example POM
<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>org.devnull</groupId>
<artifactId>gmaven-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@mcantrell
mcantrell / JstlFunctions.groovy
Created September 4, 2012 02:15
Custom JSTL function to retrieve application version from Maven build metadata
package org.devnull.zuul.web.config
import org.springframework.web.context.support.ServletContextResource
import javax.servlet.ServletContext
class JstlFunctions {
static String getApplicationVersion(ServletContext context) {
def mavenProps = new ServletContextResource(context, "/META-INF/maven/org.devnull/zuul-web/pom.properties")
if (mavenProps.exists()) {
@mcantrell
mcantrell / BaseHttpServerIntegrationTest.groovy
Last active October 9, 2015 23:57
Mocking HTTP Server Responses in Junit
import org.junit.AfterClass
import org.junit.BeforeClass
import org.mortbay.jetty.Server
import org.springframework.core.io.ClassPathResource
abstract class BaseHttpServerIntegrationTest {
static Server server
@BeforeClass
static void createServer() {