Skip to content

Instantly share code, notes, and snippets.

@zmts
zmts / tokens.md
Last active July 29, 2024 19:21
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@Cyber-Neuron
Cyber-Neuron / generators.txt
Created March 19, 2017 16:37
Using iterators and generators in multi-threaded applications
Using iterators and generators in multi-threaded applications
24 May 2012 – Bangalore
Python iterators and generators have almost the same behavior, but there are subtle differences, especially when the iterator/generator is used in a multi-threaded application.
Here is an example to demonstrate that behavior.
import threading
def count():
@LowerDeez
LowerDeez / order_conf.html
Created October 8, 2017 16:57
Django. Send mail with custom html template and context
<!DOCTYPE html>
<html>
<body>
<br>
<h2>Thank you for your order {{ order.full_name }}</h2>
<h3>Your Order ID: {{ order.short_uuid }}</h3>
<h3>Shipping Details:</h3>
@platdrag
platdrag / Threadsafe_iter.py
Last active July 9, 2024 08:36
An example generic wrapper for making any iterator / generator thread-safe compatible with python 3
import threading
'''
A generic iterator and generator that takes any iterator and wrap it to make it thread safe.
This method was introducted by Anand Chitipothu in http://anandology.com/blog/using-iterators-and-generators/
but was not compatible with python 3. This modified version is now compatible and works both in python 2.8 and 3.0
'''
class threadsafe_iter:
"""Takes an iterator/generator and makes it thread-safe by
serializing call to the `next` method of given iterator/generator.
"""