Skip to content

Instantly share code, notes, and snippets.

@rwunsch
rwunsch / aem-folder-tree.py
Last active March 19, 2024 11:49
Python script to create a "tree"-like view (file) as output of all folders and subfolders for AEM Cloud Service (AEMaaCS) - uses ASSETS API .
import requests
import json
def get_folder_structure(token, base_url, debug_mode=False, path="/api/assets"):
if debug_mode:
print(f"Fetching folder structure from {base_url}{path}")
else:
print(".", end="", flush=True)
headers = {
@rwunsch
rwunsch / Bridge-WslPorts.ps1
Created January 26, 2024 13:15
Bridge external Ports on Windows into WSL2 - Bridge-WslPorts.ps1
## https://jwstanly.com/blog/article/Port+Forwarding+WSL+2+to+Your+LAN/
## Execute with: powershell.exe -File "C:\Users\wunsch\Bridge-WslPorts.ps1"
Start-Transcript -Path "C:\Users\wunsch\Bridge-WslPorts.log" -Append
$ports = @(80, 443, 1234, 3000, 4502, 4503, 4326, 4327, 5000, 10000, 25565, 25575);
$wslAddress = bash.exe -c "ifconfig eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
if ($wslAddress -match '^(\d{1,3}\.){3}\d{1,3}$') {
@rwunsch
rwunsch / aem-cloud-migration-republish.py
Last active January 16, 2024 14:17
AEM Cloud Service | Python script to query for published items on one instance and to publish these items on another instance (instance migration)
#!/usr/bin/python3
import requests
import json
def load_config(filename="config.json"):
try:
with open(filename, 'r') as file:
config = json.load(file)
return config
@rwunsch
rwunsch / itzg_minecraft-server_docker-compose.yml
Last active January 4, 2024 14:11
itzg/minecraft-server - docker-compose.yml file for JAVA-Minecraft, RCON and Backup
version: "3.8"
## Set-up help
## - https://containers.fan/posts/setup-minecraft-server-on-docker/
services:
rcon:
image: itzg/rcon
container_name: rcon
restart: unless-stopped
@rwunsch
rwunsch / gist:d80d5945c937c93f9061785f8fcd1ebe
Created December 18, 2023 20:06
show all systemd services - and their status
systemctl list-units --type=service
@rwunsch
rwunsch / aem-cloud-service-file-upload.sh
Created November 10, 2023 08:31
AEMaaCS - AEM as a Cloud Services - File and Folder upload shell script ( initiateUpload , uploadToken , fileName , mimeType )
#!/bin/bash
# Check if pv is installed
if ! command -v pv &> /dev/null; then
echo "Error: 'pv' command not found. Please install it before running the script."
exit 1
fi
# Check if jq is installed
if ! command -v jq &> /dev/null; then
@rwunsch
rwunsch / shelly-cloud-API_CURL.sh
Last active August 31, 2023 14:24
Curl Shelly Cloud for values of one Shelly (here Shelly 3EM) - once per second - and add to CSV
#!/bin/bash
SHELLY_KEY=<shelly-key from https://home.shelly.cloud/index.html#/user_settings>
SHELLY_CLOUD_SERVER=<shelly-cloud-server from https://home.shelly.cloud/index.html#/user_settings eg. https://shelly-61-eu.shelly.cloud>
DEVICE_ID= <device-id from https://home.shelly.cloud>
CSV_OUTPUT_FILE=shelly_values.csv
curl -s -X POST $SHELLY_CLOUD/device/status -d "id=$DEVICE_ID&auth_key=$SHELLY_KEY" | jq -r '.data.device_status."em:0" | del(.["user_calibrated_phase"]) | [.]' | \
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > file.csv
// this code is the same as the servlet but for grovy console: https://github.com/OlsonDigital/aem-groovy-console
// OPTIONS
def PATH = '/content/dam'
def query = createQuery([path:PATH, type:'nt:file', 'p.limit':'99999999999999999'])
def result = query.getResult();
long totalSizeInKB = 0
result.getHits().each{
def node = it.node
@rwunsch
rwunsch / package.json
Last active February 24, 2021 19:54
Cocolatey - Essentails for Windows for automated installation (package manager choco)
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="7zip"/>
<package id="adobe-creative-cloud"/>
<package id="ant"/>
<package id="asio4all"/>
<package id="astrogrep"/>
<package id="atom"/>
<package id="bluejeansapp"/>
<package id="brackets"/>
@rwunsch
rwunsch / maven-command
Last active January 14, 2020 14:16
MAVEN (MVN) compile statement (simple and fast)
mvn clean install -Dmaven.test.skip=true -Dbaseline.skip=true -Dmaven.javadoc.skip=true -Dcheckstyle.skip
## test.skip -> skip tests
## baseline.skip -> consinstency check if version you compile is "valid", when creating "non-existing" or sample builds - this can/should be turned off
## javadoc.skip -> skip javadoc generation (makes it faster)