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 / generate-icns.sh
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: https://imagemagick.org/script/download.php
# name of your master icon, must be at least 512X512
PNG_MASTER="icon-large.png"
ICONSET_FOLDER="AppIcon.iconset"
sizes=(
16x16
32x32
// 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
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 / exportNameSpaceCND.js
Created April 11, 2019 23:59
The hackiest way to export/import namespaces between AEM instances without any external dependencies
/**
* EXPORT NAMESPACES
* 1. Open http://localhost:4502/crx/explorer/ui/namespace_editor.jsp
* 2. Open Chrome console, run script below
* 3. Copy result.
*/
/**
* IMPORT NAMESPACES
* 1. Open http://localhost:4502/crx/explorer/nodetypes/index.jsp
@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;
/**
Decodes asset names if they contain any encoded chars.
*/
import java.net.URLDecoder
START = "/content/dam"
// renames a node
def renameToDecoded(node)
@ahmed-musallam
ahmed-musallam / HttpClientService.java
Last active February 28, 2024 17:20
A simple HTTP server jUnit 5 extension based on https://gist.github.com/rponte/710d65dc3beb28d97655
package com.ahmedmusallam.service;
import java.io.IOException;
import java.net.URI;
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
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: http://jsfiddle.net/ahmedmusallam/jruxn3bh/
*/
(function () {
/**
* @param {Arrray} predicates: an array of predicates
@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"}
*
*/
@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