Assumes you already have a sphinx project installed and a project created
make html
By default this command will build documentation to
_build/html
from django.contrib.postgres.forms import DateTimeRangeField | |
from django.core.exceptions import ImproperlyConfigured | |
from django_filters import DateTimeFromToRangeFilter as DateTimeFromToRangeGenericFilter | |
class DateTimeTZFromToRangeFilter(DateTimeFromToRangeGenericFilter): | |
field_class = DateTimeRangeField | |
lookup_names = { | |
'contained_by', 'contains', 'overlap', 'fully_lt', 'full_gt', | |
'not_lt', 'not_gt', 'adjacent_to', |
from django.db import ProgrammingError, models | |
from django.db.models.constants import LOOKUP_SEP | |
from django.db.models.query import normalize_prefetch_lookups | |
from rest_framework import serializers | |
from rest_framework.utils import model_meta | |
class OptimizeModelViewSetMetaclass(type): | |
""" | |
This metaclass optimizes the REST API view queryset using `prefetch_related` and `select_related` | |
if the `serializer_class` is an instance of `serializers.ModelSerializer`. |
Assumes you already have a sphinx project installed and a project created
make html
By default this command will build documentation to
_build/html
'use strict'; | |
const co = require('co'); | |
const EventEmitter = require('events'); | |
const Promise = require('bluebird'); | |
const AWS = require('aws-sdk'); | |
const ssm = Promise.promisifyAll(new AWS.SSM()); | |
const DEFAULT_EXPIRY = 3 * 60 * 1000; // default expiry is 3 mins |
$ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
$ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv
instead. If you are looking for the previous version of this document, see the revision history.
$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10
$ pyenv install 2.6.9
https://www.postgresql.org/docs/9.3/functions-range.html
from django.contrib.postgres.fields import RangeField
from django.db import models
# Is the lower bound infinite?
@RangeField.register_lookup
class LowerInf(models.Transform):
from collections import OrderedDict | |
from rest_framework.fields import SkipField | |
from rest_framework.relations import PKOnlyObject | |
class RestrictedFieldsSerializerMixin(object): | |
""" | |
API Serializer mixin which provides support for restricting serialized data to only a subset of fields. |
import pyrsistent | |
import immutables | |
import time | |
I = 1_000_000 | |
KEY = '5' | |
for N in [5, 10, 20, 30, 100, 200, 300, 400, 500, 1000]: | |
print('=============') |
from datetime import datetime, timedelta | |
import boto3 | |
from dateutil.tz import UTC | |
client = boto3.client('iam') | |
fifteen_days_ago = datetime.now(tz=UTC) - timedelta(days=15) | |
paginator = client.get_paginator('list_roles') |