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
""" | |
base64's `urlsafe_b64encode` uses '=' as padding. | |
These are not URL safe when used in URL paramaters. | |
Functions below work around this to strip/add back in padding. | |
See: | |
https://docs.python.org/2/library/base64.html | |
https://mail.python.org/pipermail/python-bugs-list/2007-February/037195.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
class AjaxDialog extends HTMLElement { | |
connectedCallback() { | |
// Store the original children (the slot content) | |
const originalChildren = this.innerHTML; | |
this.open = this.getAttribute('open') || false; | |
this.loaded = this.getAttribute('loaded') || false; | |
this.content = this.getAttribute('content') || ''; | |
this.url = this.getAttribute('url') || ''; | |
this.button_class = this.getAttribute('button-class') || 'bg-green-600 text-white'; | |
this.dialog_class = this.getAttribute('dialog-class') || 'bg-white'; |
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
result = real_client.query( | |
q.create_role({ | |
"name": "new-role-c", | |
"privileges": [ | |
{ | |
"resource": q.function("create_user"), | |
"actions": { | |
"call": True | |
} | |
} |
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 itertools import permutations | |
xlist = ["word1", "word2", "word3"] | |
def perm_range(obj_list,num): | |
for perm in permutations(obj_list, num): | |
print(perm) | |
perm_range(xlist,2) |
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.core.exceptions import SuspiciousFileOperation | |
from django.template import Origin | |
from django.template.loaders.filesystem import Loader | |
from django.conf import settings | |
from django.utils._os import safe_join | |
class ThemeLoader(Loader): | |
themes = [theme.get('theme') for theme in settings.SITE_CONFIGS.values()] | |
current_theme = '' |
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 logging | |
from django.utils import translation | |
from django.conf import settings | |
class DomainBasedLanguageMiddleware(object): | |
""" | |
Set the language for the site based on the subdomain the request | |
is being served on. For example, serving on 'fr.domain.com' would | |
make the language French (fr). |
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 click | |
from .cli import CappyCLI | |
@click.group() | |
def cappy(): | |
pass | |
def use_apigw(ctx, param, value): | |
""" |
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.core.management.base import BaseCommand | |
from django.contrib.auth import get_user_model | |
class Command(BaseCommand): | |
help = 'Echoes AWS Creds' | |
def handle(self, *args, **options): | |
get_user_model().objects.create_superuser(username='your_user', password='your_password', email='[email protected]') |
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 boto3 | |
import datetime | |
import json | |
from requests_aws4auth import AWS4Auth | |
import requests | |
boto3.setup_default_session(region_name='us-east-1') | |
identity = boto3.client('cognito-identity', region_name='us-east-1') | |
account_id='XXXXXXXXXXXXXXX' |
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
{ | |
"dev": { | |
"aws_region": "us-east-1", | |
"s3_bucket": "yourcode-bucket", | |
"django_settings": "yourapp.settings", | |
"remote_env_file":"yourblog-dev.json", | |
"remote_env_bucket":"yourcode-bucket", | |
"use_precompiled_packages": true, | |
"domain": "yourblog-dev-apigw.yourdevdomain.com", | |
"lets_encrypt_key": "s3://yourcode-bucket/openssl.key", |
NewerOlder