This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global: | |
monitor:true | |
reporters: | |
jmx: true | |
console: | |
period: 30 | |
org.apache.sling.jcr.api.SlingRepository: | |
getDefaultWorkspace: | |
()Ljava/lang/String;: timer | |
loginAdministrative: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> { |