Skip to content

Instantly share code, notes, and snippets.

View vjvelascorios's full-sized avatar
🎯

vjvelascorios vjvelascorios

🎯
View GitHub Profile
@vjvelascorios
vjvelascorios / banxico_lib_updates.py
Created May 9, 2024 05:07
Download Banxico's Library monthly updates
import os
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
from datetime import datetime
# URL
url = "https://www.banxico.org.mx/servicios/boletin-mensual-de-la-biblioteca-del-banco-de-mexi/boletin-mensual-biblioteca-pu.html"
# Carpeta local donde se guardarán los archivos PDF
@vjvelascorios
vjvelascorios / weekly cran automation.ps1
Last active April 27, 2024 07:11
basic task programming execution and push
# Running Rscript
$fecha = Get-Date -Format "yyyy-MM-dd"
Start-Process "Rscript.exe" -ArgumentList "C:\Users\vjvelascorios\Documents\weekly-cran-packages\code\CRAN Package Tables WindowsVersion.R" -NoNewWindow -Wait
# repo update
cd "C:\\Users\\vjvelascorios\\Documents\\weekly-cran-packages"
git add .
git commit -m "Weekly update - $fecha" #not tested with "fecha" legend
git push
#!/bin/bash
script_path=$(realpath "${BASH_SOURCE[0]}")
cd "$(dirname "$script_path")"
shopt -s extglob
find . -maxdepth 1 -type f ! -name "*.pdf" ! -name "*.md" ! -name "*.tex" ! -name "$(basename "$script_path" | tr -d '[:space:]')" -exec rm {} +
@vjvelascorios
vjvelascorios / chol_decomp.jl
Created April 16, 2024 01:35
cholesky decomp
# Paso 1: Matriz simétrica y definida positiva
A = [4.0 2.0 -1.0;
2.0 5.0 3.0;
-1.0 3.0 6.0]
# Paso 2: Vector de términos constantes
b = [1.0, 2.0, 3.0]
# Paso 3: descomposición de Cholesky
L = cholesky(A).L
mkdir="~/localsites"
base_dir="/home/vjvelascorios/localsites"
for url in "$@"
do
sitio=$(echo "$url" | awk -F[/:] '{print $4}')
mkdir -p "$base_dir/$sitio"
httrack "$url" -O "$base_dir/$sitio"
done
# Get date (YYYY-MM-DD)
$fecha = Get-Date -Format "yyyy-MM-dd"
# URL
$url = "https://www.elfinanciero.com.mx/graficos/edicion-impresa/download.php?file=edicion-digital.pdf"
# Download folder
$carpeta_descargas = "C:\Users\vjvelascorios\Desktop\El Financiero"
# Filename
@vjvelascorios
vjvelascorios / dumpfold
Last active December 12, 2023 05:28
cli tool to dump all files inside child folders to the upper level
##!/bin/bash
#
#notes:
# - yes, maybe mv /a/b/*.extensionfile /a/b it's simple
# - just move this file to /usr/local/bin/
# - from 6 to 13 is a first experiment with this tool
# - to move files safely to bin is necessary install trash-cli
# - rsync was replaced for simple mv command for a better performance
@vjvelascorios
vjvelascorios / alias_renamevideos.sh
Created November 13, 2023 07:40
include resolution in videos filename
alias renombrarvideos='find . -maxdepth 1 -type f \( -name "*.mp4" -o -name "*.mkv" -o -name "*.webm" \) -exec bash -c '\''
for file; do
resolution=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "$file" 2>/dev/null)
ext="${file##*.}"
if [ -n "$resolution" ] && ! [[ "$file" =~ "_$resolution" ]]; then
newname="$(basename "$file" ".$ext")_$resolution.$ext"
mv "$file" "$newname"
fi
done
'\'' bash {} +'
#!/bin/bash
# Verificar directorio
if ! ls *.pdf 1> /dev/null 2>&1; then
echo "Error: No se encontraron archivos en el directorio actual"
exit 1
fi
# Nombre del directorio actual
folder_name=$(basename "$PWD")
niveles <- function(x) {
resultado <- levels(as.factor(x))
return(resultado)
}
if (interactive() && requireNamespace("rsthemes", quietly = TRUE)) {
# Set preferred themes if not handled elsewhere..
rsthemes::set_theme_light("base16 Summerfruit Light {rsthemes}") # light theme
rsthemes::set_theme_dark("base16 Brewer {rsthemes}") # "base16 Brewer {rsthemes}" "base16 PhD {rsthemes}"