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 -*- | |
# | |
# egn_checker.py | |
# | |
# Copyright 2011 Venelin Stoykov <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or |
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 django.core.management.base import BaseCommand | |
from django.conf import settings | |
from optparse import make_option | |
import os | |
# default dump commands, you can overwrite these in your settings. | |
MYSQLDUMP_CMD = getattr(settings, 'MYSQLDUMP_CMD', 'mysqldump --host=%(host)s --port=%(port)s --opt --complete-insert --compact --skip-add-locks -u"%(user)s" -p"%(password)s" %(database)s > %(filename)s') | |
SQLITE3DUMP_CMD = getattr(settings, 'SQLITE3DUMP_CMD', 'echo ".dump" | sqlite3 %(database)s > %(filename)s') | |
class Command(BaseCommand): |
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
# Geany's snippets configuration file | |
# use \n or %newline% for a new line (it will be replaced by the used EOL char(s) - LF, CR/LF, CR) | |
# use \t ot %ws% for an indentation step, if using only spaces for indentation only spaces will be used | |
# use \s to force whitespace at beginning or end of a value ('key= value' won't work, use 'key=\svalue') | |
# use %cursor% to define where the cursor should be placed after completion | |
# use %key% for all keys defined in the [Special] section | |
# you can define a section for each supported filetype to overwrite default settings, the section | |
# name must match exactly the internal filetype name, run 'geany --ft-names' for a full list | |
# | |
# Additionally, you can use most of the template wildcards like {developer} or {date} in the snippets. |
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: | |
from django.utils.deprecation import MiddlewareMixin | |
except ImportError: | |
MiddlewareMixin = object | |
class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
""" | |
Ignore Accept-Language HTTP headers | |
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
""" | |
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 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 django.conf import settings | |
from django.views.static import serve, Http404 | |
class StaticServeMiddleware(object): | |
""" | |
Middleware to serve media files on developer server | |
You must put this at top of all middlewares for speedups | |
(Whe dont need sessions, request.user or other stuff) | |
""" |
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
def croppedthumbnail(image, width, height, method=None): | |
''' | |
Function that make a thumbnail with given size | |
but crop image to fit in aspect ratio | |
image must be a instance of PIL.Image | |
''' | |
dst_width = int(width) | |
dst_height = int(height) | |
src_width, src_height = image.size |
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 | |
################################################################# | |
# Startup script for Django server, that will be placed | |
# in /usr/local/bin for example. It may be symlinked | |
# in project dir with name "run" like: |
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 django.contrib import admin | |
from django.conf.urls.defaults import patterns, url | |
from django.shortcuts import redirect, Http404 | |
class ActionForObjectAdmin(admin.ModelAdmin): | |
""" | |
Admin that add some urls wich can call an action for given object. | |
Example: | |
if url is /admin/myapp/mymodel/object_id/ |
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 | |
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" |
OlderNewer