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.db import models | |
class User(models.Model): | |
id = models.AutoField(primary_key=True) | |
parent = models.ForeignKey("self", null=True, blank=True, on_delete=models.CASCADE) | |
def get_tree_users_recursive(self) -> "models.QuerySet[User]": | |
return User.objects.extra( | |
where=[ |
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 inspect | |
import logging | |
import os | |
import argparse | |
import pathlib | |
import signal | |
import subprocess | |
import sys | |
import time | |
import loguru |
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
allow 10.0.0.0/8; | |
allow 172.16.0.0/12; | |
allow 192.168.0.0/16; | |
# https://www.cloudflare.com/ips-v4 | |
allow 173.245.48.0/20; | |
allow 103.21.244.0/22; | |
allow 103.22.200.0/22; | |
allow 103.31.4.0/22; | |
allow 141.101.64.0/18; |
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 os | |
import sys | |
import pathlib | |
import django | |
def django_setup(DJANGO_SETTINGS_MODULE: str): | |
if os.environ.get("DJANGO_SETTINGS_MODULE"): | |
return | |
parts = list(pathlib.Path(__file__).parent.parts) |
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 os | |
import shutil | |
import click | |
from pathlib import Path | |
def is_apple_double_file(path: Path) -> bool: | |
return ( | |
path.is_file() | |
and path.name.startswith("._") |
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 json | |
import os | |
import pathlib | |
import sqlite3 | |
from pprint import pprint | |
# pip install javascript | |
from javascript import require | |
crypto = require("crypto") |
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
/** | |
* Traverse DOM Tree | |
* @param {string[]} content | |
* @param {Element|ChildNode} node | |
* @param {string|undefined} altReplacement | |
* @returns {void} | |
*/ | |
function traverse(content, node, altReplacement) { | |
if (node.nodeType === Node.TEXT_NODE) { | |
content.push(node.textContent ?? ''); |
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 urllib.parse import quote | |
import polib | |
def google_lang_convert(lang: str): | |
if lang == "zh_Hant": | |
return "zh-TW" | |
if lang.lower().startswith("zh"): | |
return "zh-CN" | |
return lang |
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
{% extends "admin/base_site.html" %} | |
{% load i18n static %} | |
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" href="{% static "admin/css/login.css" %}"> | |
<style> | |
#id_token { | |
padding: 8px; | |
width: 100%; | |
box-sizing: border-box; | |
} |
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
# https://github.com/douweschulte/opencontrol | |
import math | |
from loguru import logger | |
import logging | |
import sys | |
import ctypes | |
import enum | |
import typing |