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) { |
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] |
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; |
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 |