Skip to content

Instantly share code, notes, and snippets.

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

mar10 obar1

🏠
Working from home
View GitHub Profile
@obar1
obar1 / make_diary.ps1
Last active September 9, 2025 08:40
Creates a dated subfolder in the current directory, adds a readme.md file if missing, and compresses the entire folder into a ZIP backup. Includes error handling for the backup process.
# Creates a dated subfolder in the current directory, adds a readme.md file if missing, and compresses the entire folder into a ZIP backup. Includes error handling for the backup process.
$currentDate = (Get-Date).ToString("yyMMdd")
# TODO: check backupFilePath
$backupFilePath = "$env:USERPROFILE\.bkp\$currentDate.zip"
$currentDirectory = Get-Location
$datedSubfolderPath = Join-Path -Path $currentDirectory -ChildPath $currentDate
$readmeFilePath = Join-Path -Path $datedSubfolderPath -ChildPath "readme.md"
@obar1
obar1 / light git clone.sh
Created August 21, 2025 09:51
light git clone
git clone --depth 1 --branch main
@obar1
obar1 / set_gcp.sh
Last active August 14, 2025 14:32
This Bash script is used to authenticate and configure access to a Google Cloud Platform (GCP) project using the gcloud CLI. It ensures the user provides a project ID, sets it as an environment variable, and then runs a series of GCP authentication and configuration commands.
#!/bin/bash
# Check if a project ID was provided
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Usage: $(basename "$0") <gcp_project_id>"
echo "This script authenticates and configures gcloud for the specified GCP project."
exit 0
fi
@obar1
obar1 / py_fetch_skillboost.py
Last active July 30, 2025 06:34
simple skillboost html page downloader
import subprocess
import sys
import requests
from pathlib import Path
REPO = "paths_"
WKHTMLTOPDF_PATH = r"C:\git\py_fetch_skillboost\wkhtmltox\bin\wkhtmltopdf.exe"
def fetch_and_save_html(path_id, input_path_html):
url = f"https://partner.cloudskillsboost.google/paths/{path_id}"
@obar1
obar1 / simple_yt_dowloader.py
Last active April 18, 2025 06:28
save yt locally in folder and play via ws
from yt_dlp import YoutubeDL
import os
import json
import html
import re
import http.server
import socketserver
import threading
# Directory to store videos
@obar1
obar1 / rsync wsl2 to dropbox.sh
Created July 6, 2024 08:55
rsync wsl2 to dropbox
rsync -avz --exclude='.git/' --exclude='.venv/' --exclude='__pycache__' --exclude='.pytest_cache' ./kb.oreilly.git/ /mnt/c/Users/mario/Dropbox/kb.oreilly.git
@obar1
obar1 / drop-wsl2-Identifier.sh
Last active June 26, 2024 13:25
drop Identifier
find . -name "*.Identifier" -type f -print0 | xargs -0 rm
@obar1
obar1 / venv_cd.sh
Last active April 28, 2025 08:25
for bashrc to automaticaly activate and deactivate venv in folders as you move between them
function check_venv() {
# Check if we're entering a directory with a .venv
if [ -d "./venv" ]; then
echo "!!! deleting venv "
rm -rf venv
fi
if [ -d "./.venv" ]; then
if [ -n "$OLDPWD" ] && [ "$PWD" != "$OLDPWD" ]; then
echo "folder changed..."
python_path=$(which python 2>/dev/null)
@obar1
obar1 / update_0to100s.sh
Last active April 24, 2025 13:19
update 0 to 100 repos
#!/bin/bash
# set -eox pipefail
update_0to100() {
cd ../0to100.git
pwd
git switch main
git pull
}
@obar1
obar1 / get oreilly cookies.md
Created December 15, 2023 04:19
get oreilly cookies

https://learning.oreilly.com/profile/

console.log(JSON.stringify(document.cookie.split(';').map(c => c.split('=')).map(i => [i[0].trim(), i[1].trim()]).reduce((r, i) => {r[i[0]] = i[1]; return r;}, {})))