Skip to content

Instantly share code, notes, and snippets.

@LuchoLopez
LuchoLopez / yt-download.sh
Created March 14, 2024 16:04
Download MP3 music from YT
#!/bin/bash
# Please, make sure you have: python3, pytube and ffmpeg before running this script
DOWNLOAD_DIR="./downloads"
mkdir -p "${DOWNLOAD_DIR}"
pytube3 -a mp4 -t "${DOWNLOAD_DIR}" "${1}"
pushd "${DOWNLOAD_DIR}"
find . -type f -iname '*.mp4' -exec sh -c 'ffmpeg -i "$1" "${1%.*}.mp3"' sh {} \;
@LuchoLopez
LuchoLopez / firestore_ids_in.py
Created January 19, 2024 03:31
Firebase - Firestore get documents in IDs list
from google.cloud.firestore_v1.field_path import FieldPath
def get_metrics(user_ids: list, db_client):
return db_client.collection(f'users').where(FieldPath.document_id(), 'in', user_ids).stream()
@LuchoLopez
LuchoLopez / firestore_wildcards.py
Created January 18, 2024 19:14
Firebase - Firestore collection - Using wildcards
def replace_wildcards(db_client, collection_path: str):
"""
Returns a generator with all the elements paths matching the collection expression.
Wildcards are allowed: So, you can use 'user/*/collection/*/subcollection/*' to retrieve all the
documents matching that expression.
"""
collection_parts = collection_path.split('*')
if len(collection_parts) == 1:
yield collection_parts[0]
else:
@LuchoLopez
LuchoLopez / deslizable.js
Created July 12, 2013 13:00
no es de mi autoria, pero esta bueno tenerlo a mano
$(function () {
var $el = $('.fixedElement'),
originalTop = $el.offset().top; // store original top position
$(window).scroll(function(e){
if ($(this).scrollTop() > originalTop ){
$el.css({'position': 'fixed', 'top': '0px'});
} else {
$el.css({'position': 'absolute', 'top': originalTop});
}
@LuchoLopez
LuchoLopez / BorrarColaImpresion.cmd
Created April 18, 2013 15:58
This tiny program stops the service that handles the printer queue, deletes printer jobs and start the service again. It works on Windows only
@echo off
echo ** Deteniendo el servicio de impresion.
:: Detiene el servicio de impresion
@net stop spooler > nul
echo ** Eliminando trabajos de la cola de impresion.
:: Elimina los archivos .shd y .spl
@del %systemroot%\system32\spool\printers\*.shd
@del %systemroot%\system32\spool\printers\*.spl
echo ** Iniciando el servicio de impresion.
:: Vuelve a iniciar el trabajo de impresion
@LuchoLopez
LuchoLopez / modemUSB.sh
Created February 27, 2013 03:23
If you're using a USB modem like ZTE or Huaweii, this tiny script should setup the enviroment to get it working.
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@LuchoLopez
LuchoLopez / words.py
Created January 19, 2013 08:18
Procesa una palabra y es capaz de devolver la cantidad de veces que una letra se repite en la misma.
#!/usr/bin/env python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
@LuchoLopez
LuchoLopez / adblock.bat
Last active December 11, 2015 00:59
Block the fuc#@! MSN ads.
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
@LuchoLopez
LuchoLopez / README.txt
Created October 18, 2012 10:28
A little and simple GMail checker.
#
# Guia rapida
#
1. pygmail.py - Verifica los nuevos correos.
2. credentials.crd - Guarda sus credenciales encriptadas y es esencial para que pygmail.py funcione correctamente.
3. crypt_pygmail.py - Genera el archivo credentials.crd
4. Si usa crontab, es muy recomendable editar el valor de la variable "path_to_credentials_file" en el archivo pygmail.py para indicarle al programa exactamente donde encontrar el archivo credentials.crd
¿Problemas, sugerencias, etc? <luislopez72@gmail.com>
@LuchoLopez
LuchoLopez / equi.py
Created October 12, 2012 23:22
A little function that recives a list, return equilibrium index (-1 when no equilibrium index is found) or index+1 (only when the sum of all list components is equal to zero) and returns another list with solutions
# A is a list object
def equi ( A ):
# solution will store all solutions to the problem
solution = list()
# the sum of all list components
A_sum = 0
# iterates for each element in the list
for index in range( len( A ) ):
A_sum += A[index]
# stores the sum of all components at left of this index position