Skip to content

Instantly share code, notes, and snippets.

@vlipovoy
vlipovoy / python_decorator_guide.md
Created March 21, 2022 19:58 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@vlipovoy
vlipovoy / encode.py
Created June 16, 2020 11:47
Encoding/decoding
import base64
# Creating a string
s = "test"
# Encoding the string into bytes
b = s.encode("UTF-8")
# Base64 Encode the bytes
e = base64.b64encode(b)
# Decoding the Base64 bytes to string
s1 = e.decode("UTF-8")
# Printing Base64 encoded string
@vlipovoy
vlipovoy / package.json
Created January 10, 2017 16:41 — forked from andreruffert/package.json
using `npm run` to build and watch with node-sass and browserify
{
"name": "my-app",
"version": "0.0.0",
"devDependencies": {
"browserify": "^10.2.4",
"watchify": "^3.2.3",
"node-sass": "^3.2.0",
"uglify": "^2.4.23",
"mkdirp": "^0.5.1",
"parallelshell": "^1.2.0",
@vlipovoy
vlipovoy / gist:fd4a2c38196057380973ff9ca01d5ff5
Created September 16, 2016 07:17 — forked from aeurielesn/gist:2511005
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,