Skip to content

Instantly share code, notes, and snippets.

@abul4fia
abul4fia / troceado.py
Last active January 8, 2021 11:38
Troceado óptimo
from math import ceil
def trocear_sin_minimo(lista, t_max):
"""Trocea la lista dada en el número mínimno de trozos de tamaño t_max, haciendo que
los trozos tengan todos aproximadamente el mismo tamaño"""
t_lista = len(lista)
num_trozos = int(ceil(t_lista/t_max)) # Numero de trozos a crear (y es el mínimo posible)
tam = int(ceil(t_lista/num_trozos)) # Tamaño de cada bloque "grande" (cumple tam <= t_max)
n_peq = tam * num_trozos - t_lista # Numero de bloques "pequeños" (tendrían tamaño tam-1)
import socket
import threading
import queue
import time
import sys
class TCPServer:
def __init__(self, port, q):
self.clientes = []
self.port = port
def funciona():
print("Funciona")
AllKeysNames = ['Fondo', 'Cuerpo', 'Ojos', 'Color', 'Pinzas', 'Puas']
Keys_input = []
while len(AllKeysNames) > 1:
print(AllKeysNames)
ele = input("Elige uno: ")
if ele not in AllKeysNames:
print("No válido")
continue
Keys_input.append(ele)
@abul4fia
abul4fia / juego.py
Last active January 28, 2022 21:32
import random
misNombres = [
"Guillermo",
"Guille",
"GGD",
"GGD708",
]
dificultades = [1, 2, 3, 4]
@abul4fia
abul4fia / Planificador
Last active March 13, 2023 00:09
Planificación con Logseq
- ## 🔥 Tareas ==vencidas==
query-table:: false
#+BEGIN_QUERY
{
:query [
:find (pull ?block [*])
:in $ ?today
:where
[?block :block/marker ?m]
[(contains? #{"TODO"} ?m)]
@abul4fia
abul4fia / Flujo de trabajo.md
Last active April 18, 2023 00:24
Planificación tipo GTD con logseq
  • Basado en [[GTD]] y en un video de Youtube de OneStutteringMind, pero ligeramente adaptado por mi.
  • Flujo de trabajo

    • Fase de captura de información

      • Añadir directamente en la agenda las cosas que tenga en la cabeza y no quiera olvidar, con el tag #inbox
      • También se pueden añadir desde el móvil enviando un mensaje a Telegram y usando mi script para descargarlo
    • Fase de análisis (clarify)

      • Se revisan los elementos de la etiqueta #inbox y se mira en qué caso se está:
        • Requiere acción (yo, o alguien, debe hacer algo acerca de este tema, para que cierto proyecto avance)
        • No requiere acción (es material de lectura o aficiones)
    • Fase de Organización

@abul4fia
abul4fia / pegar-codigo-en-stack-overflow.md
Last active June 12, 2023 16:47
Como pegar código correctamente en Stack Overflow

Cómo pegar código correctamente en Stack Overflow

Aburrido de ver código mal formateado en muchas preguntas de usuarios nuevos, he decidido crear este mini-documento.

  1. Selecciona en tu editor el código que deseas pegar. Asegúrate de que está correctamente indentado, lo cual es especialmente importante si el código es Python). Por ejemplo el siguiente:

    while not f.eof():
       l = f.readline()

if f.startswith("#"):

@abul4fia
abul4fia / fixed_fixing.py
Created June 20, 2023 07:32
How to fix objects and transforms in a manim 3D scene
# Context:
#
# Although ThreeDScene has the method `self.add_fixed_in_frame_mobjects()`
# it doesnt work as expected if you want to have transforms that happen
# in the frame coordinates, instead of in 3D coordinates
#
# See https://discord.com/channels/581738731934056449/1120217688728424549/1120217688728424549
#
# This fix fixes the fixed objects in a different way that works under transforms
@abul4fia
abul4fia / manim_textbox.py
Created June 26, 2023 18:26
Text box for manim
def create_textbox(string, width, height, text_color=BLACK, align=ORIGIN, color=BLUE, buff=0.2):
tex_align = {
tuple(UL): "\\raggedright",
tuple(LEFT): "\\raggedright",
tuple(DL): "\\raggedright",
tuple(UP): "\\centering",
tuple(ORIGIN): "\\centering",
tuple(DOWN): "\\centering",
tuple(UR): "\\raggedleft",
tuple(RIGHT): "\\raggedleft",