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
@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 / 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-запроса или команды.
@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
@bruce-shi
bruce-shi / disable_signals.py
Created September 18, 2016 02:44 — forked from RobertKolner/disable_signals.py
Temporarily disable all signals in django.
from collections import defaultdict
from django.db.models.signals import *
class DisableSignals(object):
def __init__(self, disabled_signals=None):
self.stashed_signals = defaultdict(list)
self.disabled_signals = disabled_signals or [
pre_init, post_init,
pre_save, post_save,
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
if [ -f "$NVM_DIR/bash_completion" ]; then
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
@samuelcolvin
samuelcolvin / aiopg playing with aiohttp and gunicorn.md
Last active August 7, 2020 14:01
aiopg playing with aiohttp and gunicorn

aiopg playing with aiohttp and gunicorn

Setup

virtualenv -p /usr/bin/python3.5 env && source env/bin/activate
pip install SQLAlchemy aiohttp aiopg gunicorn

Usage

@brock
brock / psql-with-gzip-cheatsheet.sh
Last active May 14, 2025 13:12
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
// 0.403273203 sec
package main
import "fmt"
import "time"
func main() {
start := time.Now().UnixNano()

System

  1. Set up iCloud Keychain
  2. Remove icons and hide Dock
  3. Default address in iMessage
  4. Install Updates
  5. Add Ru Input Sources
  6. Set up Shortcuts
  7. Add text shortcuts Text