Skip to content

Instantly share code, notes, and snippets.

View rochacbruno's full-sized avatar
🛠️
Working on Galaxy_ng and Dynaconf

Bruno Rocha rochacbruno

🛠️
Working on Galaxy_ng and Dynaconf
View GitHub Profile
from dataclasses import dataclass
@dataclass
class Potato:
value: str
class EnglishPotato(Potato): ...
@rochacbruno
rochacbruno / comp_multi.rs
Created January 13, 2025 15:01 — forked from kepler-5/comp_multi.rs
Python comprehension proc macro that handles multiple nested for-if-clauses, flattening nested structure
// Python comprehension proc macro that handles multiple nested for-if-clauses, flattening nested structure.
// Example:
//
// let vec_of_vecs = vec![vec![1, 2, 3], vec![4, 5, 6]];
//
// let result = comp![x for vec in vec_of_vecs for x in vec].collect::<Vec<_>>();
// assert_eq!(result, [1, 2, 3, 4, 5, 6]);
//
use proc_macro2::TokenStream as TokenStream2;
@rochacbruno
rochacbruno / clean_filename.rs
Created November 24, 2024 12:10
Remove date from filename Rust
use regex::Regex;
fn clean_filename(filename: &str) -> Option<String> {
// Regex to match the date/time prefix
let date_prefix_re = Regex::new(
r"^\d{4}-\d{2}-\d{2}([-T]\d{2}([:-]\d{2})?([:-]\d{2})?)?-",
)
.unwrap();
// Regex to remove the `.md` extension
let extension_re = Regex::new(r"\.md$").unwrap();
@rochacbruno
rochacbruno / validate.py
Last active November 19, 2024 16:47
Validate kwargs in Python without external dependencies
# Somewhere on your project: foo/validate.py
from functools import wraps
def validate_kwargs(*checks, required=()):
def decorator(func):
@wraps(func)
def wrapper(**kwargs):
for key, check, expected in checks:
if key in kwargs and not check(kwargs[key], expected):
@rochacbruno
rochacbruno / admonition.md
Last active January 23, 2025 07:01
Github markdown admonition

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

[!WARNING]

@rochacbruno
rochacbruno / custom.css
Created October 1, 2024 16:47
GoToSocial custom Solirized Light CSS for Brutalist Light Theme
:root {
--almost-white: #fdf6e3;
--almost-black: #586e75;
--link-fg: #2aa198;
--fg: #586e75;
--status-info-bg: #eee8d5;
--status-focus-info-bg: #eee8d5;
--single-border: 0.2rem solid #cb4b16;
--boxshadow-border: none;
--double-border: none;
@rochacbruno
rochacbruno / app.py
Last active September 29, 2024 17:10
Receive Webhooks from Github and start a deploy script
import ipaddress
import json
import os
import subprocess
from enum import Enum
import uvicorn
from dotenv import load_dotenv
from fastapi import (
BackgroundTasks,

Map Caps Lock key to be quote symbols

tap = ' tap tap = " hold = """

if_tap(
 if_tap(
@rochacbruno
rochacbruno / debug_ovi_env.md
Created February 25, 2024 13:25
Debug in OCI ENV

Debug in oci-env

Add the breakpoint to the task, then stop workers and start a worker manually.

$ s6-svc -d /var/run/service/pulpcore-worker\@1/
$ pulpcore-worker
@rochacbruno
rochacbruno / A.md
Created February 9, 2024 14:16
Delete youtube watch later

Delete whatch later videos from youtube

  • OPen youtube, change language to English
  • Go to your watch later playlist
  • OPen the inspect -> console
  • Paste the script and execute it