Skip to content

Instantly share code, notes, and snippets.

Alexey Evseev st4lk

Block or report user

Report or block st4lk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View oauth20_web_single_page.py
"""
Example of OAuth 2.0 process with client-side only web page.
We can access to user's resources without providing a client_secret!
Given access_token will be short-lived, about 1 or 2 hours, whereas
access_token given by server-side workflow is long-lived, up to 60 days.
http://stackoverflow.com/questions/9067947/facebook-access-token-server-side-vs-client-side-flows
API of facebook is used: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
"""
import webbrowser
import urllib2
View oauth20_web_server.py
"""
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
View oauth10_3leg.py
"""
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
View oauth10_2leg.py
# -*- coding: utf-8 -*-
"""
Example of less-legged client workflow using OAuth means.
OAuth 1.0a is a 3-legged process. Less-legged process is not an OAuth 1.0a,
it just use similiar means, but people used to call it OAuth...
With 2-legged process user is not interacted in process.
In such workflow client application is acting like a user.
So client can fetch resources avaliable either to all users, either it can
access to resources owned by itself (even private).
@st4lk
st4lk / bash_commands.sh
Last active Aug 29, 2015
bash: tar ps find dpgk install remove
View bash_commands.sh
# показать все процессы:
ps aux | less
# добавить auto-run startup commands команду в
/etc/rc.local
# Вывод списка установленных пакетов:
dpkg -l [маска]
# удалить пакет:
apt-get remove --purge your_program
# запаковать в tar.gz
@st4lk
st4lk / cookie.py
Created Sep 5, 2014
Fix python 2.7 cookie bug #2193
View cookie.py
@st4lk
st4lk / mandrill_email.py
Last active May 11, 2019
Python: send emails by mandrill. Django and standalone example
View mandrill_email.py
"""
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
@st4lk
st4lk / django_log_settings.py
Last active May 4, 2019
Django logging settings
View django_log_settings.py
# 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")
@st4lk
st4lk / root_logger_settings.py
Last active Jun 19, 2019
Python logging settings for root logger
View root_logger_settings.py
"""
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
@st4lk
st4lk / vkcom_audio_download.py
Last active Jun 30, 2019
Python: vkontakte.ru (vk.com) audio music downloader
View vkcom_audio_download.py
# -*- coding: utf-8 -*-
"""
Скрипт для скачивания музыки с сайта vkontakte.ru (vk.com)
Запуск:
python vkcom_audio_download.py
Принцип работы:
Скрипт проверяет сохраненный access_token. Если его нет или срок истек,
то открывается страница в браузере с запросом на доступ к аккаунту.
You can’t perform that action at this time.