Skip to content

Instantly share code, notes, and snippets.

View turicas's full-sized avatar

Álvaro Justen turicas

View GitHub Profile
@turicas
turicas / list_pt_same_normalized.py
Created September 22, 2026 15:57
List Common Voice duplicate sentences for Portuguese
#!/usr/bin/env python3
"""Find Portuguese sentences with different sentence_ids that match after normalization.
Normalization: lowercase, drop commas and periods, collapse whitespace. A group is reported when two or more distinct
sentence_ids share that key.
Usage:
python3 list_pt_same_normalized.py validated.tsv pt-same-text.tsv
"""
@turicas
turicas / secure_delete.py
Created April 9, 2026 11:59
Securely delete a list of files/directories
#!/usr/bin/env python3
"""
Securely delete directories, making file recovery via software tools (testdisk, photorec, extundelete etc.)
impractical.
Per-file strategy:
1. Overwrite contents 3x (zeros, ones, random), writing at least MIN_OVERWRITE_BYTES even for small files
2. Truncate to 0 bytes
3. Rename to a random name (destroys original directory entry)
4. Unlink
@turicas
turicas / xls2csv.py
Created March 11, 2026 15:30
Converte XLS para CSV, eliminando linhas e colunas totalmente em branco
# pip install xlrd
import argparse
import csv
from functools import lru_cache
from pathlib import Path
import xlrd
@lru_cache(maxsize=64 * 1024)
@turicas
turicas / telegram.py
Created December 2, 2025 19:28
CLI to send messages via Telegram API Bot (using only Python stdlib)
import argparse
import os
import sys
from http.client import HTTPResponse
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
def send_telegram_message(token: str, chat_id: int, message: str, parse_mode: str, timeout: float) -> HTTPResponse:
@turicas
turicas / LICENSE
Last active October 31, 2025 16:55
Script Python para fazer sorteios (específico para a PythonBrasil 2025)
Copyright 2025 Álvaro Justen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
@turicas
turicas / python-tuple-creation-time.sh
Created April 10, 2025 00:14
Python tuple creation from list comprehesion is faster than from generator expression
#!/bin/bash
python -m timeit 'tuple(n for n in range(100))'
# Result: 100000 loops, best of 5: 2.09 usec per loop
python -m timeit 'tuple([n for n in range(100)])'
# Result: 200000 loops, best of 5: 1.13 usec per loop
@turicas
turicas / README.md
Created March 22, 2025 16:03
Configure SOCKS proxy in Splinter for both Firefox and Chrome (with and without selenium-wire)

Configuring a Socks Proxy in Splinter

I only found documentation regarding HTTP proxies on Splinter, but sometimes I just want to run ssh -D 1234 some-machine and get the SOCKS proxy on port 1234 to work with the Splinter browser. After many tests, I created these examples for Firefox and Chrome and all of them work.

For Web scraping tasks, sometimes having access to all the requests the browser made is a requirement, so I made examples for making this work with selenium-wire also. Since selenium-wire creates a proxy (so it can intercept requests between Selenium and the browser), the proxy configurations must be passed in a different way.

@turicas
turicas / keycloak_local_setup.py
Created March 7, 2025 06:38
Script to create keycloak realm, backend and frontend clients and user accounts
# pip install python-keycloak
import os
from keycloak import KeycloakAdmin
from keycloak.exceptions import KeycloakGetError
server_url = "http://keycloak:8080/auth/"
admin_username = "admin"
admin_password = "admin"
@turicas
turicas / README.md
Last active March 4, 2025 17:33
Transform original postgres Docker image into agensgraph
@turicas
turicas / README.md
Last active March 5, 2026 14:24
Python versions in Debian and Ubuntu official Docker images