Skip to content

Instantly share code, notes, and snippets.

View Pr1meSuspec7's full-sized avatar

Mark Pr1meSuspec7

  • NTT Data
  • Milan
View GitHub Profile
@Pr1meSuspec7
Pr1meSuspec7 / using-multiple-github-accounts-with-ssh-keys.md
Last active August 26, 2025 10:13
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: Pr1meSuspec7 (personal) and palmierimarco (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@Pr1meSuspec7
Pr1meSuspec7 / typewriter.py
Created June 25, 2024 17:05
Function to simulate typewriter
import sys, time
def typewriter(text):
for character in text:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(0.008)
print("\n")
@Pr1meSuspec7
Pr1meSuspec7 / output.yml
Last active August 29, 2024 10:10
Ansible loop output in one file
# Save output under play
- name: Save output
ansible.builtin.copy:
content: |-
{% for host in ansible_play_hosts_all %}
{{ '### ' }}{{ host }}{{ ' ###' }}
{{ hostvars[host]['result']['stdout_lines'] | to_nice_json }}
{% endfor %}
dest: output.log
mode: "0644"
@Pr1meSuspec7
Pr1meSuspec7 / .bash_aliases
Created May 20, 2024 13:18
Linux aliases
alias python='python3.11'
alias mv='mv -v'
alias rm='rm -v'
alias cp='cp -v'
alias ping='ping -O'
alias play='ansible-playbook'
alias playsec='ansible-playbook --vault-password-file secrets.txt'
alias tf='terraform'
alias tfp='terraform plan'
alias tfa='terraform apply'
@Pr1meSuspec7
Pr1meSuspec7 / netmiko_exception.py
Created May 16, 2024 09:39
NETMIKO | Manage TimeoutException and AuthenticationException
#https://pyneng.readthedocs.io/en/latest/book/18_ssh_telnet/netmiko.html
from pprint import pprint
import yaml
import netmiko
def send_show_command(device, commands):
result = {}
try:
@Pr1meSuspec7
Pr1meSuspec7 / noroot_tcpdump.sh
Created March 13, 2024 08:08
EVE-NG | PNETLAB | TCPDUMP | Enable no-root users to run packet capture
#!/usr/bin/env bash
# This will let anyone who belongs to the 'pcap' group
# execute 'tcpdump'
sudo groupadd pcap
sudo usermod -a -G pcap $USER
sudo chgrp pcap /usr/sbin/tcpdump
sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
sudo ln -s /usr/sbin/tcpdump /usr/bin/tcpdump
@Pr1meSuspec7
Pr1meSuspec7 / Monokai.sublime-color-scheme
Created March 5, 2024 13:42
Sublime Text 4.x | Color settings for "Compare Side-By-Side" package
// Correct color/scope for "Compare Side-By-Side" plugin
// Install: Preferences > Customize Color Scheme > paste this on the right side > save
// Documentation at https://www.sublimetext.com/docs/color_schemes.html
{
"variables":
{
},
"globals":
{
@Pr1meSuspec7
Pr1meSuspec7 / colortext.py
Last active September 5, 2024 07:31
Simple colorize output
COLORS = {'grey': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36, 'white': 37}
RESET = '\033[0m'
def colortext(text, color=None):
'''Ex: print(colortext('some string', 'cyan'))'''
ascii_color = '\033[1;%dm%s'
if color is not None:
# Modulo (%) operator works in this way:
@Pr1meSuspec7
Pr1meSuspec7 / pkg_requirement.py
Last active April 1, 2020 18:02
Fucntion to check and install missing packages
import re
import sys
import subprocess
def pkg_requirement(*pkgs):
output = subprocess.check_output((['pip', 'list']))
outputDecode = output.decode("utf-8")
#print(outputDecode)
pipList = re.split(r'\s', outputDecode)
pipNeed = []
@Pr1meSuspec7
Pr1meSuspec7 / check_if_ipv4.py
Last active September 30, 2024 15:01
Function for check if input is an ipv4 address.
# regex to match ipv4
# (?:[0-9]{1,3}\.){3}[0-9]{1,3}
# v1
def check_if_ipv4(ip):
quad = ip.split(".")
quadinteger = []
try:
quadinteger = [int(num) for num in quad]
except ValueError: