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
Testitg: <class '__main__.RequiredSerializer'> | |
======== Should be True: True ========== | |
is_valid: True | |
data: ReturnDict([('is_test', True)]) | |
======== Should be True: true ========== | |
is_valid: True | |
data: ReturnDict([('is_test', True)]) | |
======== Should be True: 1 ========== | |
is_valid: True | |
data: ReturnDict([('is_test', True)]) |
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
Testitg: <class '__main__.RequiredForm'> | |
======== Should be True: True ========== | |
is_valid: True | |
cleaned_data: {'is_test': True} | |
======== Should be True: true ========== | |
is_valid: True | |
cleaned_data: {'is_test': True} | |
======== Should be True: 1 ========== | |
is_valid: True | |
cleaned_data: {'is_test': True} |
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 asyncio | |
import logging | |
import time | |
import psutil | |
logger = logging.getLogger(__name__) | |
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
cd /tmp | |
mkdir adobe_flash | |
cd adobe_flash | |
wget http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.442/install_flash_player_11_linux.x86_64.tar.gz | |
tar axvf install_flash_player_11_linux.x86_64.tar.gz | |
sudo mv ./libflashplayer.so /usr/lib/mizilla/plugins |
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
""" Cache <-> Object Mapper | |
I know there is `rom <https://pypi.python.org/pypi/rom>`_ or some. | |
""" | |
import json | |
from django.core.cache import cache | |
SEPARATOR = ':' |
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 functools import wraps | |
from django.template.response import TemplateResponse | |
def template_view(template_name): | |
""" View decorator to convert returned dictionary into TemplateResponse | |
You can apply template name for this decorator like this | |
>>> @template_view |
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
_some_global_value = 'hoge' | |
class A(object): | |
def __del__(self): | |
global _some_global_value | |
_some_global_value = 'fuga' | |
class B(object): | |
def hoge(self): | |
return _some_global_value |
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 | |
import string | |
import random | |
alphanumeric = string.ascii_letters + string.digits | |
def main(): | |
return ''.join([random.choice(alphanumeric) for _ in range(8)]) |
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
class AcceptMiddleware(object): | |
""" Middleware to add attribute for Accept header of HTTP | |
""" | |
def process_request(self, request): | |
acc = [a.split(';')[0] for a in request.META['HTTP_ACCEPT'].split(',')] | |
setattr(request, 'accepted_types', acc) | |
return None |
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.db import models | |
class Parent(models.Model): | |
name = models.CharField(max_length=255) | |
def __str__(self): | |
return self.name | |