This was tested on:
- Ubuntu 14.04 x64
- Ubuntu 16.04 x64
import logging | |
from concurrent.futures import ThreadPoolExecutor | |
from datetime import timedelta, datetime | |
from typing import Any, Dict | |
class SimpleStorageEntry: | |
_counter: int = 0 | |
id: int |
from django.db.models import Sum | |
class AbsoluteSum(Sum): | |
name = 'AbsoluteSum' | |
template = '%(function)s(%(absolute)s(%(expressions)s))' | |
def __init__(self, expression, **extra): | |
super(AbsoluteSum, self).__init__( | |
expression, absolute='ABS ', output_field=IntegerField(), **extra) |
from django.utils.functional import curry | |
class DetailsInline(admin.TabularInline): | |
model = Details | |
# formset = DetailsFormset | |
extra = 3 | |
def get_formset(self, request, obj=None, **kwargs): | |
initial = [] | |
if request.method == "GET": |
>>> import base64 | |
>>> import hashlib | |
>>> base64.b64encode(hashlib.sha1("test").digest()) | |
'qUqP5cyxm6YcTAhz05Hph5gvu9M=' |
For earlier version whos suffering from versionlock syndrome. Please follow the instructions to rollback to older SSL interface. Do not alarm by the fallback ssl interface, they received security patches for vulnerability discovered.
Current version of apt-get wkhtmltopdf does not come with Qt patch. There are some issue going with both Qt patched and non-patched. Most common use case is compatible with the patched Qt.
class IdManyRelatedField(ManyRelatedField): | |
field_name_suffix = '_ids' | |
def bind(self, field_name, parent): | |
self.source = field_name[:-len(self.field_name_suffix)] | |
super().bind(field_name, parent) | |
class IdPrimaryKeyRelatedField(PrimaryKeyRelatedField): | |
""" |
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c | |
[metadata] | |
name = {name} | |
version = file: {name}/_version.txt | |
author = Martin Larralde | |
author_email = martin.larralde@embl.de | |
url = https://github.com/althonos/{name} | |
description = {description} | |
long_description = file: README.md |
class AfterFetchQuerySetMixin: | |
""" | |
QuerySet mixin to enable functions to run immediately | |
after records have been fetched from the DB. | |
""" | |
# This is most useful for registering 'prefetch_related' like operations | |
# or complex aggregations that need to be run after fetching, but while | |
# still allowing chaining of other QuerySet methods. | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) |
from django import forms | |
from django.contrib.postgres.fields import ArrayField | |
class ChoiceArrayField(ArrayField): | |
""" | |
A field that allows us to store an array of choices. | |
Uses Django 1.9's postgres ArrayField | |
and a MultipleChoiceField for its formfield. |