Skip to content

Instantly share code, notes, and snippets.

View fix's full-sized avatar
🏠
Working from home

François-Xavier Thoorens fix

🏠
Working from home
View GitHub Profile
@bodiam
bodiam / healthcheck.groovy
Created May 25, 2015 20:16
A small script to check the health status of your Grails 3 and Spring Boot applications
#!/usr/bin/env groovy
import groovy.json.JsonSlurper
/**
* Displays the status of registered Spring Boot URL's.
* To register URL's, create a file called healthcheck.txt in the following format
*
* <name>,<url>
*
* Eg: healthcheck.txt:
@dylanmei
dylanmei / csv-to-json
Created March 25, 2014 13:50
CSV to JSON in Groovy
import groovy.json.*
if (args.size() == 0) {
println("missing argument")
System.exit(1)
}
def f = new File(args[0])
if (!f.exists()) {
println("file doesn't exist")
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@timyates
timyates / excel.groovy
Last active May 15, 2024 14:01
Create a styled Excel spreadsheet with Groovy and Apache POI
@Grab( 'org.apache.poi:poi:3.9' )
import static org.apache.poi.ss.usermodel.CellStyle.*
import static org.apache.poi.ss.usermodel.IndexedColors.*
import org.apache.poi.hssf.usermodel.HSSFWorkbook
new HSSFWorkbook().with { workbook ->
def styles = [ LIGHT_BLUE, LIGHT_GREEN, LIGHT_ORANGE ].collect { color ->
createCellStyle().with { style ->
fillForegroundColor = color.index
fillPattern = SOLID_FOREGROUND
@timyates
timyates / destructure.groovy
Created November 9, 2012 15:47
De-structuring a list of maps based on given keys
def data = [
[ user:'tim', time:1, age:33, weight:90, height:2.2 ],
[ user:'anne', time:2, height:1.8 ]
]
def destructure = { List<Map> listOfMaps, idFields=[], boolean allowNull=true ->
[ idFields ].flatten().with { flatFields ->
( listOfMaps*.keySet().flatten() as Set ).with { names ->
names = names - flatFields
listOfMaps.inject( [] ) { list, map ->
@hacknightly
hacknightly / riffwave.js
Created September 24, 2012 15:20
riffwave.js
/*
* RIFFWAVE.js v0.03 - Audio encoder for HTML5 <audio> elements.
* Copyleft 2011 by Pedro Ladaria <pedro.ladaria at Gmail dot com>
*
* Public Domain
*
* Changelog:
*
* 0.01 - First release
* 0.02 - New faster base64 encoding
@pledbrook
pledbrook / Config.groovy
Created May 16, 2012 10:17
Loading runtime config from JSON in Grails
// ... rest of Config.groovy content goes above this line to ensure that
// the JSON overrides existing settings.
ConfigLoader.addEntries(loadJson(fetchJson()), this)
def fetchJson() { return System.getenv("GRAILS_APP_CONFIG") }
def loadJson(content) { return content ? grails.converters.JSON.parse(content) : [:] }
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("")
base = alphabet.length
exports.encode = (i) ->
return alphabet[0] if i is 0
s = ""
while i > 0
s += alphabet[i % base]
i = parseInt(i / base, 10)
@hideaki-t
hideaki-t / gist:1101054
Created July 23, 2011 05:18
another custom browser using GroovyFX with JavaFX 2.0 build36+
import groovyx.javafx.GroovyFX
import groovyx.javafx.SceneGraphBuilder
import javafx.beans.value.ChangeListener
import static javafx.concurrent.Worker.State.*
GroovyFX.start({
def sg = new SceneGraphBuilder(it)
def engine = sg.webEngine()
def loadAction = { engine.load(new URL(urlBox.getText()) as String) }
def stage = sg.stage(title: "GroovyFXのテスト") {
@marc0der
marc0der / Grails on Ubuntu
Created April 4, 2011 16:07
Install Grails on Ubuntu through LaunchPad
sudo add-apt-repository ppa:groovy-dev/grails
sudo apt-get update
sudo apt-get install grails-ppa
#to add grails 2.0.x
sudo apt-get install grails 2.0.x
#to add grails 1.3.9
sudo apt-get install grails-1.3.9