Skip to content

Instantly share code, notes, and snippets.

View webdevwilson's full-sized avatar

Kerry Wilson webdevwilson

View GitHub Profile
@webdevwilson
webdevwilson / main
Created October 29, 2014 16:15
Dual ssl auth in go
# copied from https://groups.google.com/forum/#!topic/golang-nuts/dEfqPOSccIc
package main
import(
"crypto/rand"
"crypto/tls"
"io/ioutil"
"log"
"net"
@webdevwilson
webdevwilson / compare-and-copy-files.groovy
Created January 19, 2011 15:55
Groovy code to compare to directory trees and copy different files over
def path1 = new File(args[0]).absolutePath
def path2 = new File(args[1]).absolutePath
def different = compareDirs(path1, path2)
different.files.each {
println it.from
new AntBuilder().copy ( file: it.from.absolutePath, tofile : it.to.absolutePath )
}
println different.files.size() + ' of ' + different.count
@webdevwilson
webdevwilson / function.curry.js
Created January 21, 2011 20:26
Add curry method to functions
Function.prototype.curry = function(scope) {
scope = scope || window;
var cargs = [];
for (var i=1, len = arguments.length; i < len; ++i) {
cargs.push(arguments[i]);
}
var m = this;
return function() {
var args = [];
for (var i=0, len = cargs.length; i < len; ++i) {
@webdevwilson
webdevwilson / persistence.xml
Created January 25, 2011 04:54
JPA Hibernate Configuration
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="pu">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!-- Auto detect annotation model classes -->
@webdevwilson
webdevwilson / RegexMatcher.java
Created January 25, 2011 20:35
Regular Expression Matcher for Unit testing
public class RegexMatcher extends BaseMatcher{
private final String regex;
public RegexMatcher(String regex){
this.regex = regex;
}
public boolean matches(Object o){
return ((String)o).matches(regex);
@webdevwilson
webdevwilson / GenericTypeTest.java
Created May 23, 2011 16:38
Generic type erasure tests
package com.goodercode;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import org.junit.Before;
@webdevwilson
webdevwilson / http_request.groovy
Created September 30, 2011 16:49
A groovy script to send HTTP requests
def echo = System.out.&println
def url = new URL('%YOUR_URL_HERE%')
def conn = url.openConnection()
conn.useCaches = false
conn.doInput = true
conn.doOutput = true
def formData = """\
var1:blah
@webdevwilson
webdevwilson / BaseTest.java
Created January 12, 2012 18:45
Base test class
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.OngoingStubbing;
@webdevwilson
webdevwilson / pom.xml
Created January 29, 2012 13:48
Roo database reverse engineer with Oracle
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oracle.roo.jdbc</groupId>
<artifactId>com.oracle.roo.jdbc.ojdbc6</artifactId>
<packaging>bundle</packaging>
<version>11.2.0.3</version>
<name>com-oracle-roo-jdbc</name>
<description>This bundle wraps the standard Maven artifact: ${pkgArtifactId}-${pkgVersion}.</description>
<properties>
@webdevwilson
webdevwilson / WebTestBase.java
Created February 4, 2012 18:53
jquery HtmlUnit base class
public class WebTestBase {
protected WebClient webClient;
protected HtmlPage htmlPage;
protected void goTo(final String url){
return (HtmlPage)webClient.getPage(url);
}