Skip to content

Instantly share code, notes, and snippets.

View playpauseandstop's full-sized avatar

Igor Davydenko playpauseandstop

View GitHub Profile
@playpauseandstop
playpauseandstop / README.md
Created July 10, 2019 21:20
Script to update Python version for projects with pyenv & poetry

update-python.sh

Script to update Python version for projects with pyenv & poetry

Pre-requisites

This script intended to be run for projects which,

  1. Has .pyenv-version file (Python version managed by pyenv)
  2. Can be installed with make install (or make install-api)
@playpauseandstop
playpauseandstop / django-picklefield.py
Created March 31, 2010 13:00
Custom Django model field to store pickled Python objects.
from django.conf import settings
from django.db import models
from django.utils.encoding import smart_str
if hasattr(settings, 'USE_CPICKLE'):
import cPickle as pickle
else:
import pickle
@playpauseandstop
playpauseandstop / stringmethods.py
Created December 1, 2009 22:56
Make possible to use all Python string methods as Django template filters
"""
=============
stringmethods
=============
Make possible to use all Python string methods as Django template filters. Also
provide custom template tag ``{% stringmethod %}`` to use methods with more
than one argument, like ``format``, ``count`` and other.
Restrictions
@playpauseandstop
playpauseandstop / output
Created July 13, 2012 08:01
Playing with cloned virtual environments
Checking env_base virtual environment...
ordereddict exists
minimock exists
0.9
Checking env_child virtual environment...
ordereddict exists
minimock exists
0.8
@playpauseandstop
playpauseandstop / env-pip-check
Last active July 9, 2016 09:44
Tiny wrapper around pip-check cmd, to run it inside venv Python first
#!/bin/bash
#
# Tiny shell script to run ``pip-check`` cmd inside of venv or fallback to
# global ``pip-check`` after.
#
# `pip-check <https://github.com/bartTC/pip-check/>`_ is a tool for checking
# outdated versions installed in your Python virtual environment or global
# site packages.
#
# Usage
@playpauseandstop
playpauseandstop / posterous-to-blogger.py
Created April 25, 2013 14:14
Import posts from Posterous backup to Blogger account.
#!/usr/bin/env python
#
# Import posts from Posterous backup to Blogger account.
#
# Requirements
# ============
#
# * `Python <http://www.python.org/>` 2.6 or 2.7
# * `GData <http://pypi.python.org/pypi/gdata>`_ 2.0.17 or higher
#
@playpauseandstop
playpauseandstop / bench_django_memcached.py
Created November 1, 2012 14:22
Bench for getting data from Memcached via Django cache
#!/usr/bin/env python
import copy
import sys
import time
from argparse import ArgumentParser
from random import choice
from string import digits, letters
@playpauseandstop
playpauseandstop / ralc.py
Created November 1, 2012 09:46
Rates calculator
#!/usr/bin/env python
#
# Rates calculator.
#
# Requirements
# ============
#
# * `Python <http://www.python.org/>`_ 2.7
#
# Installation
@playpauseandstop
playpauseandstop / CouchBase
Created October 26, 2012 09:30
CouchBase vs. Memcached vs. Redis vs. Redis Pipelined
$ DRIVER=couchbase THREADS=10 make benchmark
env/bin/python ./benchmark.py
324 operations completed in 2.1607 s
2256 operations completed in 10.7558 s
1068 operations completed in 5.7570 s
2037 operations completed in 9.5393 s
2493 operations completed in 11.0871 s
2910 operations completed in 12.1000 s
2961 operations completed in 12.1318 s
2193 operations completed in 10.3703 s
@playpauseandstop
playpauseandstop / app.py
Created October 17, 2012 09:31
Improve registering blueprints in Flask application
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
class App(Flask):
"""
Custom ``Flask`` class.
"""
def register_blueprint(self, mixed, **kwargs):
"""