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"),
@barseghyanartur
barseghyanartur / valuta_test_output.md
Last active May 21, 2021
Test output for `valuta`
View valuta_test_output.md
$ ./runtests.py 
================================================================ test session starts =================================================================
platform linux -- Python 3.6.13, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
django: settings: project.settings.testing (from env)
rootdir: /home/delusionalinsanity/bbrepos/valuta, configfile: pytest.ini
plugins: ordering-0.6, django-4.3.0, Faker-8.1.4, pythonpath-0.7.3, cov-2.12.0
collected 35 items                                                                                                                                   

src/valuta/contrib/django_integration/tests/test_models.py .................
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
View flutter_bash_completion.rst

Enable bash completion:

source <(flutter bash-completion)

Or simply add it to your ~/.bashrc

@barseghyanartur
barseghyanartur / openoffice_convert_docx_pdf_odt_to_png.md
Created Mar 18, 2021
OpenOffice convert DocX, PDF or ODT to PNG
View openoffice_convert_docx_pdf_odt_to_png.md

DocX

soffice --headless --convert-to png test.docx

PDF

soffice --headless --convert-to png test.pdf
@barseghyanartur
barseghyanartur / imagemagick_convert_docx_pdf_odt_to_png.md
Last active Mar 18, 2021
ImageMagick convert DocX, PDF or ODT to PNG
View imagemagick_convert_docx_pdf_odt_to_png.md

DocX

convert -verbose -quality 100 -fill "rgba(255,255,255,1.00)" -density 300 -alpha off test.docx test_docx.png

PDF

convert -verbose -quality 100 -fill "rgba(255,255,255,1.00)" -density 300 -alpha off test.pdf test_pdf.png
@barseghyanartur
barseghyanartur / remove_all_local_git_branches_except_master.md
Last active Mar 18, 2021
Remove all your local git branches but keep master
View remove_all_local_git_branches_except_master.md
git branch | grep -ve " master$" | xargs git branch -D
@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