Skip to content

Instantly share code, notes, and snippets.

View bdelacretaz's full-sized avatar

Bertrand Delacretaz bdelacretaz

View GitHub Profile
<%
/* Demonstrate Sling Query in server-side Javascript */
var $ = Packages.org.apache.sling.query.SlingQuery.$
var SearchStrategy = Packages.org.apache.sling.query.api.SearchStrategy
var resourceResolver = resource.getResourceResolver()
var result = {
siblings : $(resource).siblings(),
rootChildren : $(resource).parents().last().children(),
queryResult : $(resourceResolver)
.searchStrategy(SearchStrategy.QUERY)
@bdelacretaz
bdelacretaz / memodsl.groovy
Created October 12, 2017 15:28
Groovy DSL example
import groovy.xml.MarkupBuilder
/* Simple Groovy DSL example
* slightly adapted from https://dzone.com/articles/groovy-dsl-simple-example
*/
class DslTest extends GroovyTestCase {
void testDslUsage_outputText() {
def memo = MemoDsl.make {
to "Nirav Assar"
@bdelacretaz
bdelacretaz / openwhisk-debug.patch
Created October 17, 2017 13:29
Patch to enable JVM debugging of the controller + Invoker on incubator-openwhisk-devtools
diff --git a/docker-compose/Makefile b/docker-compose/Makefile
index 1f9ca78..600a8b5 100644
--- a/docker-compose/Makefile
+++ b/docker-compose/Makefile
@@ -3,6 +3,7 @@ DOCKER_REGISTRY ?= ""
DOCKER_IMAGE_PREFIX ?= openwhisk
PROJECT_HOME ?= ./openwhisk-master
WSK_CLI ?= $(PROJECT_HOME)/bin/wsk
+JAVA_OPTS ?= ""
#!/bin/bash
# Script that signs an input file with all keys of a given Apache PMC
# Example use:
#
# ./encrypt.sh https://people.apache.org/keys/group/sling.asc somefile.txt
#
# To list which keys a file has been encrypted for, use
#
# gpg --list-only --no-default-keyring --secret-keyring /dev/null <filename>
@bdelacretaz
bdelacretaz / post.yaml
Last active January 12, 2018 14:31
Example RTD-X resource definition for a blog post
# RTD-X model for our example blog post
name: Blog Post
description: RTD-X sample Blog Post
# which resource types are accepted in a POST
# to this resource to create child resources
post-here:
- rtdx/samples/2018/blog/folder
- rtdx/samples/2018/blog/imagefolder
@bdelacretaz
bdelacretaz / netbeans-90-beta-rc2-release-binaries.txt
Created January 15, 2018 16:15
NetBeans 9.0 Beta rc2 - any binary files in the release archive?
# output of
# find . -type f | grep -v ' ' | while read f ; do file "$f" | egrep -v 'Java|XML|ASCII|PNG|JPEG|GIF|Unicode text'; done
./ant.freeform/test/unit/data/example-projects/extbuildroot/build/built.file: empty
./api.search/test/unit/data/textFiles/latin2file.txt: ISO-8859 text, with no line terminators
./api.search/test/unit/data/textFiles/utf8file.txt: UTF-8 Unicode (with BOM) text
./api.search/test/unit/src/org/netbeans/modules/search/data/0_bytes: empty
./api.search/test/unit/src/org/netbeans/modules/search/data/1_byte: very short file (no magic)
./apisupport.harness/release/etc/applicationIcon.icns: Mac OS X icon, 47580 bytes, "ics#" type
./apisupport.harness/windows-launcher-src/app.ico: MS Windows icon resource - 5 icons, 48x48, 8 bits/pixel, 32x31, 8 bits/pixel
./autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/data/dummy-signed-twice.jar: Zip archive data, at least v2.0 to extract
@bdelacretaz
bdelacretaz / DemoModels.java
Created February 1, 2018 14:56
Initial RTD-X demo models - hardcoded for now
// Actual models would be parsed from YAML, JSON, ...
// current code at
// https://github.com/bdelacretaz/sling-whiteboard/tree/rtdx/rtdx/rtdx-core
class DemoModels {
static Collection<ResourceModel> getModels() {
final List<ResourceModel> list = new ArrayList<>();
list.add(ResourceModel.BUILDER()
.withName("rtdx/root")
@bdelacretaz
bdelacretaz / output.txt
Created February 8, 2018 16:32
NetBeans 9.0 beta rc3 binary files analysis
# output of
# find . -type f | grep -v ' ' | while read f ; do file "$f" | egrep -v 'Java|XML|ASCII|PNG|JPEG|GIF|Unicode text'; done
./ant.freeform/test/unit/data/example-projects/extbuildroot/build/built.file: empty
./api.search/test/unit/data/textFiles/latin2file.txt: ISO-8859 text, with no line terminators
./api.search/test/unit/data/textFiles/utf8file.txt: UTF-8 Unicode (with BOM) text
./api.search/test/unit/src/org/netbeans/modules/search/data/0_bytes: empty
./api.search/test/unit/src/org/netbeans/modules/search/data/1_byte: very short file (no magic)
./apisupport.harness/release/etc/applicationIcon.icns: Mac OS X icon, 47580 bytes, "ics#" type
./apisupport.harness/windows-launcher-src/app.ico: MS Windows icon resource - 5 icons, 48x48, 8 bits/pixel, 32x31, 8 bits/pixel
./autoupdate.services/test/unit/src/org/netbeans/api/autoupdate/data/dummy-signed-twice.jar: Zip archive data, at least v2.0 to extract
@bdelacretaz
bdelacretaz / no-system-exit.jsp
Created February 21, 2018 15:14
Java: block System.exit() using a SecurityManager
<%--
JSP page that demonstrates blocking System.exit()
with a SecurityManager.
Do NOT use on production systems unless you know
EXACTLY what you are doing!
--%>
<%@page
contentType="text/plain"
pageEncoding="UTF-8"
import="
#!/bin/bash
# Script that runs antlr4, the jar can be downloaded
# from https://www.antlr.org/download/antlr-4.7.1-complete.jar
java -jar ~/lib/antlr4/antlr-4.7.1-complete.jar $*