Skip to content

Instantly share code, notes, and snippets.

View rmorenobello's full-sized avatar

Raúl Moreno Bello rmorenobello

View GitHub Profile
@rmorenobello
rmorenobello / format_table_with_quotes-ALL.py
Created November 20, 2025 12:45
Python scripts for Notepad++ to compress horizontally a text table with elements enclosed by " separated by spaces
# -*- coding: utf-8 -*-
# Script para Notepad++ usando el plugin PythonScript
# Formatea tablas con columnas delimitadas por comillas dobles, manteniendo las comillas.
# Se aplica a todo el contenido de la pestaña Notepad++ actual.
# Deja sólo dos espacios entre el final del elemento más largo y la siguiente columna.
#
# "COL1" "COL2" "COL3" "COL1" "COL2" "COL3"
# "VALUE1____________""" "VALUE3" --> "VALUE1____________" "" "VALUE3"
from Npp import editor
@rmorenobello
rmorenobello / Oracle - 1er evento tipo B tras evento tipo A.sql
Last active October 20, 2025 14:12
Oracle - 1er evento tipo B tras evento tipo A
/* Optimizada con analytic functions (un pase por analytic function como mucho, no consulta anidada fila a fila: */
WITH RankedOperations AS (
SELECT
ID,
ASS_ID,
FECHA,
TIPO,
-- Asignamos un número de secuencia a cada operación dentro de cada ciudadano
ROW_NUMBER() OVER (PARTITION BY ASS_ID ORDER BY FECHA, ID) AS rn
FROM
@rmorenobello
rmorenobello / Oracle-Group by rollup with titles.sql
Created October 15, 2025 12:23
Oracle - GROUP BY with rollup with titles
SELECT
CASE
WHEN GROUPING(REGION) = 1 THEN 'TOTAL GENERAL'
ELSE REGION
END AS REGION,
CASE
WHEN GROUPING(PRODUCTO) = 1 THEN 'TOTAL REGIÓN'
ELSE PRODUCTO
END AS PRODUCTO,
SUM(IMPORTE) AS TOTAL_VENTAS
# Remember str are immutable objects
# IMPORTANT: only worth it for really long strings!
# otherwise just use +=
# Summary: Append them to a list, join them with "".join()
charlist = []
text = ''
# it would also work for words, sentences, ...
for char in text_to_loop:
@rmorenobello
rmorenobello / matplotlib.py
Created October 20, 2022 17:23
DS - Data Visualization
import matplotlib.pyplot as plt # we only import pyplot
month_number = [1, 2, 3, 4, 5, 6, 7]
new_deaths = [213, 2729, 37718, 184064, 143119, 136073, 165003]
plt.plot(month_number, new_cases)
plt.ticklabel_format(axis='y', style='plain')
plt.title('New Reported Cases By Month (Globally)')
plt.xlabel('Month Number')
plt.ylabel('Number Of Cases')
@rmorenobello
rmorenobello / DQ-read_csv.py
Last active October 20, 2022 17:38
DS - input / output
import csv
file = open('dq_unisex_names.csv')
file_reader = csv.reader(file)
rows_list = list(file_reader)
file.close()
header = rows_list[0]
data = rows_list[1:]
@rmorenobello
rmorenobello / .gitattributes
Last active June 28, 2022 16:20
Git - python configurations
# Set default behavior to automatically normalize line endings to LF in Git repo.
* text=auto
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
# Force bash scripts to always use LF line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
PROJECT_DIR=/home/pentaho/projects
KETTLE_REDIRECT_STDERR=Y
KETTLE_REDIRECT_STDOUT=Y
KETTLE_MAX_LOGGING_REGISTRY_SIZE=10000
KETTLE_LOG_MARK_MAPPINGS=Y
KETTLE_JOB_LOG_SCHEMA=pentaho_dilogs
KETTLE_JOB_LOG_DB=live_logging_info
KETTLE_JOB_LOG_TABLE=job_logs
@rmorenobello
rmorenobello / Data Science - Resources
Last active October 20, 2022 17:28
DS - Data Science & Big Data Resources
Personal
========
* DataScience - Notes.ipynb
https://colab.research.google.com/drive/1gCPFfHLs3lYwCtShLN2SyarnWHoNNpxM
* Python - NumPy y Pandas.ipynb
https://colab.research.google.com/drive/1mRxlACazsHY4Iyp54vXtYNZRzTJTlT5r
* Data Science - Problem Solving strategies and tricks.ipynb
https://colab.research.google.com/drive/1NsBqiLOBY46U0bgPrx0Kpk207rhhGtdJ
* RM - Google Colab Cheatsheet.ipynb
https://colab.research.google.com/drive/1l1a9R884hNLwIhBk75FB0z95zmuTsMe4
https://www.mssqltips.com/sql-server-tip-category/52/sql-server-management-studio/