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
<div itemscope itemid="gist:example-intro"> | |
<!-- | |
POSTing this element will cause it to be written to the | |
Gist that the "gist" meta element above points to. | |
--> | |
<p> | |
This introduction can be <em>edited</em> and is stored <strong>in a Gist</strong>. | |
</p> | |
<p> | |
We use Gists initially as the API is super simple, and once that works we can "graduate" |
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
<% | |
/* | |
Demo script for my adaptTo 2021 talk, on Apache Sling repoinit: | |
https://adapt.to/2021/en/schedule/repoinit-a-mini-language-for-content-repository-initialization.html | |
Generate and execute a number (see "limit" below) of repoinit statements. | |
To use this, save this script as repoinit.esp, create | |
a node with a unique resource type that points to it | |
and request that node with the appropriate extension: |
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/bin/env jbang "$0" "$@" ; exit $? | |
import java.util.function.Supplier; | |
public class LazyLoading { | |
static int callCount = 0; | |
/** This is the core lazy loading functionality */ | |
static class LazyLoader<T> { | |
private final Supplier<T> sup; |
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
diff --git a/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java b/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java | |
index a8af34a..ad0db8c 100644 | |
--- a/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java | |
+++ b/src/test/java/org/apache/sling/commons/metrics/internal/MetricServiceTest.java | |
@@ -22,6 +22,8 @@ package org.apache.sling.commons.metrics.internal; | |
import java.lang.management.ManagementFactory; | |
import java.util.Collections; | |
import java.util.Set; | |
+import java.util.UUID; | |
+import java.util.concurrent.atomic.AtomicInteger; |
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
#!/bin/bash | |
# Example using docker start, cp and rm to process a local file and | |
# get the result back on the local filesystem. | |
# Thanks to Roman V Shaposhnik for pointing to those Docker commands | |
cat << EOF > Dockerfile | |
FROM alpine:3.11.6 | |
RUN apk update && apk upgrade |
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
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
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
#!/bin/bash | |
# List all versions of Sling modules from a Maven repository | |
# ..just a ugly hack, we should use more solid parsing, or the Maven repository API | |
# | |
BASE_URL="https://repo1.maven.org/maven2/org/apache/sling/" | |
EGREP_FILTER= | |
curl -s $BASE_URL | grep 'a href' | egrep -v '\.\./|maven-metadata' | cut -d'"' -f2 | while read mod | |
do | |
curl -s ${BASE_URL}${mod} | grep 'a href' | egrep -v '\.\./|maven-metadata' | while read line | |
do |
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
// Example capturing a 1200 x 6000 pixels screenshot | |
// from a website using https://github.com/microsoft/playwright | |
const pw = require('playwright'); | |
(async () => { | |
const browser = await pw.firefox.launch(); // or 'chromium', 'firefox' | |
const context = await browser.newContext(); | |
const page = await context.newPage(); | |
await page.goto('https://lecourrier.ch/'); |
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
--- run this with osascript | |
set unixFile to "/somepath/movie2.mov" | |
set macFile to POSIX file unixFile | |
set fileRef to (macFile as alias) | |
tell application "QuickTime Player" | |
activate | |
set movie to open fileRef | |
set the looping of movie to false | |
set the presenting of movie to true |
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
#!/bin/bash | |
# Run two video players more or less in sync | |
# assuming they start playing immediately and | |
# exit when done playing | |
while true | |
do | |
# Start all players in the background | |