Skip to content

Instantly share code, notes, and snippets.

View annacruz's full-sized avatar
🏠
Working from home

Anna Cruz annacruz

🏠
Working from home
View GitHub Profile
class MyMath
def self.euclides(num1, num2)
return num1 if num2 == 0
return euclides(num2, num1 % num2)
end
end
MyMath.euclides(12, 18)
o = '* 172.31.1.0/24 40.0.0.4 0 7678 7675 i\n'
k = [x for x in o.split(" ") if x != ''] # k = ['*', '172.31.1.0/24', '40.0.0.4', ' 0 7678 7675 i\n']
p = k[-1].split(' ') # p = ['0', '7678', '7675', 'i\n']
k.pop() # k = ['*', '172.31.1.0/24', '40.0.0.4']
k.append(p[0]) # k = ['*', '172.31.1.0/24', '40.0.0.4', '0']
p.pop(0) # p = ['7678', '7675', 'i\n']
d = ''
for z in p:
d = d + z
k.append(d.lstrip()) # k = ['*', '172.31.1.0/24', '40.0.0.4', '0', '7678 7675 i\n']
BGP table version is 0, local router ID is 10.0.0.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 172.31.1.0/24 40.0.0.4 0 7678 7675 i
*> 10.0.0.1 0 0 7675 i
*> 172.31.2.0/24 0.0.0.0 0 32768 i
* 172.31.3.0/24 40.0.0.4 0 7678 7677 i
@annacruz
annacruz / arr.txt
Last active December 20, 2015 12:00
[['BGP table version is 0, local router ID is 10.0.0.2\n'], ['Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,\n'], [' r RIB-failure, S
Stale, R Removed\n'], ['Origin codes: i - IGP, e - EGP, ? - incomplete\n'], ['\n'], [' Network Next Hop Metric LocPrf Weight Path\n'], ['* 172.31.1.0/24 4
0.0.0.4 0 7678 7675 i\n'], ['*> 10.0.0.1 0 0 7675 i\n'], ['*> 172.31.2.0/24 0.0.0.0 0
32768 i\n'], ['*> 172.31.3.0/24 10.0.0.1 0 7675 7677 i\n'], ['* 40.0.0.4 0 7678 7677 i\n']
, ['* 172.31.4.0/24 10.0.0.1 0 7675 7678 i\n'], ['*> 40.0.0.4 0 0 7678 i\n'], ['\n'], ['Total number
of prefixes 4\n']]
@annacruz
annacruz / commands.sh
Created August 1, 2013 12:42
Useful shell commands
#!/bin/sh
#Kill process by name
ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill -9
@annacruz
annacruz / bgp-table-process.py
Last active April 26, 2019 22:51
Process a BGP table, returning the tabulated data into an array. Python version.
#! /usr/bin/env python
import re
# Sample input to test
crude = '''
BGP table version is 0, local router ID is 10.0.0.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
#!/usr/bin/python
# Author: Anna Cruz <anna.cruz@uniriotec.br>
#
# This file is a script to be used as POX module.
#
#
"""
This script collects flow informations on all switches connected
in this instance of POX.
@annacruz
annacruz / comparation.rb
Created September 5, 2013 23:06
Differences between equity comparation in ruby
a.equal?(b) # object identiy - a e b se referem ao mesmo objeto
a.eql?(b) # object equivalence - a e b tem o mesmo valor
a == b # object equivalence - a e b tem o mesmo valor com conversão de tipo
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('',8085))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
data = conn.recv(1024) #receber dados
string = bytes.decode(data) #decodificar para string
@annacruz
annacruz / osx-setup.md
Last active January 4, 2016 01:49 — forked from zenorocha/.hyper.js

Based on Zeno Rocha Osx Setup

Setup Mac OS X

When you have a new MacBook...

First of all backup everything with Time Machine or in another way.

1. Run Software Update