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
@GrabResolver(name='Nexus OSS Repo', root='https://oss.sonatype.org/content/groups/public/', m2Compatible='true') | |
@Grab('com.xlson.groovycsv:groovycsv:0.3-SNAPSHOT') | |
import com.xlson.groovycsv.CsvParser | |
def csv = '''Name:Lastname | |
Mark:Andersson | |
Pete:Hansen''' | |
def data = new CsvParser().parse(csv, autoDetect:true) | |
for(line in data) { |
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
#!/bin/bash | |
# | |
# chkconfig: 35 90 12 | |
# description: carbon-cache script | |
# | |
LOCKFILE=/var/lock/subsys/carbon | |
# Get function from functions library | |
. /etc/init.d/functions |
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 LazyCollectList extends AbstractList { | |
private Closure collectClosure | |
private List backingList | |
private Map cached = [:] | |
def get(int i) { | |
if(!cached.containsKey(i)) { |
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
Object.metaClass.partition = { partitionSize -> | |
def result = delegate.inject([[]]) { partitioned, it -> | |
if(partitioned.last().size() == partitionSize) { | |
partitioned << [it] | |
} else { | |
partitioned.last() << it | |
} | |
partitioned | |
} | |
result?.last().size() == 0 ? [] : result |
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
#!/bin/bash | |
NAME_PATTERN=$1 | |
GREP_TEXT=$2 | |
find . -name "$NAME_PATTERN" -exec grep -H "$GREP_TEXT" '{}' \; |
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
#!/bin/bash | |
COMMAND=$1 | |
i=0 | |
echo "Executing: $COMMAND" | |
while true; do | |
i=$[$i+1] | |
echo "Run: $i ("`date`")" | |
$COMMAND 2>&1 1> run.log |
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
@Grab('com.xlson.groovycsv:groovycsv:0.2') | |
import com.xlson.groovycsv.CsvParse | |
def csv = '''Name-Lastname | |
Mark-'Anderson-Nielsen' | |
Pete-Hansen''' | |
def data = new CsvParser().parse(csv, separator: '-', quoteChar: "'") | |
for(line in data) { | |
println "$line.Name $line.Lastname" | |
} |
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
GIT_COMPLETION_PATH="/usr/local/git/contrib/completion/git-completion.bash" | |
if [ -f "$GIT_COMPLETION_PATH" ]; then | |
GIT_PS1_SHOWDIRTYSTATE=true | |
. "$GIT_COMPLETION_PATH" | |
ADD_PS1='$(__git_ps1)' | |
fi | |
if [[ ${EUID} == 0 ]] ; then | |
PS1="\[\033[01;31m\]\h\[\033[01;34m\] \w\[\033[33m\]$ADD_PS1\[\033[34m\] \$\[\033[00m\] " | |
else |
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
#!/usr/bin/env groovyclient | |
println(prettyPrintXml(System.in.text)) | |
def prettyPrintXml(text) { | |
def xmlNode = new XmlParser().parseText(text) | |
def writer = new StringWriter() | |
def printer = new XmlNodePrinter(new PrintWriter(writer)) | |
printer.preserveWhitespace = true | |
printer.print(xmlNode) |
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 testcommandobjects | |
class TestController { | |
static final int VALID = 5 | |
static final int INVALID = 50 | |
def resetToValid = { TestCommand cmd -> | |
rebindAgeAndRenderResponse(cmd, true) | |
} |