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 / az_vm.sh
Created September 1, 2021 20:53
Create a VM in Microsoft Azure via az and access it via SSH
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 August 18, 2021 08:42
This oneliner executes the find_packages method in order to troubleshoot setup.py
python -c "from setuptools import setup, find_packages; print(find_packages())"
@ltpitt
ltpitt / force_paste.py
Created August 5, 2021 14:57
A quick and dirty hack to type into fields where you cannot paste
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 July 7, 2021 19:32
Another README.md template

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
Last active September 1, 2022 01:01
A simple auto scroller button, can be pasted in browser console or injected in other ways in any website
// Simply copy and paste the following script in your browser's console,
// it will add an auto-scrolling button on the right part of the webpage you are visiting.
(function() {
let cssScrolling = "background-color: #f44336; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; float:right; position:fixed; right:0; top:50%;";
let cssStopped = "background-color: #4CAF50; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; float:right; position:fixed; right:0; top:50%;";
let btn = document.createElement("button");
var isScrolling = false;
btn.innerHTML = "start scroll";
btn.style.cssText = cssStopped;
@ltpitt
ltpitt / weatherwidget.html
Created May 21, 2021 07:53
Just a nifty weather widget
<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;
stat -c '%n %a' *
@ltpitt
ltpitt / ManageDeviceInputFromPowershell.ps1
Last active July 30, 2021 10:45 — forked from neo7BF/ManageDeviceInputFromPowershell.ps1
Devices input management from powershell
####################
# KEYBOARD VERSION #
####################
$shell = New-Object -ComObject WScript.Shell
while(1) {
$shell.sendkeys("{NUMLOCK}{NUMLOCK}")
$time = Get-Date;
@ltpitt
ltpitt / removeFileFromCurrentCommit.sh
Created November 25, 2020 11:13
Remove file from current commit
git reset HEAD "YOUR_FILE_PATH + YOUR_FILE_NAME"
@ltpitt
ltpitt / quickNdirtyPaywallPageScroller.js
Created November 5, 2020 13:27
Just a simple Javascript webpage scroller I needed to read content hidden behind a paywall
// Open your browser's console, paste this script in it and press enter.
// Reload the page using F5 to cancel the script's effects.
async function autoScroll(scrollStartHeight, scrollSpeed, waitTimeBetweenScrolls){
let currentScrollHeight = scrollStartHeight;
while (currentScrollHeight < document.body.scrollHeight) {
currentScrollHeight += scrollSpeed;
await new Promise(r => setTimeout(r, waitTimeBetweenScrolls));
window.scrollTo(scrollStartHeight, currentScrollHeight);
}
}