Skip to content

Instantly share code, notes, and snippets.

@Dalboz
Dalboz / rupturas_fechas.bas
Last active September 6, 2024 16:36
Ruptura para el rango de fechas seleccionadas
Function SplitYear01(fechainicio As Date, fechaFin As Date) As Variant
Dim fechaActualInicio As Date
Dim fechaActualFin As Date
Dim finAnoFiscal As Date
Dim umatriz As Collection
Dim tupla() As Variant
Dim i As Integer
Dim count As Integer
' Crear una colección para almacenar las tuplas
@Dalboz
Dalboz / nuevacuenta.bas
Last active July 4, 2024 20:57
Utils para mantener el fichero de spending y el fichero de carga
Sub AddNewAccounts()
' Desactivar la actualización de pantalla y el cálculo automático para mejorar el rendimiento
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim wsParam As Worksheet
Dim ws As Worksheet
Dim lastRow As Long
' Establecer la hoja "param"
@Dalboz
Dalboz / cargaVariables.bas
Created May 1, 2024 21:16
Rutina para crear archivos planos de carga SAP
Sub SplitExcelFile()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim chunkSize As Long
Dim outputFolder As String
Dim outputFileName As String
Dim totalValues As Long
Dim chunkCounter As Long
Dim chunkValues As Long
@Dalboz
Dalboz / Copy-FolderStructure.ps1
Last active March 12, 2024 20:40
win folder utils
# Function to show a folder selection dialog
function Get-FolderDialog($initialDirectory) {
$folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$folderBrowser.RootFolder = [System.Environment+SpecialFolder]::MyComputer
$folderBrowser.SelectedPath = $initialDirectory
$folderBrowser.ShowNewFolderButton = $false
$result = $folderBrowser.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
@Dalboz
Dalboz / dep.ps
Last active March 12, 2024 20:45
depreciation calculation
function Calculate-Amortization {
param (
[int]$assetNumber,
[double]$acquisitionCost,
[int]$usefulLife,
[string]$usefulLifeUnits,
[string]$depreciationStartDate,
[string]$capitalizationDate
)
@Dalboz
Dalboz / precios_dia.py
Last active February 19, 2024 19:10
Scrapping de precios para productos del DIA
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Script para scrappear productos de los Supermercados DIA
# Necesita tener instalado el parser lxml: sudo apt-get install python-lxml
from bs4 import BeautifulSoup
from requests import get
import locale
import re
import sys
@Dalboz
Dalboz / steps.sh
Created November 6, 2022 00:00
Convert audio files with FFmpeg while retaining original metadata
# install ffmpeg for macOS
brew install ffmpeg
# invoke ffmpeg while stating that must copy the first stream of metadata
ffmpeg -i in.opus -map_metadata 0:s:a:0 out.mp3
# check the out file and verify the metadata
@Dalboz
Dalboz / ipc.html
Last active March 1, 2024 18:34
One-liner para obtener índices de precios del transporte
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Table from API with Bootstrap</title>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body class="bg-light">
// Calculando el FTE por centro de coste con base al importe facturado
SELECT a.Nombre_Trabajador,
a.Ceco,
sum(round(a.Particionado / b.Total, 4)) AS 'FTE',
sum(round(a.Particionado / b.Total, 4) * b.Total - a.Particionado) AS 'Check'
FROM (
(SELECT a.Nombre_Trabajador,
a.CECO,
sum(a.Base) AS 'Particionado'
/* 1. Crear: base de datos y seleccionarla */
CREATE DATABASE IF NOT EXISTS videoclub;
USE videoclub;
SET character_set_server = utf8mb4;
SET collation_server = 'utf8mb4_general_ci';
/* 2. Crear tabla: socio */
CREATE TABLE socios (
codigo VARCHAR(10) NOT NULL,
nombre VARCHAR(20) NOT NULL,
apellidos VARCHAR(30) NOT NULL,