Skip to content

Instantly share code, notes, and snippets.

@mcantrell
mcantrell / jquery.ui.splitButton.js
Created October 1, 2011 02:00
jQuery UI Split Button Plugin
/**
* creates a split button UI component using jquery ui 1.8.x's menu and button groups. See comment about potential
* changes in jquery ui 1.9.x.
*
* @see http://jqueryui.com/demos/button/splitbutton.html for a non-functional example
* @see https://raw.github.com/jquery/jquery-ui/5f4a6009e9987842b3a970c77bed0b52f7e810e2/demos/button/splitbutton.html for the code used for this plugin.
*
* @param options.selected closure to execute upon menu item selection (default: execute the link href)
* @param options.showMenu closure to show context menu (default: show the menu relative to the button)
*/
@mcantrell
mcantrell / fixSharepointAlternateHeaders.ps1
Created April 20, 2012 14:58
Fix Sharepoint Alternate Headers
Add-PSSnapin Microsoft.SharePoint.PowerShell
$w = Get-SPWeb http://domain/siteName; $w.AlternateHeader = $null; $w.Update()
@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() {
@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 / 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 / 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 / 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 / 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 / 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 / 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