Skip to content

Instantly share code, notes, and snippets.

View ryankurte's full-sized avatar
🥔

ryan ryankurte

🥔
View GitHub Profile
@ryankurte
ryankurte / static-log.rs
Created March 25, 2021 22:42
Rust embedded static logging example
use core::fmt::Write;
use alloc::boxed::Box;
use embedded_hal::serial::{Write as SerialWrite};
use stm32f4xx_hal::serial;
use log::{Log, Level, Metadata, Record};
pub struct SerialLogger<E> {
@ryankurte
ryankurte / newlib_stubs.rs
Created November 29, 2020 21:44
Rust newlib stubs
#[no_mangle]
pub extern "C" fn _sbrk() {}
#[no_mangle]
pub extern "C" fn _write() {}
#[no_mangle]
pub extern "C" fn _close() {}
@ryankurte
ryankurte / config.toml
Last active February 12, 2024 13:22
Set gitlab runner to use git bash
[[runners]]
name = "tt708-windows"
url = "https://gitlab.com/"
token = "[REDACTED]"
executor = "shell"
shell = "bash"
builds_dir="/c/gitlab-runner/builds/"
cache_dir="/c/gitlab-runner/cache/"
[runners.cache]
[runners.cache.s3]
// Unaligned memcopy function
// Source: https://gist.github.com/ryankurte/29c99ef58ae636735f38b1f95da33be9
// Copyright 2020 Ryan Kurte
// Extremely untested, probably don't use this, or, test the h*ck out of it first.
// It should be _reasonably_ easy to extend this to `u32` or `u64` based methods
// for _significant_ performance improvements, however, this would either come with
// extended alignment requirements or need to switch types internally based on copy
// length.
@ryankurte
ryankurte / backup.env
Last active November 20, 2022 12:02
Linux backup automation
# Systemd environment file for backup.sh daily backup service
# Place in /etc/backup.env
# Destination for rsync file system clone
BACKUP_DEST=/media/large1/backups/raw
# Destination for restic repository
RESTIC_REPOSITORY=/media/large1/backups/restic
# Restic password file
@ryankurte
ryankurte / hal-query.sql
Last active March 11, 2020 07:03
Embedded hal dependency bigquery
# Run on https://console.cloud.google.com/bigquery
# Fetch all projects on crates.io
SELECT
projects.name, projects.platform , projects.latest_release_number, projects.dependent_projects_count,
dependencies.dependency_requirements as hal_version
FROM
`bigquery-public-data.libraries_io.dependencies` dependencies
@ryankurte
ryankurte / cross.sh
Created March 10, 2020 00:10
pkg-config multiarch stuff
#!/bin/sh
if [ $TARGET == "x86_64-unknown-linux-gnu" ]; then
cargo build --target=$TARGET --release
elif [ $TARGET == "x86_64-apple-darwin" ]; then
cargo build --target=$TARGET --release
elif [ $TARGET == "armv7-unknown-linux-gnueabihf" ]; then
sh ./cross-linux-armhf.sh
@ryankurte
ryankurte / whatever.service
Created June 16, 2019 03:41
Minimal systemd unit
# place in /etc/systemd/system/whatever.service and install with `systemd install whatever.service`
# note that if you change this file you will need to run `systemctl daemon-reload` to get systemd to notice
[Unit]
Description=A good service description
# After networking because we need that
After=network.target
[Service]
@ryankurte
ryankurte / gtest.cmake
Created April 23, 2019 03:33
Googletest vendoring and install detection for cmake
# CMake GoogleTest vendoring helper
# Adapted from https://github.com/snikulov/google-test-examples
include(ExternalProject)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTEST gtest)
set(GTEST_FORCE_SHARED_CRT ON)
set(GTEST_DISABLE_PTHREADS OFF)
use futures::{future, Future, sync::oneshot};
use tokio::spawn;
/// AsyncWait implements a `.wait()` equivalent that works from any contex.
/// This is required because at some point in the past `.wait()` stopped doing this,
/// and thus calling it in a polling context causes everything to lock up.
/// see: https://github.com/tokio-rs/tokio-core/issues/182 and related issues.
/// ``` norun
/// // This will block forever if run in the main thread context
/// let _client = TcpConnection::<JsonCodec<Request, Response>>::new(&addr, JsonCodec::new()).wait().unwrap();