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
/* | |
See https://github.com/jquery-validation/jquery-validation/issues/379. | |
The maintainors of jQuery validate are OK validating whether or not 1,000,000 and 1.000.000 are numbers, | |
but aren't getting into parsing their values (because of international formats), so the min, max, and range | |
rules don't support anything formatted. | |
*/ | |
$.validator.addMethod('min', function( value, element, param ) { | |
value = numeral(value).value(); | |
return this.optional(element) || value >= param; |
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
class Thing { | |
doStuffWithFile( file ) { | |
return new Promise( ( reject, resolve ) => { | |
/* | |
do shit... | |
*/ | |
resolve(stuff) | |
}) | |
} | |
} |
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
@Grapes([ | |
@Grab(group='org.apache.poi', module='poi', version='3.15'), | |
@Grab(group='org.apache.poi', module='poi-ooxml', version='3.15'), | |
]) | |
import org.apache.poi.ss.usermodel.* | |
import org.apache.poi.xssf.usermodel.XSSFWorkbook | |
// input file: make sure we can read it | |
File inFile = new File('../input/contacts.xlsx') |
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
def "Should return 200 when sending request to controller"() { | |
when: | |
ResponseEntity<Map> entity = testRestTemplate.getForEntity("http://localhost:" + this.port + "/hello-world", Map.class) | |
then: | |
entity.statusCode == HttpStatus.OK | |
} | |
@Test | |
void shouldReturn200WhenSendingRequestToController() { |
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
.config(['$httpProvider', function($httpProvider) { | |
// Create a new definition for the httpProvider's factory function that allows us to intercept the | |
// $http service it creates | |
var originalFactoryFunction = $httpProvider.$get[ $httpProvider.$get.length - 1 ] | |
var newFactoryFunction = function($browser, $httpBackend, $$cookieReader, $cacheFactory, $rootScope, $q, $injector, $sce) { | |
var $http = originalFactoryFunction( $browser, $httpBackend, $$cookieReader, $cacheFactory, $rootScope, $q, $injector, $sce ) | |
// Decorate the definition of .get() |
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
// get a reference to jQuery that shouldn't interfere with wordpressy bits | |
var ___safejQueryRef = ( $ == undefined ? jQuery : $ ); | |
___safejQueryRef( function() { | |
// locally make all right with the universe, jQuerywise | |
var $ = ___safejQueryRef | |
// get tabs and panes | |
var tabs = $('.cherry-tabs-nav').children(); | |
var panes = $('.cherry-tabs-pane'); |
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
/* | |
Adds a SQL-server specific callRows() method to Groovy Sql that functions like rows() against stored | |
procedures that perform DML before doing a select. | |
Essentially, it's just a set nocount on/off wrapper. | |
Usage: | |
sql.callRows( | |
"someProcName", |
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
package com.boyzoid | |
class ScottsRoundRobiner { | |
static final DEFAULT_TEAM_COUNT = 7 | |
static final DEFAULT_HOLE_COUNT = 9 | |
List makeSchedule( List teams, Integer holeCount ) { | |
List schedule = [] | |
// Checked against http://stackoverflow.com/questions/6648512/scheduling-algorithm-for-a-round-robin-tournament |
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
def someKindaClassProcessorMap = [ | |
(String) : new StringProcessor(), | |
(Date) : new DateProcessor() | |
] |
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 org.codehaus.groovy.grails.commons.GrailsApplication | |
import grails.util.GrailsUtil | |
class ErrorController { | |
def index() { | |
if ( GrailsApplication.ENV_PRODUCTION == GrailsUtil.environment ) { | |
// Production: show a nice error message | |
render(view:'production') | |
} else { |
NewerOlder