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 time | |
import functools | |
import logging | |
from django.db import connection, reset_queries | |
log = logging.getLogger("django") | |
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 functools | |
def decorator(function): | |
"""A general decorator function""" | |
@functools.wraps(function) | |
def wrapper(*args, **kwargs): | |
# Write decorator function logic here | |
# Before function call |
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 sqlalchemy.ext.declarative import declarative_base | |
class Mixin: | |
def as_dict(self): | |
return {c.name: getattr(self, c.name) for c in self.__table__.columns} | |
def as_clear_dict(self): | |
_dict = {} | |
for c in self.__table__.columns: | |
if c.foreign_keys: | |
continue |
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 | |
import mimetypes | |
from optparse import make_option | |
from django.utils.encoding import force_text | |
from django.utils.translation import ugettext as _ | |
from django.core.management.base import 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
_slugify_strip_re = re.compile(r'[^\w\s-]') | |
_slugify_hyphenate_re = re.compile(r'[-\s]+') | |
def slugify(value): | |
""" | |
Normalizes string, converts to lowercase, removes non-alpha characters, | |
and converts spaces to hyphens. | |
From Django's "django/template/defaultfilters.py". | |
""" | |
import unicodedata |
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 -*- | |
""" | |
flask-admin and "The Enum Recipe" | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Adds flask-admin support for the enum recipe on zzzeek's blog_. | |
This code is specific to SQLAlchemy. | |
.. _blog http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/ |
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
function FindProxyForURL(url, host){ | |
var myip = myIpAddress(); | |
var ipbits = myip.split("."); | |
var myseg = parseInt(ipbits[3]); | |
if(myseg == Math.floor(myseg/2)*2){ | |
proxy = 'PROXY 165.225.131.153:80; PROXY 165.225.130.193:80'; | |
} else { | |
proxy = 'PROXY 165.225.130.193:80; PROXY 165.225.131.153:80'; | |
} | |
if((host == 'localhost')||(shExpMatch(host, 'localhost.*'))||(shExpMatch(host, '*.local'))||(host == '127.0.0.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
<html> | |
<head> | |
<script src="./leaflet.js"></script> | |
<script> | |
window.onload = function() { | |
var myCrs = L.Util.extend({}, L.CRS, { | |
projection: L.Projection.LonLat, | |
transformation: new L.Transformation(1, 0, 1, 0) | |
}); |
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/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
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 referenceClosure = { | |
html { | |
body { | |
h1 "hello" | |
} | |
} | |
} | |
def markupBuilder(closure) { |
NewerOlder