Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
32
314k
url
stringlengths
93
243
const std = @import("std"); fn fib(x: u64) u64 { if (x <= 1) return x; return fib(x - 1) + fib(x - 2); } pub fn main() void { std.debug.warn("{}", fib(47)); }
https://raw.githubusercontent.com/drujensen/fib/578c15d13690fb36b1b3d8a419c5517c84abcd06/fib.zig
// MIT License // Copyright (c) 2019 Vexu // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, pub...
https://raw.githubusercontent.com/lithdew/rheia/162293d0f0e8d6572a8954c0add83f13f76b3cc6/uri.zig
//*************************************************************************** // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. The // ASF licenses this...
https://raw.githubusercontent.com/lupyuen/pinephone-nuttx/700afea277d94090efa3926a96352b4a6319e99f/dphy.zig
const root = @import("root"); pub const c = if (@hasDecl(root, "loadable_extension")) @import("c/loadable_extension.zig") else @cImport({ @cInclude("sqlite3.h"); @cInclude("workaround.h"); }); // versionGreaterThanOrEqualTo returns true if the SQLite version is >= to the major.minor.patch ...
https://raw.githubusercontent.com/vrischmann/zig-sqlite/91e5fedd15c5ea3cb42ccceefb3d0f4bb9bad68f/c.zig
pub fn main() !void { try renderer.render(.{ .Shader = SimpleBlendShader, //.Shader = CheckerShader, //.Shader = BandingShader, //.Shader = CliffordAttractorShader, //.Shader = JuliaSetShader, //.Shader = SimplexNoiseShader, //.Shader = GeometryShader, ...
https://raw.githubusercontent.com/quag/zig-generative-template/c59b72641ba7baef4c0f49e71f4576a67a4ec66c/main.zig
pub const Cairo = @import("gdk/Cairo.zig"); pub const Display = @import("gdk/Display.zig").Display; pub const Pixbuf = @import("gdk/Pixbuf.zig").Pixbuf; pub const Wayland = @import("gdk/Wayland.zig"); fn refAllDeclsRecursive(comptime T: type) void { comptime { for (@import("std").meta.declarations(T)) |dec...
https://raw.githubusercontent.com/davidmhewitt/zig-gtk/8130922d5437aeb296d1f4b928d7a76f04ca27be/gdk.zig
// Copyright (C) 2021-2024 Chadwain Holness // // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. pub const token = @import("source/token.zig"); pub const Tokenizer = @import("source/Tokenizer.zig"); pub const Dom = @import("so...
https://raw.githubusercontent.com/chadwain/rem/68dcb476a9090c9bbe0044dd26914ee1266924ed/rem.zig
const std = @import("std"); pub fn main() void { var sum: i64 = 0; var i: i64 = 1; while (i <= 1000000000): (i += 1) { sum += i; } std.debug.print("{any}\n", .{sum}); }
https://raw.githubusercontent.com/clarkzjw/one-two-three...infinity/f944fe3d68923f8e2bf3e5ec75bfc53fe4e52618/Zig.zig
pub fn puts(str: [*:0]const u8) c_int { return asm volatile ( \\ li $9, 0x3f \\ j 0xa0 : [ret] "={r2}" (-> c_int) : [str] "{r4}" (str) ); }
https://raw.githubusercontent.com/XaviDCR92/psx-zig/d1e2090f46938fff210c3cf2d79b60b1f8e98d25/puts.zig
const std = @import("std"); pub const json = @import("./json.zig"); const Map = json.DeserializeMap; pub const glTF = struct { extensionsUsed: [][]const u8 = &[_][]const u8{}, extensionsRequired: [][]const u8 = &[_][]const u8{}, accessors: []Accessor = &[_]Accessor{}, //animations: []Animation, ass...
https://raw.githubusercontent.com/leroycep/gltf-zig/9df88e095a578fed8d456911171f3ec7110eeae4/gltf.zig
const std = @import("std"); const data = @embedFile("./day2.data"); // const data = // \\forward 5 // \\down 5 // \\forward 8 // \\up 3 // \\down 8 // \\forward 2 // ; pub fn main() !void { var it = std.mem.split(u8, data, "\n"); var x: u64 = 0; var y: u64 = 0; var aim: u64 = 0; while(it.next()) |token| ...
https://raw.githubusercontent.com/IwanKaramazow/adventofcode21/0531d3835cd2fa4908829948d3800c5aee675bf4/day2.zig
const std = @import("std"); pub fn is_alsa_playing() !bool { var argv = [_][]const u8{ "sh", "-c", "grep RUNNING /proc/asound/card*/pcm*/sub*/status" }; var result = try std.ChildProcess.exec(.{ .allocator = std.heap.page_allocator, .argv = &argv }); // std.debug.print("stderr={s}\n", .{result.stderr}); ...
https://raw.githubusercontent.com/Ryp/gpio-zig/fcca36f13cfbe0f223dcbe41b68ecb33eafd80c2/alsa.zig
const std = @import("std"); const expect = std.testing.expect; const test_allocator = std.testing.allocator; test "stack" { const string = "(()())"; var stack = std.ArrayList(usize).init( test_allocator, ); defer stack.deinit(); const Pair = struct { open: usize, close: usize }; var pa...
https://raw.githubusercontent.com/akalmannakarmi/zig-try/d3ed6d7e54ae8044ed760340d8139f353d3e0d3e/e4j.zig
const std = @import("std"); pub const Format = enum { unsigned8, signed16_lsb, signed24_lsb, signed32_lsb, pub fn getNumBytes(self: Format) u16 { return switch (self) { .unsigned8 => 1, .signed16_lsb => 2, .signed24_lsb => 3, .signed32_lsb =>...
https://raw.githubusercontent.com/marler8997/audio-deinterlacer/9a30af1f0d8ca50155b8168773bf56763b084d44/wav.zig
// This is free and unencumbered software released into the public domain. pub usingnamespace @import("src/angle.zig"); pub usingnamespace @import("src/latitude.zig"); pub usingnamespace @import("src/longitude.zig"); test "Dogma" { // zig test dogma.zig const meta = @import("std").meta; meta.refAllDecls(@This...
https://raw.githubusercontent.com/dogmatists/dogma.zig/15c0227896fb5b37b06cd4e3386d28ca58f9a3e3/dogma.zig
const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const tomlZigName = "toml-zig"; const dep_opts = .{ .target = target, .optimize = optimize }; const tomlZig = b.dependency(tomlZigName, dep_op...
https://raw.githubusercontent.com/sirenkovladd/tinytask/3374a7fde03125e1ae07e6db6d7fcc9e43fd5083/build.zig
const std = @import("std"); const cli = @import("cli"); const dawn = @import("dawn"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); var port_receive_option = cli.Option{ .long_name = "port_receive", .help = "port to receive osc messages on (optional).", .value = cli...
https://raw.githubusercontent.com/dawnsynth/dawn/c9062931757d1df06766026b0bdac5a572ece30b/dawn.zig
//! https://adventofcode.com/2023/day/4 const std = @import("std"); const A = std.BoundedArray(u32, 32); fn parseWins(line: []const u8, ns: *A) !usize { ns.len = 0; var win_count: usize = 0; var it = std.mem.splitScalar(u8, line, ':'); _ = it.next().?; const x = it.next().?; var it2 = std.mem....
https://raw.githubusercontent.com/travisstaloch/advent-of-code-2023/e9b7cc6003191bd45bf55277567531e9e5fe9a4a/04.zig
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/malcolmstill/clerk/06d23ad09ece6aaf74127a316d9512ff23cb883a/lib/zig-sqlite/c.zig
const std = @import("std.zig"); const avr = @import("atmega328p.zig"); const led_pin: u8 = 5; const loop_ms = 0x0a52; const one_second = 63974; fn bit(comptime b: u3) comptime u8 { return (1 << b); } fn flipLed() void { avr.portb.* ^= bit(led_pin); } // Timer interrupt // When this uses callconv(.Interrupt) ...
https://raw.githubusercontent.com/ryanplusplus/avr-zig/7e240340a63d358665e04875d9cde7906d63e061/main.zig
const std = @import("std"); pub fn insertionSort(comptime T: type, slice: []T) void { for (1..slice.len) |i| { var base = slice[i]; var j = i; while (j >= 1 and slice[j - 1] > base) : (j -= 1) { slice[j] = slice[j - 1]; } slice[j] = base; } } fn partition(co...
https://raw.githubusercontent.com/rsphing/algo.zig/66b4ddfcc48f9cd006e5f726145f2408b55a7848/sort.zig
const std = @import("std"); const stdx = @import("./stdx.zig"); const MAX = 64; const Stack = std.BoundedArray(u8, MAX); const Stacks = [MAX]Stack; const Move = struct { from: u32, to: u32, count: u32, fn parse(line: []u8) !Move { var rest = line; _ = stdx.cut(&rest, "move ") orelse r...
https://raw.githubusercontent.com/matklad/aoc2022/67800cfb0aa3dcb0103da06c0b6f2103f1494dc7/day5.zig
const std = @import("std"); const testing = std.testing; pub const SpinLock = struct { pub const Held = struct { self: *SpinLock, pub fn release(held: Held) void { @atomicStore(bool, &held.self.locked, false, .Release); } }; locked: bool = false, pub fn acquire(s...
https://raw.githubusercontent.com/lithdew/hyperia/c1d166f81b6f011d9a23ef818b620e68eee3f49a/sync.zig
// --- Day 5: Sunny with a Chance of Asteroids --- // // You're starting to sweat as the ship makes its way toward Mercury. The Elves suggest that you // get the air conditioner working by upgrading your ship computer to support the Thermal // Environment Supervision Terminal. // // The Thermal Environment Supervision ...
https://raw.githubusercontent.com/tiehuis/advent-of-code-2019/07f48c42d0870a7030d21c08626fcc40a447e695/5_1.zig
const std = @import("std"); const memory_size = 1 << 16; const program_start = 0x3000; const Reg = enum(u16) { R0 = 0, R1, R2, R3, R4, R5, R6, R7, PC, COND, COUNT }; const Op = enum(u16) { BR = 0, ADD, LD, ST, JSR, AND, LDR, STR, RTI, NOT, LDI, STI, JMP, RES, LEA, TRAP }; const Flags = enum(u16) { POS = 1 << 0,...
https://raw.githubusercontent.com/unbalancedparentheses/lc3-vm.zig/9de025f029e546251d0611cb750f094c33706ce7/lc3.zig
const std = @import("std"); const Card = struct { nr: i9, winning_nrs: [10]i8, nrs: [25]i8, }; fn parseNrStr(comptime T: type, buf: []const u8) !T { var str = std.mem.trim(u8, buf, " "); var it = std.mem.split(u8, str, " "); var nrs: T = undefined; var i: usize = 0; while (it.next()) |...
https://raw.githubusercontent.com/froehlichA/aoc2023/2335f02043a267aed2d0e35c4fc6871b08a6dac5/04/1.zig
const std = @import("std"); const data = @embedFile("input.txt"); fn readFirstNumber( line: []const u8, start_index: *usize, end_index_exclusive: *usize, ) !?u32 { var i = end_index_exclusive.*; while (line.len > i and !std.ascii.isDigit(line[i])) { i += 1; } if (line.len <= i) {...
https://raw.githubusercontent.com/kkard2/aoc2023/6ec8e32bd8b1bc411c37748d1c2659a3b6ffec3d/04/a.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const VEC_SIZE_F32 = std.simd.suggestVectorSize(f32) orelse 4; // XXX: Because of the limitation of build system in zig v0.11, we cannot // switch between `tracy_full` and `tracy_stub` by passing compilation flags. // So...
https://raw.githubusercontent.com/NaleRaphael/llama2.zig/3ea6b14bf7db4ccec25a50db275655f5192cd0d2/run.zig
const std = @import("std"); const fs = std.fs; const print = std.debug.print; const label = [_]u8{'J', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'Q', 'K', 'A'}; const Record = struct { hand : []u8, bid : usize, }; fn cmp(_:void, a:u8, b:u8) bool { const ra = std.mem.indexOf(u8, &label, &[_]u8{a}).?; ...
https://raw.githubusercontent.com/xnhp0320/aoc2023/6e42c1e3791ba8e50c3ea0930572cade5caaef5b/7/s2.zig
const std = @import("std"); pub fn getMimeType(path: []const u8) ?[]const u8 { const extension = std.mem.lastIndexOf(u8, path, ".") orelse return null; if (std.mem.eql(u8, path[extension + 1 ..], "html")) { return "text/html"; } else if (std.mem.eql(u8, path[extension + 1 ..], "css")) { ret...
https://raw.githubusercontent.com/hajsf/zig-server/22d3e3f821217f50e0dff9e13ee5450d221c5d30/mime.zig
const std = @import("std"); const print = std.debug.print; pub fn main() !void { var file = try std.fs.cwd().openFile("data/input2.txt", .{}); defer file.close(); var reader = file.reader(); var buf: [4096]u8 = undefined; var hpos: u32 = 0; var ypos: u32 = 0; var aim: u32 = 0; while...
https://raw.githubusercontent.com/angeris/advent-of-code-2021/fcd858e08f2da93ef53a8aee0698921c896df2ec/d2-2.zig
const std = @import("std"); const Nihilist = @import("nihilist.zig").Nihilist; pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); var allocator = &arena.allocator; var args = try std.process.argsAlloc(allocator); defer std.process.argsFr...
https://raw.githubusercontent.com/stripedpajamas/nihilist/578019241123857630858161e30832788fd92e3b/main.zig
const std = @import("std"); const g = @cImport({ @cInclude("glib-object.h"); }); pub fn main() void { const obj1: ?*g.GObject = @alignCast(@ptrCast(g.g_object_new(g.G_TYPE_OBJECT, null))); const obj2: ?*g.GObject = @alignCast(@ptrCast(g.g_object_new(g.G_TYPE_OBJECT, null))); const instance1: ?*g.GType...
https://raw.githubusercontent.com/evaporei/zobject/23f6bd4c5d72ebda3da82dd189052aa1e70db985/main.zig
pub const compare = @import("./compare.zig"); pub const meta = @import("./meta.zig"); pub const sentinel = @import("./sentinel.zig"); pub const limitslice = @import("./limitslice.zig"); // disabled for now, too many things to fix during a zig update //pub const range = @import("./range.zig"); pub const mem = @import("....
https://raw.githubusercontent.com/marler8997/zog/0f5f075792ba1a9c76901a9a766125386a33cce6/zog.zig
const std = @import("std"); const libvirt = @import("libvirt"); pub fn main() !void { std.log.info("All your codebase are belong to us.", .{}); std.log.info("libvirt version: {d}", .{libvirt.c.LIBVIR_VERSION_NUMBER}); }
https://raw.githubusercontent.com/nektro/zig-libvirt/af019d9f5f5e51d5934b92ad539b3c50d67d0638/main.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/txthinking/jb/d0e3ddce48be1ca0490904397bcd030c5aa7032e/root.zig
//! This file is auto-generated by zpm-update and *should* //! not be changed. This file can be checked into your VCS //! and is able to work standalone. const std = @import("std"); pub const pkgs = struct { pub const ziggysynth = std.build.Pkg{ .name = "ziggysynth", .source = .{ .path = "vendor/zi...
https://media.githubusercontent.com/media/ikskuh/zyclone/ae63975f672d9504b5cf1c9b7616454c67193500/zpm.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/tiehuis/zig-lua/bb4e2759304b4b38df10919a499528fadfe33632/main.zig
pub extern fn add(a: i32, b: i32) i32; pub extern fn sub(a: i32, b: i32) i32;
https://raw.githubusercontent.com/hajsf/zig-and-go-simple-example/746c6a774a6f537a996c3d20effebc98d47ed47d/def.zig
const expect = @import("std").testing.expect; // 5. for loops are used to iterate over the arrays //5. for loop test "for loop" { const rust_name = [_]u8{ 'r', 'u', 's', 't' }; // character literals are equivalent to integer literals for (rust_name, 0..) |character, index| { _ = character; //we use _ ...
https://raw.githubusercontent.com/muathendirangu/zig/9566d8190e6e980418fdd2bdcf72b418b91b8948/for.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/wolffshots/ziglearn/5743d7a6748bf38207e5395ea0cc7b5dbdeaf230/for.zig
End of preview. Expand in Data Studio

Zig programming language code dataset, loaded using GitHub Search REST API.

Downloads last month
13