Skip to content

Instantly share code, notes, and snippets.

View xlson's full-sized avatar

Leonard Gram xlson

View GitHub Profile
@xlson
xlson / gist:772569
Created January 10, 2011 09:19
git oneline with commiter name
git log --pretty=format:'%h by %an message: %s'
@xlson
xlson / del2scrumptious.groovy
Created December 27, 2010 12:20
Script that transforms the Delicious backup-xml into json for import into the CouchDB application Scrumptious
#!/usr/bin/env groovy
@Grab(group='commons-lang', module='commons-lang', version='2.5')
@Grab(group='net.sf.ezmorph', module='ezmorph', version='1.0.6')
@Grab(group='commons-collections', module='commons-collections', version='3.2.1')
@Grab(group='commons-beanutils', module='commons-beanutils', version='1.8.3')
@Grab('net.sf.json-lib:json-lib:2.3-jdk15')
import net.sf.json.*
def cli = new CliBuilder(usage:'del2scrumptious.groovy')
@xlson
xlson / Deploy.groovy
Created November 11, 2010 14:39
Quick hack that makes it easier to use the tomcat plugins deploy feature.
includeTargets << grailsScript("Init")
def tomcatRedeploy(String environment) {
runTomcatTarget('undeploy', environment)
runTomcatTarget('deploy', environment)
}
def runTomcatTarget(String target, String environment) {
def proc = ['grails', "-Dgrails.env=$environment", 'tomcat', target].execute()
proc.consumeProcessOutput System.out, System.err
@xlson
xlson / gist:661256
Created November 3, 2010 15:55
Finding file ending and classifier of release artifacts in groovy using regexp
def fileNames = '''groovycsv-0.2-javadoc.jar.asc
groovycsv-0.2-javadoc.jar.asc
groovycsv-0.2-sources.jar.asc
groovycsv-0.2.ear.asc'''.split("\n")
def project = new Expando()
project.name = 'groovycsv'
def version='0.2'
def findClassifierPattern = /$project.name-$version(?:-(.+))?\.(\w+\.asc)/
@xlson
xlson / build.gradle
Created November 2, 2010 16:16
build that works around the organization and packaging issue
import org.gradle.api.internal.artifacts.publish.*
apply plugin: 'groovy'
apply plugin: 'maven'
repositories {
mavenCentral()
mavenRepo urls: "http://m2repo.spockframework.org/snapshots"
}
@xlson
xlson / gist:647043
Created October 26, 2010 14:57
Add as bookmark for "New Tab"-functionality in Safari on the iPad
javascript:window.open('about:blank')
@xlson
xlson / mp4it
Created October 7, 2010 14:29
Groovy script that uses ffmpeg to convert an avi file into a mp4 for viewing on an iPhone or iPod
#!/usr/bin/env groovy
// Validating arguments
assert args.size() == 1 : "mp4it takes 1 argument: the path to the file to be conerted into mp4"
assert new File(args[0]).exists() : "The file you specified could not be found."
def videoFilePath = args[0]
def outputFilePath = videoFilePath.replaceAll(/\.avi$/, '.mp4')
assert !new File(outputFilePath).exists()
@xlson
xlson / LazyCollect.groovy
Created September 30, 2010 21:05
Implementation of a list.lazyCollect that will defer execution of the collect closure until get(i) is called
// Impl of a lazyCollect method that will not execute
// until you actually ask for the value
class LazyCollectList extends AbstractList {
private Closure collectClosure
private List backingList
private Map cached = [:]
@xlson
xlson / Weceem 0.9.2 search stacktrace
Created September 30, 2010 11:45
Stacktrace from searching in a fresh install of Weceem 0.9.2 in Grails 1.3.4
Grails Runtime Exception
Error Details
Error 500: Executing action [show] of controller [org.weceem.controllers.WcmContentController] in plugin [weceem] caused exception: groovy.lang.MissingMethodException: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lang.String)
Servlet: grails
URI: /try-weceem/grails/wcmContent/show.dispatch
Exception Message: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lang.String)
Caused by: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lan
@xlson
xlson / gist:542696
Created August 21, 2010 18:54
Example of using groupBy and collect together
// Example of using groupBy and collect together
def values =
[[lastname: "Anderson", age: 30],
[lastname: 'Bergstrom', age: 24],
[lastname: 'Anderson', age: 45],
[lastname: 'Bergstrom', age: 40],
[lastname: 'Brown', age: 25]]
// Find average age by lastname: