This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
в vagrant файле | |
> config.vm.box = "ubuntu/trusty64" | |
заходим в папку с проектом | |
> vagrant up | |
если не работает подключение по ссш в иде, то на вм | |
> nano ~/.ssh/config # find / -name .ssh | |
Host * | |
StrictHostKeyChecking no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# можно заюзать fail2ban. больше настроек, больше функционал!!! | |
борьба с брут-форсом ssh | |
>>> last - список последних аутентификаций | |
если выдается ошибка | |
>>> last: /var/log/wtmp: No such file or directory | |
>>> Perhaps this file was removed by the operator to prevent logging last info. | |
то либо дистрибутив не создал файл для логирования, либо хакер ее снес | |
>>> tailf /var/log/auth.log - посмотреть попытки аутентификации. при переборе есть возможность, что увидим брут-форс |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from django.contrib import admin | |
from django.db import models | |
from tinymce.widgets import TinyMCE | |
from models import Message, FormSettings | |
class FormSettingsAdmin(admin.ModelAdmin): | |
formfield_overrides = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __unicode__(self): | |
return '%s%s' % (' --- ' * self.level, self.title) | |
class MPTTMeta: | |
order_insertion_by = ['title'] | |
class Meta: | |
verbose_name = _('category') | |
verbose_name_plural = _('categories') | |
ordering = ['tree_id', 'lft'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# в урле ### | |
url(r'^products/(?P<category_slug>[-/\w\d]+)/$', catalog, name='category'), | |
############ | |
def catalog(request, category_slug=None): | |
vars = {} | |
product = None | |
product_list = [] | |
if category_slug: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) pip install raven (клиент для sentry) http://raven.readthedocs.org/en/latest/config/django.html | |
2) в sentry создать проект, копируем DSN запись для джанго и вставляем в settings | |
# SENTRY_DSN = 'http://b6af96d2535f4522b12ba93e3f58f2e9:[email protected]/5' | |
http://raven.readthedocs.org/en/latest/config/django.html | |
3) в INSTALLED_APPS 'raven.contrib.django' | |
4) подключаем logging | |
5) для сбора 404-х | |
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://sphinxsearch.com/downloads/ - скачать tar.gz | |
tar -xzf | |
cd | |
1) | |
./configure --without-mysql --with-pgsql --prefix=/usr/local/sphinx --with-pgsql-libs=/usr/lib/postgresql-9.1/ --with-pgsql-includes=/usr/include/postgresql-9.1/ | |
2) make | |
3) make install | |
4) cd /usr/local/sphinx/etc/ | |
создаем sphinx.conf | |
прописываем |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(virtual_env)alex@alex:~/xpage_projects$ django-admin.py startproject drobservis_new --template=xpager-template | |
#env | |
(virtual_env)alex@alex:~$ pip install --requirement xpage_projects/pqgroup/pqgroup/requirements.txt (установить зависимости) | |
(virtual_env)alex@alex:~$ pip install -U --requirement xpage_projects/pqgroup/pqgroup/requirements.txt(обновить зависимости) | |
#end_env | |
#обновить шаблон | |
(virtual_env)alex@alex:~/xpage_projects/xpager-template$ hg pull | |
(virtual_env)alex@alex:~/xpage_projects/xpager-template$ hg update stable | |
(тоже самое сделать с /deploy ) | |
#шаблон |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prevent_russian_file_for_video(instance, filename): | |
return u"uploads/video/previews/%s" % (translify(filename),) | |
class Video(models.Model): | |
STATUS_CHOICES = ( | |
(0, _('not published')), | |
(1, _('published')) | |
) | |
title = models.CharField(max_length=255, | |
verbose_name=_('title')) |
NewerOlder