Skip to content

Instantly share code, notes, and snippets.

Abdullah Diab mpcabd

View GitHub Profile
@mpcabd
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
mpcabd / python-mac-set-html-clipboard.py
Created Jun 1, 2017
Python3 - Set Mac clipboard with HTML content
View python-mac-set-html-clipboard.py
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"'),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
)
p_hex_output = p_hex.communicate(html.encode('utf-8'))[0]
@mpcabd
mpcabd / curlp.pl
Last active May 29, 2020
curl with Proxy auto-config (PAC) files
View curlp.pl
#!/usr/bin/env perl
# This work is licensed under the GNU Public License (GPLv3).
# To view a copy of this license, visit http://www.gnu.org/copyleft/gpl.html
# To read more about this script go to: http://mpcabd.xyz/using-curl-with-proxy-pac-configuration-files/
use strict;
use warnings;
@mpcabd
mpcabd / models.py
Last active Aug 29, 2015
Archived models in Django 1.4.x
View models.py
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)
#....
View pattern_image.py
def get_pattern_from_image(file_name, pattern_width, pattern_height):
import Image
pattern_image = Image.open(file_name, 'r')
result_image = Image.new('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]
View celery_decorators.py
# This work is licensed under the GNU Public License (GPL).
# To view a copy of this license, visit http://www.gnu.org/copyleft/gpl.html
# For more information visit this blog post http://mpcabd.igeex.biz/python-celery-asynchronous-task-decorator/
# Written by Abd Allah Diab (mpcabd)
# Email: mpcabd ^at^ gmail ^dot^ com
# Website: http://mpcabd.igeex.biz
from django.utils.decorators import available_attrs
You can’t perform that action at this time.