uv run --with gradio gui.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import asyncio | |
| import random | |
| import datetime | |
| import time | |
| import os | |
| from concurrent.futures import ThreadPoolExecutor | |
| # Configuration | |
| BATCH_SIZE = 10000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " ----------------------------- | |
| " rochaCbruno Vim 9.1 config | |
| " ----------------------------- | |
| " --- Leader keys --- | |
| let mapleader = "," | |
| let maplocalleader = "," | |
| source ~/.vim/functions.vim | |
| source ~/.vim/commands.vim | |
| source ~/.vim/plugins.vim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Presenterm Intro Slide": { | |
| "prefix": "ptitle", | |
| "body": [ | |
| "---", | |
| "title: \"${1:Your Title}\"", | |
| "sub_title: \"${2:Your Subtitle (optional)}\"", | |
| "author: ${3:Your Name}", | |
| "---" | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass | |
| @dataclass | |
| class Potato: | |
| value: str | |
| class EnglishPotato(Potato): ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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): |