Skip to content

Instantly share code, notes, and snippets.

View klcodanr's full-sized avatar

Dan Klco klcodanr

View GitHub Profile
@klcodanr
klcodanr / Dockerfile
Last active September 8, 2023 13:34
pre-push GIT hook for warning on pushes to main / master / release branches
FROM ubuntu:focal
# Install Dependencies
RUN apt-get update && apt-get install -y \
curl \
git \
vim \
&& rm -rf /var/lib/apt/lists/*
# Setup GIT
const fs = require("fs");
const Path = require("path");
const winston = require("winston");
const {
FileSystemUploadOptions,
FileSystemUpload,
} = require("@adobe/aem-upload");
const log = winston.createLogger({
format: winston.format.simple(),
#!/bin/bash
# The MIT License
#
# Copyright (c) 2022 Dan Klco
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to
# deal in the Software without restriction, including
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022 Dan Klco
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
// Run in the AEM Groovy Console or similar
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
reference = bundleContext.getServiceReference(ResolverHookFactory.class);
service = bundleContext.getService(reference);
classLoader = service.getClass().getClassLoader();
Properties loadProperties(String propName) {
def url = new URL(reference.getProperty(propName))
def conn = url.openConnection();
@klcodanr
klcodanr / feature.json
Last active December 28, 2020 14:06
Feature Model Configuration for Sling Commons Mail + Commons Crypto
{
"configurations": {
"org.apache.sling.commons.crypto.internal.FilePasswordProvider~default": {
"names": [
"default"
],
"path": "/opt/a/path/on/the/local/server"
},
"org.apache.sling.commons.crypto.jasypt.internal.JasyptRandomIvGeneratorRegistrar~default": {
"algorithm": "SHA1PRNG"
@klcodanr
klcodanr / versioncleanup.groovy
Created December 10, 2020 19:34
Cleans up AEM versions
import org.apache.sling.api.resource.Resource;
import javax.jcr.*;
import javax.jcr.version.*;
start = System.currentTimeMillis();
limit = 5;
cleaned = 0;
versionManager = session.getWorkspace().getVersionManager();
@klcodanr
klcodanr / ReferenceProviderTimings.groovy
Created July 28, 2020 13:36
Simple groovy script for use with ICF Groovy Console in AEM to diagnose timing issues in ReferenceProviders
import com.day.cq.wcm.api.reference.ReferenceProvider;
def providers = getServices(ReferenceProvider.class, null);
def resource = resourceResolver.getResource("[PUT_A_PATH_HERE]");
providers.each{provider ->
out.println("");
out.println(provider.class.toString())
long start = System.currentTimeMillis();
@klcodanr
klcodanr / pom-repositories.xml
Created July 8, 2020 22:07
Repositories section from a Maven pom.xml for Cloud Manager Private Artifact repositories
<repositories>
<repository>
<id>Custom-Artifacts</id>
<url>https://myartifacts/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
@klcodanr
klcodanr / pom-repositories.xml
Created July 8, 2020 22:07
Repositories section from a Maven pom.xml for Cloud Manager Private Artifact repositories
<repositories>
<repository>
<id>Custom-Artifacts</id>
<url>https://myartifacts/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>