This file contains hidden or 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: | |
| from django.utils.deprecation import MiddlewareMixin | |
| except ImportError: | |
| MiddlewareMixin = object | |
| class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
| """ | |
| Ignore Accept-Language HTTP headers | |
This file contains hidden or 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
| """ | |
| Originaly code was taken from http://djangosnippets.org/snippets/290/ | |
| But I was made some improvements like: | |
| - print URL from what queries was | |
| - don't show queries from static URLs (MEDIA_URL and STATIC_URL, also for /favicon.ico). | |
| - If DEBUG is False tell to django to not use this middleware | |
| - Remove guessing of terminal width (This breaks the rendered SQL) | |
| - Port to Python 3 and newer versions of Django | |
| """ | |
| from django.conf import settings |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | |
| if [ `whoami` != 'root' ]; then | |
| echo "You must to be root" | |
| exit | |
| fi | |
| DOWNLOAD_URL="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" | |
| TEMPFILE="/tmp/GeoIPCity.dat" | |
| TEMPFILEGZ="$TEMPFILE.gz" | |
| GEOIP_DIR="/usr/local/share/GeoIP" |
This file contains hidden or 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 hidden or 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 | |
NewerOlder