Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Klco klcodanr

View GitHub Profile
View dumpregionconfig.groovy
// 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 Dec 28, 2020
Feature Model Configuration for Sling Commons Mail + Commons Crypto
View feature.json
{
"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 Dec 10, 2020
Cleans up AEM versions
View versioncleanup.groovy
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 Jul 28, 2020
Simple groovy script for use with ICF Groovy Console in AEM to diagnose timing issues in ReferenceProviders
View ReferenceProviderTimings.groovy
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 Jul 8, 2020
Repositories section from a Maven pom.xml for Cloud Manager Private Artifact repositories
View pom-repositories.xml
<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 Jul 8, 2020
Repositories section from a Maven pom.xml for Cloud Manager Private Artifact repositories
View pom-repositories.xml
<repositories>
<repository>
<id>Custom-Artifacts</id>
<url>https://myartifacts/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
@klcodanr
klcodanr / settings.xml
Last active Jul 8, 2020
Maven settings.xml for Cloud Manager Private Artifact repositories
View settings.xml
<settings>
<servers>
<server>
<id>Custom-Artifacts</id>
<username>${env.CUSTOM_ARTIFACTS_USERNAME}</username>
<password>${env.CUSTOM_ARTIFACTS_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
@klcodanr
klcodanr / RegisterRepoInits.java
Created Jun 17, 2020
Component to Register org.apache.sling.jcr.repoinit.RepositoryInitializer Configurations using the Bundle URLs
View RegisterRepoInits.java
package com.company;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
View svg2img.js
function svg2img(){
var svg = document.querySelector('svg');
var xml = new XMLSerializer().serializeToString(svg);
var svg64 = btoa(xml);
var b64start = 'data:image/svg+xml;base64,';
var image64 = b64start + svg64;
return image64;
};
var img = document.createElement('img');
img.src = svg2img();
View optionrenderer.jsp
<%--
Copyright 2019 Perficient Digital
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 furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE