Here I will demonstrate a few things Reform plug-in is capable of.
You can move up and down by function declarations, blocks of code and words.
import pytest | |
@pytest.fixture() | |
def real_db(_django_cursor_wrapper): | |
_django_cursor_wrapper.enable() | |
def test_index(client, real_db): | |
response = client.get('/') |
[program:celery] | |
; Full path to use virtualenv, honcho to load .env | |
command=/home/ubuntu/venv/bin/honcho run celery -A stargeo worker -l info --no-color | |
directory=/home/ubuntu/app | |
environment=PATH="/home/ubuntu/venv/bin:%(ENV_PATH)s" | |
user=ubuntu | |
numprocs=1 | |
stdout_logfile=/home/ubuntu/logs/celery.log | |
stderr_logfile=/home/ubuntu/logs/celery.err |
import gzip, zlib | |
def ungzip_stream(fd): | |
plain_fd = gzip.GzipFile(fileobj=fd, mode="r") | |
# NOTE: this is what GzipFile does on new file start, | |
# we do that directly as GzipFile tries to seek() before it | |
# and fd could be unseekable(). | |
plain_fd._init_read() | |
plain_fd._read_gzip_header() | |
plain_fd.decompress = zlib.decompressobj(-zlib.MAX_WBITS) |
class MemoizingStream(object): | |
""" | |
Write always to end, read from separate position. | |
""" | |
def __init__(self, fd): | |
print 'create memo' | |
self.memory = StringIO() | |
self.source_fd = fd | |
self.finished = False |
# Usage | |
log_key = 'smth:%d:log' % some_id | |
with extra_logging_handler('name', RedisHandler(key=log_key)): | |
# Do your thing | |
# ... | |
# Implementation |
# THIS VERSION IS OUTDATED | |
# see .inplace(), .cloning(), ._clone() and .clone() methods of QuerySetMixin | |
# in https://github.com/Suor/django-cacheops/blob/master/cacheops/query.py | |
from django.conf import settings | |
from django.db.models import Model, Manager | |
MUTATING_QUERYSETS = getattr(settings, 'MUTATING_QUERYSETS', False) | |
class QuerySetMixin(object): | |
def __init__(self, *args, **kwargs): |
function parseStrings(obj) { | |
if (_.isString(obj)) { | |
var f = parseFloat(obj); | |
return Number.isName(f) ? obj : f; | |
} else if (_.isArray(obj)) { | |
obj.forEach(function (v, i) { | |
obj[i] = parseStrings(v); | |
}) | |
} else if (_.isObject(obj)) { | |
_.forOwn(obj, function (v, k) { |
from django.db.models import Model | |
from itertools import izip | |
def attnames(cls, _cache={}): | |
try: | |
return _cache[cls] | |
except KeyError: | |
_cache[cls] = [f.attname for f in cls._meta.fields] | |
return _cache[cls] |
#!/usr/bin/perl | |
use v5.10; | |
use strict; | |
use warnings FATAL => 'all'; | |
use Mojo::UserAgent; | |
my $latest_url = Mojo::UserAgent->new->get('http://www.sublimetext.com/2') |