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 OrderedDict | |
def deep_search(needles, haystack): | |
found = {} | |
if type(needles) != type([]): | |
needles = [needles] | |
if type(haystack) == type(OrderedDict()) or type(haystack) == type(dict()): | |
for needle in needles: |
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
def import_name(name): | |
components = name.split('.') | |
mod = __import__( | |
'.'.join(components[0:-1]) | |
) | |
for m in components[1:]: | |
mod = getattr(mod, m) | |
return mod |
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
import datetime | |
def timedelta_to_string(timedelta): | |
total_seconds = timedelta.total_seconds() | |
if total_seconds < 0: | |
timedelta_str = '-' + str(datetime.timedelta() - timedelta) | |
else: | |
timedelta_str = '+' + str(timedelta) | |
return timedelta_str |
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 rest_framework.authentication import SessionAuthentication | |
class CsrfExemptSessionAuthentication(SessionAuthentication): | |
def enforce_csrf(self, request): | |
return # To not perform the csrf check previously happening |
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
Znamy przyczynę śmierci Roberta Brylewskiego. Są wyniki sekcji zwłok | |
PIOTR HALICKI dzisiaj 13:33 | |
FACEBOOK | 20 | |
TWITTER | 2 | |
He he | |
KOPIUJ LINK 0SKOMENTUJ | |
Niewydolność krążeniowo-oddechowa była przyczyną śmierci Roberta Brylewskiego – dowiedział się Onet. Tak wynika ze wstępnych wyników przeprowadzonej dziś sekcji znaeenego muzyka. Na razie jednak nie ustalono, czy miało to związek z wcześniejszym brutalnym pobiciem Brylewskiego. Będzie to jeszcze przedmiotem dalszych badań. |
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
print("Snipty is awesome!") |
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
import shortuuid | |
from django.db import models | |
def shorten_name(name): | |
if len(name) <= 3: | |
return name.lower() | |
else: | |
return name[0].lower() + ''.join([ch for ch in name[1:].lower() if ch not in 'aeiouy'][:2]) |
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 logging import getLogger | |
from django.db import connection | |
logger = getLogger(__name__) | |
class QueryCountDebugMiddleware(object): | |
""" | |
This middleware will log the number of queries run | |
and the total time taken for each request (with a | |
status code of 200). It does not currently support |
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
def left_pad(s, n, c): | |
return s.rjust(len(s) + n, c) |
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
one |