Skip to content

Instantly share code, notes, and snippets.

View little-dude's full-sized avatar
🍉

little-dude

🍉
View GitHub Profile
trait MyTrait<T> {
fn m(&self, t: T);
}
struct Foo;
impl<'t> MyTrait<&'t u32> for Foo {
fn m(&self, t: &'t u32) {}
}
@little-dude
little-dude / dyn_trait_plus_other_trait.rs
Created February 1, 2022 09:27
dyn Trait + OtherTrait
use std::fmt::Debug;
trait MyTrait: Debug {
fn m(&self);
}
#[derive(Debug)]
struct Foo;
impl MyTrait for Foo {
// This runs into https://github.com/rust-lang/rust/issues/56105
pub trait MyTrait<T> {
fn method(&self, _:T);
}
impl<T> MyTrait<T> for Box<dyn MyTrait<T>> {
fn method(&self, t: T) {
(**self).method(t)
}
pub fn parse_ip(payload: &[u8]) -> Result<IpAddr, DecodeError> {
match payload.len() {
4 => Ok(Ipv4Addr::new(payload[0], payload[1], payload[2], payload[3]).into()),
16 => Ok(Ipv6Addr::from([
payload[0],
payload[1],
payload[2],
payload[3],
payload[4],

Setting up NixOs with LUKS encrypted root

Here are my working notes on getting a system up and running.

WARNING: You can run into a hidden problem that will prevent a correct partition setup and /etc/nixos/configuration.nix from working: if you are setting up a UEFI system, then you need to make sure you boot into the NixOS installation from the UEFI partition of the bootable media. You may have to enter your BIOS boot selection menu to verify this. For example, if you setup a NixOS installer image on a flash drive, your BIOS menu may display several boot options from that flash drive: choose the one explicitly labeled with “UEFI”.

References

I used these resources:

use futures::{
stream::Stream,
task::{Context, Poll},
Future,
};
use std::pin::Pin;
use tokio::sync::mpsc::{Receiver, Sender};
/// Dummy structure that represent some state we update when we
/// receive data or events.
yarn run v1.16.0
$ /home/corentin/code/clojure/learn-reagent-course-files/giggin/node_modules/.bin/shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.0-beta4 server
shadow-cljs - config: /home/corentin/code/clojure/learn-reagent-course-files/giggin/shadow-cljs.edn cli version: 2.3.30 node: v11.15.0
shadow-cljs - starting ...
shadow-cljs - Using IP "192.168.43.195" from Interface "wlp58s0"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/home/corentin/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
@little-dude
little-dude / fetch.js
Created August 27, 2018 19:06
custom fetcher
class ResponseError {
constructor(response) {
this.response = response;
}
async read() => {
return this.response
.text()
.then(body => {
return {
@little-dude
little-dude / ipv6.rs
Created June 21, 2018 18:17
ipv6 parsing in Rust
use std::fmt;
use std::error::Error;
use std::str::FromStr;
pub struct Ipv4Network(u32, u32);
pub struct Ipv6Network(u128, u128);
#[derive(Debug)]
pub struct MalformedAddress(String);