This file contains hidden or 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 | |
| """ | |
| List all Cloudflare Pages projects across all accessible accounts and their deployment counts. | |
| Usage: | |
| CLOUDFLARE_EMAIL=you@example.com CLOUDFLARE_API_KEY=xxx \ | |
| python list_pages_deployments.py | |
| Optional flags: | |
| --account-id <ID> Limit to a specific account instead of all accessible accounts |
This file contains hidden or 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 | |
| """ | |
| Delete all Cloudflare Pages deployments for a given project. | |
| Usage: | |
| CLOUDFLARE_EMAIL=you@example.com CLOUDFLARE_API_KEY=xxx \ | |
| python delete_pages_deployments.py --project-name <PROJECT_NAME> \ | |
| --account-id <ACCOUNT_ID> | |
| The active production deployment is skipped (cannot be deleted). |
This file contains hidden or 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 boto3 | |
| import botocore | |
| from botocore import UNSIGNED | |
| from botocore.config import Config | |
| CF_AIG_TOKEN = "XYZ" # https://developers.cloudflare.com/ai-gateway/configuration/authentication/ | |
| CF_ACCOUNT_ID = "xyz" | |
| CF_AIG_NAME = "xyz" | |
| AWS_REGION = "us-east-1" |
This file contains hidden or 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 yaml | |
| import json | |
| import sys | |
| with open(sys.argv[1]) as f: | |
| y = yaml.safe_load(f) | |
| with open(sys.argv[1].replace("yml", "json").replace("yaml", "json"), "w") as ff: | |
| json.dump(y, ff) |
This file contains hidden or 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
| # https://www.ssllabs.com/ssltest/clients.html | |
| import requests | |
| SUPPORTED_CIPHERS = { | |
| "TLS_AES_128_GCM_SHA256", | |
| "TLS_AES_256_GCM_SHA384", | |
| "TLS_CHACHA20_POLY1305_SHA256", | |
| "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", | |
| "OLD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", |
This file contains hidden or 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 ipaddress import ip_network | |
| rfc_1918 = [ip_network('10.0.0.0/8'), ip_network('172.16.0.0/12'), ip_network('192.168.0.0/16')] | |
| final = [ip_network('0.0.0.0/0')] | |
| for ex in rfc_1918: | |
| for n in list(final): | |
| try: | |
| final.extend(n.address_exclude(ex)) | |
| final.remove(n) |
This file contains hidden or 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 csv | |
| import os | |
| import requests | |
| EMAIL = os.getenv("CLOUDFLARE_EMAIL") | |
| API_KEY = os.getenv("CLOUDFLARE_API_KEY") | |
| ACCOUNT_ID = os.getenv("CLOUDFLARE_ACCOUNT_ID") | |
| s = requests.Session() |
This file contains hidden or 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 logging | |
| import typing as t | |
| from elasticsearch import Elasticsearch # type: ignore | |
| from tqdm.auto import tqdm # type: ignore | |
| JSON = t.Union[str, int, float, bool, None, t.Dict[str, t.Any], t.List[t.Any]] |
This file contains hidden or 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
| # not performant, not useful for large lists | |
| # cake(a: List[int]) -> int: | |
| cake=lambda a,l=len,g=range:max([l(r)for r in[a[i:j+1]for i in g(l(a))for j in g(i,l(a))]if sum(r)==l(r)/2]+[0]) # 112 | |
| def test_1(): | |
| assert cake([]) == 0 | |
| def test_2(): |
This file contains hidden or 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 re as e | |
| import sys as y | |
| from collections import defaultdict as d | |
| o,r=sorted,d(set) | |
| [r["".join(o(w))].add(w)for w in e.split("\W"," ".join(y.stdin).lower())if len(w)==int(y.argv[1])] | |
| [print(w+": "+",".join(o(r[w])))for w in o(r)] |
NewerOlder