Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

#

Circle: q2qu1sV11am11am11am11am11am

#chromahack


#

Mandelbrot: yq111axqms CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA CMyq111axqmsA

(explanation will follow)

#chromahack


#

What is considered best practice when shutting down an #ActivityPub service? The services itself is not used by anyone, but still received a constant stream of activities for deleted users.


#

Just to get this straight:

  • the US banned exports of #AI chips to China in fear of AI supremacy
  • They restricted themselves to regulate any AI in the next 10 years
  • a few days later #grok became the reincarnation of Hitler himself

If I thought that #AGI was just around the corner I would be really concerned now.


#

Writing is a muscle. I haven't written longer pieces for some time and started work on an article two days ago. I only got 4 paragraphs done these days and the were really bad. Today I've written a dozen which read much better.


#

I've finally watched first season of the new #DoctorWho series.

I was skeptical for the first two episodes. By the third episode it felt as if the they found their groove and what made Doctor Who the show I love.




#

#zig comptime is great!

For implementing a B+Tree I have a bunch of constants which are all calculated based on the page size. At the end I can calculate a (reasonable) max depth of the tree and use this in my code to allocate slices which will always be big enough to hold the entire path to leaf node.

pub const MAX_DEPTH = max_depth_block: {
    // max file size on ext4 is 16 TiB
    const max_file_size = 16 * 1024 * 1024 * 1024 * 1024;

    // this will never be reached as the file also contains the tree
    const max_points = max_file_size / POINT_SIZE;
    const max_leaf_page = max_points / LEAF_CAPACITY;

    // log rounds down -> +1
    const max_depth = std.math.log(comptime_int, MAX_LINKS, max_leaf_page) + 1;
    break :max_depth_block max_depth;
};

#

Wrote my first data structure using comptime to replace an ArrayList where the maximum size is known at compile time. As I use it as a stack, it only implements append and pop as that is all I need.

#zig #dev

pub fn ConstStack(comptime T: type, size: comptime_int) type {
    return struct {
        items: [size]T = undefined,
        len: usize = 0,
        const Self = @This();

        pub fn append(self: *Self, item: T) !void {
            if (self.len == size) {
                return error.OutOfMemory;
            }
            self.items[self.len] = item;
            self.len += 1;
        }

        pub fn pop(self: *Self) ?T {
            if (self.len == 0) return null;
            self.len -= 1;
            return self.items[self.len];
        }
    };
}