Skip to content

Instantly share code, notes, and snippets.

View ppizarror's full-sized avatar

Pablo Pizarro R. ppizarror

View GitHub Profile
@ppizarror
ppizarror / scrollable_table_pygame_menu.py
Created March 10, 2023 21:18
Scrollable table within pygame menu using frames
import pygame
import pygame_menu
pygame.init()
surface = pygame.display.set_mode((600, 400))
# Create theme
theme = pygame_menu.themes.THEME_DARK.copy()
theme.title_font_size = 30
theme.title_bar_style = pygame_menu.widgets.MENUBAR_STYLE_SIMPLE
@ppizarror
ppizarror / transform_korea_lh_dataset.py
Created September 23, 2021 19:53
Korea Land and Housing Corporation housing floor plans transformer
# Run this script within downloaded .zip from https://www.data.go.kr/data/15037046/fileData.do (August 2019)
# Contains 330 plans in bmp format, Resolution 230-5092.
import os
import cv2
import base64
# Retrieve all files
json_files = []
def get_files(cwd='.'):
@ppizarror
ppizarror / fft_registro.m
Last active September 28, 2019 00:31
Obtener FFT de un registro [Matlab]
% Carga el registro
data = detrend(load('accRoca.txt'), 0);
FS = 200; % Muestreo, 200 datos por segundo
% Encuentra la potencia que mas se ajusta al numero de datos
n = 2^nextpow2(length(data));
% Crea el vector temporal
tdata = zeros(n, 1);
for j = 2:n
@ppizarror
ppizarror / open_python_script
Created May 29, 2019 20:03
Call command using pygame-menu, in this code we call a python script using py command
# coding=utf-8
"""
The MIT License (MIT)
Copyright 2017-2019 Pablo Pizarro R. @ppizarror
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
@ppizarror
ppizarror / open_file.py
Last active May 29, 2019 18:17
Code that opens a external program (.exe) using pygame-menu
# coding=utf-8
"""
The MIT License (MIT)
Copyright 2017-2019 Pablo Pizarro R. @ppizarror
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
@ppizarror
ppizarror / boostrap v4 w3c fix
Created October 9, 2018 02:09
Boostrap v4 w3c sanitized
@media print {
*, ::after, ::before {
text-shadow: none !important;
box-shadow: none !important
}
a, a:visited {
text-decoration: underline
}
@ppizarror
ppizarror / addfigure_xy.py
Created February 20, 2017 03:43
Paste an image into a matlab plot to (x,y) coordinates
# coding=utf-8
"""
This function adds a figure to (x,y) position to a plot.
Autor: Pablo Pizarro @ppizarror.com, 2017.
"""
# Library importation
import matplotlib.pyplot as plt
from matplotlib.offsetbox import (OffsetImage, AnnotationBbox)
from matplotlib.cbook import get_sample_data
@ppizarror
ppizarror / choice_random_point.m
Created October 1, 2016 19:57
Elige un punto random de la lista de puntos
function point = choice_random( matrix, value )
%CHOICE_RANDOM_POINT Elige un valor random de los puntos (i,j) para los
%cuales matrix(i,j)=value
p = find_coordinates(matrix, value);
l = size(p,1);
r = randi([1 l],1,1);
point = p{r};
end
function list = find_coordinates( matrix, value )
%FIND_COORDINATES Encuentra las coordenadas de la posición de un valor VALUE
%en la matriz MATRIX
% Se obtiene el largo de la matriz
l = size(matrix);
% Se almacena una lista con todos los valores posibles (coordenadas)
coordenates_list = cell(l(1)*l(2),1);