Skip to content

Instantly share code, notes, and snippets.

View kmmbvnr's full-sized avatar
💭
#StopPutin #StopWar

Mikhail Podgurskiy kmmbvnr

💭
#StopPutin #StopWar
View GitHub Profile
@kmmbvnr
kmmbvnr / README
Created March 20, 2012 04:16
Udacity cs373 code
Udacity cs373 code
@kmmbvnr
kmmbvnr / gist:bbd155f16683506e440ab5f51dac380b
Last active April 27, 2021 05:56
Advanced Turbolinks to @hotwire/turbo migration tricks
- Turbolinks.controller.disable();
+ Turbo.navigator.delegate.stop()
- Turbolinks.controller.currentVisit
+ Turbo.navigator.currentVisit
@kmmbvnr
kmmbvnr / __init__.py
Last active July 31, 2020 04:25
setry_bug_661
We couldn’t find that file to show.
@kmmbvnr
kmmbvnr / tox.ini
Last active June 15, 2018 11:50
Even less painless way to launch a script without activating first its virtual environment
[tox]
envlist = py36
skipsdist = True
[testenv]
deps = django==2.0.6
commands = {posargs:./manage.py runserver}
setenv =
PYTHONPATH={toxinidir}
PATH={envdir}/bin:{env:PATH}
@kmmbvnr
kmmbvnr / fields.py
Created March 10, 2016 05:48 — forked from mariocesar/fields.py
Django state field that enforce a workflow path
from collections import namedtuple
from functools import wraps
from itertools import chain
from django.utils.functional import curry
from django.db.models import CharField
class StateField(CharField):
Starts = namedtuple('Starts', ['state'])
@kmmbvnr
kmmbvnr / bigquery.sql
Created July 21, 2016 02:59
Query pypi package download stats
SELECT details.installer.name, COUNT(*)
FROM
TABLE_DATE_RANGE(
[the-psf:pypi.downloads],
TIMESTAMP("20160601"),
TIMESTAMP("20160630")
)
WHERE file.project='django-material'
group by details.installer.name
@kmmbvnr
kmmbvnr / README.rst
Last active February 16, 2017 07:25
Viewflow 0.12 upgrade instruction

Viewflow 0.12 upgrade instruction

  1. Django 1.6 is no longer supported. please consider upgrading.
  2. Process wait-lock was removed for all locks implementation. Django 1.8 users need to enable django-transaction-hooks that required by celery.Job task. Any 3rd party task queue implementation should use transaction.on_commit to schedule a background task.
  3. Django and DjangoRestFramework tend to use _class suffix for the variable names. Viewflow now follows the same naming theme. All _cls suffixes were renamed to _class. Check your code for the process_cls, task_cls and flow_cls variables and rename to process_class, task_class, flow_class respectively.
  4. Django-Extra-Views integration was removed. Consider using django-material or django-super-forms packages to simplify forms handling.
#!/bin/bash
DWDIR=~/Downloads/`date +%Y-%m-%d`
if [ ! -d $DWDIR ]; then
cd ~/Downloads/ && find -maxdepth 1 -type d -empty -delete
mkdir $DWDIR
unlink ~/Downloads/Current
ln -sf $DWDIR ~/Downloads/Current
fi;
class Task(Model):
@contextmanager
def activate(self):
activation = self.flow_task.activation_cls(self.task)
with activation.lock():
yield activation
def start_view(request, start_task):
with start_task.activate() as activation:
@kmmbvnr
kmmbvnr / quiz.py
Last active June 22, 2016 10:50
Little python quiz
"""
Implement @secret_decorator allows to bypass decorator on base class method
"""
class Base(object):
@secret_decorator
def method(self):
print('base')