Skip to content

Instantly share code, notes, and snippets.

@twr14152
twr14152 / sample_playbook
Last active May 1, 2021
sample_playbook_example
View sample_playbook
- name: configure cisco routers
hosts: routers
connection: ansible.netcommon.network_cli
gather_facts: no
@twr14152
twr14152 / gross_pay_calc.py
Last active Jan 15, 2021
gross_pay_calc.py
View gross_pay_calc.py
#wage
name1_wage = <>
name2_wage = <>
name3_wage = <>
name4_wage = <>
#overtime wage
name1_ot = (name1_wage/2) + name1_wage
name2_ot = (name2_wage/2) + name2_wage
name3_ot = (name3_wage/2) + name3_wage
View write_2_file.py
#Comparing write method to print method to writing to file.
def main():
fname = input("Enter filename: ")
dfname = input("Destination Filename: ")
infile = open(fname, "r")
with open(dfname, "a") as f:
data = infile.read()
infile.close()
@twr14152
twr14152 / print_2_file.py
Last active Nov 8, 2020
Write to file using print
View print_2_file.py
#Trying to understand the benefit of this method of writing to a file...
def main():
fname = input("Enter filename: ")
dfname = input("Destination Filename: ")
infile = open(fname, "r")
outfile = open(dfname, "a")
data = infile.read()
print(data)
infile.close()
@twr14152
twr14152 / kw_count.py
Last active Nov 5, 2020
Python Keyword count
View kw_count.py
import keyword
def kw_count():
a = 0
for kw in keyword.kwlist:
a+=1
print(f"{a} ", kw)
kw_count()
@twr14152
twr14152 / ios_config_script_07292020.py
Created Jul 29, 2020
requested_ios_config_script_07292020
View ios_config_script_07292020.py
#!/usr/bin/python3
#(c) 2020 Todd Riemenschneider
#
#Enable Multiprocessing
from multiprocessing import Pool
#getpass will not display password
from getpass import getpass
#ConnectionHandler is the function used by netmiko to connect to devices
from netmiko import ConnectHandler
#Time tracker
@twr14152
twr14152 / pushupCounter.go
Created Apr 5, 2020
Pushup Counter workout routine
View pushupCounter.go
/*
Specify a number of pushups you want to do in a set.
Every 30 secs do another set - 1 rep. Repeat until you reach 0.
This program will calculate how many pushups you do in total
*/
package main
import (
"fmt"
@twr14152
twr14152 / findingDupIPs.py
Created Feb 15, 2020
Finding duplicate IPs in a souce list
View findingDupIPs.py
#sample Source List
ip_address = ["10.0.0.1", "10.0.0.1", "10.0.0.2", "12.0.3.1", "10.9.0.1", "12.0.1.1", "10.0.0.2"]
ip_counts = {ip: ip_address.count(ip) for ip in set(ip_address)}
for ip, count in ip_counts.items():
if count > 1:
print(f"Dup IP:{ip} number of dup hosts {count}")
else:
continue
@twr14152
twr14152 / deepcopy notes
Created Feb 15, 2020
Using deepcopy with dictionary
View deepcopy notes
In [64]: dict1 = copy.deepcopy(sample_dict)
In [65]: dict1
Out[65]: {'first': 1, 'second': 2, 'third': 3, 'a': 1, 'b': 2}
In [66]: sample_dict
Out[66]: {'first': 1, 'second': 2, 'third': 3, 'a': 1, 'b': 2}
In [68]: sample_dict.pop("first")
Out[68]: 1
View lissajous.go
package main
import (
"image"
"image/color"
"image/gif"
"io"
"math"
"math/rand"
"os"