Skip to content

Instantly share code, notes, and snippets.

View bdelacretaz's full-sized avatar

Bertrand Delacretaz bdelacretaz

View GitHub Profile
// Read a JSON message from ActiveMQ, get a filename from it,
// use exiftool to get file metadata and encode in JSON
import groovy.json.StreamingJsonBuilder
def writer = new java.io.OutputStreamWriter(System.out)
def builder = new StreamingJsonBuilder(writer)
// Get JSON message from queue
// TODO should not ACK it if this script fails
@bdelacretaz
bdelacretaz / metrics.yaml
Created July 13, 2016 12:09
metrics.yaml for SLING-4849 which produces "Unused Config" for all 4 specified methods
global:
monitor:true
reporters:
jmx: true
console:
period: 30
org.apache.sling.jcr.api.SlingRepository:
getDefaultWorkspace:
()Ljava/lang/String;: timer
loginAdministrative:
@bdelacretaz
bdelacretaz / slingGroovyJsonRendering.groovy
Last active July 5, 2016 12:40
Sling .groovy rendering script that uses Groovy's JsonBuilder
// Sling .groovy rendering script that uses Groovy's JsonBuilder
// Requires the groovy, groovy-json, groovy-templates and groovy-jsr233 bundles, so
// that /system/console/status-slingscripting lists the Groovy engine.
// Also requires adding "groovy" as an additional extension to the
// org.apache.sling.scripting.core.impl.ScriptCacheImpl config
import groovy.json.StreamingJsonBuilder
def builder = new StreamingJsonBuilder(out)
def getChildren(r) {
@bdelacretaz
bdelacretaz / jsonwrapped.groovy
Last active July 1, 2016 13:17
Groovy JsonBuilder with simulated Sling resource wrapper
// Experimenting with Groovy JsonBuilder as a way to implement
// a JSON builder script engine for Sling
// The Sling .jsonbuild script would only contain the part
// between // SCRIPT markers below, the rest is glue that
// this new scripting engine would provide
// We'll probably need a Groovy-friendly wrapper
// with convenience methods for the current resource,
// where the tree navigation starts from
@bdelacretaz
bdelacretaz / j.groovy
Created June 30, 2016 15:07
Groovy JsonBuilder experiments
// Demonstrate various features of the Groovy StreamingJsonBuilder
// run this with groovy <filename>
// See below for typical output
// A Groovy class
class Resource { String path; String resourceType }
// Groovy list of resources
resources = [
new Resource(path:"/tmp/one", resourceType:"my/example"),
@bdelacretaz
bdelacretaz / pompl
Created September 14, 2015 12:12
pompl script - generates a list of folders for mvn -pl
# Find all pom.xml files under specified path and generate a comma-separated
# list of their folder names, suitable for use with the mvn -pl option
find "$1" -name pom.xml | grep -v '/target/' | xargs -n1 dirname | awk '{ printf $1 "," }'
Index: bundles/jcr/oak-server/pom.xml
===================================================================
--- bundles/jcr/oak-server/pom.xml (revision 1697914)
+++ bundles/jcr/oak-server/pom.xml (working copy)
@@ -41,7 +41,7 @@
WARNING make sure oak.version and sling.oak.server.version
are in sync with bundles/jcr/it-jackrabbit-oak
-->
- <oak.version>1.3.3</oak.version>
+ <oak.version>1.4-SNAPSHOT</oak.version>
@bdelacretaz
bdelacretaz / patch
Created May 29, 2015 15:30
Oak query conversion, experimental patch
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DescendantNodeImpl.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DescendantNodeImpl.java (revision 1682417)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/DescendantNodeImpl.java (working copy)
@@ -48,6 +48,10 @@
public Set<SelectorImpl> getSelectors() {
return Collections.singleton(selector);
}
+
+ public String getAncestorPath() {
# switch jdk on macosx
# thanks to @jreijn for the --version trick
# see http://blog.frd.mn/java-7-on-os-x-yosemite/ for Java7 install trick
export JAVA_HOME=`/usr/libexec/java_home --version $1`
export PATH=$JAVA_HOME/bin:$PATH
# this just confirms that we have the right JDK now
java -version
@bdelacretaz
bdelacretaz / gist:03ece77da0a10741b8fb
Created November 7, 2014 08:43
Bruce Edge's debian package patch for Sling
diff --git a/launchpad/builder/pom.xml b/launchpad/builder/pom.xml
index 079cd92..2e216a8 100644
--- a/launchpad/builder/pom.xml
+++ b/launchpad/builder/pom.xml
@@ -65,6 +65,12 @@
Context path of the Sling web application
-->
<jetty.sling.context>/</jetty.sling.context>
+
+ <!--