Skip to content

Instantly share code, notes, and snippets.

View danieldbower's full-sized avatar

Daniel Bower danieldbower

View GitHub Profile
@danieldbower
danieldbower / pom.xml
Created May 25, 2017 15:13
snippet of pom showing excluding of bouncycastle libs from maven shade / dropwizard
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.bouncycastle:*</exclude>
@danieldbower
danieldbower / xmlfile.py
Last active March 28, 2017 13:29 — forked from benbramley/xmlfile.py
Ansible lookup plugin for XML files
from __future__ import (absolute_import, division)
__metaclass__ = type
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
from ansible.utils.listify import listify_lookup_plugin_terms
import xml.etree.ElementTree as etree
# Version for Ansible 2.0
# forked from https://gist.github.com/benbramley/xmlfile.py
@danieldbower
danieldbower / InfinumMysqlDialect.groovy
Created October 15, 2014 16:47
InfinumMysqlDialect - Add Decimal to RegisterColumnType
package com.infinum
import java.sql.Types
import org.hibernate.dialect.MySQL5Dialect
import org.hibernate.type.StandardBasicTypes
class InfinumMysqlDialect extends MySQL5Dialect {
InfinumMysqlDialect () {
super ()
@danieldbower
danieldbower / runtime.groovy
Created June 24, 2014 16:39
Arbitrary Groovy at Runtime
def binding = new Binding()
def shell = new GroovyShell(binding)
def script = '''println "hello world" '''
shell.evaluate(script)
@danieldbower
danieldbower / MinusEquals.groovy
Created April 15, 2014 13:28
Groovy minus equals
def vals = [50, 25, 5, 0, -5, -25, 50]
vals.each{
println "\n\nVal is $it"
int i = 50
i =- it
println "(50 =- $it) is equal to $i"
i = 50
@danieldbower
danieldbower / groovyTruth.groovy
Last active August 29, 2015 13:59
Groovy Truth Examples
Map vals = ['Zero':0, 'Negative decimal':-0.01, 'Negative decimal':-0.05, 'Negative whole number':-1,
'Negative decimal':-1.5, 'One':1, 'Positive decimal':0.01, 'Positive decimal':0.05,
'Positive decimal':1.5, 'Empty string':'', 'Empty list':[], 'Empty hash':[:],
'Lower character':'a', 'Upper character':'A', 'Null':null
]
vals.each{ k, v ->
println (v ? "$k ( $v ) is true" : "$k ( $v ) is false")
}
@danieldbower
danieldbower / .bashrc
Created March 4, 2014 02:21
Disable -m (message parameter) in git command in bashrc
function git {
for arg
do
if [[ $arg == -m* || $arg == -[^-]*m* ]]
then
annoy_me
return 1
fi
done
command git "$@"
@danieldbower
danieldbower / retainAllExample.groovy
Created January 30, 2014 21:55
Groovy retainAll example with Closure
def a = [[id:"a"], [id:"b"], [id:"c"]]
def b = ["a", "b"]
a.retainAll(){
println it
b.contains(it.id)
}
println a
@danieldbower
danieldbower / DbUtil.java
Created October 29, 2013 15:20
Extract underlying Oracle connection from Jboss Wrapped connection, and create Oracle Clob Parameter
package com.bowerstudios.myapp.dao;
import java.io.Writer;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;
import oracle.sql.CLOB;
import org.jboss.resource.adapter.jdbc.WrappedConnection;
@danieldbower
danieldbower / deployerConfigContext.xml
Created September 6, 2012 17:59
CAS 3.5 with attributes
<?xml version="1.0" encoding="UTF-8"?>
<!-- | deployerConfigContext.xml centralizes into one file some of the declarative
configuration that | all CAS deployers will need to modify. | | This file
declares some of the Spring-managed JavaBeans that make up a CAS deployment.
| The beans declared in this file are instantiated at context initialization
time by the Spring | ContextLoaderListener declared in web.xml. It finds
this file because this | file is among those declared in the context parameter
"contextConfigLocation". | | By far the most common change you will need
to make in this file is to change the last bean | declaration to replace
the default SimpleTestUsernamePasswordAuthenticationHandler with | one implementing