Skip to content

Instantly share code, notes, and snippets.

View rakeshmandava's full-sized avatar

Rakesh Mandava rakeshmandava

  • Netbrain Tech
  • Hyderabad
View GitHub Profile
import re
from netmiko import ConnectHandler
# Define the device information
device = {
'device_type': 'cisco_ios',
'ip': 'your_switch_ip',
'username': 'your_username',
'password': 'your_password',
'secret': 'your_enable_password',
def cross(A, B):
"Cross product of elements in A and elements in B."
return [a + b for a in A for b in B]
digits = '123456789'
rows = 'ABCDEFGHI'
cols = digits
squares = cross(rows, cols)
unitlist = ([cross(rows, c) for c in cols] +
[cross(r, cols) for r in rows] +
@rakeshmandava
rakeshmandava / ip_mac.py
Last active November 14, 2021 13:48
This Script picks Mac and IP address only when an IP address is present on the interface.
import re
stringer = """Vlan1 is administratively down, line protocol is down
Hardware is CPU Interface, address is 0009.b7c7.3180 (bia 0009.b7c7.3180)
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
ARP type: ARPA, ARP Timeout 04:00:00
Last input never, output never, output hang never
Last clearing of "show interface" counters never
@rakeshmandava
rakeshmandava / positiveLookahead.txt
Created July 9, 2021 12:27
Demo of Regex Positive Look Ahead
"""
You need to write regex that will validate a password to make sure it meets the following criteria:
At least six characters long
contains a lowercase letter
contains an uppercase letter
contains a number
Valid passwords will only be alphanumeric characters.
"""
"""
In this example you have to validate if a user input string is alphanumeric. The given string is not nil/null/NULL/None, so you don't have to check that.
The string has the following conditions to be alphanumeric:
At least one character ("" is not valid)
Allowed characters are uppercase / lowercase latin letters and digits from 0 to 9
No whitespaces / underscore
"""
import re
@rakeshmandava
rakeshmandava / ISBN-10-Validation.py
Last active July 4, 2021 16:19
Python Regex "fullmatch" Example
"""
ISBN-10 identifiers are ten digits long. The first nine characters are digits 0-9.
The last digit can be 0-9 or X, to indicate a value of 10.
An ISBN-10 number is valid if the sum of the digits multiplied by their position modulo 11 equals zero.
"""
import re
def valid_ISBN10(isbn):