Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / example.py
Last active November 3, 2023 16:44
Generic sequences of animations run in paralell (for Manim)
from sequences import play_sequence_in_background, join_all
class Test(Scene):
def construct(self):
c = Circle()
sq = Square().to_corner(UR)
seq1 = play_sequence_in_background(self,
[
FadeIn(c, run_time=2),
ApplyMethod(c.shift, 3*RIGHT, run_time=3),
@abul4fia
abul4fia / 00README.md
Last active May 15, 2024 17:49
Finding sub-texts by shape in manim

Finding shapes in Tex mobjects

This module implements some utility functions to search some shapes (formulas, symbols) inside a Tex (or MathTex) mobject.

The approach is to compare the shapes (bezier curves) of the symbols, instead of the particular strings that produced them. This approach is generic and avoids the use of other manim mechanisms that would break under some circunstances, such as the presence of \frac{}{} in a formula.

The function you would probably want to use is group_shapes_in_tex(). Despite the confusing name, the goal is to find all the occurences of a given symbol (or group of symbols, or list of symbols) inside a Tex mobject, and return a VGroup containing them