Skip to content

Instantly share code, notes, and snippets.

Jeff Sheets jeffsheets

Block or report user

Report or block jeffsheets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeffsheets
jeffsheets / datepicker-focus.js
Created Jun 5, 2012
jquery ui datepicker IE focus fix
View datepicker-focus.js
/*
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",
@jeffsheets
jeffsheets / jquery.disableMSLync.js
Created Jun 26, 2012
jQuery Plugin to disable MS Lync Phone Number detection
View jquery.disableMSLync.js
/*
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 / module-ex.js
Created Aug 23, 2012
JS Module Pattern
View module-ex.js
//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 / gist:4399922
Last active Dec 10, 2015
Jetty 8 JTA via JNDI lookup in Spring with Atomikos 3.8
View gist:4399922
<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 / gist:5292986
Last active Jul 20, 2018
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.
View gist:5292986
/*
* 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 / AutowiringSpringBeanJobFactory.java
Last active Jan 4, 2018
Configuring Quartz 2.1.7 with Spring 3.1.3 in clustered mode
View AutowiringSpringBeanJobFactory.java
/**
* 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 / Datasources.groovy
Created Aug 6, 2013
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
View Datasources.groovy
/*
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 / GroovySqlWithOutputsAndResultSetRows.groovy
Last active Jun 5, 2019
Extend Groovy Sql with callWithRows method to call a Stored Procedure and process both Output Parameters and Rows from the ResultSet in the closure handler.Could be replaced if http://jira.codehaus.org/browse/GROOVY-3048 is ever completed
View GroovySqlWithOutputsAndResultSetRows.groovy
SqlHelper sql = new SqlHelper(dataSource)
List results = sql.callWithRows("{call ABC.FINDBYLAST($lastName, ${Sql.INTEGER}, ${Sql.VARCHAR})}") {
List<GroovyRowResult> rows, int status, String errorMessage ->
if (status != 0) {
throw new RuntimeException("Error received from stored proc $status : $errorMessage")
}
return rows
}
@jeffsheets
jeffsheets / AjaxlayoutController.groovy
Last active Aug 29, 2015
Grails Controller Unit Test to verify layout and template specified in render call
View AjaxlayoutController.groovy
/* action that renders a template back to browser,
* and uses custom simple 'ajax' layout */
def ajaxResults() {
def results = workService.querySomeWork()
render (template: "ajaxResults", model:[results:results as JSON], layout:'ajax')
}
@jeffsheets
jeffsheets / APoolHelper.groovy
Last active Jun 15, 2016
Grails setup for using Apache Commons Pool to pool JAX-WS Port Proxy WS Stub objects because creating the connections can be an expensive operation
View APoolHelper.groovy
import org.apache.commons.pool2.ObjectPool
import org.apache.log4j.Logger
class PoolHelper {
static Logger log = Logger.getLogger(PoolHelper)
/**
* Executes a closure using the object from the passed
* in Commons Pool, invalidating the object if an error is returned,
* and always returning it to the pool. Similar to how Groovy Sql methods work.
*/
You can’t perform that action at this time.