Skip to content

Instantly share code, notes, and snippets.

@eudoxos
eudoxos / 01-create.py
Last active March 3, 2022 12:34
uoi-heavystruct
import mupif as mp
import tqdm
# schemata must be passed at string to HeavyStruct constructor
# they are only needed when creating the container for the first time
# any subsequent access uses schemata stored in the container itself
schemata=open('schemata.json').read()
# schemaName specifies the top-level schema
# to create molecule-only container, say schemaName='gr.uoi.kostis.molecule', as in the second example
@eudoxos
eudoxos / IRsend-test-libs.ino
Created May 24, 2020 07:59
Comparing IR sending libraries for Arduino
// send a single IR NEC-encoded frabe over IR using 3 different libs
// #define LIB_IRREMOTE
// #define LIB_IRLIB2
#define LIB_IR4A
const byte IR_CMD=0xe0;
const byte IR_DEV = 0x00;
// frame structure: devId, 0xff-devId, cmd, 0xff-cmd
union Frame { uint32_t data; byte b[4]; };
#include<vector>
#include<type_traits>
#include<Eigen/Eigen>
#include<xtensor/xtensor.hpp>
#include<xtensor/xarray.hpp>
#include<iostream>
using std::cerr;
@eudoxos
eudoxos / hdf5_clean_close.hpp
Last active February 21, 2020 06:19
Disable HDF5 locking with library version 1.10 (POSIX), clean close
#include<H5cpp.h>
#include<sys/file.h>
#include<iostream>
/* With libhdf5 1.10, file gets locked but the lock is not removed at close.
Thus opening the file from the same process will fail.
This function will force unlock before the file is closed.
3 things must be done, in this order:
@eudoxos
eudoxos / sobel-filters.cpp
Last active March 22, 2019 13:26
sobel gradient filter kernel (along X), integral and floating-point (c++17, Eigen)
#include<Eigen/Core>
#include<iostream>
#include<numeric>
// based on and verified with https://stackoverflow.com/a/46262628/761090
// works for size 11 with int and 15 with long int (on amd64)
template<typename Int>
std::tuple<Eigen::Matrix<Int,Eigen::Dynamic,Eigen::Dynamic>,Int> sobelGradFilterX_int(int sz){
assert(sz>0);