Skip to content

Instantly share code, notes, and snippets.

@bockor
bockor / gist:8264a1ae4bf54e2fbc00121dc8dd0e67
Last active March 3, 2021 12:14
infoblox notes // ipam utilization + tls/ssl unsecure messages surpression
import requests
import urllib3
import json
# Surpress SSL/TLS >Insecure Warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
session = requests.Session()
session.auth = ('admin', 'infoblox')
@bockor
bockor / gist:b062e29bd69527bf00ab0cf1c4c97139
Created February 14, 2021 17:54
docker // python in bottle
https://hub.docker.com/r/d3fk/python_in_bottle/
docker pull d3fk/python_in_bottle
docker run -itd --name nra_site_inventory --rm -p 8080:8080 -v $(pwd)/yEd-SiteInventory:/usr/src/myapp -w /usr/src/myapp d3fk/python_in_bottle:latest python site_inventory.py
# This prevents Python from writing out pyc files
docker run -itd --name nra_site_inventory --rm -e PYTHONDONTWRITEBYTECODE="1" -p 8080:8080 -v $(pwd)/yEd-SiteInventory:/usr/src/myapp -w /usr/src/myapp d3fk/python_in_bottle:latest python site_inventory.py
docker stop nra_site_inventory
@bockor
bockor / gist:9a15788b9b1a27da06fc8463a71ad8b6
Last active March 3, 2021 13:08
uwsgi-as-a-systemd-service with python3 and bottle framework
*****************************************************
*** APPROACH 1: install uwsgi as a system package ***
*****************************************************
install packages
----------------
apt install uwsgi uwsgi-plugin-python3
Configure uwsgi daemon
----------------------
@bockor
bockor / gist:0c0f4a1cc9a45ab9237c359967ce2fe5
Created January 31, 2021 09:12
Remove Bytecode (.pyc) Files in Linux
find . -type f -name "*.py[co]" -delete -or -type d -name "__pycache__" -delete
@bockor
bockor / gist:6d326773706a7d03d5462a817e072c26
Last active February 17, 2021 08:48
Infoblox notes // WAPI (Web API) Sample Code for NIOS 8.4.4 using python
'''
Ref: https://community.infoblox.com/t5/DNS-DHCP-IPAM/WAPI-Web-API-Sample-Code-for-NIOS/m-p/105/highlight/true#M12
Sample -- sample python application for WAPI
'''
import sys
import json
@bockor
bockor / gist:549983def0acdc5eb8fded38702992c3
Last active November 3, 2020 18:25
python configparser
[DEFAULT]
DEBUG = True
domaindb_file = ./dummy_data/dummy_domaindb.json
servers_file = ./dummy_data/dummy_servers.json
#WSGI Server
host = 101.135.27.63
port = 8080
debug = True
reloader = True
@bockor
bockor / gist:dd35db450120ac50ada4241c54ca35df
Last active April 7, 2020 18:55
for each record from dnsmaster | do DNS resolution | ping record | get certificate details | get http(s) response status | get DNS CNAMES RR
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
## PING
#Ref: https://www.ictshore.com/python/python-ping-tutorial/
#Ref: https://stackoverflow.com/questions/58330533/how-to-handle-error-exceptions-with-pythonping
## CSV
#Ref: https://kite.com/python/docs/csv.DictWriter.writerows
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
[
{
"20S301": "SHAPE",
"20SU06": "SHAPE",
"77B301": "BRUNSSUM",
"77B302": "BRUNSSUM",
@bockor
bockor / gist:0856e1245e3d77689e497aef3eeea514
Last active March 1, 2020 15:36
get certificate issuer info in python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 26 09:43:37 2020
@author: bockor
https://stackoverflow.com/questions/30862099/how-can-i-get-certificate-issuer-information-in-python
https://gist.github.com/ryansb/d8c333eb4a74168474c4
https://kite.com/python/docs/ssl.SSLSocket.getpeercert
@bockor
bockor / gist:50fb07e0edaccbd879f2f4af8c428857
Last active March 25, 2020 19:17
pythonping example with exceptions error handling
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#Ref: https://www.ictshore.com/python/python-ping-tutorial/
#Ref: https://stackoverflow.com/questions/58330533/how-to-handle-error-exceptions-with-pythonping
#Ref: https://kite.com/python/docs/csv.DictWriter.writerows
from pythonping import ping
import socket
import csv