Skip to content

Instantly share code, notes, and snippets.

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 / workflow.md
Created Nov 18, 2021 — forked from stuartsaunders/workflow.md
Versioning and Git Workflow
View workflow.md

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 Nov 13, 2021
How to create a cli tool in go using cobra
View go_cli_tool_with_cobra.sh
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 Oct 28, 2021
Create 4 pane in tmux via script
View 4_pane_tmux.sh
#!/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'
@ltpitt
ltpitt / az_vm.sh
Created Sep 1, 2021
Create a VM in Microsoft Azure via az and access it via SSH
View az_vm.sh
az group create --location eastus2 --name MyResourceGroup
az vm create -n myVM -g MyResourceGroup --image UbuntuLTS --generate-ssh-keys
# Then search for myVM in Azure, get its ip and connect via ssh.
# Once done you can destroy the resource group using:
az group delete -n MyResourceGroup
@ltpitt
ltpitt / find_packages_oneliner.py
Created Aug 18, 2021
This oneliner executes the find_packages method in order to troubleshoot setup.py
View find_packages_oneliner.py
python -c "from setuptools import setup, find_packages; print(find_packages())"
@ltpitt
ltpitt / force_paste.py
Created Aug 5, 2021
A quick and dirty hack to type into fields where you cannot paste
View force_paste.py
import time
from pyautogui import typewrite
import easygui
text = easygui.textbox("Paste your text here, click on ok and then click in the field where you want the text to be pasted and wait for 10 seconds.", "Paste-into-anything-3000")
time.sleep(10)
typewrite(text, 0.01)
@ltpitt
ltpitt / README.md
Last active Jul 7, 2021
Another README.md template
View README.md

Building a Peanut Butter and Jelly Sandwich

Introduction

In this project, you will build a Peanut Butter and Jelly Sandwich (PB&J).

Getting Started

Before you build a PB&J, you will need to:

  • Set up a clean table
  • Get a clean dull knife
  • Have some kitchen paper handy in case of errors
@ltpitt
ltpitt / autoScroller.js
Created Jun 6, 2021
A simple auto scroller button, can be pasted in browser console or injected in other ways in any website
View autoScroller.js
(function () {
let btn = document.createElement("button");
var isScrolling = false;
btn.innerHTML = "start scroll";
btn.style.cssText =
"width:50px;height:50px;float:right;background:grey;position:fixed;right:0;top:50%;opacity:0.5;border-radius:50%"
let onclick = function() {console.log("click"); isScrolling=!isScrolling; autoScroll()};
btn.addEventListener("click", onclick);
let autoScroll = () => {if(isScrolling){window.scrollBy(0, 1);
setTimeout(autoScroll, 10)}};
@ltpitt
ltpitt / weatherwidget.html
Created May 21, 2021
Just a nifty weather widget
View weatherwidget.html
<html>
<div class="background">
<div class="container">
<style>
@import 'https://fonts.googleapis.com/css?family=Lato:300';
@import 'https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css';
html, body, .background {
width: 100%;
height: 100%;
margin: 0;