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
roles_sorted_by_perms_asc = sorted(perms_counts.items(), | |
key=lambda x: x[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
subset_roles = set() | |
for this_role, _ in roles_sorted_by_perms_asc: | |
for other_role, other_perms in roles_to_perms.items(): | |
if this_role == other_role: | |
continue | |
this_perms = roles_to_perms[this_role] | |
if this_perms.issubset(other_perms): | |
subset_roles.add(this_role) |
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
role_with_most_perms = roles_sorted_by_perms_asc[-1][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
selected_roles = {role_with_most_perms,} |
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
remaining = unique_perms - roles_to_perms['roles/owner'] |
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
while remaining: | |
for perm in remaining: | |
# get set of roles which contain permission | |
satisfy = perms_to_roles[perm] | |
# sort roles by the number of permissions they contain, select role | |
# with the most | |
sorted_roles = sorted((role, perms_counts[role]) | |
for role in satisfy) | |
selected = sorted_roles[-1][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
roles/axt.admin | |
roles/billing.admin | |
roles/billing.creator | |
roles/compute.xpnAdmin | |
roles/container.hostServiceAgentUser | |
roles/datacatalog.categoryFineGrainedReader | |
roles/datafusion.serviceAgent | |
roles/iam.serviceAccountTokenCreator | |
roles/iap.httpsResourceAccessor | |
roles/orgpolicy.policyAdmin |
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
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
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
# Import Flask, Jsonify and Requests | |
from flask import Flask, jsonify, request | |
# Create the web applicatiion via Flask | |
app = Flask(__name__) | |
# Existing To-Do List | |
# it's easiest to manipulate if this is a dict where key is the id and value is the todo | |
todos = { | |
1: "Buy Hitman 3", |
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
import argparse | |
import functools | |
import logging | |
import os | |
import signal | |
import sys | |
import time | |
_LOG_FORMAT = "%(levelname)s:%(asctime)s:%(name)s:%(message)s" | |
logging.basicConfig(stream=sys.stdout, format=_LOG_FORMAT) |