Skip to content

Instantly share code, notes, and snippets.

View progala's full-sized avatar

Przemek Rogala progala

View GitHub Profile
@progala
progala / nb_objects_del.py
Created June 27, 2022 12:11
Nautobot shell delete objects
models = [
Cable,
ConsolePort,
ConsolePortTemplate,
ConsoleServerPort,
ConsoleServerPortTemplate,
Device,
DeviceBay,
DeviceBayTemplate,
DeviceRole,
@progala
progala / requests_logging.py
Created May 25, 2022 12:09
Enable detailed logging for Python `requests`
# Taken from: https://requests.readthedocs.io/en/latest/api/#main-interface
import requests
import logging
# Enabling debugging at http.client level (requests->urllib3->http.client)
# you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# the only thing missing will be the response.body which is not logged.
try: # for Python 3
from http.client import HTTPConnection
except ImportError:
@progala
progala / netdial.go
Created February 7, 2022 15:05
Use net.Dial to connect to a website
package main
import (
"bufio"
"fmt"
"net"
)
func main() {
conn, err := net.Dial("tcp", "duckduckgo.com:80")
@progala
progala / devices.yaml
Last active January 26, 2022 10:43
Go - Decoding YAML read from file
devices:
- hostname: "csr1"
platform: "cisco_iosxe"
commands:
- "show version"
- "show interfaces"
- hostname: "nxos-spine1"
platform: "cisco_nxos"
commands:
@progala
progala / dscp_conv_table.py
Last active August 23, 2020 14:39
Solution for fun little challenge from Nick Russo https://twitter.com/nickrusso42518/status/1296852620959776777
import csv
from pathlib import Path
def compute_dscp_class(dscp):
quot, rmnd = divmod(dscp, 8)
if rmnd == 0:
dscpcl = "cs{}".format(quot)
elif (quot, rmnd) == (5, 6):
dscpcl = "ef"