Skip to content

Instantly share code, notes, and snippets.

View druskus20's full-sized avatar
🦀
::<>

Druskus druskus20

🦀
::<>
View GitHub Profile
@druskus20
druskus20 / what.rs
Last active February 25, 2025 19:03
#[tracing::instrument(level = "trace", skip(self))]
pub fn start(mut self) -> Result<()> {
let stop_event = self.main_loop.loop_().add_event(|| {
debug!("Stop message received!");
});
std::thread::spawn(move || loop {
let main_loop = self.main_loop.clone();
let msg = self.control.blocking_recv();
match msg {
@druskus20
druskus20 / broken.md
Last active November 30, 2024 18:07
EnvFilter is broken
fn main() {
    let filter = EnvFilter::new("warn,[custom_span]=warn"); // only prints warn inside of span, not
                                                            // outside

    let filter = EnvFilter::new("info,[custom_span]=warn"); // prints everything, even info inside
                                                            // of span

    let filter = EnvFilter::new("off,[custom_span]=warn"); // prints nothing
                                                           
import * as pulumi from "@pulumi/pulumi";
import TAGGABLE_RESOURCE_TYPES from "./taggable_resource_types.json";
import { ResourceTransformResult } from "@pulumi/pulumi";
// Taggable resources that do not support after-tagging.
const UNSUPPORTED_RESOURCE_TYPES: string[] = [
"aws:afterscaling/group:Group",
"aws-native:servicecatalogappregistry:Application",
@druskus20
druskus20 / fix-ethernet-ubuntu-server.md
Last active September 11, 2024 09:30
Fix ethernet connection not working on Ubuntu server laptop.

Fix ethernet connection not working on Ubuntu Server Ubuntu 22.04.4 LTS x86_64 running on my laptop.

The wifi is working, but the ethernet is not.

$ nmcli device status
DEVICE             TYPE      STATE      CONNECTION
wlp3s0             wifi      connected  Ahouse
24:29:34:7F:A9:6B  bt        unmanaged  --
enp2s0f0           ethernet  unmanaged  --
@druskus20
druskus20 / build_mpi_dardel.md
Last active June 9, 2024 13:25
Build MPI in dardel

How to build with rust and MPI on dardel supercomputer

module load rust/1.78.0`
module load cce gcc aocc PrgEnv-gnu PrgEnv-cray PrgEnv-aocc
export CRAY_MPICH_DIR=/opt/cray/pe/mpich/8.1.28/ucx/cray/17.0/lib/pkgconfig
cargo build --release --bin mpi
@druskus20
druskus20 / gcc_wrapping.md
Last active June 7, 2024 14:16
Example of gcc's --wrap
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

extern int __real_fork();

int __wrap_fork() {
    printf("wrap fork\n");
 __real_fork();
@druskus20
druskus20 / tut.md
Last active September 8, 2022 08:25 — forked from rain1024/tut.md
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.

Classes

interface Props {
   name:
    string
}

class App extends React.Component<Props> {
  render() {
 const { name } = this.props;
@druskus20
druskus20 / compiletime-builder.md
Last active March 23, 2022 19:09
A compile-time checked builder pattern for Rust

Compile time checked builder pattern

Often times we want to verify that an object is fully built before using it. In many cases, this is done at runtime, in some sort of build() method. This is an implementation that verifies completeness using generics at compile time.

/*
 * A builder pattern that checks if every field is set before building at compile-time.
 * This means, no runtime checks, if it compiles, it's fully initialized. Thus, there's no
 * overhead of checking if the struct is valid.
 *
 * (It comes at the cost of being a bit verbose, though ergonomics could be improved with a
/*
* We can use transmute and cast instead of creating a new Struct {...}. This
* technically makes it so that we don't have to push all the fields into the new struct.
* However, it's most definitely not worth it, as the compiler will optimize the code anyway by
* inlining the variables.
* This is also unsafe, although we could wrap it in a macro to guarantee that the types are
* the same size and correctly aligned.
* I am not writting that macro.
* Check https://github.com/idanarye/rust-typed-builder for a similar implementation (doesn't use
* transmute casts), therefore it doesn't need MaybeUninit, it's just uses "()"