This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from psycogreen.gevent import patch_psycopg | |
def post_fork(server, worker): | |
patch_psycopg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageCms | |
im = Image.open(image_path) | |
if im.mode != "RGB": | |
im = im.convert("RGB") | |
srgb_profile = ImageCms.createProfile("sRGB") | |
lab_profile = ImageCms.createProfile("LAB") | |
rgb2lab_transform = ImageCms.buildTransformFromOpenProfiles(srgb_profile, lab_profile, "RGB", "LAB") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Simple HTTP URL redirector | |
Shreyas Cholia 10/01/2015 | |
usage: redirect.py [-h] [--port PORT] [--ip IP] redirect_url | |
HTTP redirect server | |
positional arguments: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open django shell and do following. | |
import urls | |
def show_urls(urllist, depth=0): | |
for entry in urllist: | |
print(" " * depth, entry.regex.pattern) | |
if hasattr(entry, 'url_patterns'): | |
show_urls(entry.url_patterns, depth + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals, absolute_import, division | |
import os | |
import sys | |
# based on https://gist.github.com/magopian/7543724 | |
# | |
# refactored for manual control over permissions created. | |
projectname = input("Enter project name (for settings import): ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
import base64 | |
import binascii | |
import os | |
import re | |
import logging | |
log = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var screenshotUrl = 'http://example.com/' | |
var casper = require("casper").create({ | |
viewportSize: { | |
width: 1024, | |
height: 768 | |
} | |
}); | |
if (casper.cli.args.length < 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os, os.path | |
sys.path.append('.') | |
# Weird hack, __import__("a.b.c") returns module a unless fromlist is non-empty, then it returns module c | |
filename = __import__(sys.argv[1], fromlist=["whatever"]).__file__ | |
os.system('subl ' + os.path.dirname(filename)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes. | |
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed | |
* | |
* Usage: | |
* $ casperjs screenshots.js http://example.com | |
*/ | |
var casper = require("casper").create(); |
NewerOlder