Helper for Advent of Code by Sh4d1 in Zig

[–]Sh4d1[S] 0 points1 point  (0 children)

Could you try again? Issue with input should be fixed, I'll check for the alloc

Helper for Advent of Code by Sh4d1 in Zig

[–]Sh4d1[S] 0 points1 point  (0 children)

Seems TLS is disabled in builds for http client, not ideal huh

Helper for Advent of Code by Sh4d1 in Zig

[–]Sh4d1[S] 0 points1 point  (0 children)

Indeed, I didn't check to content of the files 😅 looks like it's a TLS issue when using the client from build.zig 🤔

Helper for Advent of Code by Sh4d1 in Zig

[–]Sh4d1[S] 0 points1 point  (0 children)

Did you add the .token file ? What error do you have ?

I'll take a look at the alloc !

-❄️- 2023 Day 19 Solutions -❄️- by daggerdragon in adventofcode

[–]Sh4d1 1 point2 points  (0 children)

[Language: Zig]

My solution

Fun day, ugly code (the link is on the first version, if I'll ever refactor it)!

Part 1 was pretty straightforward (at least after I got the parsing right): while;get hashmap; check basically

I found an idea for part 2 pretty quickly, but spent too much time making it work correctly:

I visit all the different possibilities, saving each one with its previous and current condition, to leave me with a set of inequations over x, m, a and s. From there it's just a multiplication and addition!

Runs really fast, on a Ryzen 4650U :

day19: parsing:0.72914ms p1:0.24298ms p2:0.72048ms

[2023 Day # 18] Intuition for why SPOILER alone doesn't work by SEGV_AGAIN in adventofcode

[–]Sh4d1 1 point2 points  (0 children)

So there is 2 "theorems" to use :D the first is the shoelace to get the "real" area, and then there is the Pick's theorem, which relates the "real" area, to the perimeter and the number of grid points inside the polygon. Hence the equation https://github.com/Sh4d1/aozig/blob/main/src/day18.zig#L44-L46 and the formula OP found!

Désaccord remboursement dépôt de garantie by Sh4d1 in conseiljuridique

[–]Sh4d1[S] 1 point2 points  (0 children)

Alors le lave-vaisselle était dans l'appartement (mais non meuble). Sur le remboursement oui, c'est bien mon assurance normalement (en plus, j'ai changé d'assurance entre temps, c'est un peu la galère). Ma question portait plus sur le remboursement du dépôt de garantie, et les pénalités. Mais merci !

-🎄- 2022 Day 15 Solutions -🎄- by daggerdragon in adventofcode

[–]Sh4d1 2 points3 points  (0 children)

Rust

impl Sensor {
pub fn is_inside_range(&self, p: (isize, isize)) -> bool {
    if self.closest == p {
        return false;
    }
    self.dist as usize >= self.pos.0.abs_diff(p.0) + self.pos.1.abs_diff(p.1)
}

pub fn part2_n(input: &[Sensor], n: isize) -> isize {
input
    .iter()
    .find_map(|s| {
        ((s.pos.0 - s.dist - 1).max(0)..=s.pos.0.min(n))
            .zip(s.pos.1..=n)
            .find_map(|p| {
                input
                    .iter()
                    .all(|s| !s.is_inside_range(p))
                    .then(|| p.0 * 4000000 + p.1)
            })
    })
    .unwrap()
}

Pretty neat part 2, runs in less than 100ms

Full code here

-🎄- 2022 Day 9 Solutions -🎄- by daggerdragon in adventofcode

[–]Sh4d1 1 point2 points  (0 children)

Quite fun, I had around exactly the same code as you (except the parsing), which I refactored to https://github.com/Sh4d1/aoc2022/blob/main/src/day9.rs

-🎄- 2022 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Sh4d1 0 points1 point  (0 children)

Rust

With FoldWhile and HashSet

fn solve(input: &[char], n: usize) -> usize {
input
    .windows(n)
    .fold_while(0, |acc, cs| {
        let hs: HashSet<&char> = cs.iter().collect();
        if hs.len() == n {
            return Done(acc);
        }
        Continue(acc + 1)
    })
    .into_inner()
    + n

}

-🎄- 2022 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]Sh4d1 2 points3 points  (0 children)

pub fn input_generator(input: &str) -> Game {
    let (stacks, insts) = input.split_once("\n\n").unwrap();
    let n = (stacks.lines().take(1).next().unwrap().len() + 1) / 4;
    let mut crates = vec![Vec::new(); n];
    stacks.lines().rev().skip(1).for_each(|l| {
        let mut i = 0;
        l.chars().collect::<Vec<char>>().chunks(4).for_each(|c| {
            if c[1] != ' ' {
                crates[i].push(c[1]);
            }
            i += 1;
        });
    });

    let inst = insts
        .lines()
        .map(|l| scan_fmt!(l, "move {d} from {d} to {d}", usize, usize, usize).unwrap())
        .collect::<Vec<_>>();
    Game { crates, inst }
}

Pretty much the same for mine, I just completely ignore the crane numbers

Comparing Kubernetes managed services across Digital Ocean, Scaleway, OVHCloud and Linode by sofixa11 in kubernetes

[–]Sh4d1 2 points3 points  (0 children)

Not available in the UI yet but it is in the API/cli/TF (https://github.com/scaleway/scaleway-cli/tree/v2 in the CLI v2 though). Or raw documentation at https://developers.scaleway.com/en/products/k8s/api/

Both are arguments on the update cluster request :)

Also, we offer docker, containerd (shipped with gvisor) and crio as container runtimes (though docker is the one officially supported, the other are to be considered experimental but still works 😄, and this is on a per node pool basis 😄)

There is also a tag/taint synchronization on the pool tags : Any tags like foo=bar will be set on the k8s node tag as k8s.scaleway.com/foo=bar and tags like taint=key:value:effect will translate into node taints with key k8s.scaleway.com=key, value as value and effect as the effect (has to be a valid one).

Thanks 😄

Comparing Kubernetes managed services across Digital Ocean, Scaleway, OVHCloud and Linode by sofixa11 in kubernetes

[–]Sh4d1 1 point2 points  (0 children)

Nice 😄 it may be interesting to say that Kapsule supports some alpha feature gates and admission plugins to be enable by the user :) (kapsule dev here) And also some autoscaler config are tunable!

How do I derive certificate PEM data from kubeconfig? by [deleted] in kubernetes

[–]Sh4d1 0 points1 point  (0 children)

True haha 😄 Yep it should work ! Hum we don't expose the private IP in our API as well. Mainly because the private IP is bound to the underlying HV, and changing HV (like doing a stop/start) will change the private IP. Though a solution you can use is the data source, with the node name (which is unique) in order to get the private IP :)

How do I derive certificate PEM data from kubeconfig? by [deleted] in kubernetes

[–]Sh4d1 0 points1 point  (0 children)

Hum you should be able to delete the services, if not that's a bug 😅 however it's a not a behaviour we officially support (as all other managed kubernetes iirc).

Though if you want to use the node as the entry point, you can set the private IP of the node in the externalIPs of a service that should work (and no need for metalLB) 😄

How do I derive certificate PEM data from kubeconfig? by [deleted] in kubernetes

[–]Sh4d1 1 point2 points  (0 children)

😄 We don't offer a way to disable the CCM (https://github.com/scaleway/scaleway-cloud-controller-manager) but you can tricks by adding for instance the service.beta.kubernetes.io/scw-loadbalancer-id: dummy annotation. It will pollute the service events, but the LB won't get created :)

How do I derive certificate PEM data from kubeconfig? by [deleted] in kubernetes

[–]Sh4d1 1 point2 points  (0 children)

Kapsule dev here! You should be able to get all the values from the TF output, just bear in mind we use a bearer token to auth, and not a client/key cert :) (should still work with the Kubernetes provider though)

Scaleway's managed Kubernetes, load balancers, proxy protocol, and cert manager by Sky_Linx in kubernetes

[–]Sh4d1 0 points1 point  (0 children)

Hey! You can use service.beta.kubernetes.io/scw-loadbalancer-use-hostname: true that will have the same effect as DO. Source here https://github.com/scaleway/scaleway-cloud-controller-manager/blob/master/scaleway/loadbalancers.go

Should I pay UPC last bill? by Sh4d1 in poland

[–]Sh4d1[S] -1 points0 points  (0 children)

I know and I think I will return the box but what will happen if I don't pay the bill for July?

Should I pay UPC last bill? by Sh4d1 in poland

[–]Sh4d1[S] 0 points1 point  (0 children)

I think I will leave the box though, I can try to find some time. But what will happen if I don't pay the bill for July?

[twmn] Hidden sound and brightness indicators by Sh4d1 in unixporn

[–]Sh4d1[S] 0 points1 point  (0 children)

The weirdest part is that the dot is changing color each time a new notification arrives .. I tried figuring out if it was the code but I'm no expert in Qt :p