Skip to content

Instantly share code, notes, and snippets.


Abdullah Diab mpcabd

View GitHub Profile
mpcabd / speedup.js
Last active Dec 21, 2017
Speed up all media on page
View speedup.js
function getAllMedia() {
var getDocuments = function () {
var f = function (document) {
var iframes = Array.from(document.getElementsByTagName('iframe'));
var result = [ document ];
iframes.forEach(function (iframe) {
var iframeDocument;
try {
iframeDocument = iframe.contentDocument;
} catch (error) {
mpcabd /
Created Jun 1, 2017
Python3 - Set Mac clipboard with HTML content
import subprocess
html = '<p><strong>Hello</strong> <em>Bob</em> <code>How</code> are you!</p>'
p_hex = subprocess.Popen(
('hexdump', '-ve', '1/1 "%.2x"'),
p_hex_output = p_hex.communicate(html.encode('utf-8'))[0]
mpcabd /
Last active Jun 15, 2022
curl with Proxy auto-config (PAC) files
#!/usr/bin/env perl
# This work is licensed under the GNU Public License (GPLv3).
# To view a copy of this license, visit
# To read more about this script go to:
use strict;
use warnings;
mpcabd /
Last active Jun 21, 2021
Archived models in Django 1.4.x
from django.db import models
class MyModelBase(models.Model):
class Meta:
abstract = True
field1 = models.CharField(max_length=256)
field2 = models.BooleanField(db_index=True, default=True)
def get_pattern_from_image(file_name, pattern_width, pattern_height):
import Image
pattern_image =, 'r')
result_image ='RGB', (pattern_width, pattern_height))
x = 0
while x < pattern_width:
y = 0
while y < pattern_height:
result_image.paste(pattern_image, (x, y))
y += pattern_image.size[1]
# This work is licensed under the GNU Public License (GPL).
# To view a copy of this license, visit
# For more information visit this blog post
# Written by Abd Allah Diab (mpcabd)
# Email: mpcabd ^at^ gmail ^dot^ com
# Website:
from django.utils.decorators import available_attrs