Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Programming something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Programming something in Rust, probably
View GitHub Profile
@dreamsmasher
dreamsmasher / overload.rs
Created Oct 2, 2022
Function Overloading in Rust
View overload.rs
#![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 {
View shared-bus-async.rs
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
ssokolow / escape_non_utf8_paths.rs
Last active Nov 20, 2022
Code for storing Rust Path/PathBuf data as valid UTF-8 (eg. JSON) strings
View escape_non_utf8_paths.rs
/* 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
View nostd-brainfuck.rs
#[derive(Copy, Clone)]
enum LinkedList<'a> {
Nil,
Cons(u8, &'a LinkedList<'a>),
}
struct LinkedListIter<'a> {
list: LinkedList<'a>,
}
@ryo-ARAKI
ryo-ARAKI / starship.toml
Last active Jan 30, 2023
Starship configuration file
View starship.toml
# ~/.config/starship.toml
[battery]
full_symbol = "🔋"
charging_symbol = "🔌"
discharging_symbol = ""
[[battery.display]]
threshold = 30
style = "bold red"
@yhatt
yhatt / marp.md
Created Sep 16, 2019
Marp Next example
View marp.md
marp
true

Marp

h:250

Markdown presentation ecosystem
@matthewjberger
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
spacejam / rr-with-rust.md
Last active Jan 29, 2023
using rr with rust
View rr-with-rust.md

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.

usage

@huytd
huytd / .travis.yml
Last active Nov 24, 2017
Travis CI config for Rust/Diesel project
View .travis.yml
language: rust
rust:
- nightly
cache: cargo
services:
- postgresql
before_script:
- 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