Skip to content

Instantly share code, notes, and snippets.

@diegocerdan
diegocerdan / chatgpt-temp-toggle.user.js
Created April 8, 2026 00:33
Userscript to create a shortcut in ChatGPT to toggle temporary chat
// ==UserScript==
// @name ChatGPT Temporary Chat Toggle
// @namespace https://chatgpt.com
// @version 1.0
// @description Double-tap Shift to toggle the temporary chat
// @match https://chatgpt.com/*
// @run-at document-idle
// @grant none
// @icon https://chatgpt.com/favicon.ico
// ==/UserScript==
@diegocerdan
diegocerdan / wa-dlp.py
Created April 19, 2025 00:09
Python script to convert an URL or a file to a WhatsApp-compatible video
#!/usr/bin/env python3
"""
wa-dlp.py - Download or convert videos to MP4 for WhatsApp compatibility.
This script uses yt-dlp to download a video (either from a URL or local file) and
automatically checks if the video is already in a WhatsApp-compatible format:
MP4 container with H.264 video and AAC audio. If the video meets these criteria,
it is copied without re-encoding. If not, the script converts the video to MP4.
@diegocerdan
diegocerdan / video2text.sh
Created February 20, 2024 16:40
video2text.sh
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <video_file> [language_code]"
exit 1
fi
video_file="$1"
base_name="${video_file%.*}"
output_file="${base_name}.txt"
@diegocerdan
diegocerdan / subtitle-scene-sync.py
Created October 2, 2022 02:05
Sync subtitles to video scenes
from scenedetect import detect, ContentDetector
import srt
import sys
from datetime import timedelta
video_file = sys.argv[1]
subtitle_file = sys.argv[2]
MAX_DIFF = 0.2
scenes = detect(video_file, ContentDetector())
@diegocerdan
diegocerdan / facebook_like_clicker.js
Created July 19, 2022 10:12
Clicks the Like button for a visible content on Facebook Business Messenger.
var xpath_FACE = "//*[contains(@class, 'sx_e5fb20')]"
var FACE = document.evaluate(xpath_FACE, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
FACE.click()
var xpath_LOVE = "//img[@src='https://static.xx.fbcdn.net/images/emoji.php/v9/t24/1.5/28/1f970.png']"
var LOVE = document.evaluate(xpath_LOVE, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
LOVE.click();
@diegocerdan
diegocerdan / facebook_done_clicker.js
Created July 19, 2022 10:07
Clicks the Done button on Facebook Business Messenger.
var xpath_CHECK = "//*[text()[contains(., 'Move to done')]]"
var CHECK = document.evaluate(xpath_CHECK, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
CHECK.parentElement.children[1].click();
@diegocerdan
diegocerdan / excel_manipulation.py
Created January 29, 2022 23:18
Using openpyxl to fill cells with index numbers in relation with cell color
import sys
from openpyxl import load_workbook
WHITE = '0.0'
COLOR_LEVEL = {
'0.3499862666707358' : 0,
'0.499984740745262' : 1,
'-0.499984740745262' : 1,
'-0.3499862666707358' : 2,
@diegocerdan
diegocerdan / wl-clipboard-filter.py
Last active September 26, 2019 18:57
Programatically edit your wayland clipboard
#!/bin/python
# execute:
# wl-paste -w ~/scripts/wl-clipboard-filter.py
#
# install, add to ~/.config/sway/config:
# exec "wl-paste -w ~/scripts/wl-clipboard-filter.py"
import sys
import subprocess
from urllib.parse import urlparse
@diegocerdan
diegocerdan / google-maps-autocomplete-style-hack.js
Last active November 14, 2016 00:43
Clean javascript hack to specify the otherwise fixed with of the Google Maps Autocomplete results.
var goalWidth = "500px";
function observeAutocomplete(node) {
var observer = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
if(mutation.target.style.width != goalWidth)
mutation.target.style.width = goalWidth;
});
});
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/google-apis/google-maps-api.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
<dom-module id="google-map-autocomplete">
<template>
<style>
:host {display: block;}
</style>