Skip to content

Instantly share code, notes, and snippets.

View koriaf's full-sized avatar

Arkadiy Korotaev koriaf

  • Bratislava
View GitHub Profile
@koriaf
koriaf / auth.py
Created April 30, 2017 15:34
django-oidc-provider and DRF example
"""
NOT PRODUCTION READY
Usage:
REST_FRAMEWORK = {
...
'DEFAULT_AUTHENTICATION_CLASSES': (
....
'ibr.users.accounts_api_v0.auth.OidcOauth2Auth'
@koriaf
koriaf / post_office_templated_email.py
Created September 14, 2015 09:11
Django-post_office email with custom template
def send_email(self,
template_name,
context={},
attachments={},
base_message_template='post_office/email_base_text.html',
base_message_template_html='post_office/email_base_html.html'):
'''
Try to send email by Django post_office library, with custom HTML template and
respect of user language.
@koriaf
koriaf / django-advcash.py
Created August 28, 2015 05:10
Small library to receive advcash.com SCI payments on your website.
class AdvcashProcessor(object):
'''Advcash SCI processing class - accept payments, check checksums and more
Developer documentation:
http://advcash.com/files/documents/sci_russian_2.pdf
Usage:
processor = MyWebsiteAdvcashProcessor(request_data, logger=transactions_logger)
verification_success = processor.validate()
@koriaf
koriaf / habproxy.py
Created August 18, 2015 18:40
Pythonic demonstration of BaseHTTPServer and lxml usage.
#!/usr/bin/env python2.7
# encoding: utf-8
# src: https://gist.github.com/anonymous/06e0bd519490c8f03404
# habraproxy.py — это простейший http-прокси-сервер, запускаемый локально , который показывает содержимое страниц Хабра.
# С одним исключением: после каждого слова из шести букв должен стоять значок «™».
# Мне было по фану.
#
# INSTALL:
# pip install requests lxml
#
@koriaf
koriaf / django-okpay.py
Created August 14, 2015 15:41
django-okpay (or python-okpay) payment processing script. Simple version, without full support of API and tests.
class OkpayProcessor(object):
'''OKPAY payment notification check and enrollment class.
https://dev.okpay.com/en/manual/ipn/listener-implementation.html
https://dev.okpay.com/en/manual/ipn/testing.html
https://dev.okpay.com/en/guides/accepting-payments.html#ipn
https://dev.okpay.com/en/guides/client-verification.html#code
Usage:
processor = MyWebsiteOkpayProcessor(request.POST, logger=transactions_logger)
@koriaf
koriaf / gist:089e0bb7acc6fc4891fc
Created August 9, 2015 16:56
dalek.js example of website register test (with pre-logout and post-logout to ensure that no any 302 redirect will be used for registration form page)
BASE_URL = "URL HERE";
module.exports = {
'Register test': function (test) {
REGISTER_URL = BASE_URL + '/profile/register/';
test_user_data = {
'username': 'test_user' + Math.round(Math.random() * 10000 + 10000),
};
test
.open(BASE_URL + '/profile/logout/')