Skip to content

Instantly share code, notes, and snippets.

🖥
C64/Amiga Scener/Coder

Uğur Özyılmazel vigo

🖥
C64/Amiga Scener/Coder
Block or report user

Report or block vigo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vigo
vigo / admin.py
Created Mar 14, 2019 — forked from hakib/admin.py
How to Turn Django Admin Into a Lightweight Dashboard
View admin.py
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard
from django.contrib import admin
from django.db.models import Count, Sum, Min, Max, DateTimeField)
from django.db.models.functions import Trunc
from . import models
def get_next_in_date_hierarchy(request, date_hierarchy):
View workflows-in-django.md

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
View pubsub.py
class PubSub(object):
"""
Very simple Pub/Sub pattern wrapper
using simplified Redis Pub/Sub functionality.
Usage (publisher)::
import redis
r = redis.Redis()
@vigo
vigo / tree.md
Created Nov 12, 2017 — forked from hrldcpr/tree.md
one-line tree in python
View tree.md

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!

You can’t perform that action at this time.