Skip to content

Instantly share code, notes, and snippets.

@3DRaven
3DRaven / README.md
Last active September 14, 2025 20:20
rust-analyzer and vscode settings for fast code navigation and building

Base system

16Gb RAM laptop with 16 cpu kernels

settings.json for vscode in project

{
    // "rust-analyzer.completion.limit": 10,
    // "rust-analyzer.workspace.symbol.search.limit": 50,
@3DRaven
3DRaven / README.md
Created June 24, 2025 15:38
Compressed Swap file on ubuntu 25.04
  1. Ubuntu 25.04 because LVM VDO (compression) not supported on early versions (I tried 24.04)
  2. Installed kernel 6.14
  3. apt install lvm2
  4. create partition ${your partition number} for swap
  5. sudo pvcreate /dev/nvme0n1${your partition}
  6. sudo vgcreate vg /dev/nvme0n1${your partition}
  7. sudo lvcreate --type vdo -L ${your size}G -V ${your size}G --compression y --deduplication n vg/lv_swap
  8. sudo vgchange -ay # activation all created VDO for tests before reboot
  9. sudo blkid /dev/vg/lvol0 # remember UUID ${your uuid}
  10. sudo nano /etc/fstab # append UUID=${your uuid} none swap sw 0 0 to it
@3DRaven
3DRaven / delegate.md
Last active April 19, 2025 13:42
Type-safe delegation over generics in Rust without the newtype pattern
pub struct GenericId<T>(pub i64, pub PhantomData<T>);

pub struct PhantomMyId;
pub type MyId = GenericId<PhantomMyId>;
pub struct PhantomOtherId;
pub type OtherId = GenericId<PhantomOtherId>;


pub fn foo(my_id: &amp;MyId){
@3DRaven
3DRaven / example.java
Last active March 9, 2023 13:24
Java Builder with compile time checking of full initialization (Strict Builder pattern)
public class Person {
private final String username;
private final int age;
Person(PersonBuilder personBuilder) {
this.username = personBuilder.username;
this.age = personBuilder.age;
}