Skip to content

Instantly share code, notes, and snippets.

View astrojuanlu's full-sized avatar

Juan Luis Cano Rodríguez astrojuanlu

View GitHub Profile
@astrojuanlu
astrojuanlu / navier_plate_fenics.py
Last active May 3, 2024 21:21
Navier plate in Python with FEniCS
# coding: utf-8
"""Simply supported rectangular plate on its four edges with FEniCS
Author: Juan Luis Cano Rodríguez <juanlu@pybonacci.org>
References
----------
* Timoshenko, Stephen, and S. Woinowsky-Krieger. "Theory of Plates and Shells".
New York: McGraw-Hill, 1959.
@astrojuanlu
astrojuanlu / dft_scipy.ipynb
Last active April 30, 2024 17:14
Transformada de Fourier discreta en Python con SciPy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astrojuanlu
astrojuanlu / mecanica_sympy.ipynb
Last active February 29, 2024 02:57
Mecánica con SymPy, parte I: Álgebra vectorial y Cinemática
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astrojuanlu
astrojuanlu / bezier_curves.py
Last active September 25, 2023 13:09
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 / python3_https_server.py
Last active August 3, 2023 08:20 — forked from stephenbradshaw/python3_https_server.py
Python 3 Simple HTTPS server with Certbot (for Let's Encrypt)
#!/usr/bin/env python3
# Create a basic certificate using Certbot (for Let's Encrypt) and Ansible:
# https://github.com/geerlingguy/ansible-role-certbot
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
domain = "example.com" # Edit with your domain
httpd = HTTPServer(("0.0.0.0", 443), SimpleHTTPRequestHandler)
@astrojuanlu
astrojuanlu / navier_plate_interpolate.py
Last active July 23, 2023 18:08
Navier solution of a simply supported rectangular plate
# coding: utf-8
"""Navier solution of a simply supported rectangular plate.
Author: Juan Luis Cano Rodríguez <juanlu001@gmail.com>
References
----------
* Timoshenko, S., & Woinowsky-Krieger, S. (1959). "Theory of plates and
shells" (Vol. 2, p. 120). New York: McGraw-hill.
@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 / levicivita.py
Created May 13, 2012 19:08
Símbolo de Levi-Civita en Python
# coding: utf-8
# Símbolo de Levi-Civita en Python utilizando listas por comprensión
# Fórmula extraída de http://en.wikipedia.org/wiki/Levi-Civita_symbol#Three_dimensions
# Válido para Python 2 y 3
#
# Juan Luis Cano Rodríguez <juanlu001@gmail.com>
from __future__ import print_function
import numpy as np
@astrojuanlu
astrojuanlu / ansible-notes.md
Created November 29, 2022 11:21
Ansible, there we go again
  • To install: pipx install ansible --include-deps
    • If no --include-deps, the actual ansible command, part of ansible-core (a dependency of the ansible metapackage), is not included by pipx
  • Some definitions
    • A host is a remote machine managed by Ansible
    • An inventory is a file that describes a list of managed nodes or hosts that are logically organized in groups
    • A module is a unit of work that Ansible ships to a host
      • Usually written in Python (although more languages are supported)
      • They return a JSON and they are removed from the host after execution
      • For example
  • ansible.builtin.setup is called automatically by playbooks during the implicit "Gather Facts" task
@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