Skip to content

Instantly share code, notes, and snippets.

View ahmed-musallam's full-sized avatar

Ahmed Musallam ahmed-musallam

View GitHub Profile
@ahmed-musallam
ahmed-musallam / findUnregisteredNamespacePrefixes.groovy
Last active April 12, 2018 18:39
An AEM groovy console script to find all unregistered namespace prefixes in JCR subtree
def BASE_PATH = '/content/test' // CHANGE the path to search in
// BE CAREFUL! this may have performance implecations on large trees
// start with a deep tree and work your way up.
/*
* Recurses over all nodes in the subtree "basePath"
* and checks every property of every node for prefixes that are not registered
* @returns an array or unregistered prefixes
@ahmed-musallam
ahmed-musallam / console.html
Created December 11, 2017 19:34
A simple browser console-like html setup
<!--
I use this setup primarely on jsfiddle where I do not want to open chrome console while testing js code.
example: https://jsfiddle.net/wybmxgop/1/
-->
<!-- a Mono-spaced font-->
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<style>
ul#console {
list-style-type: none;
@ahmed-musallam
ahmed-musallam / multifield.css
Last active January 23, 2018 19:52
Multifield example with bootstrap and jquery ui, see it here: https://jsfiddle.net/bdrp0eow/
.multifield form {
margin: 0 auto;
max-width: 750px;
}
.multifield .margin-1rem {
margin: 1rem !important;
}
.multifield .fieldset-container {
@ahmed-musallam
ahmed-musallam / showFiles.sh
Created January 2, 2018 18:44
See how many files each pid is opening in macOs
# based on https://www.reddit.com/r/osx/comments/3ewn93/too_many_open_files_in_system_what_is_causing_this/ctj765h/
# will print a list of comma seperated enties, each entry is in this format: <PID name>, <PID>, <Files open>
sudo lsof -n | perl -pe '$x = <>; while(<>) { ($cmd, $pid, $rest) = split(/\s+/); $cmds{$pid} = $cmd; $pids{$pid}++;} while( ($key, $val) = each %pids) { $pidName=$cmds{$key}; printf "$pidName,$key,$val \n" } ;'
@ahmed-musallam
ahmed-musallam / usage.js
Created January 16, 2018 17:45
Wait for a javascript namespace to become available, with timeout!
// in this example, we wait for jquery to become available.
waitFor("$",1000*60,function(){
console.log('jQuery is ready to be used!');
})
@ahmed-musallam
ahmed-musallam / Circular.js
Created January 25, 2018 22:11
A simple circular javascript data structure (backed by an array)
/**
* A simple circular data structure
*/
function Circular(arr, startIntex){
this.arr = arr;
this.currentIndex = startIntex || 0;
}
Circular.prototype.next = function(){
var i = this.currentIndex, arr = this.arr;
@ahmed-musallam
ahmed-musallam / AEM_SAX_PARSER_ERRORS.md
Last active October 30, 2023 19:29
org.apache.jackrabbit.vault.fs.impl.io.GenericArtifactHandler Error while parsing

How to fix AEM error org.apache.jackrabbit.vault.fs.impl.io.GenericArtifactHandler Error while parsing when deploying AEM package

I ran into this issue with one of the projects I was working on, AEM throws this very unhelpful error:

rg.apache.jackrabbit.vault.fs.impl.io.GenericArtifactHandler Error while parsing <path here>/.content.xml: {}
org.xml.sax.SAXException: null
	at org.apache.jackrabbit.vault.fs.impl.io.DocViewSAXImporter.startElement(DocViewSAXImporter.java:662)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
import javax.jcr.PropertyType
/**
* This script will find all PropertyDifinitions for a node instance from it's primaryType and mixins
* It will then determine if any of the current properties violate any of the PropertyDifinitions. it only checks property name and type.
* For example, a "dam:Asset" node with a property "test" and a property "jcr:mixinTypes" of Type Reference has two violations:
* 1. "test" is not on the list of allowed properties for that node type
* 2. "jcr:mixinTypes" must be of type "Name"
*/
@ahmed-musallam
ahmed-musallam / install-all-packages-in-current-folder.sh
Created April 11, 2018 19:45
A script to install all packages in a folder to the AEM instance at 4502
#!/bin/bash
# this script will install ALL zip packages in current directory the AEM instance at 4502
for f in *.zip
do
echo "installing: $f"
curl -u admin:admin -F file=@"$f" -F name="$f" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
echo "done."
done
@ahmed-musallam
ahmed-musallam / export-namespaces.groovy
Last active August 1, 2018 23:09
Import/Export namespaces from/to AEM instances
import com.google.gson.JsonArray
import com.google.gson.JsonObject
/**
* This script will print a JSON array of all namespaces on current AEM instance
* Each JSON object in the array will be of the format:
* {"prefix":"The namespace prefix", "uri":"The namespace uri"}
*
*/