This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
if __name__ == '__main__': | |
print(get_random_string(50, chars)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_modules(name): | |
""" | |
Get a list of all submodules given a module root name. | |
""" | |
from pkgutil import walk_packages | |
module = __import__(name) | |
# Handle modules installed in top-level | |
if not hasattr(module, '__path__'): | |
return [(name, False)] | |
submodules = [(name, True)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from six import add_metaclass | |
def print_decorator(func): | |
def replacement(*args, **kwargs): | |
result = func(*args, **kwargs) | |
print('The result of the function is: {}'.format(result)) | |
return result | |
return replacement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import fdopen | |
from json import dumps | |
from tempfile import mkstemp | |
payload = {'one': 1} | |
osfd, tmpfile = mkstemp() | |
with fdopen(osfd, 'w') as pf: | |
pf.write(dumps(payload)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# Copyright (C) 2015-2017 Carlos Jenkins <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from os import getcwd | |
from json import loads | |
from sys import argv, stdout | |
from shlex import split as shsplit | |
from os.path import expanduser, isfile, relpath, join | |
from subprocess import check_output, CalledProcessError, Popen, PIPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
# set -o xtrace | |
DOMAIN=${1:-} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from logging import getLogger as get_logger # noqa | |
from datetime import datetime | |
from github import Github | |
log = get_logger(__name__) |