Skip to content

Instantly share code, notes, and snippets.

View allsey87's full-sized avatar

Michael Allwright allsey87

View GitHub Profile
@allsey87
allsey87 / python_plugin.rs
Last active March 29, 2024 13:32
Integrating RustPython into a Bevy App
use bevy::prelude::{AppBuilder, Entity, With, World};
use bevy::ecs::system::IntoExclusiveSystem;
use rustpython_vm::{self as vm, builtins::PyCode, PyRef, scope::Scope};
pub(crate) struct PythonPlugin;
pub(crate) struct Script(pub String);
fn compile(world: &mut World) {
let interpreter = world
@allsey87
allsey87 / config.toml
Created December 5, 2019 14:31
Secret Santa Script
# Configuration file for secret santa
participants = [
"User One <u1@email.com>",
"User two <u2@email.com>",
"User three <u3@email.com>",
]
dont_pair = [
"User One, User Two",
@allsey87
allsey87 / dump_ktermios.c
Created July 24, 2018 11:47
Print the configuration of a serial port from the Linux kernel in stty -g style
static void dump_ktermios(struct device* dev, struct ktermios* ktermios, const char* func) {
char buf[128];
unsigned int idx = 0;
size_t i = 0;
idx += snprintf(buf + idx, 128 - idx, "%lx:%lx:%lx:%lx",
(unsigned long int) ktermios->c_iflag,
(unsigned long int) ktermios->c_oflag,
(unsigned long int) ktermios->c_cflag,
(unsigned long int) ktermios->c_lflag);
for(i = 0; i < NCCS; ++i)
@allsey87
allsey87 / magnetism_plugin_test_code.cxx
Created April 20, 2018 12:57
Damping in the magnetism plug-in
/* start test code here */
/* Link 0 */
CDynamics3DMultiBodyObjectModel::CLink* pcLink0 =
dynamic_cast<CDynamics3DMultiBodyObjectModel::CLink*>(itDipole0->Body);
btMultiBodyLinkCollider& col0 = pcLink0->m_cMultiBodyLink;
btScalar* vel0 = col0.m_multiBody->getJointVelMultiDof(col0.m_link);
btVector3 cDampingTorque0(vel0[0],vel0[1],vel0[2]);
@allsey87
allsey87 / bebotctrl.sh
Created April 23, 2017 02:34
Bash script for controlling the DuoVero-based BeBots
#!/bin/bash
# required programs: gnu parallel, sshpass
OPENWRT_IP='192.168.1.1'
OPENWRT_PASS='amadeus0247'
OPENWRT_USER='root'
OPENWRT_GET_LEASES='cat /tmp/dhcp.leases'
BEBOT_MAC_START='00:19:88'
BEBOT_CONN_TEST_ATTEMPTS=10
@allsey87
allsey87 / composite.sh
Created January 28, 2017 02:36
Create an image from two images by composing the first onto the second every time the file changes
#!/bin/bash
while inotifywait underlay.png
do
until composite -gravity center overlay.png underlay.png /tmp/out.png
do
sleep 0.25
done
sleep 0.25
done
@allsey87
allsey87 / smartblock.xml
Last active July 25, 2016 03:07
ARGoS Definition of the Smartblock
<prototype id="smartblock">
<body position="0.0,0.0,0.01" orientation="0,0,0"/>
<bodies reference_body="block">
<body id="block" geometry="box" size="0.055,0.055,0.055" mass="0.25">
<offset/>
<coordinates/>
</body>
<body id="magnet_tq1" geometry="sphere" radius="0.003" mass="0.001">
<offset position="0.0225,0.0225,0.047" orientation="1,0,0"/>
<coordinates/>
@allsey87
allsey87 / plot_data_from_csv.sce
Last active December 11, 2023 16:59
How to plot data in Scilab from a CSV file (with first line as the header)
clear parse_my_data
clear path
clear inputs
clear index
function parse_my_data(f_data_path)
csv_data = read_csv(f_data_path);
num_data = strtod(csv_data(2:$,1:$));
num_data_points = size(num_data,1);
my_plot = figure();
@allsey87
allsey87 / sbuffer.cc
Created May 10, 2016 14:56
Using smart pointers to cleanly integrate object orientated C libraries into a C++ application
struct SBuffer {
/* shared pointers to pixel data */
std::shared_ptr<image_u8_t> Y, U, V;
/* index (set by capture thread) */
unsigned int Index = -1;
/* capture time */
std::chrono::time_point<std::chrono::steady_clock> Timestamp;
/* default constructor */
SBuffer() :
Y(image_u8_create(0, 0), image_u8_destroy),
@allsey87
allsey87 / images-to-h264.sh
Created April 20, 2016 09:08
Convert images with timestamps in filename to h264 video
#!/bin/bash
WORKING_DIR=temp
OUTPUT=output
#create working directory
if [[ -d $WORKING_DIR ]]
then
echo "Directory '$WORKING_DIR' already exists"
exit
else