raldone01

joined 2 years ago
[–] [email protected] 2 points 4 hours ago* (last edited 4 hours ago)

Many people have very strong opinions about ip while they themselves never benefit from it. If anything they are losing out on better technologies. Many things are patented to prevent someone from beating the status quo. These patent holders often just sit on the patent and don't do anything with it because they are profiting of the established way.

[–] [email protected] 3 points 1 week ago

I am running local models only for privacy sensitive stuff. If you have ollama you can also setup openwebui and access both local and remote models through the same very nice interface! Also chatgpt API is much cheaper than subscribing.

[–] [email protected] 2 points 2 weeks ago* (last edited 2 weeks ago)

Reminds me of something I drew a while back.

I screwed up the equal length of the mandibles from the reference image. They look very similar to this bettle though. The body texture and shape is not quite right though.

[–] [email protected] 9 points 2 weeks ago* (last edited 2 weeks ago) (3 children)

A good place to put persistent malware. That's why when using docker images always mount as ro if at all possible.

[–] [email protected] 2 points 1 month ago

I had a dl380 g6 and if a non hp certified gpu was put in it would increase the baseline Fan speed to almost full. Even though the other GPUs temperature values were correctly recognised by the ILO processor.

It was ridiculous.

Maybe its better on the g7 but I wouldn't count on it.

[–] [email protected] 2 points 2 months ago* (last edited 2 months ago)

I once went to the computer of a class mate and opened stdio.h and added #define while(x) if(x). He was so confused. 🤣

[–] [email protected] 2 points 2 months ago* (last edited 2 weeks ago)

For me it actually simplifies troubleshooting by a lot. No worries when messing around inside the container. Maintainers are looking at the same picture as you and can reproduce everything more easily.

Without docker I could never run all the services I am currently.

[–] [email protected] 5 points 2 months ago (2 children)

Awesome! I have only seen people do it with their fingers.

[–] [email protected] 3 points 2 months ago* (last edited 2 months ago)

Hahaha thanks. Though I read through their website and wanted to support them.

I always buy entertainment books in paperback because I stare at screens way too much already.

University books though 🏴‍☠️ all the way.

[–] [email protected] 4 points 2 months ago* (last edited 2 months ago) (2 children)

I think I found it Et.Al but I am not sure. Bought it though.

[–] [email protected] 4 points 2 months ago (4 children)

Which book is this?

[–] [email protected] 2 points 3 months ago

I came for the typing fun and stayed for the emotional story.

What a great game!

10
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 

Hello,

I was playing around with rust and wondered if I could use const generics for toggling debug code on and off to avoid any runtime cost while still being able to toggle the DEBUG flag during runtime. I came up with a nifty solution that requires a single dynamic dispatch which many programs have anyways. It works by rewriting the vtable. It's a zero cost bool!

Is this technique worth it?

Probably not.

It's funny though.

Repo: https://github.com/raldone01/runtime_const_generics_rs/tree/v1.0.0

Full source code below:

use std::mem::transmute;
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering;

use replace_with::replace_with_or_abort;

trait GameObject {
  fn run(&mut self);
  fn set_debug(&mut self, flag: bool) -> &mut dyn GameObject;
}

trait GameObjectBoxExt {
  fn set_debug(self: Box<Self>, flag: bool) -> Box<dyn GameObject>;
}

impl GameObjectBoxExt for dyn GameObject {
  fn set_debug(self: Box<Self>, flag: bool) -> Box<dyn GameObject> {
    unsafe {
      let selv = Box::into_raw(self);
      let selv = (&mut *selv).set_debug(flag);
      return Box::from_raw(selv);
    }
  }
}

static ID_CNT: AtomicU32 = AtomicU32::new(0);

struct Node3D<const DEBUG: bool = false> {
  id: u32,
  cnt: u32,
}

impl Node3D {
  const TYPE_NAME: &str = "Node3D";
  fn new() -> Self {
    let id = ID_CNT.fetch_add(1, Ordering::Relaxed);
    let selv = Self { id, cnt: 0 };
    return selv;
  }
}

impl<const DEBUG: bool> GameObject for Node3D<DEBUG> {
  fn run(&mut self) {
    println!("Hello {} from {}@{}!", self.cnt, Node3D::TYPE_NAME, self.id);
    if DEBUG {
      println!("Debug {} from {}@{}!", self.cnt, Node3D::TYPE_NAME, self.id);
    }
    self.cnt += 1;
  }

  fn set_debug(&mut self, flag: bool) -> &mut dyn GameObject {
    unsafe {
      match flag {
        true => transmute::<_, &mut Node3D<true>>(self) as &mut dyn GameObject,
        false => transmute::<_, &mut Node3D<false>>(self) as &mut dyn GameObject,
      }
    }
  }
}

struct Node2D<const DEBUG: bool = false> {
  id: u32,
  cnt: u32,
}

impl Node2D {
  const TYPE_NAME: &str = "Node2D";
  fn new() -> Self {
    let id = ID_CNT.fetch_add(1, Ordering::Relaxed);
    let selv = Self { id, cnt: 0 };
    return selv;
  }
}

impl<const DEBUG: bool> GameObject for Node2D<DEBUG> {
  fn run(&mut self) {
    println!("Hello {} from {}@{}!", self.cnt, Node2D::TYPE_NAME, self.id);
    if DEBUG {
      println!("Debug {} from {}@{}!", self.cnt, Node2D::TYPE_NAME, self.id);
    }
    self.cnt += 1;
  }

  fn set_debug(&mut self, flag: bool) -> &mut dyn GameObject {
    unsafe {
      match flag {
        true => transmute::<_, &mut Node2D<true>>(self) as &mut dyn GameObject,
        false => transmute::<_, &mut Node2D<false>>(self) as &mut dyn GameObject,
      }
    }
  }
}

fn main() {
  let mut objects = Vec::new();
  for _ in 0..10 {
    objects.push(Box::new(Node3D::new()) as Box<dyn GameObject>);
    objects.push(Box::new(Node2D::new()) as Box<dyn GameObject>);
  }

  for o in 0..3 {
    for (i, object) in objects.iter_mut().enumerate() {
      let debug = (o + i) % 2 == 0;
      replace_with_or_abort(object, |object| object.set_debug(debug));
      object.run();
    }
  }
}

Note:

If anyone gets the following to work without unsafe, maybe by using the replace_with crate I would be very happy:

impl GameObjectBoxExt for dyn GameObject {
  fn set_debug(self: Box<Self>, flag: bool) -> Box<dyn GameObject> {
    unsafe {
      let selv = Box::into_raw(self);
      let selv = (&mut *selv).set_debug(flag);
      return Box::from_raw(selv);
    }
  }

I am curious to hear your thoughts.

297
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 

Python allows programmers to pass additional arguments to functions via comments. Now armed with this knowledge head out and spread it to all code bases.

Feel free to use the code I wrote in your projects.

Link to the source code: https://github.com/raldone01/python_lessons_py/blob/v2.0.0/lesson_0_comments.ipynb

Image transcription:

# First we have to import comment_arguments from arglib
# Sadly arglib is not yet a standard library.
from arglib import comment_arguments


def add(*args, **kwargs):
    c_args, c_kwargs = comment_arguments()
    return sum([int(i) for i in args + c_args])


# Go ahead and change the comments.
# See how they are used as arguments.

result = add()  # 1, 2
print(result)
# comment arguments can be combined with normal function arguments
result = add(1, 2)  # 3, 4
print(result)

Output:

3
10

This is version v2.0.0 of the post: https://github.com/raldone01/python_lessons_py/tree/v2.0.0

Note:

v1.0.0 of the post can be found here: https://github.com/raldone01/python_lessons_py/tree/v1.0.0

Choosing lib as the name for my module was a bit devious. I did it because I thought if I am creating something cursed why not go all the way?

Regarding misinformation:

I thought simply posting this in programmer humor was enough. Anyways, the techniques shown here are not yet regarded best practice. Decide carefully if you want to apply the shown concepts in your own code bases.

 

I have not been able to correlate it to any event in steam. I watched the volume mixer to find out that it was steam. I tried to turn off all notifications but obviously I have missed something. There is no visual cue just this sound in the background.

I appreciate any hints.

view more: next ›