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 /
Last active March 10, 2024 13:53
How to compress PDF with ghostscript

How to compress PDF using ghostscript

As a developer, it bothers me when someone sends me a large pdf file compared to the number of pages. Recently, I recieved a 12MB scanned document for just one letter-sized page... so I got to googlin, like I usually do, and found ghostscript!

to learn more abot ghostscript (gs):

What we are interested in, is the gs command line tool, which provides many options for manipulating PDF, but we are interested in compressign those large PDF's into small yet legible documents.

credit goes to this answer on askubuntu forum:

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
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 / EventUtil.ts
Last active December 19, 2023 13:59
A typescript version of the Tiny Pub/Sub written by @cowboy here:
export class EventUtil
private static observable = $({});
* Subscribe to an event
public static subscribe = function(...args){
EventUtil.observable.on.apply(EventUtil.observable, args);
ahmed-musallam /
Last active October 30, 2023 19:29 Error while parsing

How to fix AEM error 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: Error while parsing <path here>/.content.xml: {}
org.xml.sax.SAXException: null
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;
} = function(){
var i = this.currentIndex, arr = this.arr;
// this code is the same as the servlet but for grovy console:
def PATH = '/content/dam/'
def query = createQuery([path:PATH, type:'nt:file', 'p.limit':'99999999999999999'])
def result = query.getResult();
long totalSizeInKB = 0
def node = it.node
ahmed-musallam /
Last active March 3, 2022 01:05
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!

// 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 / 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.
<!-- a Mono-spaced font-->
<link href="" rel="stylesheet">
ul#console {
list-style-type: none;