Skip to content

Instantly share code, notes, and snippets.

View ltpitt's full-sized avatar
🥋
A black belt is a white belt that never quit.

Davide Nastri ltpitt

🥋
A black belt is a white belt that never quit.
View GitHub Profile
@ltpitt
ltpitt / fake_smtp_server.py
Created June 19, 2023 07:51
Fake SMTP server in Python that saves received email in TMP folder and opens them right away
import argparse
import asyncore
import logging
import os
import platform
import smtpd
import subprocess
import tempfile
from datetime import datetime
@ltpitt
ltpitt / mouse_jiggler.py
Created June 7, 2023 14:19
A simple script to jiggle your mouse around
import pyautogui
import random
import time
screen_width, screen_height = pyautogui.size()
interval = 10
while True:
x = random.randint(0, screen_width)
@ltpitt
ltpitt / rom_copy.sh
Last active January 26, 2023 23:16
Rsync command to copy rom folders across Gameboy Zeroes
rsync -auvP snes/ pi@servername:/home/pi/RetroPie/roms/snes/
@ltpitt
ltpitt / yaml_to_json.py
Created April 8, 2022 09:21
Simple cli tool to translate a YAML file to JSON
import yaml
import json
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('yaml', help='Enter YAML file path')
args = parser.parse_args()
with open(args.yaml) as infile:
os_list = yaml.load(infile, Loader=yaml.FullLoader)
@ltpitt
ltpitt / check_if_port_is_listening_on_host_list.py
Last active April 7, 2022 08:59
Simple snippet to check if a list of hosts has the specified port open or closed
import socket
from contextlib import closing
hosts = ["host1", "host2", "host3"]
port = 22
timeout_in_seconds = 2
hosts_with_opened_port = []
hosts_with_closed_port = []
hosts_with_errors = []
@ltpitt
ltpitt / telnet_server.py
Created March 31, 2022 21:55
A very basic telnet server in Python to communicate via Telnet with a Commodore 64
#!/usr/bin/env python3
import socket
# Connect to the server with `telnet $HOSTNAME 5000`.
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setblocking(False)
server.bind((socket.gethostname(), 5000))
server.listen(5)
@ltpitt
ltpitt / is_pokemon.py
Last active May 22, 2023 08:24
A simple Python snippet to find out if a name is a Pokemon or not.
import requests
topics = 'bulbasaur, go, pikachu, html'
findings = {}
for topic in topics.split(','):
topic = topic.strip()
result = requests.get(f'https://pokeapi.co/api/v2/pokemon/{topic}')
if result.text == 'Not Found':
findings[topic] = 'is not a pokemon'
@ltpitt
ltpitt / workflow.md
Created November 18, 2021 10:41 — forked from stuartsaunders/workflow.md
Versioning and Git Workflow

Semantic Versioning

Details:

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

@ltpitt
ltpitt / go_cli_tool_with_cobra.sh
Created November 13, 2021 17:25
How to create a cli tool in go using cobra
go get -v github.com/spf13/cobra/cobra
cobra init --pkg-name github.com/ltpitt/tri -a ltpitt
go mod init github.com/ltpitt/tri
go get github.com/spf13/cobra
go get github.com/spf13/viper
go build
tri.exe
@ltpitt
ltpitt / 4_pane_tmux.sh
Created October 28, 2021 15:36
Create 4 pane in tmux via script
#!/bin/bash
tmux new-session -s "CDT" -d
tmux split-window -h
tmux split-window -v
tmux split-window -v -t 0
tmux send-keys -t %0 'echo first cdt'
tmux send-keys -t %1 'echo second cdt'
tmux send-keys -t %2 'echo third cdt'
tmux send-keys -t %3 'echo fourth cdt'