Skip to content

Instantly share code, notes, and snippets.

@tmessinis
tmessinis / get_host_net_info.py
Last active June 25, 2018 03:28
Obtain IP address from hosts passed by stdin, calculate network of each IP for eacho host, and find lowest IP for each network.
#!/usr/bin/python3
####################################################################################
# Name: get_host_net_info.py #
# Author: Theodoros Messinis #
# Date Created: 20180622 #
# Purpose: Obtain IP address from hosts passed by stdin, calculate network of #
# each IP for eacho host, and find lowest IP for each network. #
####################################################################################
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDj16c2GaJEplApxhX7QAkU4GeivvxeWXKd4TMXgt/eHDkX/DMMdoLsDHNtpAPdyT5gBr1+HLeCdMreb/fBqFSiQ/8vtvKrBmBhAd4HDVSnQY0Z5sXwaabnM9no9eCnYlYrj+uIQvVdgxYj1G2MHMc+J0ZTltxpb2BEh/y0g82W8rcAj5f52SbuPQi8Zv9VLjgEDitUfiPwrS0FiTsiCgJVRAWpkF63DOtAEhJDNNjhxgEjdf497oYWkJEkLIrK+R65SYOdEsOEwzhSD2l3AzWDsT9AgoR7In8dyWTJHugLNeF8rQU53vH8ZAAacjVV4MsPX17shnQuysb7FnueLACr tmessin@gmail.com
@tmessinis
tmessinis / tmux-multi-ssh-sync.py
Last active June 3, 2018 18:41
Python script that launches tiled synced tmux panes on specified hosts via ssh
from getpass import getuser
from sys import argv
from subprocess import call
username = getuser()
hosts = []
def multi_ssh_connection(hostnames):
cmd = "tmux new-session 'ssh {0}@{1}' \; ".format(username, hostnames[0])
"""
You have N pairs of intervals, say integers.
You're required to indentify all intervals that overlap with each other.
For example, if you have
{1, 3} {12, 14} {2, 4} {13, 15} {5, 10}
The answer is {1, 3}, {12, 14}, {2, 4}, {13, 15}.
Note that you don't need to group them, so the result can be in any order like in the example.
@tmessinis
tmessinis / compact_spaces.py
Last active May 19, 2017 02:57
Write a program to compact spaces in a string i.e. Given a string you have to remove multiple occurrences of blank spaces by a single space and do that in a single pass of the arrays.
def compact_spaces(a_string):
space_check = []
return_string = ''
for char in a_string:
if char == ' ' and char not in space_check:
space_check.append(char)
return_string += char
elif char == ' ':
continue
@tmessinis
tmessinis / quicksort_recursive.py
Created April 23, 2017 16:43
Python recursive quicksort
import random
test_list = [random.randint(0,100) for num in range(random.randint(10,50))]
#test_list = [1,1,1]
def quick_sort_v2(a_list):
if len(a_list) == 2:
if a_list[0] > a_list[1]:
return [a_list[1], a_list[0]]
else:
return a_list
@tmessinis
tmessinis / DangItBobby.ps1
Created October 28, 2016 18:20 — forked from danieltharp/DangItBobby.ps1
PowerShell script to find where a user is logged into on the network and disable their NIC.
# ********************************************************************************
#
# Script Name: DangItBobby.ps1
# Version: 1.0.0
# Author: bluesoul <https://bluesoul.me>
# Date: 2016-04-06
# Applies to: Domain Environments
#
# Description: This script searches for a specific, logged on user on all or
# specific Computers by checking the process "explorer.exe" and its owner. It
@tmessinis
tmessinis / caesar_cipher.py
Last active July 28, 2016 01:28
An implementation of a simple caesar cipher
# This is an attempt at creating a caesar cipher using the ord()
# function and taking input from the user.
import re
def caesar_cipher(mode, input_str, key):
return_str = ''
char_as_num = None
num_as_char = None
char_after_cipher = None