This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
/** | |
* Utility method for quickly building mock models | |
*/ | |
public class Builder { | |
public static <T> T build(Class<T> clazz, Object... keyValues) { | |
try { | |
return build(clazz, clazz.newInstance(), keyValues); | |
} catch (InstantiationException e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<templateSet group="user"> | |
<template name="with" value="public $FooBuilder$ with$Foo$($FooType$ $foo$) { this.$foo$ = $foo$; return this; }" description="generate a builder with param setter" toReformat="true" toShortenFQNames="true"> | |
<variable name="foo" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="FooBuilder" expression="className()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="FooType" expression="typeOfVariable(foo)" defaultValue="" alwaysStopAt="false" /> | |
<variable name="Foo" expression="capitalize(foo)" defaultValue="" alwaysStopAt="false" /> | |
<context> | |
<option name="JAVA_CODE" value="true" /> | |
<option name="JAVA_COMMENT" value="false" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# just some hackity hack to manage the remote tomcat on old-darrend-desktop | |
class TomcatOldEnvironment | |
def initialize targetslot | |
@targetslot = targetslot | |
end | |
def targetslot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.xml.bind.*; | |
import javax.xml.bind.util.JAXBSource; | |
import javax.xml.namespace.QName; | |
import javax.xml.transform.stream.StreamSource; | |
public class DeepCopier<T> { | |
private static QName qname = new QName("deepcopy"); | |
private Unmarshaller unmarshaller; | |
private JAXBElement<T> contentObject; | |
private Marshaller marshaller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> T deepCopyJAXB(T object, Class<T> clazz) { | |
try { | |
JAXBContext jaxbContext = JAXBContext.newInstance(clazz); | |
JAXBElement<T> contentObject = new JAXBElement<T>(new QName(clazz.getSimpleName()), clazz, object); | |
JAXBSource source = new JAXBSource(jaxbContext, contentObject); | |
return jaxbContext.createUnmarshaller().unmarshal(source, clazz).getValue(); | |
} catch (JAXBException e) { | |
throw new RuntimeException(e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kill the process if it is running | |
PIDFILE = "/var/run/stream_load.pid" | |
def read_pidfile | |
begin | |
File.open(PIDFILE,"r") { |file| return file.gets.to_i } | |
rescue | |
puts "pidfile not found or invalid" | |
end if File.exists?(PIDFILE) | |
puts "no pidfile readable" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require 'time' | |
ASIDES_FILE = "/Users/darrend/anaside.txt" | |
# grab something and stick it somewhere | |
if(ARGV.nil? ||ARGV.empty?) | |
puts %x(cat #{ASIDES_FILE}) | |
else | |
line = ARGV.join(" ") | |
File.open(ASIDES_FILE, 'a') {|f| f.puts("#{Time.now.iso8601} | #{line}")} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby | |
# First stab at a svn log watcher for user ohnojoe. | |
# SvnRecord also allows you to easily extend the script to match on certain file names/package names | |
# that you want to watch. | |
SVN_CMD = 'svn log -l 30 -v https://my.svn.server.com/Project/branches/' | |
FILE_MATCH = '\/branches\/.*' | |
USERS_WATCHED = %w{ ohnojoe } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.LinkedList; | |
import java.util.Arrays; | |
import java.lang.reflect.Proxy; | |
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Method; | |
/** | |
* Mocks interfaces with a series of pre-determined calls and preloaded return values. | |
* |
NewerOlder