Skip to content

Instantly share code, notes, and snippets.

View bdelacretaz's full-sized avatar

Bertrand Delacretaz bdelacretaz

View GitHub Profile
@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
#!/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 / 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 ?= ""
@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"
<%
/* 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)
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<h1>Some Java</h1>
<pre><code>
public class Result implements Iterable <ResultLog.Entry> {
@bdelacretaz
bdelacretaz / template.groovy
Created June 27, 2017 11:47
Inject Groovy expressions in a plain Java string
// Demonstrate how to inject Groovy expressions
// in a plain Java string
def now = "${new Date()}"
def data = [ value : "The date is ${now}" ]
// Inject Groovy variables from inputData
// into the supplied string
def interpolate(inputData, str) {
// TODO is there a way to have another name than "x"
// for the injected variable?
@bdelacretaz
bdelacretaz / fileopen.d
Created June 22, 2017 05:22
dtrace script to dump all file open calls for a specific process
#!/usr/sbin/dtrace -s
/* dump all "open" syscalls */
/* $1 is the PID to observe */
syscall::open:entry
/pid == $1/
{
printf("'%s' (PID: %d): syscall:open %s", execname, pid, copyinstr(arg0));
}
@bdelacretaz
bdelacretaz / Lambdastuff.java
Created June 8, 2017 15:34
Example with Java 8 Lamdbam executors and futures
package lamdbastuff;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
package main
// I'm a total beginner in Go, please have mercy ;-)
// Reads a JSON input object with an "url" field that points to an image file
// Uses exiftool to extract file metadata
// Outputs a JSON document with that metadata + request information
import (
"bufio"
"encoding/json"