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 sys, time | |
def typewriter(text): | |
for character in text: | |
sys.stdout.write(character) | |
sys.stdout.flush() | |
time.sleep(0.008) | |
print("\n") |
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
# Save output under play | |
- name: Save output | |
ansible.builtin.copy: | |
content: |- | |
{% for host in ansible_play_hosts_all %} | |
{{ '### ' }}{{ host }}{{ ' ###' }} | |
{{ hostvars[host]['result']['stdout_lines'] | to_nice_json }} | |
{% endfor %} | |
dest: output.log | |
mode: "0644" |
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
alias python='python3.11' | |
alias mv='mv -v' | |
alias rm='rm -v' | |
alias cp='cp -v' | |
alias ping='ping -O' | |
alias play='ansible-playbook' | |
alias playsec='ansible-playbook --vault-password-file secrets.txt' | |
alias tf='terraform' | |
alias tfp='terraform plan' | |
alias tfa='terraform apply' |
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
#https://pyneng.readthedocs.io/en/latest/book/18_ssh_telnet/netmiko.html | |
from pprint import pprint | |
import yaml | |
import netmiko | |
def send_show_command(device, commands): | |
result = {} | |
try: |
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
#!/usr/bin/env bash | |
# This will let anyone who belongs to the 'pcap' group | |
# execute 'tcpdump' | |
sudo groupadd pcap | |
sudo usermod -a -G pcap $USER | |
sudo chgrp pcap /usr/sbin/tcpdump | |
sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump | |
sudo ln -s /usr/sbin/tcpdump /usr/bin/tcpdump |
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
Show hidden characters
// Correct color/scope for "Compare Side-By-Side" plugin | |
// Install: Preferences > Customize Color Scheme > paste this on the right side > save | |
// Documentation at https://www.sublimetext.com/docs/color_schemes.html | |
{ | |
"variables": | |
{ | |
}, | |
"globals": | |
{ |
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
COLORS = {'grey': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36, 'white': 37} | |
RESET = '\033[0m' | |
def colortext(text, color=None): | |
'''Ex: print(colortext('some string', 'cyan'))''' | |
ascii_color = '\033[1;%dm%s' | |
if color is not None: | |
# Modulo (%) operator works in this way: |
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 re | |
import sys | |
import subprocess | |
def pkg_requirement(*pkgs): | |
output = subprocess.check_output((['pip', 'list'])) | |
outputDecode = output.decode("utf-8") | |
#print(outputDecode) | |
pipList = re.split(r'\s', outputDecode) | |
pipNeed = [] |
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
# regex to match ipv4 | |
# (?:[0-9]{1,3}\.){3}[0-9]{1,3} | |
# v1 | |
def check_if_ipv4(ip): | |
quad = ip.split(".") | |
quadinteger = [] | |
try: | |
quadinteger = [int(num) for num in quad] | |
except ValueError: |