Skip to content

Instantly share code, notes, and snippets.

View esauOp's full-sized avatar
🏠
Working from home

Esaú Ortega esauOp

🏠
Working from home
  • Monterrey, Mexico
View GitHub Profile
@esauOp
esauOp / net_watchdog.py
Created November 11, 2025 19:35
A lightweight watchdog for connection reliability checks
#!/usr/bin/env python3
import time
import csv
from datetime import datetime
from urllib.request import urlopen, Request
from urllib.error import URLError
CHECK_EVERY_SECONDS = 30
TARGETS = ["https://www.google.com", "https://www.cloudflare.com", "https://www.wikipedia.org"]
LOGFILE = "net_incidents.csv"
@esauOp
esauOp / clean_clipboard_url.py
Created November 11, 2025 19:32
Strip UTM and ref parameters, then copy back
#!/usr/bin/env python3
# pip install pyperclip
import pyperclip
from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse
TRACKING_KEYS = {
"utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content",
"gclid", "fbclid", "mc_eid", "mc_cid", "igshid", "si"
}
def clean_url(url: str) -> str:
@esauOp
esauOp / quick_note.py
Created November 11, 2025 19:30
Append timestamped notes to a rolling daily file
#!/usr/bin/env python3
from datetime import datetime
from pathlib import Path
import sys
NOTES_DIR = Path.home() / "Notes" / "Daily"
NOTES_DIR.mkdir(parents=True, exist_ok=True)
def main():
if len(sys.argv):
print("Usage: quick_note.py \"your note text\"")
@esauOp
esauOp / downloads_sorter.py
Created November 11, 2025 19:27
A tiny sorter that files by type automatically
#!/usr/bin/env python3
from pathlib import Path
import shutil
DOWNLOADS = Path.home() / "Downloads"
BUCKETS = {
"Documents": {".pdf", ".docx", ".doc", ".txt", ".md", ".odt", ".rtf"},
"Images": {".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".heic"},
"Audio": {".mp3", ".wav", ".flac", ".m4a", ".ogg"},
"Video": {".mp4", ".mkv", ".mov", ".avi", ".webm"},

Installation

Post Install

Configuration

Login to the proxmox node and paste the following code:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/post-pve-install.sh)"
# tabc <profile name> do the profile change
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi
# if you have trouble with this, change
# "Default" to the name of your default theme
echo -e "\033]50;SetProfile=$NAME\a"
}
# reset the terminal profile to Default when exit from the ssh session
function tab-reset() {
// Install dependencies
// npm install fs path @angular/compiler
import * as fs from 'fs';
import * as path from 'path';
let components: any = {};
// Function to recursively read files in a directory
function readFiles(dir: string, filesList: string[] = []): string[] {
@esauOp
esauOp / raspberry_pi_script_as_service.md
Created October 28, 2020 16:56 — forked from emxsys/raspberry_pi_script_as_service.md
How to run a python script as a service in Raspberry Pi - Raspbian Jessie

How to Run a Script as a Service in Raspberry Pi - Raspbian Jessie

By: Diego Acuña

Original Article: http://www.diegoacuna.me/how-to-run-a-script-as-a-service-in-raspberry-pi-raspbian-jessie/

A pretty common task when using this device, is to run some script (for example a python script) as a service in the operating system so it can start on boot, stop and restart using systemctl and more. In this post I'm going to explain how to set a little script as a service using Raspbian Jessie in a Raspberry Pi.

Example Python Script

Principles and Assumptions MQTT was designed for low-bandwidth, high latency networks in the late 1990s/early 2000s. As a result, the designers made a number of key choices which influenced the way it "looks and feels".

Simplicity, simplicity, simplicity! Don't add too many "bells and whistles" but provide a solid building block which can easily be integrated into other solutions. Be simple to implement. Publish/subscribe messaging. Useful for most sensor applications, and enables devices to come online and publish "stuff" that hasn't been previously known about or predefined. Zero administration (or as close as possible). Behave sensibly in response to unexpected actions and enable applications to "just work" e.g. dynamically create topics when needed. Minimise the on-the-wire footprint. Add an absolute minimum of data overhead to any message. Be lightweight and bandwidth efficient. Expect and cater for frequent network disruption (for low bandwidth, high latency, unreliable, high cost-to-run networks)... -

#!/usr/bin/python
import time
import os
print "set 5 sec to stop ngnix"
time.sleep( 5 )
print "Stop Ngnix"
os.system("sudo service nginx stop")
print "Set 20 sec to renew Cerbot"
time.sleep( 20 )