Skip to content

Instantly share code, notes, and snippets.

View bellini666's full-sized avatar
πŸ“

Thiago Bellini Ribeiro bellini666

πŸ“
View GitHub Profile
@bellini666
bellini666 / bit-buffer.c
Last active August 29, 2015 14:19
c-bit-buffer
/*
Copyright (C) 2015 Thiago Bellini <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@bellini666
bellini666 / django_aggregate_subquery.py
Last active April 19, 2024 15:41
Django Aggregate Subquery
"""
This can be used to get the aggregated value of a field in a subquery, like:
>>> comments_subquery = Comment.objects.filter(
... post=OuterRef("pk"),
... )
>>> posts = Post.objects.annotate(
... most_recent_comment_date=MinSubquery(
... comments_subquery.values("created_at"),
... "created_at",