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 re | |
from re import Pattern | |
from typing import Dict, Any, cast | |
from pydantic.utils import update_not_none | |
from pydantic.validators import constr_length_validator | |
class RFC3986Regex: | |
ALPHA: Pattern = r"[a-zA-Z]" |
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.conf import settings | |
def SessionCookieSameSiteWorkaround(get_response): | |
def middleware(request): | |
# See: | |
# https://blog.chromium.org/2019/10/developers-get-ready-for-new.html | |
# https://github.com/django/django/pull/11894 | |
# https://web.dev/samesite-cookie-recipes/#handling-incompatible-clients | |
# https://www.chromium.org/updates/same-site/incompatible-clients |
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 unittest.TestCase mixin that allows using the | |
responses (https://pypi.python.org/pypi/responses/) package in tests. | |
Usage | |
----- | |
Install responses with `pip install responses`. | |
Add `ResponsesMixin` to your `TestCase` parent classes instead of using |
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
# Orignal version taken from http://www.djangosnippets.org/snippets/186/ | |
# Original author: udfalkso | |
# Modified by: Shwagroo Team and Gun.io | |
# Further modified by: Jakub Skalecki (https://rock-it.pl) | |
import hotshot | |
import hotshot.stats | |
import textwrap | |
import os |
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
# AWS S3 bucket for static hosting | |
resource "aws_s3_bucket" "website" { | |
bucket = "${var.website_bucket_name}" | |
acl = "public-read" | |
tags { | |
Name = "Website" | |
Environment = "production" | |
} |
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.generic import TemplateView | |
if settings.DEBUG: | |
# enable local preview of error pages | |
urlpatterns += patterns('', | |
(r'^403/$', TemplateView.as_view(template_name="403.html")), | |
(r'^404/$', TemplateView.as_view(template_name="404.html")), | |
(r'^500/$', TemplateView.as_view(template_name="500.html")), |
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
<toolSet name="Code Checking"> | |
<tool name="Flake8" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true"> | |
<exec> | |
<option name="COMMAND" value="/usr/local/bin/flake8" /> | |
<option name="PARAMETERS" value="--max-complexity 10 $FilePath$" /> | |
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" /> | |
</exec> | |
<filter> | |
<option name="NAME" value="Filter 1" /> | |
<option name="DESCRIPTION" /> |