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 ENDIAN = std.builtin.Endian.little; | |
| /// takes a reader and reads some data out of the reader, returns the number of | |
| /// bytes read | |
| pub fn example_func_that_takes_a_reader( | |
| reader: *std.Io.Reader, | |
| ) !u8 | |
| { |
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
| //! example of opening a file and writing to it with a writer (0.15.1+) | |
| const std = @import("std"); | |
| pub fn some_child_fn( | |
| writer: *std.io.Writer, | |
| ) !void | |
| { | |
| try writer.print("write from child_fn\n", .{}); | |
| } |
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"); | |
| /// Explorations of floating point accuracy. to run `zig test inftest.zig` | |
| // test "-0 + -1" | |
| // { | |
| // for (&[_]f32{ 0 }) | |
| // |v| | |
| // { | |
| // inline for (&.{-1, 1}) |
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
| Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
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
| Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
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
| Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
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
| /// Module that wraps up the zig json system for use in playdate | |
| const std = @import("std"); | |
| const pdapi = @import("playdate_api_definitions.zig"); | |
| pub fn read_from_json_str( | |
| input: []const u8, | |
| comptime thing_to_read: type, | |
| allocator: std.mem.Allocator, | |
| ) !thing_to_read |
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
| /// function for automatically building an imgui (via zgui) UI based | |
| /// on struct fields. Really useful when you're moving quickly and | |
| /// have a debug flags/fields struct | |
| pub fn draw_zgui_ui( | |
| for_thing: anytype | |
| ) !bool | |
| { | |
| var buf:[1024:0]u8 = undefined; | |
| @memset(&buf, 0); |
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 c_args = [_][]const u8{ | |
| "-std=c++17", | |
| "-fno-sanitize=undefined", | |
| }; | |
| // Although this function looks imperative, note that its job is to | |
| // declaratively construct a build graph that will be executed by an external | |
| // runner. |
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"); | |
| fn print_string_contents(buffer: anytype) void { | |
| std.debug.print("string print: '{s}'\n", .{ buffer }); | |
| std.debug.print("char print:\n", .{}); | |
| for (buffer) |b, ind| { | |
| std.debug.print(" {d}: {d} {s}", .{ ind, b, buffer[ind..ind+1] }); | |
| } |
NewerOlder