Skip to content

Instantly share code, notes, and snippets.


Jean Tessier jeantessier

View GitHub Profile
jeantessier / CopyMatcher.groovy
Last active Aug 29, 2015
Example of stripped down notation for Groovy, compared to Java.
View CopyMatcher.groovy
import org.apache.commons.lang.StringUtils
class CopyMatcher {
def triggerWord
def matches(product) {
product.productCopy.any { StringUtils.containsIgnoreCase it.copy, triggerWord }
jeantessier / Histogram.groovy
Created Oct 21, 2014
Building a histogram from a Grails criteria search.
View Histogram.groovy
Employee.withCriteria {
projections {
groupProperty "gender"
}.inject([:]) { histo, row ->
histo[row[0]] = row[1]
jeantessier / User.groovy
Last active Sep 5, 2015
Replace complicated Java microservice with trivial Grails 3 app.
View User.groovy
package springpack.model
@Resource(uri='/users', formats=['json', 'xml'])
class User {
String username
String email
jeantessier / gitpull.cgi
Last active Jan 30, 2019
This CGI script in Perl can be the target of a GitHub webhook to automatically pull the latest version from the repo.
View gitpull.cgi
use Digest::SHA qw(hmac_sha1_hex);
open(KEYFILE, "gitpull.secret");
chomp($secret = <KEYFILE>);
print "Content-type: text/plain\n";
print "\n";
jeantessier / handler.groovy
Created Jan 19, 2017
A listener class has a series of handlers, each with a `match` and a `handle` closure. Each closure has an optional `origin` parameter.
View handler.groovy
handlers.findAll { name, handler ->
if (handler.match.maximumNumberOfParameters == 1) {
handler.match notification
} else {
handler.match notification, origin
}.each { name, handler ->
if (handler.handle.maximumNumberOfParameters == 1) {
handler.handle notification
} else {
jeantessier / some_class_under_test.rb
Last active Apr 24, 2020
Data-Driven tests in RSpec
View some_class_under_test.rb
class SomeClassUnderTest
def some_method_under_test(input)