Skip to content

Instantly share code, notes, and snippets.

View turicas's full-sized avatar

Álvaro Justen turicas

View GitHub Profile
@turicas
turicas / kdenlive_cuesheet_tkinter.py
Created December 13, 2024 17:44
Python script with Tkinter interface to extract clip/timeline data from Kdenlive project file and create a "cue sheet" (no external dependencies)
#!/usr/bin/env python3
import csv
import os
import tkinter as tk
import xml.etree.ElementTree as ET
from pathlib import Path
from tkinter import filedialog, messagebox
def get_properties(element):
@turicas
turicas / embeddings.py
Created November 25, 2024 19:30
Image embedding using timm and Dinov2
from pathlib import Path
import timm
import torch
from PIL import Image
class FeatureExtractor:
"""Extract embeddings from images using timm's Dinov2 models"""
model_names = (
@turicas
turicas / faces.py
Created November 18, 2024 17:06
Face recognition script using face_recognition Python library
# Requirements:
# sudo apt update && sudo apt install -y cmake
# pip install face-recognition numpy opencv-python Pillow tqdm
import cv2
import face_recognition
import numpy as np
from PIL import Image
from tqdm import tqdm
@turicas
turicas / create-tags
Created April 4, 2024 22:16
Create ctags-like file using tree-sitter and awk
#!/bin/bash
filename="$1"
if [[ -z $filename ]]; then
echo "ERROR - usage: $0 <filename>"
exit 1
fi
transformation_code='
@turicas
turicas / cidade_exterior.csv
Last active February 9, 2024 02:13
Script que cria dados de exemplo de pessoas e empresas para serem usados em demonstrações
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
cidade_exterior
ABLASSERDAN
A CORUNA
ACRA
ADDISON
AGUEDA
AICHI-KEN
ALAMEDA
ALBLASSERDAM
ALCALA DE HENARES
@turicas
turicas / gist:27aa6a137f3e239c1535818fe82799d5
Created September 20, 2023 17:22
Python's timezoned now() (using only standard library)
import datetime
import time
def timezoned_now():
"""Equivalent to `datetime.datetime.now()` but replaces `tzinfo` with local timezone offset"""
offset = time.timezone if time.localtime().tm_isdst == 0 else time.altzone
delta = datetime.timedelta(seconds=-offset)
timezone = datetime.timezone(offset=delta)
@turicas
turicas / rescue.sh
Created May 4, 2023 03:51
Copy all the possible files from a failing disk (I/O error)
#!/bin/bash
# XXX: replace /dev/sdb1 with the partition you'd like to rescue
sudo apt update && sudo apt install -y gddrescue
sudo time ddrescue /dev/sdb1 /path/to/file.raw /path/to/ddrescue.log --try-again --force --verbose
sudo mkdir -p /mnt/rescued
sudo mount -o ro,loop /path/to/file.raw /mnt/rescued
cd /mnt/rescued # enjoy :)
@turicas
turicas / srt_unique.py
Created May 4, 2023 00:05
Filter repeated captions on SRT files
# pip install srt
import argparse
import srt
parser = argparse.ArgumentParser()
parser.add_argument("input_filename")
parser.add_argument("output_filename")
args = parser.parse_args()
@turicas
turicas / pdf_plot.py
Created April 26, 2023 00:22
Plot PDF text/rect objects' using rows + Pillow
# pip install pillow cached-property pdfminer.six https://github.com/turicas/rows/archive/develop.zip
import argparse
from rows.plugins.plugin_pdf import (
RectObject,
TextObject,
PDFMinerBackend,
group_objects,
YGroupsAlgorithm,
plot_objects,
@turicas
turicas / Transcrição de textos em Português com whisper (OpenAI).ipynb
Last active December 11, 2024 09:41
Transcrição de textos em Português com whisper (OpenAI)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.