Skip to content

Instantly share code, notes, and snippets.

@akaszynski
akaszynski / release.sh
Created June 10, 2025 17:41
Automatically release a patch using pyproject.toml and git
function release() {
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "Working directory not clean. Commit or stash changes first."
return 1
fi
git checkout main
git pull
@akaszynski
akaszynski / automerge.sh
Last active June 10, 2025 17:33
Check if a PR is ready to merge using GH CLI and merge it if all checks pass.
# Monitors the current GitHub pull request and automatically merges it when ready.
#
# Conditions:
# - Runs up to 30 minutes, checking every 30 seconds (max 60 attempts).
# - Exits if any status checks fail.
# - Merges when the PR is open, mergeable, and has a clean merge state.
# - Uses squash merge and deletes the source branch.
#
# Output:
# - Logs status checks, elapsed time, merge success, or timeout.
@akaszynski
akaszynski / Read in Fluent CAS
Last active April 29, 2025 16:28
read-cas-movie.py
"""
Generate one video.
Loads all ducts, identifies a pairing between all that minimizes distance
between, morphs two, and then interpolates the solution between those two.
"""
from tqdm import tqdm
from pathlib import Path
@akaszynski
akaszynski / pyvista-hover-affine.py
Created April 29, 2025 14:19
PyVista - Hover on point and click to place affine widget
import pyvista as pv
import numpy as np
import vtk
import femorph
###############################################################################
from typing import cast, Sequence
import numpy as np
@akaszynski
akaszynski / surf_data_to_cells.py
Created June 6, 2024 22:13
Demonstrate mapping face centers from an external source to the cells of an unstructured grid.
"""
Demonstrate mapping face centers from an external source to the cells of an unstructured grid.
Assumptions:
- Points from the external source are close to the centers of the faces of the
extracted surface
"""
from pykdtree.kdtree import KDTree
@akaszynski
akaszynski / gen_cyclic_gmsh.py
Created October 30, 2023 21:14
Generates a hexahedral mesh model for rotor and stator geometry using the Gmsh library.
"""
This script generates a mesh model for rotor and stator geometry using the Gmsh library.
The mesh is then written to disk and subsequently read and converted into an archive file
with mapdl-archive for further FEM analysis. The module uses pyvista for optional visualization.
Generates a single cyclic sector.
Requirements
------------
@akaszynski
akaszynski / qt_tips.md
Created July 11, 2023 21:37
General PyQt tips and tricks

Implement Scaling

Scaling can only be set on initialization (or restart)

# Enable High DPI display with PyQt
os.environ.setdefault("QT_SCALE_FACTOR", str(rcParams["scale_factor"]))
if hasattr(QApplication, "setAttribute"):
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
@akaszynski
akaszynski / measure_widget.py
Created November 1, 2022 16:01
Add measure widget example
import time
import vtk
import pyvista as pv
cube = pv.Cube()
pl = pv.Plotter(notebook=False)
pl.add_mesh(cube) # <-- Add pygeometry stuff
@akaszynski
akaszynski / lego.py
Created October 10, 2022 15:42
gmsh + pymapdl + cadquery
#!/usr/bin/env python
# coding: utf-8
# In[12]:
import cadquery as cq
import pyvista as pv
from ansys.mapdl.reader import save_as_archive
@akaszynski
akaszynski / .emacs
Created May 17, 2022 19:55
My emacs init file
(require 'package);; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; --------------------------------------
;; (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)