Skip to content

Instantly share code, notes, and snippets.

View oduvan's full-sized avatar
✂️
Cleanup

Alexander Lyabah oduvan

✂️
Cleanup
  • CheckiO Inc.
  • United States
View GitHub Profile
@oduvan
oduvan / django_unused_views.py
Created June 7, 2021 06:38
Showing usused views in Django by parsing nginx acces log
SKIP_MODULES = ('django', 'simple_history')
ACCESS_FILES = [
'/var/log/nginx/access.log',
'/var/log/nginx/access.log.1',
'/var/log/nginx/access.log.2',
] + ['/var/log/nginx/access.log.{}.gz'.format(i) for i in range(3, 31)]
RE_SEARCH_URL = r'(?:(?:POST)|(?:GET)|(?:PATCH)|(?:PUT)|(?:OPTIONS)|(?:DELETE)|(?:HEAD))\s([^\s\?]+)'
def SKIP_MATCH(url):
return requested_url.startswith('/static/')
@oduvan
oduvan / the_longest_function.py
Created March 3, 2024 16:55
Find Top 10 longest functions in your source folder
import os
import re
def find_functions(file_path):
"""
Extracts functions and their line counts from a given Python file.
"""
with open(file_path, 'r') as file:
lines = file.readlines()
from functools import cached_property
class DataProxy:
def __init__(self, user):
self.user = user
@cached_property
def plan(self):
return DBModel.objects.get(id=67)