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 base64 | |
import hashlib | |
from Crypto.Cipher import AES | |
from django.conf import settings | |
__all__ = ['Secure'] | |
class Secure: |
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
""" | |
Need Django and CProfile. | |
Just append this middleware class in MIDDLEWARE in django settings. | |
""" | |
from django.core.exceptions import MiddlewareNotUsed | |
from django.utils.deprecation import MiddlewareMixin | |
from django.conf import settings | |
import cProfile | |
import pstats |
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
""" | |
How to use: | |
dependency: | |
xlsxwriter (pip install xlsxwriter) | |
python code: | |
excel_data = [ | |
['Name', 'Birth', 'Email', 'Gender'], | |
['John Doe', '1980-02-03', 'j-doe@mail.com', 'male' ], | |
['Jane Doe', '1995-01-15', 'prettyjane@mail.com', 'female' ], |
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 re | |
from django.utils import timezone | |
def get_datetime_filename(filename): | |
pattern = re.compile(r'\.[a-z0-9]+$') | |
extension = re.search(pattern, filename).group() | |
dt = timezone.now().strftime('%Y_%m_%d_%H%M%S%f') | |
return dt + extension |
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
syntax on | |
set nu | |
set tabstop=4 | |
set autoindent | |
set ruler | |
set showcmd | |
set title | |
set wmnu | |
set showmatch |
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
server { | |
listen 80 default_server; | |
server_name ~^.*$; | |
charset utf-8; | |
client_max_body_size 128M; | |
location / { | |
uwsgi_pass unix:///tmp/app.sock; | |
include uwsgi_params; | |
} |
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
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |' | |
# noinspection PyPep8 | |
# noinspection PyPep8Naming | |
# noinspection PyTypeChecker | |
# noinspection PyAbstractClass | |
# noinspection PyArgumentEqualDefault | |
# noinspection PyArgumentList | |
# noinspection PyAssignmentToLoopOrWithParameter | |
# noinspection PyAttributeOutsideInit |
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
""" | |
required pendulum | |
""" | |
import pendulum as pd | |
settings = { | |
"compare": [ | |
"UTC", | |
"Europe/Paris", |
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 django.db import models | |
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor | |
from jackal.shortcuts import get_model | |
from jackal.shortcuts import get_object_or_None | |
class ImageDescriptor(ForwardManyToOneDescriptor): | |
def __set__(self, instance, value): | |
""" | |
:param instance: ImageField 를 정의한 모델 인스턴스 |
OlderNewer