text stringlengths 32 314k | url stringlengths 93 243 |
|---|---|
const std = @import("std");
const Type = std.builtin.Type;
const testing = std.testing;
// turns out the mask should be the size of the full struct anyway. might make this public later to be used in later
// truncation but whatever
// fn calc(comptime T: type, comptime field: FieldEnum(T)) type {
// if (@typeInfo(... | https://raw.githubusercontent.com/Khitiara/imaginarium/805dd706a8e7b4f9f64fd0df932ad12d1aa1ea7f/src/util/masking.zig |
const ascii = @import("std").ascii;
const alphabet = "abcdefghijklmnopqrstuvwxyz";
pub fn isPangram(str: []const u8) bool {
var marks = [_]bool{false} ** 26;
for (str) |strChar| {
for (alphabet) |alphabetChar, i| {
if (ascii.toLower(strChar) == alphabetChar) {
marks[i] = tr... | https://raw.githubusercontent.com/alternateved/exercism/ba9dd5d5c832f1ab345e9a94ba9294717669cc76/zig/pangram/pangram.zig |
const std = @import("std");
const backend = @import("../backend.zig");
const Size = @import("../data.zig").Size;
/// Toggle switch flat peer
pub const FlatToggleSwitch = struct {
peer: backend.PeerType,
canvas: backend.Canvas,
label: [:0]const u8 = "",
enabled: bool = true,
pub usingnamespace bac... | https://raw.githubusercontent.com/SaicharanKandukuri/capy-299f994/512c88540a160cea2e824c363e7261679b558add/src/flat/toggle_switch.zig |
const std = @import("std");
const gpu = @import("mach-gpu");
const glfw = @import("mach-glfw");
const util = @import("../util.zig");
const math = @import("../utils/math.zig");
const Rect = math.Rect;
const MaxElements = @import("ezui.zig").MaxElements;
const SwapChainFormat = gpu.Texture.Format.bgra8_unorm;
pub con... | https://raw.githubusercontent.com/Enigma-IIITS/EZUI/f1b54a75b9735544b80c1f391f25a47b21003b6b/src/ezui/renderer.zig |
//! implementation of some segment tree algorithms
const std = @import("std");
const assert = std.debug.assert;
const print = std.debug.print;
const expect = std.testing.expect;
const Allocator = std.mem.Allocator;
pub fn SegmentTree(
comptime Type: type,
comptime OpFn: fn (Type, Type) Type,
) type {
retur... | https://raw.githubusercontent.com/JosefNatanael/zig-ds/f8e4d503115e2e717f8eb76e55d93cb562d1671e/segment-simple.zig |
// Copyright (c) 2022-2023, sin-ack <sin-ack@protonmail.com>
//
// SPDX-License-Identifier: GPL-3.0-only
const std = @import("std");
const Allocator = std.mem.Allocator;
const debug = @import("../../debug.zig");
const bytecode = @import("../bytecode.zig");
const Liveness = bytecode.astcode.Liveness;
const RegisterPoo... | https://raw.githubusercontent.com/sin-ack/zigself/0610529f7a04ec0d0628abc3e89dafd45b995562/src/runtime/bytecode/CodeGen.zig |
const std = @import("std");
const common = @import("common.zig");
const FlagCtrl = packed struct(u8) {
__R0: u4,
timing_clear: bool,
trigger_clear: bool,
timer_flag: bool,
trigger_flag: bool,
};
const ModeCtrl = packed struct(u8) {
timing_cycle_sec: enum(u3) { s0p125, s0p25, s0p5, s1, s2, s4,... | https://raw.githubusercontent.com/semickolon/kirei/27df23f37165d8a2b597134b32948745b8b1bee5/src/platforms/ch58x/hal/rtc.zig |
const std = @import("std");
const time = std.time;
const Move = enum {
rock,
paper,
scissor,
};
fn parseMove(a: u8) Move {
return switch (a) {
'A', 'X' => Move.rock,
'B', 'Y' => Move.paper,
'C', 'Z' => Move.scissor,
else => Move.rock,
};
}
const Outcome = enum {
... | https://raw.githubusercontent.com/dhruvasagar/comp/a12a9fbb979d5f11ddf6c984d31009a035f88944/adventofcode/2022/day02/day02.zig |
const std = @import("std");
const profiler = @import("./listing_0081_nesting_profiler.zig");
const haversine_formula = @import("./listing_0065_haversine_formula.zig");
const referenceHaversine = haversine_formula.referenceHaversine;
const parseHaversinePairs = @import("./listing_0079_nesting_timedblock_lookup_json_pars... | https://raw.githubusercontent.com/santiagocabrera96/computer-enhance-zig/ff61abb1e93a2d0a6e2c3d1f8df090c0c04e705b/part2/src/listing_0082_nesting_haversine_main.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.... | https://raw.githubusercontent.com/jiacai2050/zig-rocksdb/dafac357d0d46eeb6f088e52df6331833bc683fe/build.zig |
usingnamespace @import("zalgebra");
const c = @import("c.zig");
const c_allocator = @import("std").heap.c_allocator;
const panic = @import("std").debug.panic;
pub const Shader = struct {
name: []const u8,
program_id: u32,
vertex_id: u32,
fragment_id: u32,
geometry_id: ?u32,
pub fn create(name:... | https://raw.githubusercontent.com/kooparse/mogwai/90fbdb659f42bc7bbd9ee8d6612cd4ebb4ea7ea9/exemples/common/shader.zig |
//
// Copyright (C) Palash Bauri
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// SPDX-License-Identifier: MPL-2.0
const BN_INFINITY = "অসীম";
const BN_NAN ... | https://raw.githubusercontent.com/bauripalash/pankti/191b8dede7c6fd8f5c72a75a7217438e11213824/src/value.zig |
pub const version = @import("std").SemanticVersion{ .major = 0, .minor = 9, .patch = 2 };
const std = @import("std");
const assert = std.debug.assert;
pub fn init(allocator: std.mem.Allocator) void {
assert(mem_allocator == null);
mem_allocator = allocator;
mem_allocations = std.AutoHashMap(usize, usize).i... | https://raw.githubusercontent.com/craftlinks/zig_learn_opengl/7208f4402c44d9cb697705218b2bbbc82a8ccdd2/libs/zstbi/src/zstbi.zig |
const std = @import("std");
const ast = @import("ast.zig");
const intrinsics = @import("intrinsics.zig");
const gc = @import("boehm.zig");
const util = @import("util.zig");
const linereader = @import("linereader.zig");
const Token = ast.Token;
const Expr = ast.Expr;
const ExprType = ast.ExprType;
const ExprValue = ast.... | https://raw.githubusercontent.com/cryptocode/bio/e525af48db08bd4fcc58f6a7f072b4350089fd64/src/interpreter.zig |
const std = @import("std");
const xev = @import("xev");
const Task = xev.ThreadPool.Task;
pub const Job = struct {
task: Task,
results: []Application = &.{},
allocator: std.mem.Allocator,
wg: xev.Async,
done: bool = false,
};
pub fn indexApplications(allocator: std.mem.Allocator) []Application {
... | https://raw.githubusercontent.com/ajkachnic/ora/702b30e88319364d0d215a541d7e9eee8fcd9723/src/tools/application.zig |
const std = @import("std");
const thread = std.thread;
const Game = @import("../model/game.zig").Game;
const State = @import("../model/game.zig").State;
const Action = @import("../model/action.zig").Action;
const http = std.http;
const Allocator = std.mem.Allocator;
const r = @cImport({
@cInclude("raylib.h");
});... | https://raw.githubusercontent.com/bhou/pioupiou/82701c42c092692863de9f45ade571fbd7f59cef/src/agents/gpt.zig |
// --------------------------------------------------------------------------
// Imports
// --------------------------------------------------------------------------
const std = @import("std");
const readU16Array = @import("../utils/loaders.zig").readU16Array;
const readI16Array = @import("../utils/loaders.zig").readI... | https://raw.githubusercontent.com/shazz/ZigMachine/ae4d23e2749f9bdbc6ad225909e63e6c5df487b8/src/scenes/bladerunners.zig |
const std = @import("std");
const input = @embedFile("input.txt");
// const input = @embedFile("input_small_2.txt");
// const input_len = 8;
const input_len = 757;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const alloc = gpa.allocator();
{
... | https://raw.githubusercontent.com/nsksbjii/Advent-of-Code-zig/0d98a270e88fa9c1c48fa5523f609ddff379f17e/2023/day8/main2.zig |
const std = @import("std");
const Api = @import("../../api/schema.zig").Api;
const bun = @import("root").bun;
const MimeType = @import("../../bun_dev_http_server.zig").MimeType;
const ZigURL = @import("../../url.zig").URL;
const HTTPClient = @import("root").bun.HTTP;
const NetworkThread = HTTPClient.NetworkThread;
cons... | https://raw.githubusercontent.com/ziord/bun/7fb06c0488da302b56507191841d25ef3c62c0c8/src/bun.js/webcore/blob.zig |
const std = @import("std");
const g = @import("spirv/grammar.zig");
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const args = try std.process.argsAlloc(allocator);
if (args.len != 2) {
usa... | https://raw.githubusercontent.com/collinalexbell/all-the-compilers/7f834984f71054806bfec8604e02e86b99c0f831/zig/tools/gen_spirv_spec.zig |
const std = @import("std");
const debug = std.debug;
pub fn squareOfSum(number: usize) usize {
var sum: usize = 0;
for (0..(number + 1)) |n| {
sum += n;
}
return sum * sum;
}
pub fn sumOfSquares(number: usize) usize {
var sum: usize = 0;
for (0..(number + 1)) |n| {
sum += n * ... | https://raw.githubusercontent.com/charlieroth/exercism/87e3f2922f55fab57d3b1005ec1567f9d919fb27/zig/difference-of-squares/difference_of_squares.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const opts = .{ .target = target, .optimize = optimize };
const neat_module = b.dependency("zigNEAT", opts).module("zigNEAT");
const exe = b... | https://raw.githubusercontent.com/cryptodeal/zig-NEAT/cb360c15dc6106391d654861719dac64ef8407de/examples/cartpole/build.zig |
const std = @import("std");
const georgios = @import("georgios");
const utils = @import("utils");
const kernel = @import("kernel.zig");
const print = @import("print.zig");
const MinBuddyAllocator = @import("buddy_allocator.zig").MinBuddyAllocator;
const console_writer = kernel.console_writer;
const platform = @impor... | https://raw.githubusercontent.com/iguessthislldo/georgios/7241783f787965aeff8d829610c9ce256ec86224/kernel/memory.zig |
const std = @import("std");
const disk = @import("disk.zig");
const term = @import("term.zig");
const fs = @import("extended/fs.zig");
const mem = std.mem;
const Allocator = mem.Allocator;
const Parameters = fs.Parameters;
var parameters: Parameters = undefined;
var relative: usize = undefined;
var manager: Allocator ... | https://raw.githubusercontent.com/sajjadium/ctf-archives/b7012a5fc5454f8c74ce534ecf4da521c5b9595e/ctfs/AmateursCTF/2023/pwn/simpleOS/src/fs.zig |
const std = @import("std");
const assert = std.debug.assert;
const Enemy = @import("enemy.zig").Enemy;
const GameState = @import("GameState.zig");
const JS = @import("JS.zig");
const Projectile = @import("projectile.zig").Projectile;
const utils = @import("utils.zig");
const Ball2D = utils.Ball2D;
const RGBColor = ut... | https://raw.githubusercontent.com/daneelsan/Dodgeballz/ac3f94ce0b54c86720d545c21f506c1aff6cd248/src/particle.zig |
const std = @import("std");
pub fn isArmstrongNumber(num: u128) bool {
const num_digits = digit_count(num);
var remainder: u128 = num;
var armstrong_sum: u128 = 0;
while (remainder != 0) : (remainder /= 10)
armstrong_sum += std.math.pow(u128, remainder % 10, num_digits);
return armstrong_... | https://raw.githubusercontent.com/ErikSchierboom/exercism/000175f6b73decb604d41aa0bbd250d11e0cea84/zig/armstrong-numbers/armstrong_numbers.zig |
// Set the resolved type for labels to .symbol_def.
// The resolved constant for these expressions is the raw symbol name.
// Any labels which do not begin with `_` and are not in a stack section will be added to the global symbol table.
// Create Sections for each named section block and set the Block.section handle t... | https://raw.githubusercontent.com/bcrist/vera/3fa048b730dedfc3551ecf352792a8322466867a/lib/assembler/typechecking.zig |
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 Lee Cannon <leecannon@leecannon.xyz>
const std = @import("std");
const core = @import("core");
const kernel = @import("kernel");
const limine = @import("limine");
export fn _start() callconv(.C) noreturn {
@call(.never_inline, @import("init.zig").in... | https://raw.githubusercontent.com/CascadeOS/CascadeOS/07e8248e8a189b1ff74c21b60f0eb80bfe6f9574/kernel/boot.zig |
const escape = @import("details/escape.zig");
const std = @import("std");
const FormatterInterface = @import("../../../json.zig").ser.Formatter;
pub fn Formatter(comptime Writer: type) type {
return struct {
const Self = @This();
pub usingnamespace FormatterInterface(
Self,
... | https://raw.githubusercontent.com/getty-zig/json/11946ff9d2f159cb06aaf423ce13bd8aa2a481e7/src/ser/impl/formatter/compact.zig |
export fn foo() void {}
// obj
| https://raw.githubusercontent.com/ziglang/zig/d9bd34fd0533295044ffb4160da41f7873aff905/doc/langref/export_builtin_equivalent_code.zig |
const std = @import("std");
const flecs = @import("flecs");
const q = flecs.queries;
pub const Velocity = struct { x: f32, y: f32 };
pub const Position = struct { x: f32, y: f32 };
pub const Acceleration = struct { x: f32, y: f32 };
pub fn main() !void {
var world = flecs.World.init();
defer world.deinit();
... | https://raw.githubusercontent.com/prime31/zig-flecs/1350d78d00dd6528b2d645a1e7275e1b6390a288/examples/systems.zig |
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
const std = @import("../std.zig");
const bui... | https://raw.githubusercontent.com/dip-proto/zig/8f79f7e60937481fcf861c2941db02cbf449cdca/lib/std/event/rwlock.zig |
const std = @import("std");
const main = @import("root");
const graphics = main.graphics;
const draw = graphics.draw;
const Shader = graphics.Shader;
const TextBuffer = graphics.TextBuffer;
const Texture = graphics.Texture;
const vec = main.vec;
const Vec2f = vec.Vec2f;
const gui = @import("../gui.zig");
const GuiCom... | https://raw.githubusercontent.com/PixelGuys/Cubyz/df0e809845a161678d91f4e5e0dcd24e67c4b6c0/src/gui/components/Button.zig |
const base = @import("base");
const math = base.math;
const Vec4f = math.Vec4f;
pub const Result = struct {
reflection: Vec4f,
pub fn init(reflection: Vec4f, p: f32) Result {
return .{ .reflection = .{ reflection[0], reflection[1], reflection[2], p } };
}
pub fn empty() Result {
retur... | https://raw.githubusercontent.com/Opioid/zyg/d8eacc469020972fd11eb5c6c21ce5115d943581/src/core/scene/material/bxdf.zig |
const std = @import("std");
const builtin = @import("builtin");
// A tiny circular buffer to store queries we are interested in receiving the replies from.
// Also tracks the current sequence id, so ignoreEvent must be called for every request.
pub const ReplyBuffer = struct {
const ReplyEvent = struct {
s... | https://raw.githubusercontent.com/Aransentin/zigwin/4df40163aad0eb52be6b150ff6add668a1348bb2/src/x11/replybuffer.zig |
const std = @import("std");
const math = std.math;
const print = std.debug.print;
const Complex = std.math.Complex;
const isSignedInt = std.meta.trait.isSignedInt;
const Allocator = std.mem.Allocator;
const ValueType = @import("type_helpers").ValueType;
// Conjugate Pair Lookup Table --------------------------------... | https://raw.githubusercontent.com/BlueAlmost/zfft-orchard/b83445ab809b26e5e5dfd3092a2d695355cab02a/src/LUT.zig |
// code taken from here: https://zig.news/kilianvounckx/zig-interfaces-for-the-uninitiated-an-update-4gf1
const std = @import("std");
const Iterator = struct {
const Self = @This();
ptr: *anyopaque,
nextFn: fn (*anyopaque) ?u32,
pub fn init(ptr: anytype) Self {
const Ptr = @TypeOf(ptr);
... | https://raw.githubusercontent.com/lhk/zig_runtime_polymorphism/b854f616ebc86b5f675b2612c7da522ce1b4b757/src/blogpost.zig |
const std = @import("std");
const slotmap = @import("slotmap");
const Key = slotmap.Key;
const SlotMap = slotmap.SlotMap;
const SecondaryMap = slotmap.SecondaryMap;
const print = std.debug.print;
pub fn main() void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
var users = SlotMap(u64)... | https://raw.githubusercontent.com/mmstick/zig-slotmap/3e67e6a79c325388b9377c762ef9b47b4c11ef0f/examples/secondary.zig |
const std = @import("std");
const rg = @import("../../renderer/render_graph/render_graph.zig");
const application = @import("../../application/application.zig");
const Config = @import("../../application/config.zig").Config;
const DefaultRenderer = @import("../../renderer/default_renderer.zig").DefaultRenderer;
const ... | https://raw.githubusercontent.com/Black-Cat/nyancore/257e111e77dfa8288e0d14a9055a137b3113f1c8/src/tools/mesh_viewer/main.zig |
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... | https://raw.githubusercontent.com/OfflineBrain/monkey-zig-interpreter/2750c4079729aeb77733a16815f2c422ea4a984f/build.zig |
pub const stm32f407vet6 = @import("stm32f407vet6.zig");
pub const stm32f429bit6 = @import("stm32f429bit6.zig");
pub const stm32l475vet6 = @import("stm32l475vet6.zig");
pub const stm32mp157x = @import("stm32mp157x.zig");
// "not good smell"
pub const reg = @import("reg/reg.zig");
| https://raw.githubusercontent.com/octopus-os-org/octopus/9611e81199a624f5815be0b842b99eb3e3e29695/octopus/chip/st/st.zig |
const pad = @import("assets.zig").padding;
const rotate_speed = @import("settings.zig").rotate_speed;
const std = @import("std");
const map = @import("map.zig");
const math = @import("std").math;
const utils = @import("utils.zig");
pub const px_per_tile: i16 = 50; //88;
pub const size_mult: f32 = 5.0; //8.0;
pub var ... | https://raw.githubusercontent.com/Slendergo/zig-client/a2248790993ec2611863e9e1f8ff5b50592c3d11/src/camera.zig |
const math = @import("math.zig");
const Transform = @import("Transform.zig");
const GlobalTransform = @This();
translation: math.Vec3 = math.Vec3.ZERO,
rotation: math.Quat = math.Quat.IDENTITY,
scale: math.Vec3 = math.Vec3.ONE,
pub fn transformPoint(self: GlobalTransform, point: math.Vec3) math.Vec3 {
var p = s... | https://raw.githubusercontent.com/Sudoku-Boys/Sudoku/218ea16ecc86507698861b59a496ff178a7a7587/src/engine/GlobalTransform.zig |
const std = @import("std");
const SinglyLinkedList = std.SinglyLinkedList;
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const aoc = @import("aoc");
const expectEqual = aoc.expectEqual;
// TODO: refactor the struct to hold a slice
pub fn Permutations(comptime T: type) type {
return struct ... | https://raw.githubusercontent.com/erplsf/adventofcode/b969bf82b00ff7d2e7e0b1ca6c36a12b5865cff0/zig/src/permute_v2.zig |
//https://github.com/dmgk/zig-uuid
const std = @import("std");
const crypto = std.crypto;
const fmt = std.fmt;
const testing = std.testing;
const bun = @import("root").bun;
pub const Error = error{InvalidUUID};
const UUID = @This();
bytes: [16]u8,
pub fn init() UUID {
var uuid = UUID{ .bytes = undefined };
... | https://raw.githubusercontent.com/resourcemod/sidejs/2eb853f13a96d6434fe9dba78906a390b1eb90fa/src/js/bun-bun-v1.0.30/src/bun.js/uuid.zig |
const scanner = @import("scanner.zig");
const chunk = @import("chunk.zig");
const value = @import("value.zig");
const config = @import("config.zig");
const std = @import("std");
const GPAlloc = std.heap.GeneralPurposeAllocator(.{});
const Token = scanner.Token;
const TokenType = scanner.TokenType;
const vm = @import("v... | https://raw.githubusercontent.com/storyfeet/crafting_zlox/8d470acaca5157a13c441add346953c2e1953878/src/compiler.zig |
pub fn showBlockTextureGen() void {
showSettingsScreen(blecs.components.screen.TextureGen);
}
pub fn showBlockEditor() void {
showSettingsScreen(blecs.components.screen.BlockEditor);
}
pub fn showChunkEditor() void {
showSettingsScreen(blecs.components.screen.ChunkEditor);
}
pub fn showCharacterEditor() ... | https://raw.githubusercontent.com/btipling/blockens/76087f14d79a303f4cae8d09d8cfaaf86a69a0e0/src/game/blecs/systems/screen_helpers.zig |
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig");
const translate = @import("translate.zig");
export fn napi_register_module_v1(env: c.napi_env, exports: c.napi_value) c.napi_value {
translate.register_function(env, exports, "greet", greet) catch return null;
return expor... | https://raw.githubusercontent.com/staltz/zig-nodejs-example/f68ba9852114e614dbdee58ac03e41b00dfcff36/src/lib.zig |
// Inspired by: https://gist.github.com/Accalmie/d328287c05f0a417892f
// Simple Sniffer in winsock by Silver Moon ( m00n.silv3r@gmail.com )
const std = @import("std");
const ws = @cImport(@cInclude("winsock2.h"));
const Protocol = enum(u8) { TCP = 6, UDP = 17 };
// Bit field order reversed because data is received a... | https://raw.githubusercontent.com/tris790/packet-sniffer/d52d9be9d18da1df8472f02d0db9d36f208ae23b/src/packet_sniffer.zig |
//comptime
//{
// asm (
// \\ .set ALIGN, 1 << 0
// \\ .set MEMINFO, 1 << 1
// \\ .set FLAGS, ALIGN | MEMINFO
// \\ .set MAGIC, 0x1BADB002
// \\ .set CHECKSUM, -(MAGIC + FLAGS)
// \\
// \\ .section .multiboot
// \\ .align 4
// \\ .long MAGIC
//... | https://raw.githubusercontent.com/Kbz-8/42_KFS/decb1dfa62f1ca893094f3f6fd5ed6e43a53c4d9/sources/kernel/arch/x86/boot.zig |
// File: binary_search_tree.zig
// Created Time: 2023-01-15
// Author: sjinzh (sjinzh@gmail.com)
const std = @import("std");
const inc = @import("include");
// 二叉搜索树
pub fn BinarySearchTree(comptime T: type) type {
return struct {
const Self = @This();
root: ?*inc.TreeNode(T) = null,
mem_... | https://raw.githubusercontent.com/qianjiangboy/hello-algo/9baf4a1753ab097e574046431dfbbd488a6739b8/codes/zig/chapter_tree/binary_search_tree.zig |
const std = @import("std");
const sdl = @import("sdl.zig");
const settings = @import("settings.zig");
const game = @import("game");
const math = @import("math.zig");
pub const Event = enum {
exit,
ok,
};
pub fn handleInput(state: *game.GameState) Event {
var event: sdl.SDL_Event = undefined;
while ... | https://raw.githubusercontent.com/j-helland/zig-htn-demo/a8a2dbc1b606f25631c29e3b3f829230da1e558e/src/input.zig |
const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
try solve("d09/test1");
try solve("d09/input");
}
fn solve(filename: []const u8) !void {
const file = try std.fs.cwd().openFile(filename, .{});
defer file.close();
var buf_reader = std.io.bufferedReader(file.reader()... | https://raw.githubusercontent.com/andrewflbarnes/advent-of-code-2023/852c602dac382ff738e7a41c003bd51e6e947939/d09/soln.zig |
// Copyright 2024 The Nushift Authors.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE or copy at
// https://www.boost.org/LICENSE_1_0.txt)
const std = @import("std");
pub const FBSWriter = std.io.FixedBufferStream([]u8).Writer;
pub const FBSWriteError = std.io.Fixed... | https://raw.githubusercontent.com/davepollack/nushift/83f074c7bb2a2fa8405818eee8be8526c24ff4f8/examples/hello-world/src/writing.zig |
const std = @import("std");
pub fn main() !void {
var file = try std.fs.cwd().openFile("input.txt", .{});
defer file.close();
var buf_reader = std.io.bufferedReader(file.reader());
var in_stream = buf_reader.reader();
// -1 is "unset" flag
var first: i32 = -1;
var last: i32 = 0;
var ... | https://raw.githubusercontent.com/VirgileHenry/aoc-zig/ceb7feb4ee0f26d6cc82d7c3c8fa6a7fdf42dba4/day1/part1/src/main.zig |
const assert = @import("std").debug.assert;
pub const DrawListSharedData = opaque {};
pub const Context = opaque {};
pub const DrawCallback = ?fn (parent_list: ?*const DrawList, cmd: ?*const DrawCmd) callconv(.C) void;
pub const DrawIdx = u16;
pub const ID = u32;
pub const InputTextCallback = ?fn (data: ?*InputTextCal... | https://raw.githubusercontent.com/digitalcreature/ube/c5e5c9f4b54f1981ead8337faf4513c83b92fc01/src/imgui/imgui.zig |
usingnamespace @import("./common.zig");
const Input = struct {
time: u64,
ids: []const u64,
};
pub fn cleanInput(allocator: *mem.Allocator, file: []const u8) !*Input {
var input = try allocator.create(Input);
var lines = mem.tokenize(file, "\n");
input.time = try parseInt(u64, lines.next().?, 10);... | https://raw.githubusercontent.com/meatcar/adventofcode/0639eac0a8f191db2bd745942b208658b73a469b/2020/days/day13.zig |
const std = @import("std");
pub inline fn fromMegabytes(mb: f64) f64 {
return mb * 1024 * 1024;
}
pub inline fn toMegabytes(bytes: f64) f64 {
return bytes / 1024 / 1024;
}
| https://raw.githubusercontent.com/Wraith29/zvm/9046774d8f34df89214db780cc877f4384ee4d54/src/size.zig |
const std = @import("std");
const imgui_app = @import("./imgui_app.zig");
const fbo_dock = @import("./fbo_dock.zig");
const dockspace = @import("./dockspace.zig");
pub const ImGuiApp = imgui_app.ImGuiApp;
pub const FboDock = fbo_dock.FboDock;
pub const MouseInput = fbo_dock.MouseInput;
pub const Dock = dockspace.Dock;... | https://raw.githubusercontent.com/ousttrue/zigcell/5675ff842ac6cee1868f5c66fd9a70fb60a1b7e7/pkgs/imutil/src/main.zig |
// Copyright (C) 2024 Robert A. Wallis, all rights reserved.
const std = @import("std");
pub fn extension(filename: []const u8) ?[]const u8 {
if (std.mem.lastIndexOf(u8, filename, ".")) |pos| {
return filename[pos..];
}
return null;
}
test extension {
try std.testing.expectEqualStrings(".jpg",... | https://raw.githubusercontent.com/robert-wallis/dirstat/4ca0e171459dc19f6790a3e71beb4819ccb3bb51/src/string.zig |
const std = @import("std");
const registry = @import("registry.zig");
const xml = @import("../xml.zig");
const cparse = @import("c-parse.zig");
const mem = std.mem;
const Allocator = mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const api_constants_name = "API Constants";
pub const ParseResult = stru... | https://raw.githubusercontent.com/zetaframe/zetaframe/00bdecafd183c6c55721d89278b6cebd91dbecdd/render/lib/vulkan-zig/generator/vulkan/parse.zig |
const std = @import("std");
extern "r2" fn add(a: i32, b: i32, mul: *i32) i32;
fn main() void {
const add_res = add(a1, a2, &mul_res);
std.info.log("Hello World", .{add_res});
}
| https://raw.githubusercontent.com/radareorg/radare2-rlang/de319d226e77d1fe3118ce0c2f83264ee023a15d/wasm3/zig/examples/r2pipe.zig |
const std = @import("std");
const types = @import("types.zig");
const descriptors = @import("descriptors.zig");
const Reflector = @This();
allocator: std.mem.Allocator,
env: *types.JNIEnv,
pub fn init(allocator: std.mem.Allocator, env: *types.JNIEnv) Reflector {
return .{ .allocator = allocator, .env = env };
}
... | https://raw.githubusercontent.com/zig-java/jui/a957d9376db101cb136a62d89341abdfef1529ab/src/Reflector.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const phantom = @import("phantom");
const Output = @import("output.zig");
const Self = @This();
allocator: Allocator,
kind: phantom.display.Base.Kind,
output: ?*Output,
pub fn init(alloc: Allocator, kind: phantom.display.Base.Kind) Self {
return .{
... | https://raw.githubusercontent.com/PhantomUIx/display-uefi/f7bc713d8ec5f65cb30261acb3e6714953c8c118/src/phantom/display/backends/uefi/display.zig |
const std = @import("std");
const expect = std.testing.expect;
const c = @import("chunk.zig");
const debug = @import("debug.zig");
const vm = @import("vm.zig");
pub fn main() anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer {
const leaked = gpa.deinit();
if (leaked) exp... | https://raw.githubusercontent.com/faheywf/zlox/2a8b6531ba03faeb781f24cef500168fc3f9442a/src/main.zig |
const std = @import("std");
const builtin = @import("builtin");
const debug = std.debug;
const heap = std.heap;
const mem = std.mem;
const process = std.process;
const testing = std.testing;
/// An example of what methods should be implemented on an arg iterator.
pub const ExampleArgIterator = struct {
const Erro... | https://raw.githubusercontent.com/txthinking/jb/d0e3ddce48be1ca0490904397bcd030c5aa7032e/src/deps/zig-clap/clap/args.zig |
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{})... | https://raw.githubusercontent.com/SebastianKeller/zig_matrix/72a8398cb3db73a118490a1e5d6301adac77a493/build.zig |
const std = @import("std");
const log = std.log.scoped(.ntp_client_build);
const client_version = std.SemanticVersion{ .major = 0, .minor = 0, .patch = 7 };
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const flags = b.depen... | https://raw.githubusercontent.com/FObersteiner/ntp-client/f6aa38b788940b64274469f553f371c30ad8af30/build.zig |
const std = @import("std");
pub const ziloVerison = "0.0.1";
pub fn ArrayList2D(comptime T: type) type {
return std.ArrayList(std.ArrayList(T));
}
const CommandKeyTag = enum {
up, down, left, right,
backspace,
char,
none,
};
pub const CommandKey = union(CommandKeyTag) {
up: void,
down: v... | https://raw.githubusercontent.com/LittleJianCH/zilo/7ac8877d1948f3c4ca73c074a42ad5d7d1c4bdc0/src/editor/def.zig |
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
//! Xoroshiro128+ - http://xoroshiro.di.uni... | https://raw.githubusercontent.com/dip-proto/zig/8f79f7e60937481fcf861c2941db02cbf449cdca/lib/std/rand/Xoroshiro128.zig |
const std = @import("std");
const math = std.math;
const ecs = @import("zflecs");
const zm = @import("zmath");
const ecsu = @import("../flecs_util/flecs_util.zig");
const fd = @import("../config/flecs_data.zig");
const IdLocal = @import("../core/core.zig").IdLocal;
const input = @import("../input.zig");
const ztracy = ... | https://raw.githubusercontent.com/Srekel/tides-of-revival/e5a78dfb9f2b8792a5ee53ccf75144c25469ff4f/src/systems/input_system.zig |
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
const udivmod = @import("udivmod.zig").udivm... | https://raw.githubusercontent.com/dip-proto/zig/8f79f7e60937481fcf861c2941db02cbf449cdca/lib/std/special/compiler_rt/divti3.zig |
const std = @import("std");
const zglfw = @import("zglfw");
const IdLocal = @import("core/core.zig").IdLocal;
pub const TargetMap = std.AutoHashMap(IdLocal, TargetValue);
pub const FrameData = struct {
index_curr: u32 = 0,
target_defaults: TargetMap,
targets_double_buffer: [2]TargetMap,
targets: *Targ... | https://raw.githubusercontent.com/Srekel/tides-of-revival/e5a78dfb9f2b8792a5ee53ccf75144c25469ff4f/src/input.zig |
const std = @import("std");
const Table = @import("table-helper").Table;
pub fn main() anyerror!void {
try std.io.getStdOut().writer().print("{}\n", .{Table(&[_][]const u8{ "Version", "Date" }){ .data = &[_][2][]const u8{
.{ "0.7.1", "2020-12-13" },
.{ "0.7.0", "2020-11-08" },
.{ "0.6.0", "... | https://raw.githubusercontent.com/pmuens/ziglearn/2e9a847b75d8f4981c8d2ecd8d3063ae4c87f13e/chapter-3/packages/src/main.zig |
// DevOS.zig - library root
//2023apr25:(VK) Created
//2023may07:(VK)!works
//2023may08:(VK)+OSwin
//2023may08:(VK)+GBuf
//2023may16:(VK)+say
//2023jun03:(VK)+OSwin,IRender
//2023jun13:(VK)+Timer
//2023jul16:(VK)+beep
//2023jul27:(VK)+IAnyList
// Obeisances to The Supreme Absolute Person, who is the only i... | https://raw.githubusercontent.com/oldwo/zigui/45d2c4504b3cc51a740f495e118f4f7a0a5b6185/src/DevOS.zig |
const c = @import("./chunk.zig");
const Chunk = c.Chunk(u8);
const OpCode = c.OpCode;
const v = @import("./value.zig");
const Value = v.Value;
const Debug = @import("./debug.zig");
const std = @import("std");
const build_options = @import("build_options");
const Allocator = std.mem.Allocator;
const compiler = @import("... | https://raw.githubusercontent.com/Wuschli/keto/692fa08495c5c46241f2f5e268282c685a37f730/src/vm.zig |
const std = @import("std");
pub const c = @import("c.zig");
pub usingnamespace @import("cast.zig");
pub usingnamespace @import("girepository.zig");
| https://raw.githubusercontent.com/paveloom-z/zig-girepository/b9358f41e9bd455bc19f5a373070d6c0616745bc/src/lib.zig |
// File: binary_tree_dfs.zig
// Created Time: 2023-01-15
// Author: sjinzh (sjinzh@gmail.com)
const std = @import("std");
const inc = @import("include");
var list = std.ArrayList(i32).init(std.heap.page_allocator);
// 前序遍历
fn preOrder(comptime T: type, root: ?*inc.TreeNode(T)) !void {
if (root == null... | https://raw.githubusercontent.com/codingonion/hello-algo-zig/8a860aec2e5d5b30653b6611224fcbc823055d2b/chapter_tree/binary_tree_dfs.zig |
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024 Lee Cannon <leecannon@leecannon.xyz>
const std = @import("std");
const LibraryDependency = @import("LibraryDependency.zig");
const ApplicationDescription = @This();
/// The name of the application:
/// - used for the path to the root file `apps/{name... | https://raw.githubusercontent.com/CascadeOS/CascadeOS/07e8248e8a189b1ff74c21b60f0eb80bfe6f9574/build/ApplicationDescription.zig |
//! Creating paths and manipulating path data.
const std = @import("std");
const c = @import("../c.zig");
const PathDataType = @import("../enums.zig").PathDataType;
const Error = @import("../utilities/error_handling.zig").Error;
/// Convenience struct to iterate over the data elements in a Cairo path.
const PathIterat... | https://raw.githubusercontent.com/jackdbd/zig-cairo/c2736f512b5a48a5ad38a15973b2879166da1d8a/src/drawing/path.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const use_native_backend = b.option(bool, "native-backend", "Use Zig's native x86 backend for compilation") orelse false;
const exe = b.addExecuta... | https://raw.githubusercontent.com/efjimm/Cellulator/ddd3986732591780485279d2ba08c8ffb1eed7d7/build.zig |
const zss = @import("zss");
const tokenize = zss.syntax.tokenize;
const parse = zss.syntax.parse;
const Utf8String = zss.util.Utf8String;
const std = @import("std");
pub fn main() !u8 {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const... | https://raw.githubusercontent.com/chadwain/zss/e65690f7f0802222f300e7fbe70bc41f2d202030/examples/parse.zig |
const bun = @import("root").bun;
const std = @import("std");
const LineOffsetTable = bun.sourcemap.LineOffsetTable;
const SourceMap = bun.sourcemap;
const Bitset = bun.bit_set.DynamicBitSetUnmanaged;
const Output = bun.Output;
const prettyFmt = Output.prettyFmt;
/// Our code coverage currently only deals with lines of... | https://raw.githubusercontent.com/resourcemod/sidejs/2eb853f13a96d6434fe9dba78906a390b1eb90fa/src/js/bun-bun-v1.0.30/src/sourcemap/CodeCoverage.zig |
const std = @import("std");
const utils = @import("utils.zig");
pub fn main() !void {
const lines = utils.readFileLines("day3_input.txt");
var map = utils.makeMap(utils.Pos, usize);
var p = utils.Pos{};
var steps: usize = 0;
var it = std.mem.separate(lines[0], ",");
while (it.next()) |d| {
... | https://raw.githubusercontent.com/lukechampine/advent/fb5db7bc2f413760f6e8f4982b905d664bff0279/2019/day3.zig |
const std = @import("std");
const stdin = std.io.getStdIn().reader();
const stdout = std.io.getStdOut().writer();
const expect = std.testing.expect;
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const ... | https://raw.githubusercontent.com/dradtke/advent/8c420c8ff28f102c56e5c05852c6d2845edb2ce5/2021/zig/day05/part2.zig |
//
// ------------------------------------------------------------
// TOP SECRET TOP SECRET TOP SECRET TOP SECRET TOP SECRET
// ------------------------------------------------------------
//
// Are you ready for the THE TRUTH about Zig string literals?
//
// Here it is:
//
// @TypeOf("foo") == *const [3:0]u8
... | https://raw.githubusercontent.com/JolliestJames/ziglings/9bb24bb99e4811c1ad6c78db654cffc0758138b6/exercises/077_sentinels2.zig |
const std = @import("std");
/// Zig version. When writing code that supports multiple versions of Zig, prefer
/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
pub const zig_version = std.SemanticVersion.parse("0.9.1") catch unreachable;
/// Temporary until self-hosted is feature complete... | https://raw.githubusercontent.com/pierback/glob-delete/4cf18a452d3acaf281698a1f70804c7eccb11dfb/zig-cache/o/9782c9449f2be494fc3cfbf74ce55b1c/builtin.zig |
const std = @import("std");
const zaudio = @import("zaudio");
fn data_callback(device: *zaudio.Device, output: ?*anyopaque, input: ?*const anyopaque, frame_count: u32) callconv(.C) void {
_ = frame_count;
_ = input;
_ = output;
_ = device;
std.log.info("here", .{});
}
fn create() !void {
var c... | https://raw.githubusercontent.com/marloncalvo/space-glow-zig/bbb28bc53f3895931d966bf7f245a0faa71755cb/src/main.zig |
// The Table struct presents a "view" over our rx buffer that we
// can query without needing to allocate memory into, say, a hash
// map. For small tables (I assume we'll only see smallish tables)
// this should be fine performance-wise.
const std = @import("std");
const mem = std.mem;
const WireBuffer = @import("wire... | https://raw.githubusercontent.com/malcolmstill/zig-amqp/6f2ae2061a9fb6e6ca9d6770f3cfdc8e67c5fa8a/src/table.zig |
const lib = @import("lib");
const assert = lib.assert;
const config = lib.config;
const Allocator = lib.Allocator;
const ELF = lib.ELF(64);
const log = lib.log.scoped(.uefi);
const PhysicalAddress = lib.PhysicalAddress;
const PhysicalMemoryRegion = lib.PhysicalMemoryRegion;
const VirtualAddress = lib.VirtualAddress;
co... | https://raw.githubusercontent.com/birth-software/birth/23a3c67990b504c487bbcf21dc4f76e898fa23b8/src/bootloader/birth/uefi/main.zig |
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const args = try std.process.argsAlloc(allocator);
defer std.process.argsFree(allocator, args);
if (args.len != 2) {
std.log... | https://raw.githubusercontent.com/DivergentClouds/wise/c44b3155ff9be92f0858291eef93547ab37c80c5/src/main.zig |
const std = @import("std");
const print = std.debug.print;
const tools = @import("../utils/tools.zig");
const cmd = @import("../utils/commands.zig");
const Cli = @import("../main.zig").Cli;
pub fn app(cli: Cli) !void {
try tools.titleMaker("ZIX Configuration");
cmd.configPrint(cli.repo, tools.boolToString(cli... | https://raw.githubusercontent.com/alvaro17f/zix/bebb630f1b670a8f0a53358c4c96b92dc7454d51/src/app/app.zig |
const std = @import("std");
const c = @import("c.zig").c;
const DefaultPrng = std.rand.DefaultPrng;
const CELL_WIDTH = @import("main.zig").CELL_WIDTH;
const CELL_HEIGHT = @import("main.zig").CELL_HEIGHT;
pub const Cell = enum { dead, alive };
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.a... | https://raw.githubusercontent.com/Skarsh/zig-conway/0fb702dbf4925d2a35e8b33b5d905246feb8470e/src/grid.zig |
const std = @import("std");
const Point = @This();
x: f32 = 0,
y: f32 = 0,
pub fn nonZero(self: *const Point) bool {
return (self.x != 0 or self.y != 0);
}
pub fn plus(self: *const Point, b: Point) Point {
return Point{ .x = self.x + b.x, .y = self.y + b.y };
}
pub fn diff(a: Point, b: Point) Point {
r... | https://raw.githubusercontent.com/david-vanderson/dvui/8645f753c1b2eb93f1bd795e2d24469f5493b670/src/Point.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Arr = std.ArrayListUnmanaged(u32);
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const alloc = gpa.allocator();
const program = program: {
const program_text = program_tex... | https://raw.githubusercontent.com/Reconcyl/eso/bc48a02d77517840fa86c95382aa5f02fa900f2c/morbusz/main.zig |
const gfx = @import("gfx");
const math = @import("std").math;
const Renderer = @import("Renderer.zig");
const Rect = Renderer.Rect;
const Sprite = Renderer.Sprite;
const effects_tex = gfx.effects;
const teleport_tex = gfx.teleport;
pub const hurt_fx = gfx.hurt;
pub fn load() void {
effects_tex.loadFromUrl("img/ef... | https://raw.githubusercontent.com/ZigEmbeddedGroup/sycl-badge/0087e9a138dd9c816be545000a5a39ecbd6e0e15/showcase/carts/zeroman/src/effects.zig |
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... | https://raw.githubusercontent.com/Molcarrus/ParticleMagnet-Zig/8e376bf676aa7bef9ccce34788a799b75348ea8b/build.zig |
const lib = @import("lib.zig");
const std = @import("std");
extern var end: [*]u8;
extern var timer_scratch: *u64;
fn intToString(int: u64, buf: []u8) []const u8 {
return std.fmt.bufPrint(buf, "0x{x}", .{int}) catch "";
}
pub export fn main() void {
var buf: [20]u8 = undefined;
const ptr: *u64 = @ptrFrom... | https://raw.githubusercontent.com/csirak/zestos/1a6b7a20ab388827d5d9ebae8a2e245e2e73b702/kernel/main.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.