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 random | |
import string | |
import typing | |
from django.conf import settings | |
# if you have a Report-To service, add it to settings.py along with | |
# adding ReportToMiddleware to settings.MIDDLEWARE | |
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.views.defaults import page_not_found as django_page_not_found | |
from django.views.decorators.csrf import requires_csrf_token | |
from django.views.defaults import ERROR_404_TEMPLATE_NAME | |
@requires_csrf_token | |
def page_not_found(request, exception, template_name=ERROR_404_TEMPLATE_NAME): | |
path = request.path.strip("/") | |
# custom logic goes here | |
# see if there's a lowercase match |
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
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
deploy: |
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 bash | |
POSITIONAL_ARGS=() | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-v | --version) | |
shift | |
PY_VERSIONS+=($1) | |
shift |
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.contrib.gis.db import models | |
from django.utils.translation import gettext_lazy as _ | |
def validate_is_true(value): | |
if value is not True: | |
raise ValidationError(validate_is_true.error_message) | |
validate_is_true.error_message = _("This field is required") |
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
# Hosts/domain names that are valid for this site; required if DEBUG is False | |
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts | |
ALLOWED_HOSTS = [ | |
'yourdomain.tld', | |
'.compute-1.amazonaws.com', # allows viewing of instances directly | |
] | |
import requests | |
EC2_PRIVATE_IP = None | |
try: |
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
-i https://pypi.org/simple | |
anyio==3.6.2; python_full_version >= '3.6.2' | |
certifi==2022.12.7; python_version >= '3.6' | |
click==8.1.3; python_version >= '3.7' | |
colorama==0.4.6 | |
commonmark==0.9.1 | |
h11==0.14.0; python_version >= '3.7' | |
httpcore==0.16.3; python_version >= '3.7' | |
httpx==0.23.1 | |
idna==3.4 |
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 InactivityLogout(object): | |
def process_request( self, request ): | |
from datetime import datetime, timedelta | |
from django.conf import settings | |
COOKIE_AGE = getattr(settings, 'SESSION_COOKIE_AGE', 7200) | |
if datetime.now() – request.session.get_expiry_date() < timedelta(seconds = COOKIE_AGE): | |
request.session.set_expiry(datetime.now() + timedelta(seconds = COOKIE_AGE)) | |
return None # pass through |
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
function supports3d() { | |
// borrowed from modernizr | |
var div = document.createElement('div'), | |
ret = false, | |
properties = ['perspectiveProperty', 'WebkitPerspective']; | |
for (var i = properties.length - 1; i >= 0; i--){ | |
ret = ret ? ret : div.style[properties[i]] != undefined; | |
}; | |
// webkit has 3d transforms disabled for chrome, though |
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
BEGIN MESSAGE. | |
8rHFJDMpGIA41B8 QZMupuT8RVyFhvW 84aINuZp5plhrwt nDpHtI8d7rLSWxi | |
0ADNh9uwFOaUwzs VX4X9sLPkqpTCKq 6Xr2MZHgg4NiRQQ 4XMdUxe3HLsLbpo | |
JRL4KlRGMOWl8V2 iUcX5KqbTuLBJQI SfV7gcNmjUYqQzj GyD0qJpNZNUPCKY | |
ZuoHGCv6LPULidT gBacYA6j2iUe5Eb MjJ7d. | |
END MESSAGE. |
NewerOlder