Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@bsodmike
bsodmike / README.md
Last active April 22, 2024 15:34
STM32CubeIDE with Portenta H7

stm32h747xi_STM32CubeIDE_gist

Portenta H7

  • Bottom: Tx
  • Top: Rx

Traces

Tx from Arduino Portenta H7

@bsodmike
bsodmike / towards_impeccable_rust.md
Last active April 3, 2024 12:09
Towards Impeccable Rust by Jon Gjengset, session at Rust Nation UK (27th March 2024)

Towards Impeccable Rust

Testing

  • Miri
  • Test for error conditions

Embrace chaos (fuzzing)

  • Async/sync chaos Turmoil / shuttle
  • Value checks: quickcheck / proptest
  • Logic chaos: cargo-mutants
@bsodmike
bsodmike / crontab
Created March 17, 2024 07:41
pfSense crontab
# ┌───────────── Minute (0 - 59)
# │ ┌─────────── Hour (0 - 23)
# │ │ ┌───────── Date (1 - 31)
# │ │ │ ┌─────── Month (1 - 12)
# │ │ │ │ ┌───── Day of Week (0 - 7,0 Sunday,6 Saturday,7 Sunday)
# │ │ │ │ │
0 0 * * * /etc/rc.restart_webgui
@bsodmike
bsodmike / ssh_key_Ed25519.md
Created October 26, 2022 06:41
Create Ed25519 SSH key (ECDSA)
@bsodmike
bsodmike / handlers.rs
Last active March 5, 2023 16:06
Axum Redirect is syntactic sugar for a Response
async fn accept_form(Form(input): Form<Input>, state: Extension<AppState>) -> Response<Body> {
dbg!(&input);
match save_form(&input, &state).await {
Ok(_) => (),
Err(e) => tracing::error!("Failed: {:?}", e),
}
let mut response = Response::builder()
.status(StatusCode::SEE_OTHER)
---
criticalpatterns:
- 'pam_unix[\w\d\D]*failure'
- 'gkr-pam[\w\d\D]*invalid'
- 'USER_AUTH[\w\d\D]*pam_gnome_keyring[\w\d\D]*failed'
criticalexceptions:
- 'timestamp:".*",level:"(error|warn)"'
- '0 errors'
@bsodmike
bsodmike / atomics.rs
Created October 15, 2021 13:15
Crust of Rust: Atomics and Memory Ordering // My Notes
use std::cell::UnsafeCell;
use std::sync::atomic::{AtomicBool, Ordering};
const LOCKED: bool = true;
const UNLOCKED: bool = false;
pub struct Mutex<T> {
locked: AtomicBool,
v: UnsafeCell<T>,
}
@bsodmike
bsodmike / rust.rs
Created October 10, 2021 05:29
Rust library alloc test failure (against master)
Error whilst running `./x.py test --keep-stage 1 library/alloc/`
```rust
Updating only changed submodules
Submodules updated in 0.01 seconds
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Testing alloc stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
running 265 tests
@bsodmike
bsodmike / main.rs
Created October 9, 2021 14:11
Crust of Rust: functions, closures, and their traits - My Notes.
#![feature(const_trait_impl, const_fn_trait_bound)]
fn main() {
println!("Howdy partner?");
let mut x = bar::<i32>;
println!("{}", std::mem::size_of_val(&x));
baz(bar::<u32>);
baz(bar::<i32>);
//quox(bar::<u32>);
make_fn()();
@bsodmike
bsodmike / Gemfile
Created February 23, 2021 08:34
RSpec example using Webmock to stub and API request
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "faraday"
gem "json"
group :test do