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 / ComponentPropertyUpdater.java
Created March 19, 2019 17:15
An ACS MCP that helps in updating one component property in bulk
package com.mycom.core.mcp;
import com.adobe.acs.commons.fam.ActionManager;
import com.adobe.acs.commons.mcp.ProcessDefinition;
import com.adobe.acs.commons.mcp.ProcessInstance;
import com.adobe.acs.commons.mcp.form.CheckboxComponent;
import com.adobe.acs.commons.mcp.form.FormField;
import com.adobe.acs.commons.mcp.form.PathfieldComponent;
import com.adobe.acs.commons.mcp.model.GenericReport;
import java.io.Serializable;
@ahmed-musallam
ahmed-musallam / device-detector.js
Last active September 10, 2019 04:23
Device Detector JS
/***
*
* a trimmed down version (~812 bytes minified, not gzipped) of: https://github.com/matthewhudson/current-device/blob/master/src/index.js
* to determine current device is mobile, tablet or desktop
* USAGE:
* 1. prebuilt property: `window.device.type` returns "mobile", "tablet" or "desktop"
* 2. could call `window.device.mobile()` or `window.device.tablet()` or `window.device.desktop()` to check for each
* 3. other methods such as `window.device.windows()`, `window.device.windowsPhone()`, `window.device.android()`, `window.device.blackberry()`
*/
@ahmed-musallam
ahmed-musallam / README.md
Last active January 29, 2020 16:48
A simple groovy console script to find AEM pages with a certain template then display them in a nice table

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

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

@ahmed-musallam
ahmed-musallam / README.md
Last active December 1, 2020 23:10
A simple local playground for mustache template (jsfiddle style)

A simple local playground for mustache template (jsfiddle style)

download mustache-playground.html and open with a browser tested only on chrome

you can now use in on my site: http://ahmedmusallam.com/mustache.html

Purpose:

quick templating for strings/html. Made to create multiple templates on the fly for repetitive jira ticket discriptions.

@ahmed-musallam
ahmed-musallam / DnDInteraction.js
Created February 20, 2017 22:58
How to Create ‘Drag and Drop’ Experiences for AEM authors
/* JsLint ignore Granite object from validation */
/* globals Granite*/
//define new interaction for dropping assets into fields, this wil copy the Asset's path into the field
var customePathbrowserInteraction;
(function (Granite, $) {
if (Granite && Granite.author && Granite.author.ui && Granite.author.ui.Interaction) {
// selector of element we want to drag
var DRAGGABLE_SELECTOR = '.cq-draggable.card-asset',
@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 / 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;
// poll async featch calls in a syncronized fashion, IE do not start the next function call until the previous was resolved.
// also allows for throttling :)
async function poll(fn, onData, throttle) {
const _throttle = throttle || 5000;
let lastPollStarted;
async function _poll(_fn, _onData) {
lastPollStarted = new Date().getTime();
let response = await _fn();
if (response.status === 200) {
// Get and show the message
// this code is the same as the servlet but for grovy console: https://github.com/OlsonDigital/aem-groovy-console
// OPTIONS
def PATH = '/content/dam/'
def query = createQuery([path:PATH, type:'nt:file', 'p.limit':'99999999999999999'])
def result = query.getResult();
long totalSizeInKB = 0
result.getHits().each{
def node = it.node
@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;