Skip to content

Instantly share code, notes, and snippets.

@xaedes
xaedes / list_valheim_portal_names.py
Created February 9, 2023 23:16
List Valheim Portal Names of given db file
#!python
import mmap
import argparse
def portals(dbfile):
with open(dbfile, 'rb') as db:
mm = mmap.mmap(db.fileno(), 0, access= mmap.ACCESS_READ)
i, l = 0, set()
while True:
@xaedes
xaedes / copilot-mk-pip-package.py
Last active October 7, 2022 13:36
a python script which accepts command line arguments for package name to create folders and files for empty pip installable python package with that name.
#-*- mode: python -*-
# -*- coding: utf-8 -*-
#
# made 85% by copilot.
# copilot-mk-pip-package.py
# ---
# a python script which accepts command line arguments for package name to create folders and files for empty pip installable python package with that name.
#
# 1. creates the directory structure for a python package
# 2. creates the setup.py file
@xaedes
xaedes / soa_np.py
Last active August 22, 2022 16:35
python class for dynamically resizeable struct of arrays (SoA) with numpy arrays
# MIT License
#
# Copyright (c) 2022 xaedes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@xaedes
xaedes / example_dynamic_soa_np.py
Created August 22, 2022 13:48
Example for dynamically resizeable SoA (struct of arrays) class using numpy arrays
class Trajectory:
def __init__(self, capacity):
self._capacity = capacity
self._size = 0
self.position = np.empty(shape=(self._capacity, 2), dtype=np.float64)
self.yaw = np.empty(shape=(self._capacity, 1), dtype=np.float64)
self.yawrate = np.empty(shape=(self._capacity, 1), dtype=np.float64)
def size(self):
return self._size
@xaedes
xaedes / Log Hightlight.sublime-settings
Created July 4, 2022 18:48
C++ Compile Error "Log Hightlight.sublime-settings"
{
/* Configuration ____________________________________________
*/
// enable context menu
"context_menu": true,
// Auto Highlight for a log file, build window
"auto_highlight" : true,
@xaedes
xaedes / cpp_encode_nmea_gga_zda.cpp
Created January 27, 2022 22:07
Encode NMEA GGA and ZDA messages using C++
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
char computeChecksum(const std::string& str)
{
char checksum = 0;
for (int i=0; i<str.size(); ++i)
@xaedes
xaedes / arithmetic_tuple_plus.cpp
Created May 31, 2021 22:42
Recursive arithmetic std::tuple example with operator+()
#include <iostream>
#include <tuple>
#include <type_traits>
// https://gist.github.com/ntessore/dc17769676fb3c6daa1f
namespace std14
{
template<typename T, T... Ints>
struct integer_sequence
{
@xaedes
xaedes / gist:de252d992dab0ca9c38867197f38f41a
Created May 23, 2021 15:50
simple autopilot for iss sim spacex
let a = setInterval(() => {
// retrieve values from simulation
let roll = fixedRotationZ;
let pitch = fixedRotationX;
let yaw = fixedRotationY;
let rpy = new THREE.Vector3(roll, pitch, yaw);
let rollRate = -rateRotationZ/10.0;
let pitchRate = -rateRotationX/10.0;
let yawRate = -rateRotationY/10.0;
@xaedes
xaedes / WebGL3DVisualizationInJupyterWithVispy_Demo.py
Created November 17, 2020 00:16
WebGL3DVisualizationInJupyterWithVispy_Demo
# demo video at https://www.youtube.com/watch?v=EjXU5WVjGU0
import ipywidgets as widgets
import numpy as np
import vispy
import vispy.gloo as gloo
from vispy import app
from vispy.util.transforms import perspective, translate, rotate
@xaedes
xaedes / factorio item box message signaling sender blueprint v2.txt
Created October 10, 2020 16:37
Sends X items to lower right chest when at least one item arrives on upper right chest (request). Makes sure the correct amount of items is sent with a small state machine. Sending will not start until all items are prepared.
0eNrdWlFvqzYU/isWT9tEqtiQkES7k6btdX25e6g0VZFLnMYqGGabdl2V/75jkiaUALEpTe/dSxvAfDbfd87hfMCLd5cULJdcaG/x4q2YiiXPNc+Et/C+MrFS6AZxzVKFdIaS7IlJJPn9RqN4w5RGTxsmENUoYRS2MsHKwYhKyR+Zgh2oyPPaOT9I9ncBP368Qn/QBxilCsmQ3jAUZ1KyWCOaZoUAuPV+ag5jGOx44nqDKFIpTRKkNNUMpTTecMGukFksF/cwBo6JTJvjUiPA4Qky43dQFKbKJcvh/+rK8z0eZ0J5i79ePMXvBU0MC/o5Z3D55gQYIWhqtqiEyVOmeTyKs/SOC6oz6W0BQazYP94Cb/2zGCsW8xWTzQBke+t7cJVcc7ZbUbnxvBRFesckzHDAMWvWVOgqkO/lmeI75V48wBuF5Grie8/eIoiuJjDPihtyywFT32BomSXLO7ahjxwA4Kw1TzSTLXQ8cqkL2HNYxW7E6MZcQ2wEA9xxhY/bcr8Qu0mVgcLmz71kTFQvkK/g6uHMmMu44LrcLumsHif147fbbWXMK0nEkaRgfhGSxhWScJUj+K2WZrY1TRRzYSyyIyQ4LsWkzSihad4ZLPOSh6Yrf50Ojq0OJ6+5VHrpSsROGm9hVM9SyMZSnoX3i7d14WDylgPSwkF4Josb6MA7MmaWQXHEPbKjetBDDD2KGQz7k6Csxg/mxAxKLd0X71+vf4eBWaHzwk0eJwGmdQFqWTs7Fcj3iH1M1+DmdjE/6a33fBi9jwGO3eXEdSlHFxAychMqqCmD21Jv2nXzayrHbnm3B31f0l1316QvPeg/pGSc5c/LsvAv1zJLl1wAzmu1dxEowG4KhXapEvXTZ35JfcZ9iiLesV/R8eceOuK+GkJ7eT7F/JZeqJZcYXeRba+x5xeBWxcxsYufmWP8RJ8QP1Q8azAJ9+daj88ND/zemyO2U2x+uAgtqVB5JvXojiW6Sa3wtSk8qcekARmPHaAnbtC4D7SJsiawo0lYg20