Skip to content

Instantly share code, notes, and snippets.

View Cguilliman's full-sized avatar
🐯
#TiggerForm

Ihor Bondarenko Cguilliman

🐯
#TiggerForm
  • Madgicx
  • Kiev, Ukraine
View GitHub Profile
@LowerDeez
LowerDeez / decorators.py
Last active December 26, 2019 08:52
Celery. Task no simultaneous execution
from functools import wraps
from django.core.cache import cache
from celery.five import monotonic
CACHE_LOCK_EXPIRE = 10
# HANDLER
from django.utils.translation import ugettext_lazy as _
from rest_framework.exceptions import ErrorDetail
from rest_framework.views import exception_handler
non_field_errors = 'non_field_errors'
def set_custome_errors(errors):
# run.py file
from app.app import init
if __name__ == "__main__":
init()
# app/app.py file
from sanic import Sanic
@omarryhan
omarryhan / Sanic-Gino-Alembic migrations Setup
Last active May 30, 2020 15:49
Sanic/Gino/Alembic migrations
# Do the first 6 steps only once.
1. pip install --user alembic
2. bash: ``cd {{my_project}} && alembic init alembic``
3. bash: ``text_editor {{my_project}}/alembic.ini``
4. Change: "sqlalchemy.url = postgres://{{username}}:{{password}}@{{address}}/{{db_name}}"
5. bash: ``text_editor {{my_project}}/alembic/env.py``
6. Now, import your metadata/db object from your app.:
# {{my_project}}/{{my_project_dir}}/app.py
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 17, 2024 12:37
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@natekupp
natekupp / gist:1763661
Created February 8, 2012 00:55
Python B-Trees
class BTreeNode(object):
"""A B-Tree Node.
attributes
=====================
leaf : boolean, determines whether this node is a leaf.
keys : list, a list of keys internal to this node
c : list, a list of children of this node
"""
def __init__(self, leaf=False):