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
$values = array( | |
array( | |
'title' => 'Example', | |
'uid' => 1, | |
'created' => REQUEST_TIME, | |
), | |
array( | |
'title' => 'Example 2', | |
'uid' => 1, | |
'created' => REQUEST_TIME, |
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
# NOTE: This code was extracted from a larger class and has not been | |
# tested in this form. Caveat emptor. | |
import django.conf | |
import django.contrib.auth | |
import django.core.handlers.wsgi | |
import django.db | |
import django.utils.importlib | |
import httplib | |
import json | |
import logging |
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 multipliers(): | |
return (lambda x: i*x for i in range(4)] | |
print [m(2) for m in multipliers()] |
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 yes_or_no(question): | |
reply = str(raw_input(question+' (y/n): ')).lower().strip() | |
if reply[0] == 'y': | |
return True | |
if reply[0] == 'n': | |
return False | |
else: | |
return yes_or_no("Uhhhh... please enter ") |
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
class LotListView(ListView): | |
model = Article | |
context_object_name = 'articles' | |
def get_context_data(self, **kwargs): | |
context = super(LotListView, self).get_context_data(**kwargs) | |
context['articles_data'] = [self._get_article_view_model(a) for a in context['articles']] | |
return context | |
@staticmethod |
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 | |
members = [ | |
#{'name': 'member', 'skills': set('skill1', 'skill2', ...)} | |
{'name': 'Jan', 'skills': set(('PHP', 'HTML'))}, | |
{'name': 'Bep', 'skills': set(('HTML', 'CSS'))}, | |
{'name': 'Leo', 'skills': set(('CSS', 'PHP'))} | |
] | |
project = OrderedDict([ | |
#'task': ['skill', nrhourswork] | |
('A', ['PHP', 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
class BaseDataStructure(object): | |
"""The class is intended for definition contract objects which might be used as argument for various classes. | |
The example of using: | |
class SomeServiceInput(BaseDataStructure): | |
__accessible__ = { | |
'email': str, | |
'template_type': int, | |
} | |
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
# Generated by Django 2.2 on 2019-06-06 14:38 | |
""" | |
If you add a migration that uses content types and/or permissions you should apply the functions to fill particular tables in DB. | |
""" | |
from django.db import migrations | |
from django.contrib.contenttypes.management import create_contenttypes | |
from django.contrib.auth.management import create_permissions | |
from django.apps import apps as _apps |
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
# | |
# File templatetags/custom_pagination.py | |
# | |
from django import template | |
register = template.Library() | |
@register.simple_tag |
OlderNewer