Skip to content

Instantly share code, notes, and snippets.

View cdeszaq's full-sized avatar
💭
Doing a little wiring...

Rick Jensen cdeszaq

💭
Doing a little wiring...
View GitHub Profile
println("Configuring data sources")
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
// This can be used in lieu of changing the metaclass in the constructor,
// but affects _all_ classes, which can be a big overhead
// ExpandoMetaClass.enableGlobally()
class RobotDog {
String name
RobotDog() {
// Make the metaclass an expando so that we can cache behavior better
def mc = new ExpandoMetaClass(RobotDog,false,true)
// isPalindrome - ignore cases, spaces and punctuation
// Empty string is false
// O(1) space, cant modify original string
[1,2,3,4,5,6].each {
println "Running isPalindrome${it}"
assert !"isPalindrome${it}"("") // False
assert !"isPalindrome${it}"(" !,! ") // False
assert "isPalindrome${it}"("M") // True
assert "isPalindrome${it}"("MM..M") // True
// isPalindrome - ignore cases, spaces and punctuation
// Empty string is false
// O(1) space, cant modify original string
[1,2,3,4,5,6].each {
println "Running isPalindrome${it}"
assert !"isPalindrome${it}"("") // False
assert !"isPalindrome${it}"(" !,! ") // False
assert "isPalindrome${it}"("M") // True
assert "isPalindrome${it}"("M.") // True
@cdeszaq
cdeszaq / Problem.md
Last active December 19, 2015 01:59

TODO: Fill in the problem statement

var empty_list = function(selector) {
return selector(undefined, undefined, true);
};
var prepend = function(el, list) {
return function(selector) {
return selector(el, list, false);
};
};
var head = function(list) {

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@cdeszaq
cdeszaq / gist:5222593
Created March 22, 2013 16:15
Plugins and Dependencies from BuildConfig.groovy
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// Allows connecting to MySQL DBs
runtime 'mysql:mysql-connector-java:5.1.22'
// For JodaTime plugin
compile "org.jadira.usertype:usertype.jodatime:1.9.1"
// So that spock can work with Grails 2.2
@cdeszaq
cdeszaq / RequestPeerEvaluationController.groovy
Created February 7, 2013 19:40
Example of how to have multiple child elements created from a single view. Of note, the `RequestedPeersCommand` object is the part that lets n People be selected to request peer evaluations from.
package edu.wisc.radiology.performanceevaluations
import grails.converters.JSON
import grails.converters.XML
import grails.plugins.springsecurity.Secured
import grails.validation.Validateable
@Secured("hasRole('ROLE_USER')")
class RequestPeerEvaluationController {
@cdeszaq
cdeszaq / MyDomain.groovy
Created December 27, 2012 14:50
Example of how to DRY up complex Grails validation logic and share it across different domain objects.
class MyDomain {
...
static constraints = {
items(validator: requiresAtleastOne)
}
}