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
# models.py | |
from django.db import models | |
class User(models.Model): | |
# Old field (blue version) | |
name = models.CharField(max_length=100) | |
# New fields (green version) | |
first_name = models.CharField(max_length=50, null=True, blank=True) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
""" | |
Encrypted field for Django for encrypting data at rest. | |
Inspired by: https://scottarc.blog/2024/06/02/encryption-at-rest-whose-threat-model-is-it-anyway/ | |
""" | |
import base64 | |
import os | |
from django.db import models | |
from cryptography.hazmat.primitives.ciphers.aead import AESGCM |
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 ast | |
import inspect | |
from pathlib import Path | |
from django.apps import apps | |
from django.conf import settings | |
from django.core.checks import Error, register, Tags | |
from .models import UniversalBaseModel | |
@register(Tags.models) |
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
frofrom typing import Union | |
from filetype.types import application, archive, audio, document, font, image, video | |
ImageFileType = Union[ | |
image.Dwg, | |
image.Xcf, | |
image.Jpeg, | |
image.Jpx, | |
image.Apng, |
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
{ | |
"manifest_version": 3, | |
"name": "Superpower ChatGPT", | |
"version": "5.1.2", | |
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzG6ZR+j3lpHF0XrDLIXdrk25idObfq+RK7WM+pIaQmDO2nM5Y+SZJJbFwyxjWX+3V6XOgS5v9Lpnqg46OJ/W9Q5i23Usx1MXgaJBTlEFz0XG+PYK6BElhc9itS7m6oCLknin97a533tusXmm8zW7kaDGy8vycMDY6Ffbqa3sn0PqZ8bXUlAjgO91dQcB8EtlT906hwhZjtfEYvp2hdxYkRFxfuaR1WMLkxttVXv506RXJowxq0LO3aqj83QeJoXkQF1wbzCxYO1VpVGEmYIQxIKw/csusZNZs8gwJrIWtOzhMgDNOFzXNeZl0ASgoj2M9UsZp+Dunn57VT8tQyaE6QIDAQAB", | |
"description": "ChatGPT with superpowers! Sync/search history locally, create folders, export all chats, pin messages, access thousands of prompts", | |
"icons": { | |
"16": "images/icon-16.png", | |
"32": "images/icon-32.png", | |
"48": "images/icon-48.png", |
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 ast | |
import astor | |
import tkinter as tk | |
from tkinter import scrolledtext, IntVar, Checkbutton | |
class EllipsisTransformer(ast.NodeTransformer): | |
def __init__(self, remove_args, remove_methods): | |
self.remove_args = remove_args | |
self.remove_methods = remove_methods |
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
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"type": "object", | |
"properties": { | |
"services": { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"type": {"type": "string"}, |
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
def path_walk(path: str) -> Generator[str, None, None]: | |
"""Walks a directory tree yielding all files and directories. | |
This uses a breadth-first algorithm. | |
""" | |
queue = deque([path]) | |
while queue: | |
current = queue.popleft() | |
for entry in os.scandir(current): | |
entry: os.DirEntry |
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 ctypes, sys | |
from ctypes import windll, wintypes | |
from uuid import UUID | |
class GUID(ctypes.Structure): # [1] | |
_fields_ = [ | |
("Data1", wintypes.DWORD), | |
("Data2", wintypes.WORD), | |
("Data3", wintypes.WORD), | |
("Data4", wintypes.BYTE * 8) |
NewerOlder