Skip to content

Instantly share code, notes, and snippets.

@dfparker2002
dfparker2002 / MapEntryEfficiencyExample.java
Created Jan 18, 2021
Efficient use of map (via Map.Entry) to find/retrieve value
View MapEntryEfficiencyExample.java
// src: https://github.com/eugenp/tutorials/blob/ad2a34dc4aad84d249cfe38efe43f93ec7af9486/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryEfficiencyExample.java
import java.util.HashMap;
import java.util.Map;
public class MapEntryEfficiencyExample {
public static void main(String[] args) {
MapEntryEfficiencyExample mapEntryEfficiencyExample = new MapEntryEfficiencyExample();
Map<Integer, String> bookMap = new HashMap<>();
bookMap.put(1, "Clean Code");
@dfparker2002
dfparker2002 / JcrQueryLibrary.md
Created Nov 5, 2020 — forked from neozilon/JcrQueryLibrary.md
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.
View JcrQueryLibrary.md

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@dfparker2002
dfparker2002 / MapEntryTest.java
Created Sep 2, 2020
AEM Resource Mock example
View MapEntryTest.java
// src: https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/54afe1508ff37f60eb68204333e48fe22da3b2df/bundle/src/test/java/com/adobe/acs/commons/redirectmaps/models/MapEntryTest.java
/*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2013 Adobe
* %%
* Licensed 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
@dfparker2002
dfparker2002 / BufferedServletOutput.java
Created Jul 21, 2020
/** * Helper class to be used in {@link ServletResponse} wrappers. * It allows to buffer the output without committing it to the underlying response. * Also it exposes methods to access the buffers for the writer and output stream. * When calling close it will automatically spool the buffers to the underlying response. */
View BufferedServletOutput.java
// src: https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/7fc9c309106f262daca01e5ecb58c3a0d96b84ba/bundle/src/main/java/com/adobe/acs/commons/util/BufferedServletOutput.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import org.slf4j.Logger;
View MockExternalizerFactory.java
//src: https://github.com/adobe/aem-core-wcm-components/blob/164f8ba575d7b7db080008cea5032209d9857d34/testing/junit/core/src/main/java/com/adobe/cq/wcm/core/components/testing/MockExternalizerFactory.java
package com.adobe.cq.wcm.core.components.testing;
import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.commons.Externalizer;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
@dfparker2002
dfparker2002 / .nifi on docker with flow persistance part1.md
Created Jan 18, 2020 — forked from mannharleen/.nifi on docker with flow persistance part1.md
current status: not using docker-compose. need to run nifi, registry and jupyter notebook under once container
View .nifi on docker with flow persistance part1.md

sOME sETUP:

ubuntu@ip-10-201-97-84:~/nifi-persisted/nouser$ ls
getnifi.sh  nifi-1.8.0  nifi-1.8.0-bin.zip  nifi-toolkit-1.8.0  nifi-toolkit-1.8.0-bin.zip  scripts

ubuntu@ip-10-201-97-84:~/nifi-persisted/nouser$ ls scripts/
common.sh  start.sh           toolkit.sh                          update_login_providers.sh
secure.sh  update_cluster_state_management.sh

ubuntu@ip-10-201-97-84:~/nifi-persisted/nouser$ cat getnifi.sh
@dfparker2002
dfparker2002 / README.md
Created Jan 18, 2020 — forked from pawndev/README.md
Apache Nifi docker-compose local test
View README.md

docker compose nifi

To launch this project, simply use the docker-compose cli

docker-compose up

Wait a couple of seconds, then execute the next command :

View bitnami-bitnami.conf
# Default Virtual Host configuration.
<IfVersion < 2.3 >
NameVirtualHost *:443
</IfVersion>
# Default SSL Virtual Host configuration.
<IfModule !ssl_module>
LoadModule ssl_module modules/mod_ssl.so
@dfparker2002
dfparker2002 / ValueFormat.java
Created Jan 6, 2020
Break out sling value properties
View ValueFormat.java
// src: https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/10d9603878e4d534144aad8196af804652de67d3/bundle/src/main/java/com/adobe/acs/commons/mcp/model/ValueFormat.java
/*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2017 Adobe
* %%
* Licensed 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
@dfparker2002
dfparker2002 / DuplicatesCounter.java
Created Dec 31, 2019
Demo different approaches to get count of duplicated elements in an arrayList
View DuplicatesCounter.java
// src: https://github.com/eugenp/tutorials/blob/85922e3a35f492cd8a6faba254f150ef98f7a588/core-java-modules/core-java-collections-list-3/src/main/java/com/baeldung/list/duplicatescounter/DuplicatesCounter.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Demo different approaches to get count of duplicated elements in an
* arrayList