A curated list of awesome Go storage projects and libraries. Inspired by awesome-go.
Please take a quick gander at the contribution guidelines first. Thanks to all contributors; you rock!
from random import choice | |
from string import ascii_lowercase, digits | |
from django.contrib.auth.models import User | |
def generate_random_username(length=16, chars=ascii_lowercase+digits, split=4, delimiter='-'): | |
username = ''.join([choice(chars) for i in xrange(length)]) | |
if split: | |
username = delimiter.join([username[start:start+split] for start in range(0, len(username), split)]) |
import random, string | |
def random_generator(size=6, chars=string.ascii_uppercase + string.digits): | |
""" | |
Usage: | |
>>> random_generator().lower() | |
'w9gz1z' | |
>>> random_generator(3, "6793YUIO") | |
'6U7' | |
""" |
def generate_client_key(): | |
""" | |
Generate a suitable client key | |
""" | |
api_key = hashlib.sha1(os.urandom(32)).hexdigest() | |
return api_key | |
def generate_client_secret(): | |
""" | |
Generate a suitable client secret |
""" | |
List of all disposable email service domains. | |
Possible usage: | |
- To prevent email address from temporary email services while registering users. | |
""" | |
DESPOSABLE_EMAIL_DOMAINS = [ | |
'0-mail.com', | |
'027168.com', | |
'0815.ru', |
# Run the following command: | |
sudo apt-get install python-setuptools python-dev build-essential | |
# Install pip: | |
sudo apt-get install python-pip | |
# Install `virtualenv`: | |
pip install virtualenv |
A curated list of awesome Go storage projects and libraries. Inspired by awesome-go.
Please take a quick gander at the contribution guidelines first. Thanks to all contributors; you rock!
func levenshteinDistance(s string, t string) int { | |
s = strings.ToLower(s) | |
t = strings.ToLower(t) | |
if s == t { | |
return 0 | |
} | |
if len(s) == 0 { | |
return len(t) | |
} | |
if len(t) == 0 { |
from PIL import Image | |
from io import BytesIO | |
def compress_image(original_file, max_size, scale): | |
""" | |
It should compress the size of the given file with the particular `scale` | |
until `max_size` limit is achieved. | |
""" | |
assert(0.0 < scale < 1.0) |
from rest_framework.generics import get_object_or_404 | |
class CaseInsensitiveLookupMixin(object): | |
""" | |
Apply this mixin to any view or viewset to get kwargs with lowercase | |
values. Based on a `lookup_field` attribute. | |
""" | |
def get_object(self): | |
queryset = self.get_queryset() # Get the base queryset |
/* | |
* script to export data in all sheets in the current spreadsheet as individual csv files | |
* files will be named according to the name of the sheet | |
* author: Michael Derazon | |
*/ | |
function onOpen() { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}]; | |
ss.addMenu("csv", csvMenuEntries); |