Skip to content

Instantly share code, notes, and snippets.

View test.md
$ cat t.py
from pprint import pprint
from pytheory import Tone, Fretboard, charts_for_fretboard


tones = (
    Tone.from_string("F2"),
    Tone.from_string("C3"),
    Tone.from_string("G3"),
    Tone.from_string("D4"),
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 gist:356f7b6061f76fee2227a721aaa958fa
from django.core.exceptions import ValidationError
from django.db.models import Field, CharField
__all__ = ['MultiColumnField']
try:
from hashlib import md5
except ImportError:
from md5 import new as md5
@barseghyanartur
barseghyanartur / gist:e78545138572e555433c36685e7b331f
Created May 11, 2021 — forked from gipi/gist:2401143
Multi columns django custom field
View gist:e78545138572e555433c36685e7b331f
#look also
# https://github.com/dcramer/django-ratings/blob/master/djangoratings/fields.py
from django.core.exceptions import ValidationError
from django.db.models import Field, CharField
__all__ = ['MultiColumnField']
try:
from hashlib import md5
@barseghyanartur
barseghyanartur / git-pushing-multiple.rst
Created Feb 17, 2021 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.
View git-pushing-multiple.rst

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

View zero_downtime_reindexing.py
from datetime import datetime
from elasticsearch_dsl import (
DocType,
String,
Integer,
Float
)
def _suffix():
@barseghyanartur
barseghyanartur / bench.py
Created Apr 22, 2020 — forked from marians/bench.py
Benchmarking serialization/unserialization in python using json, pickle and cPickle
View bench.py
import cPickle
import pickle
import json
import random
from time import time
from hashlib import md5
test_runs = 1000
def float_list():
@barseghyanartur
barseghyanartur / bench.py
Created Apr 22, 2020 — forked from marians/bench.py
Benchmarking serialization/unserialization in python using json, pickle and cPickle
View bench.py
import cPickle
import pickle
import json
import random
from time import time
from hashlib import md5
test_runs = 1000
def float_list():
@barseghyanartur
barseghyanartur / apache-multi-ad-reverse-proxy.conf
Created Mar 16, 2020 — forked from alivesay/apache-multi-ad-reverse-proxy.conf
Apache reverse proxy with LDAP authentication against multiple Active Directory domains
View apache-multi-ad-reverse-proxy.conf
<AuthnProviderAlias ldap auth1>
AuthLDAPURL "ldaps://auth1.example.com:636/DC=example,DC=com?sAMAccountName?sub?(objectClass=*)"
AuthLDAPBindDN "ldap_query"
AuthLDAPBindPassword "password"
</AuthnProviderAlias>
<AuthnProviderAlias ldap auth2>
AuthLDAPURL "ldaps://auth2.example.com:636/DC=example,DC=com?sAMAccountName?sub?(objectClass=*)"
AuthLDAPBindDN "ldap_query"
AuthLDAPBindPassword "password"
@barseghyanartur
barseghyanartur / hg-to-git-conversion.md
Created Feb 7, 2020 — forked from HerrPi/hg-to-git-conversion.md
Mercurial to Git repo conversion (hg-to-git)
View hg-to-git-conversion.md