Skip to content

Instantly share code, notes, and snippets.

View ncopiy's full-sized avatar
💭
🌚 weekend developer

ncopiy ncopiy

💭
🌚 weekend developer
View GitHub Profile
@ncopiy
ncopiy / tree.md
Created June 19, 2023 10:13 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@ncopiy
ncopiy / asserts.py
Created November 25, 2019 17:03 — forked from kmike/asserts.py
assertNumQueries decorator and context manager
import functools
import sys
import re
from django.conf import settings
from django.db import connection
def shrink_select(sql):
return re.sub("^SELECT(.+)FROM", "SELECT .. FROM", sql)
def shrink_update(sql):