Skip to content

Instantly share code, notes, and snippets.

View saveshodhan's full-sized avatar
💭
The more I know, the more I know I don't.

Shodhan saveshodhan

💭
The more I know, the more I know I don't.
  • Zattoo
  • Berlin, Germany
View GitHub Profile
@saveshodhan
saveshodhan / pause.md
Last active April 17, 2021 08:51
Python snippets
  • Implementing pause
import os
os.system('read -s -n 1 -p "Press any key to continue...\n"')
@saveshodhan
saveshodhan / requests_retry.py
Created August 19, 2019 14:10
Using the "Retry" feature of the Requests module
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry # or, from requests.packages.urllib3.util.retry import Retry
## to get rid of that SSL insecure warning ##
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def requests_retry(url, total=3, backoff_factor=0.3, method_whitelist=None, status_forcelist=None):
"""Create and return a Retry object
@saveshodhan
saveshodhan / install_nginx.sh
Last active March 20, 2019 05:27 — forked from simonw/gist:92481
Compile nginx standalone without root access
# Compile nginx standalone without root access
mkdir ~/installed
mkdir ~/installed/nginx
mkdir ~/src
cd ~/src
# for latest tar.gz files, refer this link:
# https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#compiling-and-installing-from-source
# we will not compile any dependencies, only unzip them in different directories and pass their paths while configuring nginx
@saveshodhan
saveshodhan / logging.py
Last active September 27, 2018 14:39
Python logging configuration
import logging
import logging.handlers
from functools import wraps
LOGGER_NAME = "APPLOGGER"
LOGGER_HANDLER_NAME = "APPHANDLER"
LOGGER_FILENAME = "log.out"
LOGGER_FORMATTER = "[%(asctime)s] %(levelname)s : %(user)s : %(funcName)s : %(message)s"
LOGGER_DATEFMT = "%Y-%m-%d %H:%M:%S"
LOGGER_USER = "app"