Skip to content

Instantly share code, notes, and snippets.

@bgth
bgth / gunicorn_service.py
Last active Jan 30, 2017 — forked from TheWaWaR/gunicorn_service.py
Gunicorn service script {Start | Restart | Stop | Reload | Quit}
View gunicorn_service.py
# python3 based gunicorn service
#!/usr/bin/env python3
#coding: utf-8
#####################################
# Sample Config file #
# pidfile='config/gunicornRun.pid'; #
# app='server:app'; #
# bind='127.0.0.1:8000' #
#####################################
@bgth
bgth / DjangoUniqueString
Last active Nov 26, 2019
Django's Generate Unique String
View DjangoUniqueString
# https://github.com/django/django/blob/master/django/utils/crypto.py#L51
SECRET_KEY = "My Secret Key";
def get_random_string(length=12,
allowed_chars='abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'):
"""
Returns a securely generated random string.
The default length of 12 with the a-z, A-Z, 0-9 character set returns
a 71-bit value. log_2((26+26+10)^12) =~ 71 bits
@bgth
bgth / MIT-License
Last active Jan 27, 2017
This license applies to all public gists https://gist.github.com/bgth
View MIT-License
All public gists https://gist.github.com/bgth
Copyright 2017, bgth
MIT License, http://www.opensource.org/licenses/mit-license.php
@bgth
bgth / copyrightDynamicEjs
Created Jan 8, 2017
To make the year dynamically added in the copyright notice in express ejs template, use the below
View copyrightDynamicEjs
©&nbsp;2016-<%= new Date().getFullYear() %>