Skip to content

Instantly share code, notes, and snippets.

View ahmed-musallam's full-sized avatar

Ahmed Musallam ahmed-musallam

View GitHub Profile
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 / AEM_SAX_PARSER_ERRORS.md
Last active May 14, 2024 11:53
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)
@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 / 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 / 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 / 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 / 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 / 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 / README.md
Created November 13, 2017 20:14
A ChartJs plugin to add offset to chart's min/max on the y axes

A ChartJs plugin to add offset to chart's min/max on the y axes

Take a look at this SF question for more details, see my answer.

how to use:

  1. Add code after chartjs code
  2. In chartsjs options set options.customOffset to any number you want to offset the chart
@ahmed-musallam
ahmed-musallam / README.md
Last active May 14, 2024 11:51
A simple groovy console script to find AEM pages with a certain component then display them in a nice table

A simple groovy console script to find AEM pages with a certain component then display them in a nice table

Copy script to AEM groovy console, change parameters and run!