Skip to content

Instantly share code, notes, and snippets.

@jeffsheets
jeffsheets / Datasources.groovy
Created August 6, 2013 20:23
Rollback transactions from multiple Datasource in Grails Integration Tests Prior to Grails 2.3.x, and with Grails 1.3.x on datasources plugin Fixed in 2.3.x
/*
Sample Datasources.groovy file for datasources 0.5 plugin with grails 1.3.x
*/
datasources = {
datasource(name: 'db2') {
domainClasses([com.sheetsj.domain.db2.MyObj, com.sheetsj.domain.db2.MyObj2])
services(['myDb2Stuff'])
driverClassName('com.ibm.db2.jcc.DB2Driver')
dialect(org.hibernate.dialect.DB2Dialect)
@jeffsheets
jeffsheets / AutowiringSpringBeanJobFactory.java
Last active February 12, 2022 14:44
Configuring Quartz 2.1.7 with Spring 3.1.3 in clustered mode
/**
* Autowire Quartz Jobs with Spring context dependencies
* @see http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring/15211030#15211030
*/
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;
public void setApplicationContext(final ApplicationContext context) {
beanFactory = context.getAutowireCapableBeanFactory();
}
@jeffsheets
jeffsheets / gist:5292986
Last active July 20, 2018 14:39
Hibernate DetachedCriteria using subqueries exists clause, while eager fetching the lazy collection that is in the exists clause, and running via Spring HibernateTemplate findByCriteria, and limit results to max of 2000.
/*
* HQL would look something like this:
*
* from Person p join fetch p.addresses address
* where exists (
* from Address addr left join addr.state st
* where addr.personId = p.id
* and st.abbreviation = :abbreviation
* )
*/
@jeffsheets
jeffsheets / gist:4399922
Last active December 10, 2015 07:18
Jetty 8 JTA via JNDI lookup in Spring with Atomikos 3.8
<New id="tmjndi" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>java:/TransactionManager</Arg>
<Arg>
<New class="com.atomikos.icatch.jta.UserTransactionManager"/>
</Arg>
</New>
<New id="tx" class="org.eclipse.jetty.plus.jndi.Transaction">
<Arg>
@jeffsheets
jeffsheets / module-ex.js
Created August 23, 2012 15:13
JS Module Pattern
//From https://github.com/sjurgemeyer/GR8-US-2012/blob/master/Mobile-and-Grails-ZachLendon/Mobile-and-Grails-ZachLendon.pdf
var module = (function () {
// private variables and functions
var foo = 'bar';
// constructor
var module = function () {
};
@jeffsheets
jeffsheets / jquery.disableMSLync.js
Created June 26, 2012 16:13
jQuery Plugin to disable MS Lync Phone Number detection
/*
The IE Microsoft Lync Plugin puts an icon next to all phone numbers in the html markup.
This causes page layouts to break, especially with scrolling table plugins.
The icon is also included in printouts.
This disableMSLync plugin hides phone numbers from MS Lync by replacing the normal hyphen
with the non-breaking hyphen character code.
*/
@jeffsheets
jeffsheets / datepicker-focus.js
Created June 5, 2012 18:32
jquery ui datepicker IE focus fix
/*
After jquery ui datepicker selection, blur and change
events fire before focus is returned to the input field,
handling a quirk from IE browsers
*/
$("input.dateInput").datepicker({
changeMonth: true,
changeYear: true,
showAnim: "fadeIn",