Skip to content

Instantly share code, notes, and snippets.

View lamoni's full-sized avatar

Lamoni Finlayson lamoni

  • Tesla
  • Austin, TX
View GitHub Profile
@lamoni
lamoni / linus-vs-line-lengths.md
Last active July 21, 2022 23:16
Linus Torvalds vs Line Lengths

From Linus Torvalds

Date Fri, 29 May 2020 12:19:02 -0700 Subject Re: clean up kernel_{read,write} & friends v2 share 4k On Fri, May 29, 2020 at 6:08 AM David Laight wrote:

A wide monitor is for looking at lots of files.

Not necessarily.

@lamoni
lamoni / gist:73120ee1d9d3d3e9dbfb5f969e256862
Last active September 30, 2021 11:21
Convert Cisco or Arista config format to a pseudo-set format
# Quick POC #1, obviously want to get rid of the "terminal" assumption
def convert_from_arista_to_pseudo_set_format(contents: str):
final = []
contents = 'terminal' + contents.split('terminal', 1)[1]
contents = contents.split('\n!\n')
for block in contents:
split = block.split('\n')
main = f'set {split[0]}'
@lamoni
lamoni / asdot_and_asplain.py
Last active February 27, 2024 22:35
Convert 4 byte ASN (ASPLAIN) to ASDOT Notation and vice versa with Python
# e.g. Convert 4261160822 to 65020.10102
def convert_ASPLAIN_to_ASDOT(as_number):
if not(isinstance(as_number, int)) or as_number < 0 or as_number > 4294967295:
raise Exception('Invalid AS Number: must be int, must be greater than or equal to 0 and less than or equal to 4294967295')
return '{}.{}'.format(as_number // 65536, as_number % 65536)
# e.g. Convert 65020.10102 to 4261160822
def convert_ASDOT_to_ASPLAIN(as_dot_number):
if not(isinstance(as_dot_number, str)) or as_dot_number.count('.') != 1: