This file contains hidden or 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 base64 | |
import json | |
from typing import Any, Optional, Union | |
from cryptography.fernet import Fernet | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives import hashes | |
from django.conf import settings | |
from django.db import models |
This file contains hidden or 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
def deep_get(path, data, default=None): | |
""" | |
Uses a provided dot-notation path to retrieve values from a deeply nested dict | |
""" | |
if isinstance(path, str): | |
path = path.split('.') | |
obj = data | |
for key in path: | |
obj = obj.get(key) | |
if obj is None: |
This file contains hidden or 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 copy import deepcopy | |
from functools import reduce | |
def merge_dicts(dict1: dict, dict2: dict) -> dict: | |
""" | |
Merges dicts. | |
""" | |
for key in dict2: | |
if key not in dict1 or not isinstance(dict1[key], dict): |
This file contains hidden or 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 io import BytesIO | |
from django.conf import settings | |
from django.core.files.uploadedfile import InMemoryUploadedFile | |
from django.core.files.uploadhandler import FileUploadHandler | |
from rest_framework.parsers import DataAndFiles, FileUploadParser | |
class BodyUploadHandler(FileUploadHandler): | |
def new_file(self, *args, **kwargs): |
This file contains hidden or 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 coreapi | |
from django.core.exceptions import FieldDoesNotExist | |
from rest_flex_fields.utils import is_expanded | |
from rest_framework.exceptions import APIException | |
from rest_framework.schemas.inspectors import AutoSchema | |
class FlexFieldSchema(AutoSchema): | |
def __init__(self, view, *args, **kwargs): | |
super().__init__(*args, **kwargs) |
This file contains hidden or 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 catalog import CatalogMember | |
from collections import OrderedDict | |
from itertools import chain | |
from rest_framework.exceptions import APIException | |
from rest_framework.fields import ReadOnlyField | |
from rest_framework.serializers import Serializer | |
class CatalogSerializer(Serializer): |
This file contains hidden or 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 math | |
import board | |
import neopixel | |
import analogio | |
import time | |
from simpleio import map_range | |
NEOPIXEL_PIN = board.D5 | |
NEOPIXEL_COUNT = 20 |
This file contains hidden or 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
{ | |
"python.pythonPath": "~/.virtualenvs/pfgym/bin/python", | |
"python.linting.enabled": true, | |
"python.linting.flake8Enabled": true, | |
"python.linting.mypyEnabled": true, | |
"python.jediEnabled": true | |
} |
This file contains hidden or 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 asyncio | |
from time import time | |
from httpx import AsyncClient | |
async def async_request(url: str): | |
async with AsyncClient() as client: | |
resp = await client.get(url) | |
result = len(resp.read()) |
This file contains hidden or 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
let g:ycm_server_python_interpreter = '/home/jsatt/.virtualenvs/pfapi/bin/python' | |
let $PATH .= ':/home/jsatt/.virtualenvs/pfapi/bin' |
NewerOlder