Skip to content

Instantly share code, notes, and snippets.

@st4lk
st4lk / celery_settings_eager.py
Last active March 5, 2023 09:53
celery eager
# 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://'
@st4lk
st4lk / argparse_example.py
Created November 22, 2022 15:03
python argparse example
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',
)
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
"""
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
"""
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
"""
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
# -*- 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 June 17, 2021 05:34
bash: tar ps find dpgk install remove
# показать все процессы:
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 September 5, 2014 11:30
Fix python 2.7 cookie bug #2193
@st4lk
st4lk / mandrill_email.py
Last active August 2, 2021 05:31
Python: send emails by mandrill. Django and standalone example
"""
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