Author: Jeod
Contributors:
- TerrorTowers
- hxdr0n0s
- Unstoppable
- Agent
| # GitHub Action that will run prettier on the whole repo and commit the changes to the PR. | |
| name: Prettier | |
| on: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| prettier: | |
| runs-on: ubuntu-latest |
| import asyncio | |
| async def task(seconds: int=5): | |
| """Sleep for some time.""" | |
| await asyncio.sleep(seconds) | |
| return f"slept {seconds} seconds!" | |
| async def multi_task(sleeps_to_sleep: list[int]): | |
| """Start coroutines from a list of inputs.""" | |
| all_the_tasks = [task(sleep_time) for sleep_time in sleeps_to_sleep] |
Each day at our company, developers are required to document their activities, painstakingly jotting down their daily work and future plans. A monotonous chore that I just really dislike.
So now, there's a scribe for that :
| import requests | |
| import pynetbox | |
| from termcolor import colored | |
| from nornir import InitNornir | |
| from nornir_utils.plugins.functions import print_result | |
| from nornir_napalm.plugins.tasks import napalm_get | |
| from nornir.core.filter import F | |
| # NetBox Layer 3 switches (Base Inventory Group Defined in the config file below) |
| $docker-compose up | |
| [+] Running 1/0 | |
| ⠿ Container nat-js-nat-js-1 Created 0.0s | |
| Attaching to nat-js-nat-js-1 | |
| nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859286 [INF] Starting nats-server | |
| nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859416 [INF] Version: 2.8.4 | |
| nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859428 [INF] Git: [66524ed] | |
| nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859442 [INF] Name: NBYAJSZUVNQHW4VUQZC2JDJX4QPECWSQTNJSXZAYKLL3IGTOFXART7FG | |
| nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859460 [INF] Node: a7Zbpbhh |
| # -*- coding: utf-8 -*- | |
| # Copyright 2020 Red Hat | |
| # GNU General Public License v3.0+ | |
| # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | |
| """ | |
| flatten a complex object to dot bracket notation | |
| """ | |
| from __future__ import absolute_import, division, print_function |
| # roles/template_test/filter_plugins/eth_builder.py | |
| # -*- coding: utf-8 -*- | |
| # Copyright 2020 Red Hat | |
| # GNU General Public License v3.0+ | |
| # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | |
| """ | |
| sample use of dataclass in filter plugin |
| from extras.validators import CustomValidator | |
| from virtualization.models import VirtualMachine | |
| class UniqueVirtualMachineNamesCasefold(CustomValidator): | |
| """Enforce case-insensitive unique VM names. | |
| Your configuration.py file would contain something like this: | |
| CUSTOM_VALIDATORS = { |