Skip to content

Instantly share code, notes, and snippets.

View IMBlues's full-sized avatar
💪
全世界无产阶级联合起来 ☭

布鲁斯搬砖鱼 IMBlues

💪
全世界无产阶级联合起来 ☭
View GitHub Profile
@IMBlues
IMBlues / delete_files.py
Last active June 1, 2021 16:51
Delete files without any fd open(non-asyncio)
# -*- coding: utf-8 -*-
import datetime
import getopt
import glob
import logging
import subprocess
import sys
from collections import namedtuple
from pathlib import Path
from typing import Generator, Dict
@IMBlues
IMBlues / delete_files.py
Last active June 1, 2021 08:38
Delete files without any fd open
# -*- coding: utf-8 -*-
import asyncio
import datetime
import getopt
import glob
import logging
import os
import sys
from collections import namedtuple
from pathlib import Path
@IMBlues
IMBlues / inject.py
Last active April 8, 2024 20:11
Make your Django REST framework supporting dependency injection
# -*- coding: utf-8 -*-
import functools
from collections import namedtuple
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Optional, Type
from django.conf import settings
from django.utils.module_loading import import_string
from rest_framework import status
@IMBlues
IMBlues / nginx-ingress.grok
Last active March 17, 2021 09:58
Grok pattern for nginx ingress in Kubernetes
"%{IPORHOST:client_ip} - \[%{IPORHOST:x_forwarded_for}\] - %{DATA:client_identity} \[%{HTTPDATE:request_timestamp}\] \"(?:%{WORD:method} %{NOTSPACE:path}(?: HTTP/%{NUMBER:http_version})?|-)\" %{NUMBER:status_code:int} (?:%{NUMBER:bytes_sent:float}|-) (?:\"(?:%{URI:referrer}|-)\") %{QS:user_agent} %{NUMBER:request_length:int} %{NUMBER:response_time:float} \[%{DATA:upstream_proxy}\] %{DATA:upstream_endpoint} %{NUMBER:upstream_bytes_sent:int} (-|%{NUMBER:upstream_response_time:float}) (-|%{NUMBER:upstream_response:int})"