Skip to content

Instantly share code, notes, and snippets.

<VirtualHost *:80>
ServerName http://tust.ivanov-ivan.ru
WSGIDaemonProcess tust user=ivan group=tust
WSGIProcessGroup tust
Alias /media/ /home/ivan/sites/_envs/trust/lib/python2.5/site-packages/django/contrib/admin/media/
Alias /static/ /home/ivan/sites/tust/static/
WSGIScriptAlias / /home/ivan/sites/tust/hosting/django.wsgi
<Directory /home/ivan/sites/tust/hosting>
$ ./manage.py celeryd -B&
[1] 12765
$ ps fx
PID TTY STAT TIME COMMAND
11189 pts/1 S 0:00 su nadovmeste
11190 pts/1 S 0:00 \_ bash
12765 pts/1 Sl 0:01 \_ [celeryd.MainProcess] Running... (-B)
12772 pts/1 S 0:03 | \_ [celeryd.PoolWorker-2]
12778 pts/1 S 0:00 | \_ [celerybeat]
[2010-05-15 19:23:00,366: DEBUG/MainProcess] TaskPool: Finding dead pool processes...
[2010-05-15 19:23:00,366: DEBUG/MainProcess] Mediator: Running callback for task: offers.tasks.FinalizePurchases[28b6857e-f7ef-4586-90b6-4763f773dbc1]
[2010-05-15 19:23:00,366: DEBUG/MainProcess] TaskPool: Apply <function execute_and_trace at 0x8f0da3c> (args:('offers.tasks.FinalizePurchases', '28b6857e-f7ef-4586-90b6-4763f773dbc1', [], {}) kwargs:{})
[2010-05-15 19:23:00,367: DEBUG/MainProcess] TaskPool: Finding dead pool processes...
[2010-05-15 19:23:00,368: DEBUG/MainProcess] Task accepted: purchases.tasks.UpdatePaymentsInfoTask[8db8acf1-18d4-4f12-a1a4-646a9d77d324]
Killed
(nadovmeste)nadovmeste@nadovmeste:~/src/nadovmeste$ [2010-05-15 19:23:58,611: DEBUG/PoolWorker-2] worker got EOFError or IOError -- exiting
[2010-05-15 19:23:58,611: INFO/PoolWorker-2] process shutting down
[2010-05-15 19:23:58,612: DEBUG/PoolWorker-2] running all "atexit" finalizers with priority >= 0
[2010-05-15 19:23:58,612: DEBUG/PoolWorker-2] runn
@kmike
kmike / asserts.py
Created September 10, 2010 12:24
assertNumQueries decorator and context manager
import functools
import sys
import re
from django.conf import settings
from django.db import connection
def shrink_select(sql):
return re.sub("^SELECT(.+)FROM", "SELECT .. FROM", sql)
def shrink_update(sql):
@kmike
kmike / gist:1596526
Created January 11, 2012 20:11
nltk under python 2.7
_________________________________ [tox sdist] __________________________________
[TOX] ***creating sdist package
[TOX] /Users/kmike/svn/nltk$ /usr/local/Cellar/python/2.7.2/bin/python setup.py sdist --formats=zip --dist-dir .tox/dist >.tox/log/0.log
[TOX] ***copying new sdistfile to '/Users/kmike/.tox/distshare/nltk-2.0.1rc3.zip'
______________________________ [tox testenv:py27] ______________________________
[TOX] ***reusing existing matching virtualenv py27
[TOX] ***upgrade-installing sdist
[TOX] /Users/kmike/svn/nltk/.tox/py27/log$ ../bin/pip install --download-cache=/Users/kmike/svn/nltk/.tox/_download /Users/kmike/svn/nltk/.tox/dist/nltk-2.0.1rc3.zip -U --no-deps >30.log
[TOX] /Users/kmike/svn/nltk/nltk/test$ ../../.tox/py27/bin/python testrunner.py
[?1034h
@kmike
kmike / gist:2049651
Created March 16, 2012 11:21
SplitDateField
class SplitDateInput(forms.MultiWidget):
"""
Виджет для ввода даты с 3 полями.
"""
def __init__(self, attrs=None):
widgets = [
forms.TextInput(attrs=attrs), # день
forms.Select(attrs=attrs, choices=MONTHS.items()), # месяц
forms.TextInput(attrs=attrs), # год
]
@kmike
kmike / shortcuts.py
Created April 18, 2012 21:26
TemplateResponse subclass with extra goodies
from django.template.response import TemplateResponse
class show(TemplateResponse):
"""
TemplateResponse subclass with extra goodies. It is intended to be used
as a better replacement of `django.shortcuts.render`.
"""
def resolve_template(self, template):
"""
@task
@utils.run_as_sudo
def from_07_to_08():
question = """
This task updates server from django-fab-deploy 0.7.x to 0.8.x:
it prepares the server and updates apache.conf and nginx.conf.
Before upgrading please make sure that:
1) {{ APACHE_PORT }} are replaced with {{ PORTS['apache'] }}
parent_module = None
for index, module_name in enumerate(mod_list):
full_name = '.'.join(mod_list[:index])
module = sys.modules.setdefault(full_name, types.ModuleType(module_name))
if parent_module:
setattr(parent_module, module_name, module)
import functools
class UnicodeMixin(object):
"""Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3."""
if PY3:
def __str__(self):
return self.__unicode__()
else: