text
stringlengths
32
314k
url
stringlengths
93
243
const root = @import("root"); pub const c = if (@hasDecl(root, "loadable_extension")) @import("c/loadable_extension.zig") else @cImport({ @cInclude("sqlite3.h"); }); // versionGreaterThanOrEqualTo returns true if the SQLite version is >= to the major.minor.patch provided. pub fn versionGreaterThan...
https://raw.githubusercontent.com/OAguinagalde/zig-issue-repro/134932fb6982f5c49c881f232c9be580035c7868/deps/zig-sqlite/c.zig
pub usingnamespace @import("src/main.zig"); pub const bun = @import("src/bun.zig"); pub const content = struct { pub const error_js_path = "packages/bun-error/dist/index.js"; pub const error_js = @embedFile(error_js_path); pub const error_css_path = "packages/bun-error/dist/bun-error.css"; pub const ...
https://raw.githubusercontent.com/ziord/bun/7fb06c0488da302b56507191841d25ef3c62c0c8/root.zig
pub usingnamespace @import("src/main.zig"); pub const bun = @import("src/bun.zig"); pub const content = struct { pub const error_js_path = "packages/bun-error/dist/index.js"; pub const error_js = @embedFile(error_js_path); pub const error_css_path = "packages/bun-error/dist/bun-error.css"; pub const ...
https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/javascript/bun/root.zig
const lua = @cImport({ @cInclude("lua.h"); @cInclude("lualib.h"); @cInclude("lauxlib.h"); }); export fn add(s: ?*lua.lua_State) c_int { const a = lua.luaL_checkinteger(s, 1); const b = lua.luaL_checkinteger(s, 2); const c = a + b; lua.lua_pushinteger(s, c); return 1; } pub fn main() ...
https://raw.githubusercontent.com/akavel/blimps-zig/423dccc4a0b076028f5a0862c7f22df918304cc8/.gyro/github.com-tiehuis-zig-lua-archive-bb4e2759304b4b38df10919a499528fadfe33632.tar.gz/pkg/zig-lua-bb4e2759304b4b38df10919a499528fadfe33632/main.zig
const expect = @import("std").testing.expect; test "for" { //character literals are equivalent to integer literals const string = [_]u8{ 'a', 'b', 'c' }; for (string, 0..) |character, index| { _ = character; _ = index; } for (string) |character| { _ = character; } ...
https://raw.githubusercontent.com/t0yohei/zig-practice/0f86d58d7f1a3cc03fcdc67c40b3d20630879cea/for_loops.zig
//! Matrix math operations pub fn mul(comptime M: usize, comptime N: usize, comptime P: usize, comptime T: type, a: [N][M]T, b: [P][N]T) [P][M]T { var res: [P][M]T = undefined; for (&res, 0..) |*column, i| { for (column, 0..) |*c, j| { var va: @Vector(N, T) = undefined; comptim...
https://raw.githubusercontent.com/leroycep/utils.zig/51e07120e8b05e6c5941bc53c765b072a9958c0f/mat.zig
// This code is based on https://github.com/frmdstryr/zhp/blob/a4b5700c289c3619647206144e10fb414113a888/src/websocket.zig // Thank you @frmdstryr. const std = @import("std"); const os = std.os; const bun = @import("root").bun; const string = bun.string; const Output = bun.Output; const Global = bun.Global; const Envir...
https://raw.githubusercontent.com/oven-sh/bun/fab96a74ea13da04459ea7f62663c4d2fd421778/src/http/websocket.zig
// There is a generic CRC implementation "Crc()" which can be paramterized via // the Algorithm struct for a plethora of uses. // // The primary interface for all of the standard CRC algorithms is the // generated file "crc.zig", which uses the implementation code here to define // many standard CRCs. const std = @imp...
https://raw.githubusercontent.com/ziglang/zig/d9bd34fd0533295044ffb4160da41f7873aff905/lib/std/hash/crc/impl.zig
const std = @import("std"); const c = @cImport(@cInclude("alsa/asoundlib.h")); const main = @import("main.zig"); const backends = @import("backends.zig"); const util = @import("util.zig"); const inotify_event = std.os.linux.inotify_event; const is_little = @import("builtin").cpu.arch.endian() == .little; const default...
https://raw.githubusercontent.com/hexops/mach/b72f0e11b6d292c2b60789359a61f7ee6d7dc371/src/sysaudio/alsa.zig
const std = @import("std"); // support zig 0.11 as well as current master pub usingnamespace if (@hasField(std.meta, "trait")) std.meta.trait else struct { const TraitFn = fn (type) bool; pub fn isNumber(comptime T: type) bool { return switch (@typeInfo(T)) { .Int, .Float, .ComptimeInt, .Co...
https://raw.githubusercontent.com/capy-ui/capy/0f714f8317f69e283a1cdf49f2f39bdfdd88ec95/src/trait.zig
const math = @import("std").math; pub fn binarySearch(comptime T: type, input: []const T, search_value: T) ?usize { if (input.len == 0) return null; if (@sizeOf(T) == 0) return 0; var low: usize = 0; var high: usize = input.len - 1; return while (low <= high) { const mid = ((high - low) / ...
https://raw.githubusercontent.com/acmeism/RosettaCodeData/29a5eea0d45a07fe7f50994dd8a253eef2c26d51/Task/Binary-search/Zig/binary-search-3.zig
const std = @import("std"); const python = @cImport(@cInclude("Python.h")); // wasmGetSignalState has to be defined at the typescript level, since it potentially // reads from a small SharedArrayBuffer that WASM does not have access to. It returns // any pending signal. extern fn wasmGetSignalState() i32; export fn ...
https://raw.githubusercontent.com/sagemathinc/cowasm/e8bba5584f03937611619934f0d5858e4d03853d/python/python-wasm/src/signal.zig
const macro = @import("pspmacros.zig"); comptime { asm (macro.import_module_start("sceAudio", "0x40010000", "27")); asm (macro.import_function("sceAudio", "0x8C1009B2", "sceAudioOutput")); asm (macro.import_function("sceAudio", "0x136CAF51", "sceAudioOutputBlocking")); asm (macro.import_function("sceAu...
https://raw.githubusercontent.com/zPSP-Dev/Zig-PSP/53edbc71ed6b0339e7d7a06c9d84794eea2288dd/src/psp/nids/pspaudio.zig
//HSLuv-C: Human-friendly HSL //<https://github.com/hsluv/hsluv-c> //<https://www.hsluv.org/> // //Copyright (c) 2015 Alexei Boronine (original idea, JavaScript implementation) //Copyright (c) 2015 Roger Tallada (Obj-C implementation) //Copyright (c) 2017 Martin Mitáš (C implementation, based on Obj-C implementation) /...
https://raw.githubusercontent.com/david-vanderson/dvui/8645f753c1b2eb93f1bd795e2d24469f5493b670/src/hsluv.zig
name: []const u8, description: []const u8, type: []const u8, tokens: Tokens, editor: Style, editor_cursor: Style, editor_line_highlight: Style, editor_error: Style, editor_warning: Style, editor_information: Style, editor_hint: Style, editor_match: Style, editor_selection: Style, editor_whitespace: Style, editor_gutte...
https://raw.githubusercontent.com/neurocyte/flow-themes/15e8cad1619429bf2547a6819b5b999510d5c1e5/src/theme.zig
/// /// TOPPERS/ASP Kernel /// Toyohashi Open Platform for Embedded Real-Time Systems/ /// Advanced Standard Profile Kernel /// /// Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory /// Toyohashi Univ. of Technology, JAPAN /// Copyright (C) 2005-2020 by Em...
https://raw.githubusercontent.com/toppers/asp3_in_zig/7413474dc07ab906ac31eb367636ecf9c1cf2580/kernel/task.zig
// The I/O APIC manages hardware interrupts for an SMP system. // http://www.intel.com/design/chipsets/datashts/29056601.pdf // See also picirq.c. const mp = @import("mp.zig"); const trap = @import("trap.zig"); const IOAPIC = 0xFEC00000; // Default physical address of IO APIC const REG_ID = 0x00; // Register index: ...
https://raw.githubusercontent.com/saza-ku/xv6-zig/2a31edcf16854ceb0ff11c5aa5949d13fac2f28c/src/ioapic.zig
base: Context, version: u32, debug_info: []const u8 = &.{}, debug_line: []const u8 = &.{}, debug_loc: []const u8 = &.{}, debug_ranges: []const u8 = &.{}, debug_pubnames: []const u8 = &.{}, debug_pubtypes: []const u8 = &.{}, debug_str: []const u8 = &.{}, debug_abbrev: []const u8 = &.{}, pub fn isWasmFile(data: []const...
https://raw.githubusercontent.com/kubkon/zig-dwarfdump/24f1b9a73dff6d1b39b4ade558230aa303e1d849/src/Context/Wasm.zig
const std = @import("std"); const libalign = @import("../util/libalign.zig"); const PixelFormat = @import("pixel_format.zig").PixelFormat; const Color = @import("color.zig").Color; pub const InvalidateRectFunc = fn (r: *ImageRegion, x: usize, y: usize, width: usize, height: usize) void; pub const ImageRegion = stru...
https://raw.githubusercontent.com/FlorenceOS/Florence/aaa5a9e568197ad24780ec9adb421217530d4466/lib/graphics/image_region.zig
const std = @import("std"); const inquirer = @import("inquirer"); // Comparison adaptation of https://github.com/SBoudrias/Inquirer.js/blob/master/packages/inquirer/examples/pizza.js pub fn main() !void { std.log.info("All your codebase are belong to us.", .{}); var gpa = std.heap.GeneralPurposeAllocator(.{}...
https://raw.githubusercontent.com/nektro/zig-inquirer/cf43dd6c9f328073f7468b5341c69ed0bb185db3/src/main.zig
const std = @import("std"); const core = @import("core.zig"); events: std.ArrayList(Event), const Self = @This(); pub fn create(allocator: std.mem.Allocator) Self { return .{ .events = std.ArrayList(Event).init(allocator), }; } pub fn addEvent(self: *Self, ev: Event) std.mem.Allocator.Error!void { ...
https://raw.githubusercontent.com/AntonC9018/durak_domino/0cff8c06c94810ace5fe8e84d05977ffb7c93d5c/src/EventQueue.zig
// // A big advantage of Zig is the integration of its own test system. // This allows the philosophy of Test Driven Development (TDD) to be // implemented perfectly. Zig even goes one step further than other // languages, the tests can be included directly in the source file. // // This has several advantages. On the ...
https://raw.githubusercontent.com/egonik-unlp/Ziglings---egonik-unlp/1d7e89127f1f905d49e5c2c5e176f17a0fdce7e2/exercises/102_testing.zig
// SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2024 Lee Cannon <leecannon@leecannon.xyz> const core = @import("core"); const std = @import("std"); const acpi = @import("acpi"); /// The Fixed ACPI Description Table (FADT) defines various fixed hardware ACPI information vital to an ACPI-compatible /// OS, ...
https://raw.githubusercontent.com/CascadeOS/CascadeOS/07e8248e8a189b1ff74c21b60f0eb80bfe6f9574/lib/acpi/FADT.zig
const expect = @import("std").testing.expect; test "if statement" { const a = true; var x: u16 = 0; if (a) { x += 1; } else { x += 2; } try expect(x == 1); }
https://raw.githubusercontent.com/Sobeston/zig.guide/a49e8a20cd5b3699fc1510f3c9c2c5a698869358/website/versioned_docs/version-0.12/01-language-basics/03.expect.zig
const Procedures = @import("procedures.zig"); const PhysAlloc = @import("phys_alloc.zig"); const std = @import("std"); pub const ModuleSpec = struct { name: []const u8, init: ?*const fn () void, deinit: ?*const fn () void, }; pub var loaded_modules: std.ArrayList(ModuleSpec) = undefined; // TODO: Suppor...
https://raw.githubusercontent.com/sawcce/mimi/527c2076c556b187d4fb82e0cac882b25ae7c0e3/kernel/src/modules/module.zig
const std = @import("std"); fn root() []const u8 { return std.fs.path.dirname(@src().file) orelse "."; } const root_path = root() ++ "/"; pub const include_dir = root_path ++ "curl/include"; const package_path = root_path ++ "src/main.zig"; const lib_dir = root_path ++ "curl/lib"; pub const Define = struct { ...
https://raw.githubusercontent.com/renerocksai/gpt4all.zig/6fd8327a75c945ba4d0d681a5eaab89d49e0b553/src/zig-libcurl/libcurl.zig
const std = @import("std"); const network = @import("network"); const uri = @import("uri"); const serve = @import("serve.zig"); const logger = std.log.scoped(.serve_gemini); pub const GeminiListener = struct { const Binding = struct { address: network.Address, port: u16, socket: ?network.So...
https://raw.githubusercontent.com/ikskuh/zig-serve/2e11e5671d52c256c66bd4d60b1e5975fb9f27f8/src/gemini.zig
const std = @import("std.zig"); const builtin = @import("builtin"); const unicode = std.unicode; const io = std.io; const fs = std.fs; const os = std.os; const process = std.process; const File = std.fs.File; const windows = os.windows; const linux = os.linux; const mem = std.mem; const math = std.math; const debug = s...
https://raw.githubusercontent.com/2lambda123/ziglang-zig/d7563a7753393d7f0d1af445276a64b8a55cb857/lib/std/child_process.zig
const w4 = @import("wasm4.zig"); const std = @import("std"); pub const Shard = enum(u2) { air, square, ring, circle, }; pub const Item = packed struct { top_right: Shard = .air, bottom_right: Shard = .air, bottom_left: Shard = .air, top_left: Shard = .air, pub fn rotateClockwise(s...
https://raw.githubusercontent.com/luehmann/assemblio/d1de94c299b99aea9ef40a209e3c8064b3e661e9/src/item.zig
//! The PWM is a counter that increments once every clock until it reaches //! a certain limit. When that limit is hit, the counter is reset to 0. //! This behaviour is called a PWM slice. Each slice has also two channels. //! Each Channel (a and b) has a level value. As soon as the PWM hits that level //! value, you c...
https://raw.githubusercontent.com/ZigEmbeddedGroup/sycl-workshop-2022/8ed9cc49aea938370860d1fbddb29b7dbc47d0a6/demos/pwm.zig
const std = @import("std"); const Pos = struct { x: usize = 0, y: usize = 0, fn new(x: usize, y: usize) Pos { return Pos{ .x = x, .y = y }; } }; const NumberPos = struct { number: usize = 0, pos: Pos = Pos{}, fn new(number: usize, x: usize, y: usize) NumberPos { return Nu...
https://raw.githubusercontent.com/Niphram/aoc2023/19dd061eafbc10c9ce56b678d786e43f4418e7be/src/day03.zig
const utils = @import("utils.zig"); const term = @import("term.zig"); const config = @import("config.zig"); const logo_embed = @embedFile("resources/logo.txt"); const logo_arr = utils.splitLine(logo_embed); pub const height: u32 = logo_arr.len; pub const width: u32 = logo_arr[0].len; pub fn dump(y: u32, x: u32) void ...
https://raw.githubusercontent.com/atemmel/spider/849f376ea460bc327a08d6b2ef904287f7f93b62/src/logo.zig
const std = @import("std"); pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "zigit", .root_source_file = .{ .path = "src/main.zig" }, .target = b.standardTargetOptions(.{}), .optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .Rel...
https://raw.githubusercontent.com/Dosx001/zigit/09a7ce06aef7c6fc6769db324325fc8a80dd38e1/build.zig
const std = @import("std"); const vk = @import("vk.zig"); const Framebuffer = @This(); vk: vk.api.VkFramebuffer, device: vk.api.VkDevice, pub fn deinit(self: Framebuffer) void { vk.api.vkDestroyFramebuffer(self.device, self.vk, null); }
https://raw.githubusercontent.com/Sudoku-Boys/Sudoku/218ea16ecc86507698861b59a496ff178a7a7587/vulkan/Framebuffer.zig
const std = @import("std"); const print = std.debug.print; const List = std.ArrayList; const util = @import("util.zig"); const gpa = util.gpa; const data = @embedFile("../data/day10.txt"); fn find(char: u8) ?u8 { const openings = [_]u8{ '(', '[', '{', '<' }; const closings = [_]u8{ ')', ']', '}', '>' }; ...
https://raw.githubusercontent.com/natecraddock/aoc/f749f9a30b7adf2421df68678e08a698fa8cdd10/2021/src/day10.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/rjkroege/ziglings/ed4a97781b7ef89d7b6cbb0b36255eb2aa66e4ec/exercises/077_sentinels2.zig
// This code was generated by a tool. // IUP Metadata Code Generator // https://github.com/batiati/IUPMetadata // // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. const std = @import("std"); const interop = @import("../interop.zig"); const iup = @import("../iup.z...
https://raw.githubusercontent.com/batiati/IUPforZig/dad3a26ab0e214a379f59d8d664830e1e08d8722/src/elements/dial.zig
const std = @import("std"); const History = struct { lists: std.ArrayList(std.ArrayList(i32)), pub fn init(numbersText: []const u8, allocator: std.mem.Allocator) !History { var result = History{ .lists = std.ArrayList(std.ArrayList(i32)).init(allocator) }; try result.lists.append(std.ArrayList...
https://raw.githubusercontent.com/ocitrev/advent-of-code/7ecf5b4d74b68bec14e2dabc8ea7550f3df75020/src/2023/day9.zig
const std = @import("std"); const ArrayList = std.ArrayList; const common = @import("common.zig"); const expect = std.testing.expect; const print = std.debug.print; fn measureIncreases(depths: []const usize) usize { var count: usize = 0; var previous: usize = undefined; for (depths) |v| { if (v >...
https://raw.githubusercontent.com/brettporter/advent-of-code-2021/853781b877cedb62eb4a70cb536db4b91ccae060/src/advent1.zig
const std = @import("std.zig"); const assert = std.debug.assert; const testing = std.testing; const mem = std.mem; const math = std.math; pub fn binarySearch( comptime T: type, key: T, items: []const T, context: anytype, comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,...
https://raw.githubusercontent.com/natanalt/zig-x86_16/1b38fc3ef5e539047c76604ffe71b81e246f1a1e/lib/std/sort.zig
// BITCOUNT key [start end] pub const BITCOUNT = struct { //! ``` //! const cmd = BITCOUNT.init("test", BITCOUNT.Bounds{ .Slice = .{ .start = -2, .end = -1 } }); //! ``` key: []const u8, bounds: Bounds = .FullString, const Self = @This(); pub fn init(key: []const u8, bounds: Bounds) BITC...
https://raw.githubusercontent.com/kristoff-it/zig-okredis/4566f358afd2c4f9096e086f22925220286d37b5/src/commands/strings/bitcount.zig
const std = @import("std"); /// The runtime’s logging scope. pub const log_runtime = std.log.scoped(.Runtime); /// The handler’s logging scope. pub const log_handler = std.log.scoped(.Handler); pub const Allocators = struct { gpa: std.mem.Allocator, arena: std.mem.Allocator, }; pub const Context = struct { ...
https://raw.githubusercontent.com/by-nir/aws-lambda-zig/9ca01fa5398e150de3479f9c9709d6d798b8d3b0/src/lambda.zig
const std = @import("std"); const warn = std.debug.warn; pub const io_mode = .evented; const argParser = struct { const Self = @This(); p: []i32 = undefined, i: usize = undefined, flags: [3]u1 = undefined, fn get(s: Self, n: usize) i32 { if (s.i + n >= s.p.len) return -0xaa; var a =...
https://raw.githubusercontent.com/travisstaloch/advocode2019/55ed89e9114d151178428f0eb1162483c820901e/7.zig
const std = @import("std"); const path = std.fs.path; const assert = std.debug.assert; const target_util = @import("target.zig"); const Compilation = @import("Compilation.zig"); const build_options = @import("build_options"); const trace = @import("tracy.zig").trace; const libcxxabi_files = [_][]const u8{ "src/ab...
https://raw.githubusercontent.com/collinalexbell/all-the-compilers/7f834984f71054806bfec8604e02e86b99c0f831/zig/src/libcxx.zig
const std = @import("std"); const windows = @import("windows.zig"); const IUnknown = windows.IUnknown; const BYTE = windows.BYTE; const HRESULT = windows.HRESULT; const WINAPI = windows.WINAPI; const UINT32 = windows.UINT32; const BOOL = windows.BOOL; const FALSE = windows.FALSE; const L = std.unicode.utf8ToUtf16LeStri...
https://raw.githubusercontent.com/alpqr/zw/e987d667917cfe26438c0b72bb781529f9722be5/libs/zwin32/src/xaudio2fx.zig
const std = @import("std"); const gl = @import("zopengl"); const Shader = @import("Shader.zig"); const Texture = @import("Texture.zig"); pub const PostProcessor = @This(); const Self = PostProcessor; pub fn init(shader: Shader, width: u32, height: u32) !Self { var self = Self{ .post_processing_shader = s...
https://raw.githubusercontent.com/loic-o/potential-guacamole/13479663faa5cf663d85440f4237b19ce59ba68f/src/PostProcessor.zig
pub const Symbol_Target = union (enum) { not_found, instruction: Instruction_Ref, expression: Expression.Handle, // always in the same file where it's being referenced stack: Stack_Ref, // If this is an instruction target, it must be in the same file as `s` pub fn instruction_handle(self: Symbo...
https://raw.githubusercontent.com/bcrist/vera/3fa048b730dedfc3551ecf352792a8322466867a/lib/assembler/symbols.zig
const cpu = @import("mk20dx256.zig"); pub fn enable() void { asm volatile ("CPSIE i" : : : "memory" ); } pub fn disable() void { asm volatile ("CPSID i" : : : "memory" ); } pub fn trigger_pendsv() void { cpu.SystemControl.ICSR = 0x10000000; } exter...
https://raw.githubusercontent.com/vlabo/zrt/c5b367b90d62b6eeec9a261b9bf55aa946b53928/src/teensy3_2/interrupt.zig
const std = @import("std"); pub fn build(b: *std.Build) void { // standard target and optimize options const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // build sandbox const sandbox = b.addExecutable(.{ .name = "sandbox", .root_source_fi...
https://raw.githubusercontent.com/procub3r/riscv_emu/e4010fe001d2a7007f893522ec6798312cb25141/build.zig
//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints. //! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value. //! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`. //...
https://raw.githubusercontent.com/mundusnine/FoundryTools_windows_x64/b64cdb7e56db28eb710a05a089aed0daff8bc8be/lib/std/Thread/Futex.zig
//! Implementation of the IND-CCA2 post-quantum secure key encapsulation //! mechanism (KEM) CRYSTALS-Kyber, as submitted to the third round of the NIST //! Post-Quantum Cryptography (v3.02/"draft00"), and selected for standardisation. //! //! Kyber will likely change before final standardisation. //! //! The namespace...
https://raw.githubusercontent.com/2lambda123/ziglang-zig/d7563a7753393d7f0d1af445276a64b8a55cb857/lib/std/crypto/kyber_d00.zig
// // Now that we've seen how methods work, let's see if we can help // our elephants out a bit more with some Elephant methods. // const std = @import("std"); const Elephant = struct { letter: u8, tail: ?*Elephant = null, visited: bool = false, // New Elephant methods! pub fn getTail(self: *Eleph...
https://raw.githubusercontent.com/yuanw/didactic-fortnight/55f80ebd80f431da28f821b24fb5d2e40971e99c/zigling/exercises/048_methods2.zig
const std = @import("std"); const Self = @This(); const Token = @import("../../token/token.zig"); token: Token = undefined, value: []const u8 = undefined, pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; try std.fmt.format(w...
https://raw.githubusercontent.com/adia-dev/tingle-lang/149ad29dab299b16bffd18a4fbc6d574235018b6/src/ast/expressions/identifier.zig
// // Being able to group values together lets us turn this: // // point1_x = 3; // point1_y = 16; // point1_z = 27; // point2_x = 7; // point2_y = 13; // point2_z = 34; // // into this: // // point1 = Point{ .x=3, .y=16, .z=27 }; // point2 = Point{ .x=7, .y=13, .z=34 }; // // The Point ...
https://raw.githubusercontent.com/drewr/ziglings/404fdfe27fd148b55ed1fa107e7cd3ed79b2d668/exercises/037_structs.zig
const std = @import("std"); const RaylibVector2 = @import("root").raylib.Vector2; fn VecFunctions( comptime VecT: type, comptime N: usize, comptime NumT: type, ) type { return struct { pub inline fn fromVector(vector: @Vector(N, NumT)) VecT { return VecT{ .v = vector }; } ...
https://raw.githubusercontent.com/kyle-marshall/zigmo/be37d46077d1280035bb6f22b161ca7de3d2d080/src/math/vec.zig
const std = @import("std"); const print = std.debug.print; const math = std.math; const Complex = std.math.Complex; const ElementType = @import("./helpers.zig").ElementType; const pi = math.pi; pub fn gausswin(x: anytype, alpha: anytype) void { const T = @TypeOf(x); comptime var T_elem = ElementType(T); ...
https://raw.githubusercontent.com/BlueAlmost/zsignal/70547dbf26bfac8677890a94a2d6dfef123424fb/src/gausswin.zig
const std = @import("std"); const args = @import("args"); const init = @import("commands/init.zig"); const update = @import("commands/update.zig"); const generate = @import("commands/generate.zig"); const server = @import("commands/server.zig"); const routes = @import("commands/routes.zig"); const bundle = @import("com...
https://raw.githubusercontent.com/jetzig-framework/jetzig/179b5e77c3a79ca3506e318e91e8e1ade698ba30/cli/cli.zig
// cat ../../julia-play/challenges/advocode2019/1.in | zig run 1.zig const std = @import("std"); const warn = std.debug.warn; pub fn main() anyerror!void { const file = std.io.getStdIn(); const stream = &file.inStream().stream; var buf: [20]u8 = undefined; var sum: usize = 0; var sum2: usize = 0; ...
https://raw.githubusercontent.com/travisstaloch/advocode2019/55ed89e9114d151178428f0eb1162483c820901e/1.zig
const rl = @import("raylib").c; const MouseButton = @import("raylib").input.MouseButton; pub fn main() void { const screen_width = 800; const screen_height = 450; rl.InitWindow(screen_width, screen_height, "raylib [core] example - mouse input"); defer rl.CloseWindow(); var ball_position = rl.Vect...
https://raw.githubusercontent.com/KilianVounckx/rayz/7d3df9b058b5abe49a4894c0f09aeeab58b75bc8/examples/input_mouse__c_api.zig
const std = @import("std"); pub fn build(b: *std.build.Builder) void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options // for rest...
https://raw.githubusercontent.com/maihd/fun-with-zig/923660ba365b80ad2e24af4e6cb649ccc186023f/compile_raylib/build.zig
// // It seems we got a little carried away making everything "const u8"! // // "const" values cannot change. // "u" types are "unsigned" and cannot store negative values. // "8" means the type is 8 bits in size. // // Example: foo cannot change (it is CONSTant) // bar can change (it is VAR...
https://raw.githubusercontent.com/rjkroege/ziglings/ed4a97781b7ef89d7b6cbb0b36255eb2aa66e4ec/exercises/003_assignment.zig
const std = @import("std"); const assert = std.debug.assert; const data = @embedFile("../data/day13_input"); fn part1(positions: []Pos, folds: []Pos) void { // Should be large enough var grid = [_][655]Value{[_]Value{Value.empty} ** 655} ** 895; for (positions) |_, i| { var pos = positions[i]; ...
https://raw.githubusercontent.com/stefalie/aoc2021/dea0a68012a2283b1e0453c883641c4c5734bca1/src/day13.zig
//! GB ROM interface //! //! References I've found helpful: //! //! - Pan Docs: The Cartridge Header: https://gbdev.io/pandocs/The_Cartridge_Header.html const std = @import("std"); const print = std.debug.print; fn checksum_header(comptime T: type, comptime R: type, bytes: []T) R { var result: R = 0; for (byte...
https://raw.githubusercontent.com/namuol/boyziigame/b0a8ec271ea647529eeb237c94b336aa8e0a140a/src/rom.zig
pub const cpu = @import("raspberrypi/cpu.zig"); pub const memory = @import("raspberrypi/memory.zig"); const board = switch (@import("build_options").board) { .rpi3 => @import("devices/bcm/bcm2837.zig"), .rpi4 => @import("devices/bcm/bcm2711.zig"), }; const Uart = @import("devices/pl011/uart.zig"); pub const c...
https://raw.githubusercontent.com/tdeebswihart/zkernel/eca7f0efbe669d85b2083dbfb245973bad346a3d/lib/bsp/raspberrypi.zig
const std = @import("std"); const Block = @import("block.zig"); const FCF = @import("fcf.zig"); // https://www.fileformat.info/format/foxpro/dbf.htm // TODO: docs const MagicString = [14]u8{ 0x0C, 0x47, 0x45, 0x52, 0x42, 0x49, 0x4C, 0x44, 0x42, 0x33, 0x20, 0x20, 0x20, 0x00 }; pub const Header = extern struct { fo...
https://raw.githubusercontent.com/tsunaminoai/lastchoice/75b21301a17aaa4d67363397f93450572fa0c477/src/header.zig
// SPDX-License-Identifier: GPL-3.0 // Copyright (c) 2021 Keith Chambers // This program is free software: you can redistribute it and/or modify it under the terms // of the GNU General Public License as published by the Free Software Foundation, version 3. const std = @import("std"); pub inline fn Pixel(comptime Typ...
https://raw.githubusercontent.com/kdchambers/fliz/a8f43f8b0ffa19e90f22d36da20ed7892396b18a/src/geometry.zig
const std = @import("std"); const Vm = @import("./Vm.zig"); pub const routines = [_]Vm.NativeRoutine{ // General purpose .{ .name = "PRINT", .func = nativePrint }, .{ .name = "ASSERT", .func = nativeAssert }, .{ .name = "EQUALS", .func = nativeEquals }, .{ .name = "TO", .func = nativeTo }, //...
https://raw.githubusercontent.com/yukiisbored/zcauchemar/d23c51f0478f2f84861c2108a0bcf70a1fd1eec9/src/stdlib.zig
pub const RandomState = u32; pub fn init_random(seed: u32) RandomState { return seed; } pub fn random32(state: *RandomState) u32 { state.* +%= 0x6D2B79F5; var z = state.*; z = (z ^ z >> 15) *% (1 | z); z ^= z +% (z ^ z >> 7) *% (61 | z); return z ^ z >> 14; } pub fn randomf_range(comptime min: ...
https://raw.githubusercontent.com/DanB91/Wozmon64/29920645644a04037a7906850ac58ab43312ada3/src/toolbox/src/random.zig
const std = @import("std"); const Func = struct { name: []const u8, args: []const Arg, ret: []const u8, js: []const u8, }; const Arg = struct { name: []const u8, type: []const u8, }; // TODO - i don't know what to put for GLboolean... i can't find an explicit // mention anywhere on what size ...
https://raw.githubusercontent.com/leroycep/hexagonal-chess/ebc60fe485830eccebab5641b0d0523231f40bc5/tools/webgl_generate.zig
pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16; pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32; pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64; pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit; pub ...
https://raw.githubusercontent.com/veera-sivarajan/shell/255b1266fd62bfca22bdaf4d6e5b133b5d9f3d45/src/lexer.zig
// based on // options: { // target: Element; // anchor?: Element; // props?: Props; // hydrate?: boolean; // intro?: boolean; // $$inline?: boolean; // } pub const Options = struct {}; // based on // interface T$$ { // dirty: number[]; // ctx: null|any; // bound: any; // update: () => void; // c...
https://raw.githubusercontent.com/pluvial/zvelte/0f418df85c40e47d9d6e5294f9a2801e122e4b7c/src/runtime/component.zig
const std = @import("std"); // Find the first occurence of a non-repeat sequence of four characters. // This will be four unique characters, where none of the characters are the same. // possible regex: /^\%(.*\(.\).*\1\)\@!.*$ // regex in zig seems to not be quite there yet. // so we'll do it with a simple algo, it's...
https://raw.githubusercontent.com/ewaldhorn/whatamess/ff94d4af6b435d30564d0e2eb5d25d6f571884fc/languages/zig/learning/assorted/non_repeater/non_repeater.zig
const page_frame_manager = @import("vm/page_frame_manager.zig"); //const BumpAllocator = page_frame_manager.BumpAllocator; var page_allocator: page_frame_manager.BumpAllocator = undefined; // Make a page frame pub fn get_page_frame_manager() *page_frame_manager.BumpAllocator { //ASSERT INITED? return &page_al...
https://raw.githubusercontent.com/jamesmintram/jimzos/8eb52e7efffb1a97eca4899ff72549f96ed3460b/kernel/src/vm.zig
const std = @import("std"); const Direction = enum { north, south, east, west }; const Value = enum(u2) { zero, one, two }; test "enum ordinal value" { try std.testing.expect(@intFromEnum(Value.zero) == 0); try std.testing.expect(@intFromEnum(Value.one) == 1); try std.testing.expect(@intFromEnum(Value.tw...
https://raw.githubusercontent.com/mgcth/learnzig/4886d0bbaf735af89ba1d59d3b166a38530f3a12/zig.guide/language/enums.zig
//! Sfc64 pseudo-random number generator from Practically Random. //! Fastest engine of pracrand and smallest footprint. //! See http://pracrand.sourceforge.net/ const std = @import("std"); const math = std.math; const Sfc64 = @This(); a: u64 = undefined, b: u64 = undefined, c: u64 = undefined, counter: u64 = undefin...
https://raw.githubusercontent.com/2lambda123/ziglang-zig/d7563a7753393d7f0d1af445276a64b8a55cb857/lib/std/Random/Sfc64.zig
const std = @import("std"); const Contact = @import("../models/contact.zig"); contacts: []const Contact, query: ?[]const u8, pub fn format( value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { _ = fmt; _ = options; try writer.print( ...
https://raw.githubusercontent.com/daniel1hort/contact.app/da7c3cfe44af9c2bd9974947553adb205b38c582/src/components/contractsList.zig
// SPDX-License-Identifier: MPL-2.0 // Copyright © 2024 Chris Marchesi //! A polygon plotter for fill operations. const std = @import("std"); const debug = @import("std").debug; const mem = @import("std").mem; // const options = @import("../options.zig"); const nodepkg = @import("path_nodes.zig"); const Polygon = ...
https://raw.githubusercontent.com/vancluever/z2d/8d7750b7d0f9d77fd549e7740786b410dbf49a8a/src/internal/FillPlotter.zig
const concepts = @import("../lib.zig"); const concept = "UnsignedIntegral"; pub fn unsignedIntegral(comptime T: type) void { comptime { if (!concepts.traits.isIntegral(T) or concepts.traits.isSignedIntegral(T)) { concepts.fail(concept, ""); } } }
https://raw.githubusercontent.com/ibokuri/concepts/fc952a054389d3aeade915b5760c96c762651124/src/concepts/unsigned_integral.zig
const input = @embedFile("./i1.txt"); const std = @import("std"); // Moving clockwise => R // ---------------------------- // 3 // ┌─────┐ // │North│ // └─────┘ // ┌────┐ .─. ┌────┐ // 2│West│( )│East│0 // └────┘ `─' └────┘ // ┌─────┐ // │South│ // └─────┘ // 1...
https://raw.githubusercontent.com/Mario-SO/advent-of-zig/99022111499fb7c9f06129f7744a8a2c6ebb56b7/src/aoc2016/day1a.zig
const std = @import("std"); const c = @import("sokol_zig"); const log = std.log.scoped(.app); pub const App = struct { const window_title = "Hello"; pub fn init(self: *@This()) !void { _ = self; } pub fn deinit(self: @This()) void { _ = self; } pub fn onInit(self: @This()) !...
https://raw.githubusercontent.com/rsepassi/xos/29992dbf86781f8c2ef49745d9a3643b0eac3dfc/pkg/sokol_hello/app.zig
const std = @import("std"); const Allocator = std.mem.Allocator; pub fn Queue(T: type) type { const queue = struct { front: *node, back: *node, size: u64, allocator: Allocator, const node = struct { data: T, next: *node, }; pub fn in...
https://raw.githubusercontent.com/22102913/Common-Algorithms-Zig/bcfd4d358fe6ce6df60aec4288013043db849a33/src/queues.zig
const zignite = @import("../zignite.zig"); const expect = @import("std").testing.expect; const ProducerType = @import("producer_type.zig").ProducerType; test "empty:" { try expect(zignite.empty(i32).isEmpty()); } pub fn Empty(comptime T: type) type { return struct { pub const Type = ProducerType(@This...
https://raw.githubusercontent.com/shunkeen/zignite/840dcda178be270a2e7eb273aed98e3740c82f22/src/producer/empty.zig
const std = @import("std"); const builtin = @import("builtin"); const Builder = std.build.Builder; const Allocator = std.mem.Allocator; const Sdk = @import("../Sdk.zig"); const UserConfig = Sdk.UserConfig; // This config stores tool paths for the current machine const build_config_dir = ".build_config"; const local_c...
https://raw.githubusercontent.com/SpexGuy/Zig-Oculus-Quest/faa672c704e5d94940b0f76b51d50c7c32d5d866/build/auto-detect.zig
const std = @import("std"); const kernel_config = .{ .arch = std.Target.Cpu.Arch.x86_64, }; const FeatureMod = struct { add: std.Target.Cpu.Feature.Set = std.Target.Cpu.Feature.Set.empty, sub: std.Target.Cpu.Feature.Set = std.Target.Cpu.Feature.Set.empty, }; fn getFeatureMod(comptime arch: std.Target.Cpu...
https://raw.githubusercontent.com/Arnau478/ytos/4a54a3155c996be251e3ae00f5c9ad697066460d/build.zig
// https://csprimer.com/watch/fast-pangram/ const std = @import("std"); pub export fn main() void { run() catch unreachable; } fn run() !void { const in = std.io.getStdIn(); defer in.close(); var in_buf = std.io.bufferedReader(in.reader()); var reader = in_buf.reader(); const out = std.io.ge...
https://raw.githubusercontent.com/CrepeGoat/cs-primer/35f7a2529ecfffe219365a2a67237745b2bc24af/src/computer-systems/intro-to-c/fast-pangram.zig
const common = @import("../common.zig"); const jsFree = common.jsFree; const jsCreateClass = common.jsCreateClass; const Classes = common.Classes; const toJSBool = common.toJSBool; const Undefined = common.Undefined; const True = common.True; const object = @import("../object.zig"); const Object = object.Object; const ...
https://raw.githubusercontent.com/CraigglesO/workers-zig/af4c3475a0d01e200ccf88d79987df0e7ea815fa/lib/bindings/streams/readable.zig
const std = @import("std"); fn Parameter(comptime T: type) type { return struct { long_name: ?[]const u8 = null, short_name: u8 = 0, description: []const u8 = "", metavar: ?[]const u8 = null, default: ?T = null, value: ?T = null, allocator: ?std.mem.Allocator...
https://raw.githubusercontent.com/pseudocc/robin/0edde52fdd49508a2b759913ffbbfeab26d7ae80/src/args.zig
const std = @import("std"); const gen = @import("generate.zig"); const print = std.debug.print; const Str = []const u8; pub var items = gen.items; pub const Item = gen.Item; pub var player = gen.player; pub const ambiguous = gen.ambiguous; pub const Distance = gen.Distance; pub fn getDistanceNumber(from: ?*Item, to: ...
https://raw.githubusercontent.com/jiangbo/todo/54b6dec1f75b8e0d195fe0f63107005438c9ce2c/zig/advent/src/world.zig
const std = @import("std"); pub const Options = struct { enable_cross_platform_determinism: bool = true, }; pub const Package = struct { target: std.Build.ResolvedTarget, options: Options, zmath: *std.Build.Module, zmath_options: *std.Build.Module, pub fn link(pkg: Package, exe: *std.Build.St...
https://raw.githubusercontent.com/candrewlee14/learn-opengl-zig/e4ef89200c7194766a72003f6581f200482759d1/libs/zmath/build.zig
const std = @import("std"); const utils = @import("utils.zig"); const res = @import("res.zig"); const SourceBytes = @import("literals.zig").SourceBytes; // https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files pub const Resource = enum { accelerators, bitmap, cursor, dialog, ...
https://raw.githubusercontent.com/2lambda123/ziglang-zig/d7563a7753393d7f0d1af445276a64b8a55cb857/src/resinator/rc.zig
const std = @import("std"); const Token = @import("lexer.zig").Token; // TODO: // * Cleanup pratt parser. // * Cleaner interface to heap allocate expressions. const LoxValue = union(Tag) { const Tag = enum { number, string, bool, nil }; number: f32, string: []const u8, bool: bool, nil, pub fn...
https://raw.githubusercontent.com/JamisonCleveland/zig-lox/21c0c8164c23acad2967697d575a9f7d6fb3b85d/src/ast.zig
const std = @import("std"); const toolbox = @import("toolbox.zig"); pub fn println_string(string: toolbox.String8) void { platform_print_to_console("{s}", .{string.bytes}, false); } pub fn println(comptime fmt: []const u8, args: anytype) void { platform_print_to_console(fmt, args, false); } pub fn printerr(com...
https://raw.githubusercontent.com/DanB91/UPWARD-for-Playdate/5d87bf7ef4ad30983ba24ad536228e4ca4ce8b63/modules/toolbox/src/print.zig
// Ported from musl, which is licensed under the MIT license: // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT // // https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c // https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c const std = @import("../std.zig"); const math = std.math; const expect = std.te...
https://raw.githubusercontent.com/ziglang/gotta-go-fast/c915c45c5afed9a2e2de4f4484acba2df5090c3a/src/self-hosted-parser/input_dir/math/sinh.zig
const std = @import("std"); extern const custom_global_symbol: u8; export fn getCustomGlobalSymbol() u8 { return custom_global_symbol; }
https://raw.githubusercontent.com/aherrmann/rules_zig/2c2ec8c2a3bc91e883dc307ead97e4703201e834/e2e/workspace/linker-script/lib.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const time = std.time; const engine = @import("engine"); const Player = engine.Player(SevenBag); const GameState = Player.GameState; const kicks = engine.kicks; const PeriodicTrigger = engine.PeriodicTrigger; const SevenBag = engine.bags.SevenBag; const...
https://raw.githubusercontent.com/TemariVirus/Budget-Tetris-Bot/b080082fe26338d3a8c28f760368943b9a13ed17/src/main.zig
const std = @import("std"); pub fn main() !void { const name = "Пётр"; var buf: [100]u8 = undefined; const greeting = try std.fmt.bufPrint(&buf, "Привет, {s}!", .{name}); std.debug.print("{s}\n", .{greeting}); }
https://raw.githubusercontent.com/dee0xeed/learning-zig-rus/13b78318628fa85bc1cc8359e74e223ee506e6a9/src/examples/ex-ch06-06.zig
const std = @import("std"); const pipes = @import("./pipes.zig"); const fmt = std.fmt; const heap = std.heap; const io = std.io; const mem = std.mem; pub fn main() !void { var gpa = heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); const stdin = io.getStdIn().reader(); const stdo...
https://raw.githubusercontent.com/arntj/advent-of-code/d6a234e5bf9dd22ed10e7e215b3c262edfee61ff/2023/10/day10.zig
const std = @import("std"); const print = std.debug.print; const DemoError = error{Demo}; fn demo(good: bool) DemoError!u8 { return if (good) 19 else DemoError.Demo; } // Only need ! in return type if errors are not caught. pub fn main() !void { // Not catching possible errors. var result = try demo(true)...
https://raw.githubusercontent.com/mvolkmann/zig-examples/7d9877a2f2535c8bb61ceb0f2059c377f49bd079/try_catch_demo.zig
// @link "deps/zlib/libz.a" const std = @import("std"); const bun = @import("root").bun; const mimalloc = @import("./allocators/mimalloc.zig"); pub const MAX_WBITS = 15; test "Zlib Read" { const expected_text = @embedFile("./zlib.test.txt"); const input = bun.asByteSlice(@embedFile("./zlib.test.gz")); s...
https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/javascript/bun/src/zlib.zig
const std = @import("std"); const time = @import("../../time.zig"); const usb = @import("../../usb.zig"); const Host = @import("../dwc_otg_usb.zig"); const reg = @import("registers.zig"); const Self = @This(); // ---------------------------------------------------------------------- // Mutable state // -----------...
https://raw.githubusercontent.com/aapen/aapen/c02010f570ec1f69905afe607d2ed4080c2e8edb/src/drivers/dwc/root_hub.zig