Skip to content

Instantly share code, notes, and snippets.

@akaszynski
akaszynski / rdmem.c
Last active October 24, 2019 13:03
Simple demo to read and modify a remote array
/**
Copied most of the read from:
https://gist.github.com/FergusInLondon/fec6aebabc3c9e61e284983618f40730
Added write portion at the end
*/
#define _GNU_SOURCE
#include <sys/uio.h>
#include <stdio.h>
@akaszynski
akaszynski / check_version.py
Last active February 4, 2020 21:05
Check if a Python version string meets a minimum version
def version_tuple(v):
"""Converts a version string to a tuple"""
return tuple(map(int, (v.split("."))))
def meets_version(va, vb):
"""Check if a version string meets a minimum version.
Parameters
----------
@akaszynski
akaszynski / undervolt_iter.py
Created June 10, 2020 12:39
Undervolt Stability Tester
#!/usr/bin/python
"""Iteratively decrease the core and cache voltage offset until system
becomes unstable.
Requires:
- undervolt
start by running
$ sudo modprobe msr
@akaszynski
akaszynski / simple_paino.py
Created February 21, 2021 16:39
Simple script to capture
"""
Simple script to turn the keyboard into a basic piano.
Install dependancies with:
$ pip install pynput pysinewave
$ sudo apt install libportaudio2
This script has the bonus "feature" to listen the entire keyboard input, so
when it's running, when typing outside of the terminal it will still play
@akaszynski
akaszynski / keyboard
Created March 19, 2021 02:39
keyboard configuration file for global emacs remapping
# KEYBOARD CONFIGURATION FILE
# place at /etc/default/keyboard
# swaps capslock and ctrl
# swap right control with right alt
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
@akaszynski
akaszynski / check_version.py
Last active April 26, 2021 17:45
Implements a simple version check for a client/server pair.
"""
Implements a simple version check for a client/server pair.
Used when you want to verify if your server version is a minimum
value.
The decorator allows arguments within the decorator itself.
"""
@akaszynski
akaszynski / stress_pymapdl.py
Created May 7, 2021 16:37
Stress test pymapdl
"""Simple stress test for pymapdl"""
from ansys.mapdl.core import launch_mapdl, LocalMapdlPool
pool = LocalMapdlPool(10, nproc=1)
# mapdl =launch_mapdl()
def make_kp(mapdl):
mapdl.clear()
mapdl.prep7()
@akaszynski
akaszynski / refactor.py
Created May 24, 2021 04:46
refactor mapdl_functions
import re
import shutil
from pathlib import Path
import os
from typing import Optional, Union
from ansys.mapdl.core.mapdl_types import *
@akaszynski
akaszynski / create_surf.py
Created January 18, 2022 23:23
Create a simple PyVista PolyData from a set of points.
"""
Basic example to show how to turn a set of points into a surface, assign values,
and plot it using PyVista.
Points are stored in "data.csv". Points are structured and it's possible, though
slightly harder, to create a pyvista.StructuredGrid using them. Instead, its
much easier to simply to use the delaunay_2d filter.
"""
import numpy as np
@akaszynski
akaszynski / script.py
Created January 27, 2022 21:59
Demo how to write output from MAPDL to disk with PyMAPDL
# enter the solver routine and solve
mapdl.slashsolu()
output = mapdl.solve()
# write output to disk
with open('mapdl_output.txt', 'w') as fid:
fid.write(outout)