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.http.response import (Http404, HttpResponseNotModified, | |
CompatibleStreamingHttpResponse) | |
from django.utils.http import http_date | |
from django.views.static import was_modified_since | |
from gridfs import GridFS | |
from mongoengine.connection import get_db | |
from bson.objectid import ObjectId | |
def file(request, collection_name, grid_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
vertical layout > flex layout > flex autoscrolly |
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
[core] | |
editor = joe | |
[color] | |
ui = auto | |
[push] | |
default = simple | |
[pull] | |
rebase = true | |
[rerere] | |
enabled = 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
Python 3.4.2 (default, Jul 9 2015, 17:24:30) | |
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> class A: | |
... def __init__(self): | |
... self.__foo = 'bar' | |
... | |
>>> class B(A): | |
... def foo(self): | |
... print(self._A__foo) |
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
description = models.TextField(validators=[MaxLengthValidator(128)], max_length=128, verbose_name='Краткая аннотация', help_text='Максимум 128 символов') | |
description = models.TextField( | |
validators=[MaxLengthValidator(128)], | |
max_length=128, | |
verbose_name='Краткая аннотация', | |
help_text='Максимум 128 символов') |
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 another_profile(request, id): | |
user2 = CustomUser.objects.get(id = id) | |
if request.user.is_authenticated(): | |
if request.user == user2: | |
viewable = False | |
else: | |
viewable = True | |
userlist = request.user.friends.all() | |
try: | |
Friendship.objects.get(user=request.user) |
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 dist import * | |
try: | |
from local import * | |
except ImportError: | |
from local_sample import * | |
from warnings import warn | |
warn( | |
'Local settings not found (settings/local.py).' | |
'Using local_sample.py instead.') |
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
filename = os.path.join(root, name) | |
try: | |
os.remove(filename) | |
except OSError: | |
log.error('Error removing file %s' % filename) |
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
a = ['123', '1234', None, '12'] | |
## 1 | |
from operator import methodcaller | |
b = [methodcaller('__len__')(x) for x in a if x] | |
print(b) | |
## 2 | |
b = [len(x) for x in a if x] | |
print(b) |
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
# Use uswsusp | |
SLEEP_MODULE="uswsusp" | |
# Always use suspend_hybrid instead of suspend | |
if [ "$METHOD" = "suspend" ]; then | |
METHOD=suspend_hybrid | |
fi |
OlderNewer