Find ALL Anagrams in a String example: s: “cbaebabacd” p: “abc” output:[0,6] #It is apparently a index #Sliding Window with HashMap def findAnagrams(s: str,p: str): ns,np = len(s), len(p) if ns < np: return [] p_count = Counter(p) s_count = Counter() output = [] for i in range(ns): s_count[s[i]] +=1...
[Read More]
Writing Production-grade Python Code
My thoughts on Git, in other word, vision control, we can have a roll back.
[Read More]
Phone Interview about Network Engineer
Okya, I did not post immediately after the phone interview cuz I was tired from my trip to Ottawa. I was meant to go to the career fair in ottawa, but I ended up studying at the University of Ottawa. I think that time I was studying a real case...
[Read More]
Unit Testing
Before talking about what is unit testing, I still gonna be finishing off my implementation of python regular expression. vrf_list = ["vrf" + s for s in text.strip().split("vrf") if s] return_dict = {} for vrf in vrf_list: #parse the VRF name from the definition line name_regex = re.compile(r"vrf\s+definition\s+(?P<name>\S+)") sub_dict =...
[Read More]
Abstracting Network Automation Tasks with NAPALM
Introduction to one of python's library
NAPALM is another tool for network automation. It is built on netmiko.
~~~
#!/usr/bin/env python
from napalm import get_network_driver
from jinja2 import Environment,FileSystemLoader
from yaml import safe_load
[Read More]