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 collections import defaultdict | |
class DictObject(dict): | |
""" | |
Simple dict subclass for making it possible to to access keys as attributes | |
This class can be used as object_hook when deserializing JSON for easy | |
access to attributes of the JSON objects. |
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
#!/bin/bash | |
# Usage: | |
# ./pfx2pem.sh /path/to/domain.pfx | |
# | |
# Creates domain.pem and domain.key in the current directory | |
# | |
# Based on https://gist.github.com/ericharth/8334664#gistcomment-1942267 | |
pfxpath="$1" | |
if [ ! -f "$pfxpath" ]; |
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 os | |
import sys | |
import subprocess | |
PDFTK_DOCKER_IMAGE = 'agileek/pdftk' | |
def main(*argv): | |
file_args = {'stamp', 'output'} |
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
// Place your settings in this file to overwrite the default settings | |
{ | |
//-------- Editor configuration -------- | |
// Controls the font family. | |
"editor.fontFamily": "Ubuntu Mono", | |
// Controls the font size. | |
"editor.fontSize": 14, |
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
""" | |
Easy parsing of CSV files. | |
Every row is a named tuple with column name defined by the header (first row). | |
By default header is not returned (only rows containing the data) | |
""" | |
import csv | |
from collections import namedtuple |
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
try: | |
import json | |
except ImportError: | |
from django.utils import simplejson as json | |
from django.http import HttpResponse | |
from django.conf import settings | |
from django.core.serializers.json import DjangoJSONEncoder | |
JSON_CONTENT_TYPE = 'application/json; charset=%s' % (settings.DEFAULT_CHARSET, ) |
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 | |
# -*- coding: utf-8 -*- | |
""" | |
Fetch SEO data from given URL | |
""" | |
from HTMLParser import HTMLParser | |
from urllib2 import build_opener | |
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
import re | |
from time import time | |
from django.core.exceptions import MiddlewareNotUsed | |
from django.conf import settings | |
from django.db import connection | |
PATH_INFO_RE = re.compile(r'^(/favicon\.ico|%s|%s)' % (settings.STATIC_URL, settings.MEDIA_URL)) | |
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
class XUACompatibleMiddleware(object): | |
""" | |
Add a X-UA-Compatible header to the response | |
This header tells to Internet Explorer to render page with latest | |
possible version or to use chrome frame if it is installed. | |
""" | |
def process_response(self, request, response): | |
response['X-UA-Compatible'] = 'IE=edge,chrome=1' | |
return response |
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 time import time | |
class TimeIt: | |
""" | |
Simple class for easy measuring time for code execution | |
Usage: | |
with TimeIt('Simple description of my code'): | |
do something... |
NewerOlder