Skip to content

Instantly share code, notes, and snippets.

@djmcgill
djmcgill / aoc2018d23.rs
Created February 4, 2023 18:54
WIP aoc2018d23.rs
use regex::Regex;
use std::{
collections::{HashMap, HashSet},
hash::Hash,
str::FromStr,
};
// const INPUT: &str = REAL;
const INPUT: &str = TEST2;
use crate::user::UserReply;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[serde(remote = "UserReply")]
pub struct MyUserReply {
pub id: String,
pub first_name: String,
pub last_name: String,
pub date_of_birth: String,
@djmcgill
djmcgill / main.rs
Created February 17, 2019 17:13
GPS serial creating working, reading not working
#![no_std]
#![no_main]
use core::f32::consts::PI;
use core::fmt::Write;
use arduino_mkrzero::atsamd21g18a::{CorePeripherals, Peripherals};
use arduino_mkrzero::clock::{GenericClockController, ClockGenId, ClockSource};
use arduino_mkrzero::delay::Delay;
use arduino_mkrzero::prelude::*;
@djmcgill
djmcgill / main.rs
Last active February 17, 2019 12:08
Adding a second serial UART
#[entry]
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.PM,
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
@djmcgill
djmcgill / rich_phantoms.rs
Created January 22, 2019 22:46
An implementation of phantom types with control over variance and send/sync inheritance
// It should support any combination of {Covariant, Contravariant, Invariant} × {AlwaysSendSync, NeverSendSync, InheritSendSync}.
use core::marker::PhantomData;
/// Is Covariant and Send/Sync
/// ```
/// use rich_phantoms::*;
/// use core::marker::PhantomData;
/// let _x: PhantomCovariantAlwaysSendSync<&'static str> = PhantomData;
/// let _y: &(dyn Send + Sync) = &_x;
@djmcgill
djmcgill / domain.rs
Last active October 7, 2017 23:23
kd_tree agaaaiin
use na::*;
use na::allocator::Allocator;
use std::vec::IntoIter;
/// An n-dimensional point with a defined n-vector from the origin
pub trait NPoint: Clone
where
DefaultAllocator: Allocator<f64, Self::N>,
{
@djmcgill
djmcgill / mod.rs
Created October 7, 2017 16:15
kd_tree simplification 2
use na::*;
use na::allocator::Allocator;
/// A kd tree
pub struct KdTree<N: DimName>(Box<kd_tree::KdTreeImpl<N>>)
where
N: DimName,
DefaultAllocator: Allocator<f64, N>;
impl<N: DimName> KdTree<N>
where
@djmcgill
djmcgill / mod.rs
Created October 7, 2017 15:58
kd_tree simplification
mod kd_tree {
use na::*;
use na::allocator::Allocator;
/// kd-Tree implementation structure
pub(super) enum KdTreeImpl<N> where N: DimName, DefaultAllocator: Allocator<f64, N> {
Node(usize, Box<KdTreeImpl<N>>, Box<VectorN<f64, N>>, Box<KdTreeImpl<N>>),
Empty()
}
@djmcgill
djmcgill / ClientExample.scala
Created April 21, 2017 10:53 — forked from rklaehn/Client example
akka http file server
package akkahttptest
import akka.http.Http
import akka.stream.ActorFlowMaterializer
import akka.actor.ActorSystem
import akka.stream.scaladsl.{Sink, Source}
import akka.http.model._
object TestClient extends App {