raldone01

joined 2 years ago
[–] [email protected] 1 points 1 hour ago (1 children)

The issue is that the web login requires their app. All major banks in my country have this requirement but I will have another look when the time for a new phone comes.

[–] [email protected] 5 points 1 day ago (6 children)

I moved over to mostly open source apps where possible. My main issue will be the banking apps that insist on safety net.

Graphene os is great on paper but I would like to buy a different brand than pixel like fairphone.

[–] [email protected] 6 points 5 days ago (1 children)

The Phillips hue bridge app. They forced online login in the new version for "security". I don't see how connecting to Philipps servers is more secure than local only.

[–] [email protected] 3 points 6 days ago

Here are some extremely deep and very serious quotes I have collected over time:

Hard work pays off!
— Torbjörn, Overwatch

If you see a bomb technician running, follow him. — Space Engineers Loading Screen

Obesity is literally a problem you can run from.

Yes the planet got destroyed. But for a beautiful moment we created a lot of value for shareholders.

You sure do talk a lot for never saying anything.

Language. It's going on as we speak.

60% of the time, it works every time.

Ask no questions get no lies.

I am done with self-harm. It's time to harm others.

After all is said and done, more has been said than done.

If it cost me my life man i'd save my only friend. That's something I could live with. I could take that to the end. — Bittle bones nicky

I don't exactly hate you but if you were on fire and I had water I would drink it.

Therapist: "I am tired of all my patients playing victim."

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

I have not had problems with usb so far on my fw16 but the integrated graphics 780M.... My god the amd gpu drivers are a mess.

Crashes and artifacts daily. At least it is somewhat possible to contact amd and work on a fix together with them.

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

Hiking is fun, really?

Still loving programming - makes sense.

Still no significant other yet - alright I guess, too bad though.

[–] [email protected] 2 points 3 weeks ago* (last edited 3 weeks 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] 2 points 3 weeks ago

Thanks for the link. I just setup joplin and joplin server.

I migrated all my old samsung notes to joplin.

Sadly I still can't replace OneNote. There is no open source alternative for an infinite canvas with proper custom server based sync that helps to resolve conflicts. Logseq looks pretty good but the server sync implementation is not open source.

[–] [email protected] 4 points 1 month 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] 10 points 1 month ago* (last edited 1 month ago) (4 children)

Also it seems like every one note version is good at some task or has access to formatting/organization options that others can only view.

I wish there was an open source solution in a similar manner to immich (quality and organization) wise.

[–] [email protected] 2 points 1 month ago* (last edited 1 month 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] 10 points 1 month ago* (last edited 1 month 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.

1
submitted 5 months ago* (last edited 5 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.

1
submitted 5 months ago* (last edited 5 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 a static ip (lets say 142.251.208.110).

I own the domain: website.tld

My registrar is godaddy.

If I want to change my nameserver godaddy won't allow me to enter a static ip. It wants a hostname. I observed that many use ns1.website.tld and ns2.website.tld.

I don't understand how this can work because ns1.website.tld would be served by my dns server which is not yet known by others.

Do I need a second domain like domains.tld where I use the registrars dns server for serving ns1.domains.tld which I can then use as the nameserver for website.tld?

I would like to avoid the registrars nameserver and avoid getting a second domain just for dns.

Thank you for your input.

 

I have two machines running docker. A (powerful) and B (tiny vps).

All my services are hosted at home on machine A. All dns records point to A. I want to point them to B and implement split horizon dns in my local network to still directly access A. Ideally A is no longer reachable from outside without going over B.

How can I forward requests on machine B to A over a tunnel like wireguard without loosing the source ip addresses?

I tried to get this working by creating two wireguard containers. I think I only need iptable rules on the WG container A but I am not sure. I am a bit confused about the iptable rules needed to get wireguard to properly forward the request through the tunnel.

What are your solutions for such a setup? Is there a better way to do this? I would also be glad for some keywords/existing solutions.

Additional info:

  • Ideally I would like to not leave docker.
  • Split horizon dns is no problem.
  • I have a static ipv6 and ipv4 on both machines.
  • I also have spare ipv6 subnets that I can use for intermediate routing.
  • I would like to avoid cloudflare.
view more: next ›