This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| pub const raw = @import("zig-network"); | |
| const heap_allocator = std.heap.c_allocator; | |
| // config vars | |
| pub var serverConnectionPort: u16 = 0x4d3; | |
| pub var addressFamily: raw.AddressFamily = .ipv4; | |
| pub var maxConnectionsPerFrame: usize = 4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const Allocator = std.mem.Allocator; | |
| const assert = std.debug.assert; | |
| const print = std.debug.print; | |
| const Timer = std.time.Timer; | |
| const data = @embedFile("data/day01.txt"); | |
| const EntriesList = std.ArrayList(i16); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var tok = std.mem.tokenize(line, "- :"); | |
| var min = try std.fmt.parseInt(u32, tok.next().?, 10); | |
| var max = try std.fmt.parseInt(u32, tok.next().?, 10); | |
| var char = tok.next().?[0]; | |
| var pass = tok.next().?; | |
| assert(tok.next() == null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// This function issues a compile error with a helpful message if there | |
| /// is a problem with the provided context type. A context must have the following | |
| /// member functions: | |
| /// - hash(self, PseudoKey) Hash | |
| /// - eql(self, PseudoKey, Key) bool | |
| /// If you are passing a context to a *Adapted function, PseudoKey is the type | |
| /// of the key parameter. Otherwise, when creating a HashMap or HashMapUnmanaged | |
| /// type, PseudoKey = Key = K. | |
| pub fn verifyContext(comptime RawContext: type, comptime PseudoKey: type, comptime Key: type, comptime Hash: type) void { | |
| comptime { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const Channel = struct { | |
| value: u32, | |
| frame: anyframe, | |
| }; | |
| fn generate(channel: *Channel) void { | |
| suspend { channel.frame = @frame(); } | |
| var i: u32 = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rlBegin(RL_QUADS); | |
| float lastCornerX = center.x + cosf(DEG2RAD*angle)*radius; | |
| float lastCornerY = center.y + sinf(DEG2RAD*angle)*radius; | |
| // NOTE: Every QUAD actually represents two segments | |
| for (int i = 0; i < segments/2; i++) | |
| { | |
| float nextAngle = angle + stepLength*2.0f; | |
| float nextCornerX = center.x + cosf(DEG2RAD*(nextAngle))*radius; |
OlderNewer