Skip to content

Instantly share code, notes, and snippets.

View vovanbo's full-sized avatar
💭
I am

Vladimir Bolshakov vovanbo

💭
I am
View GitHub Profile
@richmondwang
richmondwang / graphene_sqlalchemy_optimizer.py
Last active April 13, 2017 14:10
This is a fork of yfilali's resolve_related def in his post (https://yacine.org/2017/02/27/graphqlgraphene-sqlalchemy-and-the-n1-problem/). Updated a little to add selecting only the requested fields.!!!This is only experimental!!!
# -*- coding: utf-8 -*-
from inflection import underscore
from sqlalchemy import inspect
from sqlalchemy.orm import RelationshipProperty, joinedload, load_only
class RelationshipPathNode(object):
def __init__(self, value, parent=None):
if parent:
parent.isLeaf = False
@yumike
yumike / base.py
Last active August 23, 2018 14:29
cian-prof
# coding: utf-8
import re
from collections import defaultdict, deque
from statsd.client import StatsClient, Timer
class Prof(object):
"""Инструмент для профилирования времени исполнения кода в контексте
HTTP-запроса или команды.
@yumike
yumike / base.py
Last active August 23, 2018 14:29
cian-slowlog
# coding: utf-8
import threading
import time
from collections import deque
from datetime import datetime
from functools import wraps
from django.utils.encoding import smart_text
@yumike
yumike / middleware.py
Last active August 23, 2018 14:29
cian-statprof
# coding: utf-8
from cian_statprof.profiler import Profiler
from cian_statprof.sampler import Sampler
profiler = Profiler(Sampler(), Logger(), {'is_enabled': True})
class StatisticalProfilerMiddleware(object):
def process_request(self, request):
@jxskiss
jxskiss / example.py
Last active May 23, 2022 07:55
Use "fysom" state machine as global machine
from django.db import models
from fysom_singleton import *
class ItemStatus(object):
NEW = 'new'
NEED_INFO = 'need_info'
REVIEWING = 'reviewing'
REDOING = 'redoing'
CONFLICT = 'conflict'
@aleneum
aleneum / example.py
Last active April 10, 2019 15:03
this gist was done to evaluate how django and transitions could work together and is based on work from jxskiss. See his [gist](https://gist.github.com/jxskiss/01816eec9a2b64bae341f4d07f58646e) for more details.
# add the other files to your django app and migrate
# enter django shell with python manage.py shell and execute the following
# I called my app 'issues'; so change issues to your app name in case you choose another one
# there are 5 models which realize state machine bindings to django models in different ways
# Item: add a transitions.Machine instance to each record/item
# ItemSingleton: add each model to a global transitions.Machine
# ItemSingletonSet: Extend transitions.Machine to use set instead of list to store models; this increases look up speed in add_model
# ItemNoMachine: just a minimal model without a state machine (for referencing purposes)
# ItemFysom: add a customized fysom machine to each record/item
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@caseywatts
caseywatts / 0 README.md
Last active December 11, 2024 05:12
d3 & c3 npm shim to es6 module for Ember
#!/bin/bash
# !!WARNING!!
# This will DELETE all efforts you have put into configuring nix
# Have a look through everything that gets deleted / copied over
nix-env -e '.*'
rm -rf $HOME/.nix-*
rm -rf $HOME/.config/nixpkgs