Skip to content

Instantly share code, notes, and snippets.

View geblanco's full-sized avatar

Guillermo Blanco geblanco

View GitHub Profile
@geblanco
geblanco / Singleton.py
Created December 13, 2022 14:49
Singleton class
# coding=utf-8
class Singleton(object):
def __new__(cls):
if not hasattr(cls, "instance"):
cls.instance = super(Singleton, cls).__new__(cls)
return cls.instance
@geblanco
geblanco / pdiff.py
Last active December 27, 2022 08:17
Script to get permissions diff between multiple directories or files. You can get a files permission list by passing -p and a single directory
#!/usr/bin/env python3
import argparse
from glob import glob
from typing import List, Tuple, Union, Iterable, Optional
from pathlib import Path
from itertools import combinations
from dataclasses import dataclass
@geblanco
geblanco / striptqdm.sh
Last active November 30, 2023 07:56
Simple bash script to remove tqdm output from logfile
#!/bin/bash
# Intended usage:
# - You run a super long script with fancy tqdm progress bars in a remote server as usual:
#
# nohup python super_long_script.py > super_long.log &
# # monitor as long as you want
# tail -f super_long.log
@geblanco
geblanco / pyprojreqs.sh
Last active November 20, 2023 12:14
Script to automatically extract dependencies from a pyproject.toml file.
#!/bin/bash
# If a requirements.txt file is supplied, it will be updated with the latest versions of each package.
# If a pyproject.toml is required, package upgrades will just be printed.
echo "Careful:" >&2
echo " - Virtual Env is required" >&2
echo " - If any of your PYPY packages contain the strin 'http', it is possible that it gets astray, manually inspect it" >&2
def_deps_key="dependencies"
@geblanco
geblanco / zsh_setup.sh
Last active June 19, 2023 17:13
Minimal setup to get zsh and companions working. Installer for fresh servers...
#/bin/bash
# Install:
# - zsh (requires sudo)
# - oh-my-zsh
# - zsh-autosuggestions plugin
# - conda-zsh-completion plugin
# - custom themes
# - custom zshrc and styles
@geblanco
geblanco / args2json.py
Created September 11, 2023 10:59
Dump received arguments to json
#!/bin/python3
import sys
import json
data = sys.stdin.readlines()
args = []
for line in data:
line = line.replace("\\", "").strip().split(" ")
args.extend(line)