Skip to content

Instantly share code, notes, and snippets.

View renerocksai's full-sized avatar
🎯
Focusing

Rene Schallner renerocksai

🎯
Focusing
View GitHub Profile
@renerocksai
renerocksai / cookies_main.zig
Last active May 20, 2023 18:10
Below file returns 2 cookies: one that's valid for 1min, one that's valid for 1h
const std = @import("std");
const zap = @import("zap");
// We send ourselves a request with a cookie
fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
const uri = try std.Uri.parse(url);
var h = std.http.Headers{ .allocator = a };
defer h.deinit();
@renerocksai
renerocksai / compose_structs.zig
Last active May 18, 2023 14:21
Composing Structs in ZIG
const std = @import("std");
pub const ContextDescriptor = struct {
name: []const u8,
type: type,
};
/// Provide a tuple of structs of type like ContextDescriptor
pub fn MixContexts(comptime context_tuple: anytype) type {
var fields: [context_tuple.len]std.builtin.Type.StructField = undefined;