Skip to content

Instantly share code, notes, and snippets.

@tristobal
tristobal / rename_imgs.py
Last active January 4, 2019 14:10
Script para renombrar imágenes a partir de la fecha en la que fueron tomadas.
from itertools import chain
import datetime
import exifread
import os
import shutil
TAG_DATE_TIME_ORIGINAL = "EXIF DateTimeOriginal"
IMAGES_FIRST_PATH_ORIGIN = "/home/user/Pictures/Photos/First"
IMAGES_SECOND_PATH_ORIGIN = "/home/user/Pictures/Photos/Second"
@tristobal
tristobal / send.py
Created March 2, 2020 20:26
Script para enviar un mensaje con headers a una cola RabbitMQ desde python
import pika
routing_key = 'test'
#Mensaje con formato JSON
message = """
{
"hola": "mundo",
"lorem": "ipsum"
}"""
@tristobal
tristobal / automate_translation_deepl.py
Last active April 20, 2022 19:15
From a file with word/phrases in english (one per lin) this script translate them using deepl.com
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
import time
@tristobal
tristobal / RSAUtils.java
Last active January 15, 2021 16:14
Read RSA keys from file
package com.globant.augmented.coding.auth.security.jwt;
import org.springframework.core.io.ClassPathResource;
import sun.misc.BASE64Decoder;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.interfaces.RSAPrivateKey;
@tristobal
tristobal / create_module.py
Last active May 5, 2022 19:37
Python script to create a module for FoundryVTT with your compendiums
"""
The idea for this script is to have a tiny "world" with your custom compediums and then export it as a new module.
This file must be located in your world folder, for example:
"<foundrydata folder>/Data/worlds/<your module name>"
"""
import json
import os
@tristobal
tristobal / move_mouse.py
Last active September 25, 2024 17:55
Python script that performs circular cursor movements every X minutes (3 by default) and shutdown the computer at fixed time.
import datetime as dt
import logging
import math
import os
import random
import sys
import time
import pyautogui
@tristobal
tristobal / stop_long_running_tasks.py
Created November 16, 2021 18:19
Airflow DAG that search and stop long running tasks
import airflow
from airflow import settings
from airflow.models import clear_task_instances, DAG, TaskInstance, Variable
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
from airflow.utils.state import State
from datetime import datetime, timezone
import logging
# Seconds in an hour
@tristobal
tristobal / deleteme.py
Created December 14, 2021 19:25
Passing a variable from a DAG to an external function
# dags/deleteme.py
from datetime import timedelta
from airflow import DAG
from airflow.operators.dummy import DummyOperator
from airflow.utils.dates import days_ago
from includes.taskgroup import build_taskgroup
@tristobal
tristobal / letters_to_word.py
Last active March 17, 2022 01:09
Letters to (spanish) words using pyenchant
from itertools import permutations
import enchant
def prepare_list(word_):
new_letters = [word_]
for i_, letter in enumerate(word_, start=0):
if letter in 'aeiou':
new_letter = letter + u'\u0301'
@tristobal
tristobal / translate_coc7-module-fr-toc.py
Created July 8, 2022 17:05
translate_coc7-module-fr-toc
import json
from googletrans import Translator
from functools import reduce
def deep_get(dictionary, keys, default=None):
return reduce(lambda d, key: d.get(key, default) if isinstance(d, dict) else default, keys.split("."), dictionary)