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 /
Created February 24, 2020 15:42
A Shell script to generate .ico and .icns files (mac/windows app icons) from a single PNG
# Required deps:
# imagemagick:
# name of your master icon, must be at least 512X512
// 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
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:
* to determine current device is mobile, tablet or desktop
* 1. prebuilt property: `window.device.type` returns "mobile", "tablet" or "desktop"
* 2. could call `` or `window.device.tablet()` or `window.device.desktop()` to check for each
* 3. other methods such as ``, `window.device.windowsPhone()`, ``, `window.device.blackberry()`
ahmed-musallam / exportNameSpaceCND.js
Created April 11, 2019 23:59
The hackiest way to export/import namespaces between AEM instances without any external dependencies
* 1. Open http://localhost:4502/crx/explorer/ui/namespace_editor.jsp
* 2. Open Chrome console, run script below
* 3. Copy result.
* 1. Open http://localhost:4502/crx/explorer/nodetypes/index.jsp
ahmed-musallam /
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;
Decodes asset names if they contain any encoded chars.
START = "/content/dam"
// renames a node
def renameToDecoded(node)
ahmed-musallam /
Last active February 28, 2024 17:20
A simple HTTP server jUnit 5 extension based on
package com.ahmedmusallam.service;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
ahmed-musallam / ArrayFilterWithPredicates.js
Last active June 23, 2018 14:44
A simple method to filter an array of objects based on predicates for strings
* Built this to filters a large array based on predicates to use with a Vuejs app I was building.
* It provides a declarative way to filter an array of objects whose properties are strings.
* But it can be adapted and improved for other types.
* you can see an example vuejs app that uses this method here:
(function () {
* @param {Arrray} predicates: an array of predicates
ahmed-musallam / export-namespaces.groovy
Last active August 1, 2018 23:09
Import/Export namespaces from/to AEM instances
* 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"}
ahmed-musallam /
Created April 11, 2018 19:45
A script to install all packages in a folder to the AEM instance at 4502
# this script will install ALL zip packages in current directory the AEM instance at 4502
for f in *.zip
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."