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
""" | |
Settings for root logger. | |
Log messages will be printed to console and also to log file (rotated, with | |
specified size). All log messages from used libraries will be also handled. | |
Three approaches for defining logging settings are used: | |
1. using logging classes directly (py25+, py30+) | |
2. using fileConfig (py26+, py30+) | |
3. using dictConfig (py27+, py32+) | |
Choose any variant as you like, but keep in mind python versions, that |
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 -*- | |
""" | |
Скрипт для скачивания музыки с сайта vkontakte.ru (vk.com) | |
Запуск: | |
python vkcom_audio_download.py | |
Принцип работы: | |
Скрипт проверяет сохраненный access_token. Если его нет или срок истек, | |
то открывается страница в браузере с запросом на доступ к аккаунту. |
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
# django | |
CELERY_TASK_ALWAYS_EAGER = True | |
CELERY_TASK_EAGER_PROPAGATES = True | |
CELERY_BROKER_URL = 'memory://' | |
# celery | |
task_always_eager = True | |
task_eager_propagates = True | |
broker_url = 'memory://' |
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
# Logging settings for django projects, works with django 1.5+ | |
# If DEBUG=True, all logs (including django logs) will be | |
# written to console and to debug_file. | |
# If DEBUG=False, logs with level INFO or higher will be | |
# saved to production_file. | |
# Logging usage: | |
# import logging | |
# logger = logging.getLogger(__name__) | |
# logger.info("Log this message") |
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
import argparse | |
parser = argparse.ArgumentParser(description='Argparse example command') | |
parser.add_argument('just_string', help='Positional required string argument') | |
parser.add_argument( | |
'--flag', action='store_true', help='Not required boolean argument with default value', | |
) | |
parser.add_argument( | |
'--value', type=str, default='ok', help='Not required string argument with default value', | |
) |
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
https://www.strava.com/activities/5852666203 | |
https://www.strava.com/activities/5859516575 | |
https://www.strava.com/activities/5863080829 | |
https://www.strava.com/activities/5869926075 | |
https://www.strava.com/activities/5873818023 | |
https://www.strava.com/activities/5879180311 | |
https://www.strava.com/activities/5883958872 | |
https://www.strava.com/activities/5888354651 |
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
""" | |
Example of mandrill service in python (http://mandrill.com/) | |
Description of usage in python: | |
Russian: http://www.lexev.org/2014/send-email-django-project-mandrill-service/ | |
English: http://www.lexev.org/en/2014/send-email-django-project-mandrill-service/ | |
""" | |
# ====== | |
# Django |
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
# показать все процессы: | |
ps aux | less | |
# добавить auto-run startup commands команду в | |
/etc/rc.local | |
# Вывод списка установленных пакетов: | |
dpkg -l [маска] | |
# удалить пакет: | |
apt-get remove --purge your_program | |
# запаковать в tar.gz |
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
""" | |
Example of OAuth 2.0 process with web server. | |
API of facebook is used: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow | |
""" | |
import webbrowser | |
import urllib2 | |
import json | |
from urllib import urlencode | |
from urlparse import parse_qsl, urlparse |
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
""" | |
Example of OAuth 1.0a 3-legged standard process from the client side. | |
API of bitbucket is used: https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket | |
""" | |
import random | |
import time | |
from urlparse import parse_qsl, urlparse | |
from urllib import quote, urlencode | |
import urllib2 | |
import binascii |
NewerOlder