Skip to content

Instantly share code, notes, and snippets.

Programming something in Rust, probably

Matthew J. Berger matthewjberger

Programming something in Rust, probably
View GitHub Profile
dreamsmasher /
Created Oct 2, 2022
Function Overloading in Rust
#![feature(fn_traits, unboxed_closures)]
macro_rules! orelse {
(($($lhs:tt)+), $rhs:tt) => {$($lhs)+};
((), ($($rhs:tt)*)) => {$($rhs)*}
macro_rules! overload {
$v:vis fn $fn_name:ident {
use core::{fmt::Debug, future::Future};
use embassy::blocking_mutex::raw::RawMutex;
use embassy::mutex::Mutex;
use embedded_hal::digital::blocking::OutputPin;
pub use embedded_hal::spi::{
blocking, Error, ErrorKind, ErrorType, Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3,
use embedded_hal_async::spi;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
ssokolow /
Last active Nov 20, 2022
Code for storing Rust Path/PathBuf data as valid UTF-8 (eg. JSON) strings
/* POSIX paths in JSON via escaping which
doesn't alter valid UTF-8 paths.
The trick is recognizing that JSON can store binary nulls in strings
but nulls are the only character that can't occur in POSIX paths,
so we can use it as an escape character that won't change how existing
serialized paths get interpreted.
Copyright 2018-2020, Stephan Sokolow
#[derive(Copy, Clone)]
enum LinkedList<'a> {
Cons(u8, &'a LinkedList<'a>),
struct LinkedListIter<'a> {
list: LinkedList<'a>,
ryo-ARAKI / starship.toml
Last active Jan 30, 2023
Starship configuration file
View starship.toml
# ~/.config/starship.toml
full_symbol = "🔋"
charging_symbol = "🔌"
discharging_symbol = ""
threshold = 30
style = "bold red"
yhatt /
Created Sep 16, 2019
Marp Next example



Markdown presentation ecosystem
matthewjberger / Angle.cs
Last active Aug 9, 2018
A C# 2D Vector class that can be bound to from a ViewModel and has rectangular and polar representations. (Uses MVVMLightLibs from nuget)
View Angle.cs
namespace Vector2Example
using System;
using GalaSoft.MvvmLight;
public class Angle : ObservableObject
private Angle() { }
public static Angle FromRadians(double radians)
spacejam /
Last active Jan 29, 2023
using rr with rust

using rust with rr

rr is a great debugging tool. it records a trace of a program's execution, as well as the results of any syscalls it executes, so that you can "rewind" while you debug, and get deterministic forward and reverse instrumented playback. it works with rust, but by default if you try it out, it could be pretty ugly when you inspect variables. if this bothers you, configure gdb to use a rust pretty-printer

rr is probably in your system's package manager.


huytd / .travis.yml
Last active Nov 24, 2017
Travis CI config for Rust/Diesel project
View .travis.yml
language: rust
- nightly
cache: cargo
- postgresql
- psql -c 'create database build_db;' -U postgres
- echo "DATABASE_URL=postgres://postgres@localhost/build_db" > .env
- cargo install diesel_cli --no-default-features --features=postgres