Skip to content

Instantly share code, notes, and snippets.

@ur001
ur001 / promise_queue.js
Last active June 27, 2019 14:35
Promise based Lock and Queue
/**
* Асинхронная очередь с локами на чтение/запись
*/
class Queue {
constructor() {
this.queue = [];
this.readLock = new Lock();
this.writeLock = new Lock();
this.setEmpty();
}
@ur001
ur001 / decorators.py
Created May 28, 2014 13:20
Django models decorator for tracking fields changes
def track_field_changes(only=None, exclude=()):
"""
Django models decorator for tracking fields changes
:only: fields to track for changes (all otherwise)
:exclude: fields to exclude from tracking
Adds to model instance:
get_old_value(field_name) — old value of given field
is_changed(field_name=None) — is any field (or given field) is changed