Skip to content

Instantly share code, notes, and snippets.

View cholick's full-sized avatar
:shipit:

Matt Cholick cholick

:shipit:
View GitHub Profile
@cholick
cholick / gist:2029461
Created March 13, 2012 15:38
Testing apache-commons ComparatorChain
//Quick test to check the ComparatorChain in the apache-commons libraries.
@Grab(group='commons-collections', module='commons-collections', version='3.0')
@Grab(group='commons-beanutils', module='commons-beanutils', version='1.8.3')
import org.apache.commons.beanutils.BeanComparator
import org.apache.commons.collections.comparators.ComparatorChain
import org.apache.commons.collections.comparators.NullComparator
class Test {
@cholick
cholick / gist:2067147
Created March 18, 2012 00:45
Groovy example from Ken Kousen, hit url using collection for params and display image in swing window
//useful Groovy example from SpringOne talk by Ken Kousen
//hit url using collection for params and display image in swing window
import java.awt.BorderLayout as BL
import javax.swing.WindowConstants as WC
import groovy.swing.SwingBuilder
import javax.swing.ImageIcon
def base = 'http://chart.apis.google.com/chart?'
def params = [cht: 'p3', chs: '400x200', chd: 't:60,40', chl: 'Hello|World']
@cholick
cholick / github_issues.groovy
Created March 21, 2012 05:08
Script to export issues with comments for a github project
/**
*
* This script pulls all the issues from github for the project in the working directory
* and tosses them onto standard out
* Prerequisites: configure git with a username:
* $ git config --global github.user username
*
* @author Matt Cholick
*
* todo: Deal with rate limiting
@cholick
cholick / build.gradle
Created June 10, 2012 00:50
Gradle task for gmetrics
//Minimal configuration needed for Gradle build file with GMetrics integration
apply plugin: 'groovy'
repositories {
mavenCentral()
}
configurations {
gmetrics
}
@cholick
cholick / RatingServiceIntSpec.groovy
Created August 8, 2012 02:10
Example Spock Test
@Slf4j
class RatingServiceIntSpec extends BaseDatabaseIntSpec {
RatingService ratingService
def setup() {
ratingService = injector.getInstance(RatingService.class)
}
def 'Test that save ratings persists and update'() {
@cholick
cholick / replicator.groovy
Last active December 10, 2015 00:19
Groovy program that rewrites itself exactly using a new, random filename.
def p = '''
@Grab(group='commons-lang', module='commons-lang', version='2.4') import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric
File file = new File("${randomAlphanumeric(8)}.groovy").write(p)
new GroovyShell(new Binding([p: "def p = ${"'"*3}${p}${"'"*3}; ${p.readLines()[3]}"])).evaluate(p.readLines()[0..2].join(';') as String)
'''; new GroovyShell(new Binding([p: "def p = ${"'"*3}${p}${"'"*3}; ${p.readLines()[3]}"])).evaluate(p.readLines()[0..2].join(';') as String)
@cholick
cholick / gist:5054035
Created February 28, 2013 03:52
Productivity fix
echo "\n184.72.112.163 reddit.com\n184.72.112.163 www.reddit.com" | sudo tee -a /etc/hosts
@cholick
cholick / project-config.xml
Created March 3, 2013 18:35
TeamCity configuration for an IntelliJ plugin building and testing against two versions of the SDK
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project SYSTEM "../project-config.dtd">
<project id="project2">
<parameters />
<build-type id="bt4" name="IntelliJ 11.1 (IDEA IC 117-1054)">
<description />
<settings>
<parameters />
<build-runners>
@cholick
cholick / build.gradle
Last active October 24, 2018 21:08
Using Gradle & jarjar to repackage and embed incompatible transitive dependencies
apply plugin: 'groovy'
repositories {
mavenCentral()
}
configurations {
patch
[compile, testCompile]*.exclude module: 'jersey-server'
}
@cholick
cholick / init.sh
Last active August 29, 2015 13:56
Pre-commit hook to check for Spock @ignore annotation
# Script to initially setup hook globally
# For existing repositories, re-run "git init"
git config --global init.templatedir '~/.git_template'
mkdir -p ~/.git_template/hooks
tee > ~/.git_template/hooks/pre-commit << 'EOF'
git stash -q --keep-index
red=$(tput setaf 1)