Skip to content

Instantly share code, notes, and snippets.

View bandit145's full-sized avatar
💭
Angrily deleting config-drifted VMs

Philip Bove bandit145

💭
Angrily deleting config-drifted VMs
View GitHub Profile
@bandit145
bandit145 / Vagrantfile
Created May 3, 2023 16:55
Problem vagrantfile
Vagrant.configure('2') do |config|
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.scope = 'machine'
end
config.vm.define "lb1" do |c|
##
@bandit145
bandit145 / string_recurse.py
Last active August 22, 2021 00:44
recursion exercise
name = 'Dakota'
# data_struct = {
# 'data1': {
# 'data2': {}
# }
# }
import pysnmp.hlapi as pysnmp
COMMUNITY = pysnmp.CommunityData('data')
ADDRESS = ''
DATA = 'cdpCacheDeviceId'
table_results = pysnmp.nextCmd(pysnmp.SnmpEngine(), COMMUNITY, pysnmp.UdpTransportTarget((ADDRESS, 161)), pysnmp.ContextData(),
pysnmp.ObjectType(pysnmp.ObjectIdentity('CISCO-CDP-MIB', DATA)), lexicographicMode=False)
count = 0
for row in table_results:
Counterpoint courtesy of /u/crankysysadmin
I see people on here trying to learn Linux, but I feel like a lot of them take the wrong path and either try to learn Linux using a cert of some kind, or try to learn it on their own but focus on the wrong stuff.
You don't actually have to be an expert, or learn the entire platform from top to bottom. There are ways you can learn things that make you immediately useful in a mixed environment with a decent Linux footprint.
First, the stuff you shouldn't waste time on in my opinion (you can always return to this stuff later):
• Desktop linux. In reality you're going to be managing linux boxes via SSH from a Mac or Windows machine. If you have a spare PC and want to set it up there's nothing wrong with that, but it's only marginally useful career-wise to get an Ubuntu desktop going and get web browsers and stuff going. You're probably not going to be managing Linux desktops.
@bandit145
bandit145 / gpg_loader.sh
Created October 6, 2018 05:44
gpg loader
if [[ ! $(top -b -n 1 | grep gpg-agent) = *"gpg-agent"* ]]; then
gpg-agent --daemon > .gpg-info
fi
source ~/.gpg-info
@bandit145
bandit145 / centos7.json
Last active July 23, 2018 21:14
packer vmware-iso crash log
{
"builders":[
{
"type": "vmware-iso",
"iso_url": "https://mirrors.ocf.berkeley.edu/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso",
"iso_checksum_type": "sha256",
"guest_os_type":"rhel7_64Guest",
"network":"{{user `vm_network`}}",
"vm_name":"{{user `vm_name`}}",
@bandit145
bandit145 / Books.xml
Last active June 19, 2018 19:26
swapping powershell xml contexts between nodes
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
@bandit145
bandit145 / convertto-jsonbroken.ps1
Last active April 15, 2018 22:06
ConvertTo-Json seems to be very broken and flattens nested arrays into strings
#PSVersion 5.1.14393.1770
$test = @{testarr=@(@{links=@(1,2)})}
$test
$test | ConvertTo-Json
$test | ConvertTo-Json | ConvertFrom-Json
@bandit145
bandit145 / System.py
Created March 15, 2018 22:50
Using a staticmethod to return instantiated versions of itself
class System:
names_from_api = ['server1','server2','server3']
def __init__(self, hostname):
self.hostname = hostname
@staticmethod
def get_systems(name):
system_list = []
for hostname in System.names_from_api:
@bandit145
bandit145 / test_hostrecord.py
Created December 15, 2017 16:14
example update_if_exists failure
from infoblox_client import objects, connector
import getpass
def main():
username = input('Username > ')
password = getpass.getpass('Password > ')
conn = connector.Connector({'host':'infoblox.example.com','username':username,'password':password,
'ssl_verify':False,'wapi_version':"1.7"})