Skip to content

Instantly share code, notes, and snippets.

@bgth
bgth / gunicorn_service.py
Last active January 30, 2017 13:19 — forked from TheWaWaR/gunicorn_service.py
Gunicorn service script {Start | Restart | Stop | Reload | Quit}
# 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 November 26, 2019 08:26
Django's Generate Unique String
# 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 January 27, 2017 07:23
This license applies to all public gists https://gist.github.com/bgth
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 January 8, 2017 11:41
To make the year dynamically added in the copyright notice in express ejs template, use the below
©&nbsp;2016-<%= new Date().getFullYear() %>