Skip to content

Instantly share code, notes, and snippets.

@astrojuanlu
astrojuanlu / bezier_curves.py
Last active March 11, 2026 16:38
Interactive Bézier curves with Python using just matplotlib.
import matplotlib
matplotlib.use('webagg')
import numpy as np
from scipy.special import binom
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
@astrojuanlu
astrojuanlu / gist:540d392a6f1611e1cdbddaa85b9915c9
Last active February 17, 2026 16:01
Simple audit log listener for MinIO AIStor Server
$ python3 -u -c "from http.server import BaseHTTPRequestHandler, HTTPServer;
class S(BaseHTTPRequestHandler):
def do_POST(self):
l = int(self.headers['Content-Length'])
print(self.rfile.read(l).decode('utf-8'), flush=True)
self.send_response(200); self.end_headers()
def log_message(self, format, *args): return
HTTPServer(('0.0.0.0', 8099), S).serve_forever()" | tee minio.txt
$ tail -f minio.txt | jq --unbuffered -r '. |
"[\(.time[11:19])] \(.remotehost) | \(.api.name) " +
@astrojuanlu
astrojuanlu / async_jsonapi.py
Created April 28, 2022 10:57
Retrieving all paginated results from a JSONAPI using Python, httpx, and asyncio
import asyncio
import os
import httpx
async def get_all(url, headers):
result = {}
next_url = url
@astrojuanlu
astrojuanlu / juego-vida.py
Created November 6, 2012 16:40
Juego de la vida de Conway en Python
# coding: utf-8
"""Juego de la vida de Conway.
Autor: Juan Luis Cano <juanlu001@gmail.com>
El tablero es un array de NumPy, donde 0 significa célula muerta y 1 célula
viva. Se muestra una animación con matplotlib.
"""
@astrojuanlu
astrojuanlu / dft_scipy.ipynb
Last active January 9, 2025 21:19
Transformada de Fourier discreta en Python con SciPy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astrojuanlu
astrojuanlu / example.yaml
Last active December 18, 2024 09:38
Experiments with YAML and JSON5
document:
key1: "value1"
key2: "value2"
list1:
- "item1"
- "item2"
- dictionary1:
key3: "value3"
key4: "value4"
list2:
@astrojuanlu
astrojuanlu / aiormq_consumer.py
Last active November 26, 2024 21:41
Asynchronous RabbitMQ/AMQP client using aiormq with graceful cancellation.
import asyncio
import logging
import os
import aiormq
logger = logging.getLogger(__name__)
RABBITMQ_HOST = os.environ["RABBITMQ_HOST"]
RABBITMQ_PORT = os.environ["RABBITMQ_PORT"]
@astrojuanlu
astrojuanlu / plot_galilean.py
Last active October 16, 2024 07:10
Plot Galilean moons in Python with poliastro
from astropy.time import Time
from astropy.coordinates import CartesianRepresentation
from matplotlib import pyplot as plt
from poliastro.twobody import Orbit
from poliastro.bodies import Jupiter
from poliastro.frames import get_frame, Planes
from poliastro.plotting.static import StaticOrbitPlotter
def change_attractor(orbit, new_attractor, plane=Planes.EARTH_EQUATOR):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astrojuanlu
astrojuanlu / Walker constellations.ipynb
Last active August 25, 2024 14:14
Analysis of Walker constellations (star pattern) following the 1970 report.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.