Skip to content

Instantly share code, notes, and snippets.

@igarag
igarag / Git.md
Last active February 11, 2022 18:57
Remove secrets from git repository

Remove secrets

Using filter-repo

Install

pip install -U git-filter-repo
@igarag
igarag / split_dataset.sh
Created September 20, 2021 11:58
Move n files from one directory to another.
# Move n files from one directory to another.
# Useful for separating datasets in train/val
# that do not have code implemented in the training itself.
#!/bin/bash
i=0
j=$(stat source_folder/* --printf "%i\n" | wc -l )
NUM_FILES=314
@igarag
igarag / align_dataset.py
Created September 20, 2021 11:54
Remove from the image folder any image that is not in the labels folder.
"""
Source: https://unix.stackexchange.com/questions/528490/python-removing-jpg-files-without-matching-txt-files
Remove from the image folder any image that is not in the labels folder.
It is recommended to make a previous raw folder for security. In the opposite
case (more labels than images) rename the necessary directories and variables.
.
├── images
│ ├── 1.jpg
│ ├── 2.jpg
import numpy as np
import cv2
cap = cv2.VideoCapture('path_to_video.mp4')
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
name = 'output.mp4'
out = cv2.VideoWriter(name, fourcc, 25.0, (1920, 1080))
@igarag
igarag / separate_nested_list.py
Last active January 30, 2020 08:30
Convert list of lists or nested list to flat list (without brackets).
"""
(Does not work on python2)
Input example:
--------------
main_list =
[
[[3, 100, 37, 142, 96]],
[[3, 246, 37, 290, 97], [3, 101, 37, 143, 96]],
[[1, 194, 6, 233, 73], [1, 156, 6, 195, 72], [3, 246, 38, 290, 99], [3, 102, 39, 146, 98], [4, 85, 74, 133, 115], [7, 284, 168, 355, 236]],
@igarag
igarag / videos.md
Last active June 7, 2020 12:26
Comandos ffmpeg

ffmpeg commands

Extract all video frames and save it in png format

ffmpeg -i <<video>> -vf "select=eq(pict_type\,I)" -vsync vfr frame_%04d.png -hide_banner

Convert from mvk to mp4

@igarag
igarag / python_commands.md
Last active March 4, 2020 10:50
Pequeños atajos y comandos en Python

Python commands

Virtual env SIN paquetes instalados

virtualenv --no-site-packages my-venv

Instalar programas desde git (Archlinux)

Enlace al foro donde se explica

Cuando clonas un repo, tiene que contener el siguiente archivo.

Makefile
PKGBUILD
...
@igarag
igarag / linux_commands.md
Last active February 22, 2024 08:47
Comandos en Linux para obtener información del sistema.

Linux - cheat sheets

Comandos generales

Descripción Comando
Eliminar ficheros por fecha (todos los que superen la fecha) find /opt/backup -type f -mtime +30 -exec rm -f {} \;
Eliminar ficheros por nombre find /var/log -name "*.log" -type f -mtime +30 -exec rm -f {} \;
Calcular y ordenar directorios por tamaño sudo du -sch [!.]* *
Detectar máquinas con nmap nmap -sn 192.168.0.1-254 ó nmap -v -sn 192.168.0.0/24
@igarag
igarag / docker_cheatsheet.md
Last active August 6, 2019 21:57
Docker commands

Docker

Comandos básicos

Descripción Comando
Bajar imagen de Ubuntu docker pull ubuntu:18.04
Listar imágenes descargadas docker images
Arrancar un contenedor vía IMAGE ID o TAG docker run -it IMAGE_ID bash
Arrancar un contenedor vía TAG docker run -it ubuntu:18.04 bash