avatar_url
stringlengths
47
116
name
stringlengths
1
46
full_name
stringlengths
7
60
created_at
stringdate
2016-04-01 08:17:56
2025-05-20 11:38:17
description
stringlengths
0
387
default_branch
stringclasses
44 values
open_issues
int64
0
4.93k
stargazers_count
int64
0
78.2k
forks_count
int64
0
3.09k
watchers_count
int64
0
78.2k
tags_url
stringlengths
0
94
license
stringclasses
27 values
topics
listlengths
1
20
size
int64
0
4.82M
fork
bool
2 classes
updated_at
stringdate
2018-11-13 14:41:18
2025-05-22 08:23:54
has_build_zig
bool
2 classes
has_build_zig_zon
bool
2 classes
zig_minimum_version
stringclasses
50 values
repo_from
stringclasses
3 values
dependencies
listlengths
0
38
readme_content
stringlengths
0
437k
dependents
listlengths
0
21
https://avatars.githubusercontent.com/u/57973645?v=4
nuttx
NuttX/nuttx
2024-10-22T03:01:32Z
Mirror of Apache NuttX RTOS for Scheduled Builds (Linux / macOS / Windows)
master
0
2
1
2
https://api.github.com/repos/NuttX/nuttx/tags
Apache-2.0
[ "ci", "d", "embedded", "nuttx", "rtos", "rust", "zig" ]
327,501
true
2025-05-22T02:55:21Z
false
false
unknown
github
[]
<a></a> <a></a> <a></a> <a></a> Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()). For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX. Getting Started First time on NuttX? Read the <a>Getting Started</a> guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal. Documentation You can find the current NuttX documentation on the <a>Documentation Page</a>. Alternatively, you can build the documentation yourself by following the Documentation Build <a>Instructions</a>. The old NuttX documentation is still available in the <a>Apache wiki</a>. Supported Boards NuttX supports a wide variety of platforms. See the full list on the <a>Supported Platforms</a> page. Contributing If you wish to contribute to the NuttX project, read the <a>Contributing</a> guidelines for information on Git usage, coding standard, workflow and the NuttX principles. License The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the <a>License Page</a> for more information.
[]
https://avatars.githubusercontent.com/u/179981696?v=4
solana-zig-program-template
ziglana/solana-zig-program-template
2024-10-13T09:58:57Z
Minimal Solana Zig program template
main
0
2
0
2
https://api.github.com/repos/ziglana/solana-zig-program-template/tags
NOASSERTION
[ "solana", "zig", "zig-package", "ziglana", "ziglang", "zup" ]
48
false
2025-03-30T00:53:13Z
true
true
unknown
github
[ { "commit": "refs", "name": "base58", "tar_url": "https://github.com/joncinque/base58-zig/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/joncinque/base58-zig" }, { "commit": "refs", "name": "solana-program-sdk", "tar_url": "https://github.com/joncinque/solana-...
solana-zig-program-template Minimal Solana Zig program template
[]
https://avatars.githubusercontent.com/u/1102632?v=4
Zig-Raylib-Flake-Template
quot/Zig-Raylib-Flake-Template
2024-09-02T20:35:53Z
Nix flake template for Zig Raylib development with dependencies
main
0
2
0
2
https://api.github.com/repos/quot/Zig-Raylib-Flake-Template/tags
-
[ "nix", "nix-flake", "nixos", "raylib", "raylib-zig", "zig" ]
8
false
2025-01-30T09:24:59Z
true
true
unknown
github
[ { "commit": "devel.tar.gz", "name": "raylib-zig", "tar_url": "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Not-Nik/raylib-zig" } ]
Zig/Raylib Nix Flake Template A starting point for developing Zig with Raylib using Nix or in NixOS. Based on: https://github.com/nix-community/templates/tree/main/zig Using Raylib-Zig: https://github.com/Not-Nik/raylib-zig Building raylib-zig in NixOS throws errors caused by missing system libraries. <code>error: unable to find dynamic system library 'GL' using strategy 'paths_first'. ... error: unable to find dynamic system library 'X11' using strategy 'paths_first'.</code> This flake sets up a development environment with those missing dependencies so you don't have to install them on your base OS. How to use Currently, the flake is only setup to use <code>nix develop</code>. You can use <code>nix develop --command bash -c "zig build run; exit;"</code> if you want to do a one-time run without staying in the develp environment. Tested With <ul> <li>Zig 0.13.0</li> <li>Raylib 5.5-dev through raylib-zig</li> </ul>
[]
https://avatars.githubusercontent.com/u/188629493?v=4
clap-zig-bindings
interpunct/clap-zig-bindings
2024-11-15T22:02:18Z
manually written idiomatic zig bindings for CLAP audio API (mirror)
main
0
2
0
2
https://api.github.com/repos/interpunct/clap-zig-bindings/tags
LGPL-3.0
[ "audio", "clap", "library", "zig", "zig-package" ]
59
false
2025-04-30T19:47:13Z
true
true
0.13.0
github
[]
<a>clap-zig-bindings</a> Zig bindings for the <a>CLAP</a> audio API. This is a full hand-written translation. Everything is done to make the most of Zig's type system. Currently covers 100% of the api as of CLAP version <code>1.2.2</code>. This library does not cover draft extensions. For an example on how to use this library, see the <a>clap-bindings-example</a> git repo. This is not a plugin framework! including as a dependency Use the <code>zig fetch</code> command, ie: <code>sh zig fetch --save git+https://git.sr.ht/~interpunct/clap-zig-bindings</code> Then add the following to your <code>build.zig</code>: <code>zig const clap_bindings = b.dependency("clap-bindings", .{}) exe.root_module.addImport("clap-bindings", clap_bindings.module("clap-bindings"));</code> This library currently targets Zig version <code>0.13.0</code>. issue tracker Browse tickets at <a>https://todo.sr.ht/~interpunct/clap-zig-bindings</a>. If you have issues and there is no open ticket for them at the page above please send an email with your problems to <a>my public inbox</a>. I will look into and make any needed tickets for them. This does not require a sourcehut account. contributing Patches and disscussion are are done via email on <a>my public inbox</a>. This is funcitonality built in to git. If this workflow is new to you please refer to <a>https://git-send-email.io</a>. I promise that it is quick and easy to both learn and set up. license <code>clap-zig-bindings</code> is distributed under LGPLv3, see the LICENSE file.
[]
https://avatars.githubusercontent.com/u/23241991?v=4
NeuroSpeed
lovc21/NeuroSpeed
2024-10-06T18:34:32Z
NeuroSpeed is a UCI chess engine ♟️ written in Zig that is optimized for bullet and ultra-bullet games🌠
main
0
2
0
2
https://api.github.com/repos/lovc21/NeuroSpeed/tags
MIT
[ "bullet", "chess-engine", "zig" ]
1,191
false
2025-05-06T19:34:56Z
true
true
0.11.0
github
[]
NeuroSpeed NeuroSpeed is a UCI chess engine that is optimized for extreme time controls. The goal of this chess engine is to see what can be optimized so it can beat other chess engines when it comes to low time, for example, bullet games or ultra-bullet games. Releases This chess engine is still in development. When I have it in working order and with some results, I will release it as version 1 (v1) Strength <strong>TODO:</strong> <ul> <li>Update the strength table:</li> </ul> | Version | Release Date | CCRL Blitz | CCRL 40/15 | |---------|--------------|------------|------------| | v1.0 | 2024-01-01 | 3000 | 3050 | | v1.1 | 2024-03-15 | 3100 | 3150 | | v2.0 | 2024-06-10 | 3200 | 3250 | Features These are the features that were implemented so far: <code>Bitboard board representation Pre-calculated attack tables Magic bitboards </code> How to Build <strong>TODO:</strong> <ul> <li>Add a "How to Build" section</li> </ul> Thanks and Acknowledgements <ul> <li>Huge shout-out to <a>Maksim Korzh</a> for his <a>chess programming series</a>. It's a great help in explaining complex topics in chess engine development.</li> <li>Big thanks to the <a>Avalanche</a> chess engine and <a>Lambergar</a> chess engine, where I got a lot of inspiration and a better idea of how to write Zig code, as these chess engines were implemented in Zig.</li> <li>Huge shout-out to the <a>Stockfish Discord</a> for being helpful when it comes to questions, and to the <a>Stockfish</a> engine for its great implementation and clean code</li> <li>And just like 99% of chess engines, a big thanks to the <a>Chess Programming Wiki</a> for being such a well-structured base of knowledge when it comes to chess engine design</li> </ul>
[]
https://avatars.githubusercontent.com/u/146390816?v=4
gifsicle
allyourcodebase/gifsicle
2025-01-14T15:35:54Z
gifsicle using the zig build system
master
0
2
0
2
https://api.github.com/repos/allyourcodebase/gifsicle/tags
GPL-2.0
[ "gif", "gifsicle", "zig", "zig-package" ]
23
false
2025-03-20T03:44:12Z
true
true
0.14.0
github
[ { "commit": "ed5b01816b42423e0ae6897cad0149cda561898c", "name": "gifsicle_upstream", "tar_url": "https://github.com/kohler/gifsicle/archive/ed5b01816b42423e0ae6897cad0149cda561898c.tar.gz", "type": "remote", "url": "https://github.com/kohler/gifsicle" } ]
Gifsicle This is <a>gifsicle</a> packaged using Zig build system needs zig version <code>0.14.0</code> or higher Options You can set these options when importing as a dependency with <code>b.dependency("gifsicle", .{ option=value })</code> or when building directly with <code>zig build -Doption=value</code> |Option Name|default|description | |-----------|:-----:|----------------------------------------------| | dynamic | false | Build lib as shared (dynamic library) | | tools | true | Build cli tools (gifsicle, gifview, gifdiff) | | terminal | true | Output gif to terminal | Thanks to andrew's fork of <a>ffmpeg</a> for the knowhow
[]
https://avatars.githubusercontent.com/u/47033578?v=4
Math-Papers-with-Code
ramsyana/Math-Papers-with-Code
2024-12-26T05:52:59Z
A collection of implementations of mathematical algorithms and concepts from various academic papers in multiple programming languages.
main
0
2
0
2
https://api.github.com/repos/ramsyana/Math-Papers-with-Code/tags
MIT
[ "academic-project", "c", "math", "paper", "python", "zig" ]
133
false
2025-04-11T06:23:53Z
false
false
unknown
github
[]
Math Papers with Code A collection of implementations of mathematical algorithms and concepts from various academic papers in multiple programming languages. Implemented Papers Current Implementations | Paper Title | Author(s) | arXiv | Implementations | Status | Directory | |------------|-----------|--------|-----------------|---------|-----------| | Relative Sizes of Iterated Sumsets | Noah Kravitz | <a>2412.18598</a> | | ✅ Complete | <code>papers/iterated-sumsets/</code> | | A Remark on an Explicit Formula for the Sums of Powers of Integers | José L. Cereceda | <a>2503.14508v2</a> | | ✅ Complete | <code>papers/stirling-numbers-power-sums/</code> | | The Neveu-Schwarz Group and Schwarz's Extended Super Mumford Form | Katherine A. Maxwell &amp; Alexander A. Voronov | <a>2412.18585</a> | | ⏸️ On Hold | <code>papers/super-mumford/</code> | | Derivative Polynomials and Infinite Series for Squigonometric Functions | Bart S. Van Lith | <a>2503.19624</a> | | ✅ Complete | <code>papers/squigonometry/</code> | | Inverse Source Problems for a Multidimensional Time-Fractional Wave Equation | D.K. Durdiev | <a>2503.17404v1</a> | | ✅ Complete | <code>papers/frac-wave-inverse-problems/</code> | Implementation Status Legend | Status | Description | |--------|-------------| | ✅ Complete | Implementation finished and tested | | 🚧 In Progress | Currently being implemented | | 📝 Planned | On roadmap for implementation | | ⏸️ On Hold | Implementation paused | Coming Soon Future papers will be added to this collection. Suggestions for new implementations are welcome through issues or pull requests. Repository Structure Each paper implementation is organized in its own directory with its implementation: <code>. ├── README.md ├── papers/ │ ├── iterated-sumsets/ │ │ ├── README.md │ │ └── python/ │ │ ├── iterated_sumsets.py │ │ └── tests/ │ ├── super-mumford/ │ │ ├── README.md │ │ └── python/ │ │ ├── core/ │ │ │ ├── __init__.py │ │ │ ├── laurent_series.py │ │ │ ├── matrix_ops.py │ │ │ └── vector_spaces.py │ │ ├── geometry/ │ │ │ ├── __init__.py │ │ │ ├── grassmannian.py │ │ │ └── line_bundles.py │ │ ├── groups/ │ │ │ ├── __init__.py │ │ │ ├── heisenberg.py │ │ │ ├── neveu_schwarz.py │ │ │ └── witt.py │ │ ├── tests/ │ │ │ ├── __init__.py │ │ │ ├── test_laurent_series.py │ │ │ ├── test_matrix_ops.py │ │ │ └── test_vector_spaces.py │ │ ├── utils/ │ │ │ ├── __init__.py │ │ │ └── validation.py │ │ ├── README.md │ │ └── pyproject.toml │ └── future-papers/ │ ├── README.md │ └── python/ └── common/ ├── testing/ └── benchmarks/</code> Using the Implementations Each paper implementation includes its own README with specific instructions. For Python implementations: ```bash Example for Super Mumford project cd papers/super-mumford/python pip install -r requirements.txt python -m pytest tests/ ``` Contributing Contributions are welcome! To contribute: <ol> <li>Select a mathematics paper to implement</li> <li>Create a new directory under <code>papers/</code></li> <li>Implement the paper's concepts</li> <li>Include:</li> <li>README.md with paper details</li> <li>Source code</li> <li>Tests (if applicable)</li> <li>Docker support (if applicable)</li> <li>Documentation (if applicable)</li> <li>Performance benchmarks (optional)</li> </ol> Please see CONTRIBUTING.md for detailed guidelines. Paper Implementation Guidelines Each paper implementation should: <ol> <li><strong>Documentation</strong></li> <li>Include link to original paper</li> <li>Explain key concepts</li> <li>Provide usage examples</li> <li> Document any assumptions or limitations </li> <li> <strong>Code Structure</strong> </li> <li>Clear organization</li> <li>Well-commented code</li> <li>Tests</li> <li> Docker support (where applicable) </li> <li> <strong>Performance</strong> </li> <li>Efficient implementations</li> <li>Benchmarking (optional)</li> <li>Optimization notes</li> </ol> License This project is licensed under the MIT License - see the <a>LICENSE</a> file for details. Acknowledgments <ul> <li>All original paper authors</li> <li>Contributors to the implementations</li> <li>Open source community</li> </ul>
[]
https://avatars.githubusercontent.com/u/44122379?v=4
whisper-zig
baristikir/whisper-zig
2024-10-19T18:54:56Z
Example repository to demonstrate usage of whisper.cpp in Zig.
main
0
2
0
2
https://api.github.com/repos/baristikir/whisper-zig/tags
-
[ "whisper-cpp", "zig" ]
67
false
2024-11-16T03:29:03Z
true
true
unknown
github
[]
Whisper.cpp with Zig This repository demonstrates the usage of <a>whisper.cpp</a> in Zig. Usage First download a Whisper model from <a>huggingface</a>. <code>shell $ ./whisper.cpp/models/download-ggml.sh base.en $ zig build &amp;&amp; ./zig-out/bin/whisper-zig -- -m ggml-base.en.bin -f ./whisper.cpp/samples/jfk.wav</code> Tests <code>shell $ ./whisper.cpp/models/download-ggml.sh base.en $ zig build test</code> Sources <ul> <li><a>whisper.cpp</a></li> <li><a>dr_wav</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/51542168?v=4
ps
mostik/ps
2025-01-07T23:25:18Z
linux proc/pid/stat
main
0
2
0
2
https://api.github.com/repos/mostik/ps/tags
-
[ "zig", "zig-package" ]
7
false
2025-03-31T06:03:25Z
true
true
unknown
github
[]
Proc stat Install <code>zig fetch --save https://github.com/Mostik/ps/archive/v0.0.1.tar.gz</code> ```zig //build.zig const ps = b.dependency("ps", .{}).module("ps"); exe.root_module.addImport("ps", ps); <code></code>zig const std = @import("std"); const ps = @import("ps"); pub fn main() !void { <code>var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); const stat: ps.ProcStat = try ps.get(allocator, std.os.linux.getpid()); std.debug.print("PID: {d} Vsize: {d} \n", .{ stat.pid, stat.vsize }); </code> } ```
[]
https://avatars.githubusercontent.com/u/161890530?v=4
coff_loader
soheil-01/coff_loader
2024-12-05T09:46:56Z
An experimental COFF loader for executing Cobalt Strike Beacon Object Files (BOFs)
main
0
2
0
2
https://api.github.com/repos/soheil-01/coff_loader/tags
-
[ "beacon-object-file", "cobalt-strike", "coff-loader", "zig" ]
12
false
2025-02-21T13:06:09Z
true
true
unknown
github
[]
COFF Loader A Common Object File Format (COFF) loader implementation in Zig.
[]
https://avatars.githubusercontent.com/u/113083639?v=4
zopenvr
zig-gamedev/zopenvr
2024-11-04T00:23:43Z
Zig build package and bindings for https://github.com/ValveSoftware/openvr
main
1
2
2
2
https://api.github.com/repos/zig-gamedev/zopenvr/tags
MIT
[ "bindings", "gamedev", "openvr", "zig" ]
83
false
2025-04-28T00:49:33Z
true
true
0.14.0
github
[ { "commit": "c29e0fec072c282a8c6234c5837db071af42a11f.tar.gz", "name": "zwindows", "tar_url": "https://github.com/zig-gamedev/zwindows/archive/c29e0fec072c282a8c6234c5837db071af42a11f.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/zig-gamedev/zwindows" } ]
<a>zopenvr</a> Zig build package and bindings for <a>OpenVR</a> v2.2.3 Work in progress | Interface | Status | | --------------- | :-----------------: | | Applications | ✅ | | BlockQueue | | | Chaperone | ✅ | | ChaperoneSetup | | | Compositor | ✅(d3d12 only) | | Debug | | | DriverManager | | | ExtendedDisplay | | | HeadsetView | | | Input | ✅ | | IOBuffer | | | Notifications | | | Overlay | | | OverlayView | | | Paths | | | Properties | | | RenderModels | ✅ | | Resources | | | Screenshots | | | Settings | | | SpatialAnchors | | | System | ✅ | | TrackedCamera | | Getting started Example <code>build.zig</code>: ```zig pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ ... }); <code>const zopenvr = b.dependency("zopenvr", .{}); exe.root_module.addImport("zopenvr", zopenvr.module("zopenvr")); try @import("zopenvr").addLibraryPathsTo(zopenvr, exe); try @import("zopenvr").installOpenVR(zopenvr, &amp;exe.step, target.result, .bin); @import("zopenvr").linkOpenVR(exe); </code> } ``` Now in your code you may import and use <code>zopenvr</code>: ```zig const std = @import("std"); const OpenVR = @import("zopenvr"); pub fn main() !void { ... <code>const openvr = try OpenVR.init(.scene); defer openvr.deinit(); const system = try openvr.system(); const name = try app.system.allocTrackedDevicePropertyString(allocator, OpenVR.hmd, .tracking_system_name); defer allocator.free(name); ... </code> } ```
[ "https://github.com/zig-gamedev/zig-gamedev" ]
https://avatars.githubusercontent.com/u/48713070?v=4
fun
omdxp/fun
2024-09-12T08:17:00Z
fun is a statically-typed language that transpiles to C, combining safety and performance with C's efficiency.
main
8
2
0
2
https://api.github.com/repos/omdxp/fun/tags
MIT
[ "c", "transpiler", "zig" ]
251
false
2025-05-04T14:31:44Z
true
true
0.14.0
github
[]
fun <a></a> <a></a> A statically-typed programming language that transpiles to C, designed for safety, performance, and leveraging the power of C. Written in Zig. Table of Contents <ul> <li><a>fun</a></li> <li><a>Table of Contents</a></li> <li><a>Features</a></li> <li><a>Installation</a></li> <li><a>CLI Usage</a></li> <li><a>Quickstart</a></li> <li><a>Examples</a></li> <li><a>Project Structure</a></li> <li><a>Contributing</a></li> <li><a>Changelog</a></li> <li><a>License</a></li> </ul> Features <ul> <li>Statically-typed language with C-like performance</li> <li>Transpiles to readable C code</li> <li>Simple, expressive syntax</li> <li>Imports and modularity</li> <li>Pattern matching with <code>fit</code> statement</li> <li>Type-safe variables and functions</li> <li>CLI with multiple output and debug options</li> <li>AST printing and analysis</li> <li>Comprehensive error handling</li> <li>Example and test suite</li> </ul> Installation Requires <a>Zig</a> (v0.14.0+ recommended). <code>bash zig build</code> This will build the <code>fun</code> compiler in <code>zig-out/bin/fun</code>. CLI Usage ``` Usage: fun -in [-out ] [-no-exec] [-outf] [-ast] [-help] Arguments: -in Input file to compile (required) -out Output file (optional, defaults to input filename with .c extension) -no-exec Disable automatic compilation and execution (optional, execution enabled by default) -outf Generate .c output file (optional, disabled by default) -ast Print AST nodes (optional, disabled by default) -help Show this help message ``` Quickstart Write your first program in <code>hello.fn</code>: ```fun imp std.io; fun main(str[] args) { printf("Hello, World!\n"); } ``` Compile and run: <code>bash zig build ./zig-out/bin/fun -in hello.fn</code> Examples Explore the <a><code>examples/</code></a> directory for more: - Basic: <a><code>test.fn</code></a> - Advanced: <a><code>advanced/custom_functions.fn</code></a> - Imports: <a><code>imports/main.fn</code></a> - Error cases: <a><code>error_cases/</code></a> Project Structure <ul> <li><code>cmd/</code> — CLI entrypoint</li> <li><code>modules/</code> — Core compiler modules (lexer, parser, codegen, semantics, utils, etc.)</li> <li><code>examples/</code> — Example programs</li> <li><code>tests/</code> — Test suite</li> <li><code>build.zig</code> — Zig build script</li> </ul> Contributing Contributions are welcome! Please open issues or pull requests. See <a>CONTRIBUTING.md</a> if available. Changelog See <a>CHANGELOG.md</a> for release notes and development history. License This project is licensed under the MIT License. See the <a>LICENSE</a> file for details.
[]
https://avatars.githubusercontent.com/u/2926836?v=4
game-of-life-gpu
johanhenriksson/game-of-life-gpu
2024-10-22T12:31:10Z
GPU-accelerated Game of Life implemented in zig/vulkan. Made in 6 days at Codecation 2024.
main
0
2
0
2
https://api.github.com/repos/johanhenriksson/game-of-life-gpu/tags
-
[ "vulkan", "zig" ]
962
false
2025-03-13T10:19:28Z
true
true
0.13.0-dev.351+64ef45eb0
github
[ { "commit": "66b7b773bb61e2102025f2d5ff0ae8c5f53e19cc.tar.gz", "name": "vulkan_zig", "tar_url": "https://github.com/Snektron/vulkan-zig/archive/66b7b773bb61e2102025f2d5ff0ae8c5f53e19cc.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Snektron/vulkan-zig" }, { "commit": "v1.3....
404
[]
https://avatars.githubusercontent.com/u/133709987?v=4
BellmanZig
cartersusi/BellmanZig
2024-08-16T22:29:42Z
(Zig) Arbitrage using Bellman-Ford's Algorithm
main
0
2
0
2
https://api.github.com/repos/cartersusi/BellmanZig/tags
-
[ "bellman-ford-algorithm", "market", "zig" ]
40
false
2024-08-21T04:52:01Z
true
true
unknown
github
[]
Bellman Ford implementation in Zig <code>---@linux ~/BellmanZig (main)&gt; ./zig-out/bin/BellmanZig Targets: { AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTC, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLF, CLP, CNH, CNY, COP, CRC, CUC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GGP, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STD, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VES, VND, VUV, WST, XAF, XAG, XAU, XCD, XDR, XOF, XPD, XPF, XPT, YER, ZAR, ZMW, ZWL } Timestamp: 1724079600 Num Rates: 169 Arbitrage opportunity: XPF ---&gt;INR ---&gt;XPF ---@linux ~/BellmanZig (main)&gt;</code>
[]
https://avatars.githubusercontent.com/u/476352?v=4
msgpack-zig
rockorager/msgpack-zig
2024-09-05T15:08:41Z
msgpack encoding and decoding in zig | msgpack.org[Zig]
main
0
2
0
2
https://api.github.com/repos/rockorager/msgpack-zig/tags
MIT
[ "msgpack", "zig", "zig-package" ]
10
false
2024-11-14T11:44:41Z
true
true
unknown
github
[]
msgpack-zig msgpack-zig provides a simple API for encoding and decoding msgpack data. The API is designed to similar to <code>std.json</code>. Msgpack inherently requires less allocation than JSON so the return values are slightly different. <blockquote> <span class="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">IMPORTANT</span> msgpack-zig uses zig 0.13.0 </blockquote> Usage <blockquote> <span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span> Refer to the <a>documentation</a> for additional usage. </blockquote> There are two main functions provided by msgpack-zig: ```zig /// Pack a given type as a msgpack Value pub fn pack(comptime T: type, writer: std.io.AnyWriter) anyerror!void {} /// Unpack the next msgpack Value from reader as type T pub fn unpack(comptime T: type, reader: std.io.AnyReader) anyerror!void {} ``` For packing, any type which has a function signature <code>msgpackPack(self: T, writer: std.io.AnyWriter) anyerror!void</code> will use this function has for packing. Otherwise it will be packed using the defaults. Likewise, unpacking types can implement <code>msgpackUnpack(writer: std.io.AnyWriter) anyerror!T</code> to unpack from a stream, or <code>msgpackUnpackFromValue(value: msgpack.Value) anyerror!T</code> to unpack from a msgpack.Value. Value msgpack values are stored internally as a tagged union. Note that we impose a limitation on maps: the keys <em>must</em> be strings, similar to JSON (the msgpack specification allows for any msgpack type to be a key). <code>zig pub const Value = union(enum) { i64: i64, u64: u64, f64: f64, nil: void, bool: bool, str: []const u8, bin: []const u8, array: []Value, map: std.StringHashMap(Value), ext: struct { id: i8, data: []const u8, }, };</code> Roadmap <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Automatic unpacking of <code>map</code> to structs
[]
https://avatars.githubusercontent.com/u/6793008?v=4
ex_zig_zigler_wasmex
ndrean/ex_zig_zigler_wasmex
2024-12-18T22:08:16Z
Demo of running Zig code in Elixir with Zigler and in WebAssembly server-side with Wasmex and client-side with native WebAssembly
main
0
2
0
2
https://api.github.com/repos/ndrean/ex_zig_zigler_wasmex/tags
MIT
[ "elixir", "wasmex", "webassembly", "zig", "zigler" ]
297
false
2024-12-19T09:37:54Z
false
false
unknown
github
[]
Running Zig code in Elixir with Zigler and in Wasi-WebAssembly with Wasmex I was curious about the difference in execution time between <code>NIF</code> and <code>WebAssembly</code>. <ul> <li>NIF with <code>Zigler</code> server-side</li> <li>WASI with <code>Wasmex</code> server-side</li> <li>WASM with native <code>WebAssembly</code> in the browser</li> </ul> And the winner is NIF, about two times faster. All <code>Zig</code> code compiled <code>ReleaseFast</code> in all cases. Compilation: <ul> <li><code>Zigler</code> compiles the <code>Zig</code> for you</li> <li>you pass the target <code>.wasi</code> in <code>zig build</code> for <code>WASI</code></li> <li>you pass or <code>.freestanding</code> in <code>zig build</code> for <code>WebAssembly</code>.</li> </ul> The main difference between the two solutions is the way you pass data to and from the host. Receive data <strong>into</strong> <code>Elixir</code>: <ul> <li>with <code>Zigler</code>, you can receive a struct as a map. <code>Zigler</code> is quite impressive. It also provides also <a>resources</a>: a (safe) way to return pointers to native data structures from a <code>NIF</code>.</li> <li>with <code>Wasmex</code> or <code>WebAssembly</code>, you receive a memory index when the data is in binary form</li> </ul> When using WebAssembly, the crux of the interaction is the serialisation of the data structure in Zig you want to pass to Elixir in order to fit the linear memory model. It remains to pattern match on the binary on the Elixir side. Pass data <strong>from</strong> <code>Elixir</code>: <ul> <li>with <code>Zigler</code>, you pass an array of data</li> <li>with <code>Wasmex</code> or <code>WA</code>, you write data to an index that has been allocated by <code>Zig</code>. This way, you can pass strings or serialised data.</li> </ul> Results The results of the Genetic Algorithm ran 32 times to collect stats back in Elixir are: Server-side: ```elixir Threaded NIF iex(24)&gt; :timer.tc(fn -&gt; GAThreaded.calc(10, "I want a beer! What about you?!") end) {2_624_277, %{max: 1733, min: 545, elitism: 10, mean: 969.25, std_dev: 467.44238906711723}} unthreaded NIF iex(26)&gt; :timer.tc(fn -&gt; GAStd.calc(10, "I want a beer! What about you?!") end) {2_038_405, %{max: 1926, min: 537, elitism: 10, mean: 994.46875, std_dev: 347.26} WASI iex(29)&gt; :timer.tc(fn -&gt; GAWasi.calc(10, "I want a beer! What about you?!") end) {4_613_034, %{max: 1532, min: 474, elitism: 10, mean: 894.25, std_dev: 264.93, trials: 32}} ``` Browser: <code>js 4_952_399, { elitism: 10, mean: 1086.98, stdDev: 451.45, min: 428, max: 2668, trials: 32, };</code> Dataflow in <code>Javascript</code>. You need to pass a string from the host (Javascript) to the WebAssembly container, and recover data from the WAC. <ul> <li>you call a Zig function that allocates memory of a given length</li> <li>you populate the WA memory at this position (via an ArrayBuffer given by TextDecoder with "ascii" encoding)</li> <li>you call a Zig function to read the memory at this position and populate an internal variable</li> <li>to recover data from Zig, you need to serialise it into a linear format</li> <li>you call a Zig function that sends you the index of this data</li> <li>you populate a DataView at this index and convert the data</li> </ul>
[]
https://avatars.githubusercontent.com/u/6756180?v=4
zig-gpa-ffi
kassane/zig-gpa-ffi
2024-12-15T17:20:38Z
Testing GPA in FFI
main
2
2
0
2
https://api.github.com/repos/kassane/zig-gpa-ffi/tags
MIT
[ "allocation", "allocator", "bindings", "cpp", "ffi", "ffi-bindings", "malloc-free", "memory-allocation", "memory-management", "rust", "rust-allocator-interface", "zig", "ziglang" ]
22
false
2025-05-04T20:18:12Z
false
false
unknown
github
[]
zig-gpa-ffi Testing <a><code>std.heap.DebugAllocator</code></a> in FFI. Required <ul> <li>Zig 0.14.0 or master</li> <li>Rust 1.82.0 or nightly</li> </ul> Some references for tests <ul> <li>Rust <a>Global Allocator</a></li> <li>C++ <a>new</a>/<a>delete</a> operators override</li> <li>C++17 <a>PMR</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/43353831?v=4
advent-of-code
storopoli/advent-of-code
2024-11-26T22:50:06Z
Advent of Code Solutions
main
0
2
0
2
https://api.github.com/repos/storopoli/advent-of-code/tags
CC0-1.0
[ "advent-of-code", "haskell", "rust", "zig" ]
77
false
2024-12-21T20:10:26Z
false
false
unknown
github
[]
🦌🎅🏻⛄🎁 <em>Advent of Code</em> (AoC) ☃️❄️🤶🎄 <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> AoC '24 in Haskell (in progress) <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> AoC '25 (yet to come) About <em>Advent of Code</em> A nice video about AoC on YouTube: <ul> <li><a>Eric Wastl – Advent of Code: Behind the Scenes</a>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/5428479?v=4
network-exercises
tricktux/network-exercises
2024-10-13T11:16:12Z
Solution to the prothackers problems
master
0
2
0
2
https://api.github.com/repos/tricktux/network-exercises/tags
-
[ "c", "catch2", "cmake", "cmake-init", "linux", "makefile", "network-programming", "protohacker-solutions", "protohackers", "protohackers-solutions", "server", "socket-programming", "sockets", "zig" ]
617
false
2025-05-11T15:24:12Z
false
false
unknown
github
[]
network-exercises This is the network-exercises project. 0: Smoke Test Deep inside Initrode Global's enterprise management framework lies a component that writes data to a server and expects to read the same data back. (Think of it as a kind of distributed system delay-line memory). We need you to write the server to echo the data back. Accept TCP connections. Whenever you receive data from a client, send it back unmodified. Make sure you don't mangle binary data, and that you can handle at least 5 simultaneous clients. Once the client has finished sending data to you it shuts down its sending side. Once you've reached end-of-file on your receiving side, and sent back all the data you've received, close the socket so that the client knows you've finished. (This point trips up a lot of proxy software, such as ngrok; if you're using a proxy and you can't work out why you're failing the check, try hosting your server in the cloud instead). Your program will implement the TCP Echo Service from RFC 862. Building and installing See the <a>BUILDING</a> document. Contributing See the <a>CONTRIBUTING</a> document. Licensing
[]
https://avatars.githubusercontent.com/u/146390816?v=4
libxml2
allyourcodebase/libxml2
2024-12-18T18:31:19Z
libxml2 ported to the zig build system
master
0
2
0
2
https://api.github.com/repos/allyourcodebase/libxml2/tags
MIT
[ "zig", "zig-package" ]
15
false
2025-05-20T22:33:00Z
true
true
0.14.0
github
[ { "commit": null, "name": "libxml2", "tar_url": null, "type": "remote", "url": "git+https://gitlab.gnome.org/GNOME/libxml2.git?ref=v2.14.3#8d509f483dd5ce268b2fded9c738132c47d820d8" }, { "commit": "6c72830882690c1eb2567a537525c3f432c1da50", "name": "zlib", "tar_url": "https://gith...
<a></a> libxml2 This is <a>libxml2</a>, packaged for <a>Zig</a>. Installation First, update your <code>build.zig.zon</code>: ``` Initialize a <code>zig build</code> project if you haven't already zig init zig fetch --save git+https://github.com/allyourcodebase/libxml2.git#2.14.3 ``` You can then import <code>libxml2</code> in your <code>build.zig</code> with: <code>zig const libxml2_dependency = b.dependency("libxml2", .{ .target = target, .optimize = optimize, }); your_exe.linkLibrary(libxml2_dependency.artifact("libxml2"));</code>
[ "https://github.com/ZigEmbeddedGroup/regz", "https://github.com/allyourcodebase/libxkbcommon", "https://github.com/allyourcodebase/libxml2", "https://github.com/allyourcodebase/wayland", "https://github.com/dasimmet/ugtar", "https://github.com/dasimmet/zig-libxml2", "https://github.com/doccaico/libxml2-...
https://avatars.githubusercontent.com/u/80534748?v=4
zig-gobject-template
thetek42/zig-gobject-template
2024-11-14T19:12:45Z
A sample application illustrating how to use zig-gobject. – ⚠️ MIRROR OF https://git.tjdev.de/thetek/zig-gobject-template ⚠️
main
0
2
0
2
https://api.github.com/repos/thetek42/zig-gobject-template/tags
MIT
[ "gtk", "gtk4", "gui", "libadwaita", "zig" ]
14
false
2025-03-06T16:11:46Z
true
true
0.13.0
github
[ { "commit": "master", "name": "gobject", "tar_url": "https://github.com/ianprime0509/zig-gobject/releases/download/v0.2.1/bindings-gnome46.tar.zst/archive/master.tar.gz", "type": "remote", "url": "https://github.com/ianprime0509/zig-gobject/releases/download/v0.2.1/bindings-gnome46.tar.zst" },...
zig-gobject-template This is a sample application illustrating how to use <a>zig-gobject</a>. Features <ul> <li>Gtk4 + LibAdwaita</li> <li><a>Blueprints</a></li> <li>libintl (Translation)</li> <li>GSchema (Preferences)</li> </ul> Usage <ol> <li>Replace all IDs and similar items to your desired values. Hint: <code>sh grep -r --exclude-dir=zig-out --exclude-dir=.zig-cache "zig-gobject-template"` find -name "*zig-gobject-template*" -not -path "./zig-out/*" -not -path "./.zig-cache/*"</code></li> <li>Build (and run) the application: <code>sh zig build zig build run</code></li> </ol> Building for Windows Since building natively on Windows does not work paricularly well, you need to cross-compile the application from Linux: ```sh fetch required libraries dependencies (only required the first time) sh fetch-windows-libs.sh cross-compile to windows zig build -Dtarget=x86_64-windows ```
[]
https://avatars.githubusercontent.com/u/101195284?v=4
apz
0xrinegade/apz
2024-10-31T09:22:37Z
blazigly spicy http server
main
0
2
0
2
https://api.github.com/repos/0xrinegade/apz/tags
Unlicense
[ "blazigly", "http-server", "zig", "zig-package" ]
5
false
2025-02-23T03:37:56Z
true
true
unknown
github
[ { "commit": "refs", "name": "spice", "tar_url": "https://github.com/judofyr/spice/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/judofyr/spice" } ]
apz zig api
[]
https://avatars.githubusercontent.com/u/148249444?v=4
ifj-compiler
rm-a0/ifj-compiler
2024-09-13T14:07:44Z
Compiler for a subset of Zig
main
0
2
0
2
https://api.github.com/repos/rm-a0/ifj-compiler/tags
-
[ "compiler", "zig" ]
996
false
2025-05-15T19:50:32Z
false
false
unknown
github
[]
IFJ24 Compiler Custom compiler written in C for a subset of the Zig programming language. Overview This project is an implementation of a compiler for the IFJ24 imperative programming language. It includes lexical analysis, parsing, semantic analysis, and code generation. The compiler follows an LL(1) parsing approach and generates target code with optimizations. Features <ul> <li><strong>Lexical Analysis</strong>: FSM-based lexer for tokenizing source code</li> <li><strong>Parsing</strong>: Recursive descent parser</li> <li><strong>Semantic Analysis</strong>: Symbol table and type checking</li> <li><strong>Code Generation</strong>: Optimized target code output</li> </ul> Team <ul> <li><strong>Michal Repčík (xrepcim00)</strong> – Lexer, AST, Parser</li> <li><strong>Alex Marinica (xmarina00)</strong> – Symbol table, Semantic analysis</li> <li><strong>Šimon Bobko (xbobkos00)</strong> – Grammar, LL parsing, Expression parser, Testing</li> <li><strong>Martin Kandera (xkande00)</strong> – Code generation, Testing</li> </ul> Build &amp; Run <ol> <li>Clone the repository: <code>sh git clone https://github.com/rm-a0/ifj-compiler cd ifj24-compiler</code></li> <li>Compile the project: <code>sh make</code> </li> <li>Run: <code>sh make run &lt; src.ifj24</code></li> </ol> Documentation For more detailed documentation, use the documentation in the <code>doc</code> folder. Refer to <code>doc/documentation.tex</code> for in-depth details. Final Evaluation <ul> <li>Lexical Analysis - 85%</li> <li>Syntax Analysis - 95%</li> <li>Semantic Analysis - 81%</li> <li>Code Generation (basic tests) - 68%</li> <li>Code Generation (advanced tests) - 42%</li> <li>Code Generation (complex tests) - 22%</li> <li>FUNEXP extension - 90%</li> <li><strong>Total</strong> - 65%</li> </ul>
[]
https://avatars.githubusercontent.com/u/190158618?v=4
zig-libp2p
zen-eth/zig-libp2p
2024-12-01T03:57:41Z
Libp2p implementation in Zig
main
12
2
4
2
https://api.github.com/repos/zen-eth/zig-libp2p/tags
-
[ "libp2p", "libp2p-muxer", "libp2p-pubsub", "libp2p-security", "libp2p-transport", "yamux", "zig", "ziglang" ]
244
false
2025-05-20T13:33:40Z
true
true
0.11.0
github
[ { "commit": "refs", "name": "libxev", "tar_url": "https://github.com/mitchellh/libxev/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/mitchellh/libxev" } ]
zig-libp2p Zig implementation of <a>libp2p</a>, a modular network stack that allows you to build your own peer-to-peer applications. <strong>Note</strong>: This is a work in progress and not yet ready for production use. The API may change frequently as we iterate on the design and implementation. Prerequisites <ul> <li>Zig 0.14.0</li> </ul> Building To build the project, run the following command in the root directory of the project: <code>bash zig build -Doptimize=ReleaseFast</code> Running Tests To run the tests, run the following command in the root directory of the project: <code>bash zig build test --summary all</code>
[]
https://avatars.githubusercontent.com/u/36546318?v=4
zig-pong
Mario-SO/zig-pong
2025-01-05T10:41:40Z
Pong game implemented in Zig
main
0
2
0
2
https://api.github.com/repos/Mario-SO/zig-pong/tags
-
[ "raylib-zig", "zig" ]
188
false
2025-04-15T15:54:57Z
true
true
unknown
github
[ { "commit": "master", "name": "raylib-zig", "tar_url": "https://github.com/Not-Nik/raylib-zig/archive/master.tar.gz", "type": "remote", "url": "https://github.com/Not-Nik/raylib-zig" } ]
🏓 Zig Pong A modern take on the classic Pong game, built with Zig and Raylib! ✨ Features <ul> <li>🎮 Smooth player controls (W/S or Up/Down arrows)</li> <li>🤖 Smart AI opponent that tracks the ball</li> <li>🌟 Beautiful glow shader effects</li> <li>📈 Progressive difficulty - ball and paddles speed up as you play</li> <li>🎯 Score tracking system</li> <li>🎨 Clean minimalist visuals with retro feel</li> </ul> 🎯 Controls <ul> <li><code>W</code> or <code>↑</code> - Move paddle up</li> <li><code>S</code> or <code>↓</code> - Move paddle down</li> </ul> 🛠️ Building Make sure you have Zig and Raylib installed, then: <code>bash zig build run</code> 🎥 Game Preview <ul> <li>Glowing particles and effects</li> <li>Center line divider</li> <li>Real-time score display</li> <li>Smooth ball physics</li> <li>Dynamic paddle movement</li> </ul> https://github.com/user-attachments/assets/8d09cfeb-f419-471f-854b-2b17c291cc42 🔧 Technical Details <ul> <li>Built with Zig programming language</li> <li>Uses Raylib for graphics</li> <li>Custom GLSL shader for glow effects</li> <li>60 FPS smooth gameplay </li> </ul>
[]
https://avatars.githubusercontent.com/u/75046310?v=4
anyascii-zig
sweetbbak/anyascii-zig
2025-01-12T04:27:33Z
A Zig native port of the anyascii library for Zig and C
main
0
2
0
2
https://api.github.com/repos/sweetbbak/anyascii-zig/tags
-
[ "c", "unicode", "zig", "zig-library", "zig-package" ]
261
false
2025-02-20T22:19:00Z
true
true
0.13.0
github
[]
anyascii-zig a Zig port of the <code>anyascii</code> C implementation. Converts Unicode characters to their best ASCII representation AnyAscii provides ASCII-only replacement strings for practically all Unicode characters. Text is converted character-by-character without considering the context. The mappings for each script are based on popular existing romanization systems. Symbolic characters are converted based on their meaning or appearance. All ASCII characters in the input are left unchanged, every other character is replaced with printable ASCII characters. Unknown characters and some known characters are replaced with an empty string and removed. | Symbols | Input | Output | | ---------- | --------- | --------------------- | | Emojis | 👑 🌴 | <code>:crown: :palm_tree:</code> | | Misc. | ☆ ♯ ♰ ⚄ ⛌ | * # + 5 X | | Letterlike | № ℳ ⅋ ⅍ | No M &amp; A/S | This project uses <code>Zig mach</code> (0.14.0-dev.2577+271452d22) but it is also compatible with: <ul> <li><code>Zig 0.13.0</code></li> <li><code>Zig master</code> (as of 1/11/25)</li> </ul> Use in your project ```bash or pick a specific branch or commit zig fetch --save https://github.com/sweetbbak/anyascii-zig/archive/refs/heads/main.zip ``` in <code>build.zig</code>: <code>zig // Add anyascii.zig dependency. const anyascii = b.dependency("anyascii-zig", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("anyascii", anyascii.module("anyascii"));</code> Using the C library build the shared library and the static library <code>bash zig build -Doptimize=ReleaseFast</code> install the given header file at <code>include/anyascii.h</code> and the shared object (or static object) to your prefered location ```c include "../include/anyascii.h" include include static char* actual; int main() { actual = malloc(256); anyascii(0xD55C, actual); // 한 printf("anyascii: %s\n", actual); // Han (Korean) <code>char* output = malloc(256); anyascii_string("René François Lacôte", output); printf("anyascii_string: %s\n", output); </code> } ``` you can try out the simple example in the <code>example</code> directory: ```bash zig build -Doptimize=ReleaseFast gcc -o ascii example/anyascii.c \ -Wall -Wextra -Werror -Os -fPIE \ -I./include -L zig-out/lib \ -l:libanyascii.a -lc ./ascii ``` Examples | input | got | | ------------------------- | --------------------------- | | 'René François Lacôte' | 'Rene Francois Lacote' | | 'Blöße' | 'Blosse' | | 'Trần Hưng Đạo' | 'Tran Hung Dao' | | 'Nærøy' | 'Naeroy' | | 'Φειδιππίδης' | 'Feidippidis' | | 'Δημήτρης Φωτόπουλος' | 'Dimitris Fotopoylos' | | 'Борис Николаевич Ельцин' | 'Boris Nikolaevich El'tsin' | | 'Володимир Горбулін' | 'Volodimir Gorbulin' | | 'Търговище' | 'T'rgovishche' | | '深圳' | 'ShenZhen' | | '深水埗' | 'ShenShuiBu' | | '화성시' | 'HwaSeongSi' | | '華城市' | 'HuaChengShi' | | 'さいたま' | 'saitama' | | '埼玉県' | 'QiYuXian' | | 'ደብረ ዘይት' | 'debre zeyt' | | 'ደቀምሓረ' | 'dek'emhare' | | 'دمنهور' | 'dmnhwr' | | 'Աբովյան' | 'Abovyan' | | 'სამტრედია' | 'samt'redia' | | 'אברהם הלוי פרנקל' | ''vrhm hlvy frnkl' | | '⠠⠎⠁⠽⠀⠭⠀⠁⠛' | '+say x ag' | | 'ময়মনসিংহ' | 'mymnsimh' | | 'ထန်တလန်' | 'thntln' | | 'પોરબંદર' | 'porbmdr' | links upstream anyascii that this project is ported from: <a>anyascii</a> used this project for reference: <a>anyascii/go</a> learned about anyascii and got the idea from here: <a>zigzedd/anyascii.zig</a>
[]
https://avatars.githubusercontent.com/u/90518536?v=4
zigcoin
Decryptu/zigcoin
2024-12-01T21:33:50Z
A fast and minimal CLI cryptocurrency information tool written in Zig, using the CoinGecko API v3.
main
0
2
0
2
https://api.github.com/repos/Decryptu/zigcoin/tags
MIT
[ "bitcoin", "coingecko", "coingecko-api", "crypto", "cryptocurrency", "zig", "ziglang" ]
426
false
2024-12-22T17:25:35Z
true
false
unknown
github
[]
ZigCoin A fast and minimal CLI cryptocurrency information tool written in Zig, using the CoinGecko API v3. Features <ul> <li>Fetch real-time cryptocurrency price data</li> <li>Display market information including:</li> <li>Current price</li> <li>Market cap</li> <li>24h volume</li> <li>Price changes</li> <li>Supply information</li> <li>Clean and minimal CLI output</li> <li>Zero configuration needed</li> </ul> Prerequisites <ul> <li>Zig 0.11.0 or later</li> <li>libcurl development files</li> </ul> Installing Dependencies Ubuntu/Debian <code>bash sudo apt-get install libcurl4-openssl-dev</code> macOS <code>bash brew install curl</code> Building <code>bash zig build</code> Running <code>bash ./zig-out/bin/zigcoin &lt;coin-id&gt;</code> Examples: <code>bash ./zig-out/bin/zigcoin bitcoin ./zig-out/bin/zigcoin ethereum ./zig-out/bin/zigcoin dogecoin</code> Error Handling The tool provides clear error messages for common issues: <ul> <li>Invalid coin ID</li> <li>Network request failures</li> <li>API rate limiting</li> <li>Missing data</li> </ul> Project Structure <code>bash src/ ├── main.zig - Entry point and argument handling ├── api.zig - CoinGecko API client implementation ├── types.zig - Data structures and types ├── json.zig - JSON response parsing └── display.zig - Output formatting and display</code> Contributing <ol> <li>Fork the repository</li> <li>Create your feature branch</li> <li>Commit your changes</li> <li>Push to the branch</li> <li>Create a Pull Request</li> </ol> License This project is licensed under the MIT License - see the LICENSE file for details. Acknowledgments <ul> <li>CoinGecko API for providing the cryptocurrency data</li> <li>Zig community</li> <li>libcurl for HTTP requests</li> </ul> Known Limitations <ul> <li>Currently only supports single coin queries</li> <li>Requires internet connection</li> <li>Subject to CoinGecko API rate limits</li> </ul>
[]
https://avatars.githubusercontent.com/u/23480513?v=4
gnu-m4-zig
cbilz/gnu-m4-zig
2025-02-01T18:59:18Z
GNU M4 packaged for Zig
main
0
1
0
1
https://api.github.com/repos/cbilz/gnu-m4-zig/tags
MIT
[ "gnu", "gnu-m4", "m4", "zig", "zig-package" ]
170
false
2025-02-26T17:19:23Z
true
true
unknown
github
[ { "commit": null, "name": "upstream", "tar_url": null, "type": "remote", "url": "https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz" } ]
GNU M4 packaged for Zig Work in progress. Goal This project aims to provide a Zig package for GNU M4 that runs on Linux, macOS and Windows without system dependencies. The longer-term goal is to extract a reusable Zig library for compiling projects that rely on Autotools and Gnulib. Status Compiles and appears to run correctly on my Linux system when built in <code>ReleaseFast</code> or <code>ReleaseSmall</code> mode. However, with safety checks enabled, the executable hits an illegal instruction immediately on startup, presumably due to undefined behavior. Next steps <ol> <li>Fix the illegal instruction issue.</li> <li>Port the test suite and integrate it as a build step.</li> <li>Implement those configuration checks that do not depend on preprocessing, compilation or execution of probing code. Exclude any unused or redundant checks.</li> <li>Implement a <code>LazyValue</code> system to allow other build steps to pass configuration values to <code>ConfigHeader</code>.</li> <li>Implement remaining configuration checks, again excluding unused or redundant ones.</li> <li>Extract a reusable configuration library for projects using Autotools or Gnulib.</li> </ol> Requirements <ul> <li>Uses Zig 0.14.0-dev.3367+1cc388d52.</li> </ul> Limitations <ul> <li>Native language support is disabled.</li> </ul>
[]
https://avatars.githubusercontent.com/u/29946764?v=4
BES
forentfraps/BES
2024-09-18T01:26:24Z
BogusEncryptionStandard
main
0
1
0
1
https://api.github.com/repos/forentfraps/BES/tags
MIT
[ "aes", "aes-encryption", "blazingly-fast", "encryption", "x86", "zig" ]
20
false
2024-09-18T21:51:59Z
true
true
unknown
github
[]
BogusEncryptionStandard (BES) BogusEncryptionStandard (BES) is an <strong>ironic encryption algorithm</strong> designed for educational and entertainment purposes. It leverages the <code>aesenc</code> x86 opcode as a pseudo-random number generator (PRNG) to encrypt data in a highly inefficient and impractical manner. <strong>Please note that BES is not intended for real-world cryptographic use and should not be used to secure sensitive information.</strong> Table of Contents <ul> <li><a>Overview</a></li> <li><a>How It Works</a></li> <li><a>Getting Started</a></li> <li><a>Prerequisites</a></li> <li><a>Building the Project</a></li> <li><a>Usage</a></li> <li><a>Command-Line Options</a></li> <li><a>Examples</a></li> <li><a>Testing</a></li> <li><a>License</a></li> </ul> Overview BES encrypts data by iteratively generating outputs with the help of <code>aesenc</code> instruction until the first byte of the output matches the byte to be encrypted. The ciphertext consists of the number of iterations it took to find each matching byte. The decryption process reverses this by regenerating the PRNG outputs using the same seed and counts. How It Works <ol> <li><strong>Encryption:</strong></li> <li>For each byte in the plaintext:<ul> <li>Initialize a counter to zero.</li> <li>Generate a PRNG output using <code>aesenc</code> with the current seed.</li> <li>Increment the counter.</li> <li>If the first byte of the PRNG output matches the plaintext byte, record the counter value as part of the ciphertext.</li> <li>Update the seed with the latest PRNG output.</li> </ul> </li> <li>The ciphertext is a sequence of counters representing the number of iterations for each byte.</li> </ol> <em>Note: if the required byte is not found after 65535 iterations, everything goes up in flames, since it is obviously the user's fault for picking a faulty key. However the probabiliy of that is like 10^-112</em> <ol> <li><strong>Decryption:</strong></li> <li>For each counter in the ciphertext:<ul> <li>Use the initial seed to generate PRNG outputs.</li> <li>Iterate the PRNG the number of times specified by the counter.</li> <li>The first byte of the final PRNG output is the decrypted byte.</li> <li>Update the seed with the latest PRNG output.</li> </ul> </li> </ol> Getting Started Prerequisites <ul> <li><strong>Zig Programming Language</strong> (version 0.13.0 or later)</li> <li><strong>NASM</strong> assembler (for assembling the ASM code)</li> <li><strong>x86-64 CPU</strong> with support for AES-NI and AVX instructions</li> </ul> Building the Project BES can be built on both <strong>Linux</strong> and <strong>Windows</strong> systems. <ol> <li><strong>Clone the Repository:</strong></li> </ol> <code>git clone https://github.com/forentfraps/BES.git cd BES</code> 2. <strong>Build it</strong> <code>zig build</code> Usage Command-Line Options ``` -e Encrypt mode -d Decrypt mode -k [hex_string] 16-byte key in hex (default: 0xDEADBEEFCAFEBABEEF) -i [filepath] Input file path -o [filepath] Output file path (default: output.enc) -h Display help menu ``` Examples <ul> <li>Encrypt a file: <code>./bes -e -i plaintext.txt -o ciphertext.enc -k DEADBEEFCAFEBABEEF</code></li> <li>Decrypt a file: <code>./bes -d -i ciphertext.enc -o decrypted.txt -k DEADBEEFCAFEBABEEF</code></li> <li>Display a help menu: <code>./bes -h</code></li> </ul> Testing The project includes a test suite to verify the correctness of the encryption and decryption functions. - Run tests: <code>zig build test</code> Licence This project is licensed under the MIT License. See the LICENSE file for details.
[]
https://avatars.githubusercontent.com/u/54022416?v=4
my-torrent
billvog/my-torrent
2024-12-01T12:14:53Z
A simple BitTorrent client in Zig 🦎
main
0
1
0
1
https://api.github.com/repos/billvog/my-torrent/tags
MIT
[ "bittorrent", "zig" ]
112
false
2025-01-05T19:08:23Z
true
true
unknown
github
[ { "commit": "e60669413b7f781506a66da4d4b8fbb84fac1a19.tar.gz", "name": "network", "tar_url": "https://github.com/billvog/zig-network/archive/e60669413b7f781506a66da4d4b8fbb84fac1a19.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/billvog/zig-network" } ]
my-torrent A simple BitTorrent client written in Zig ⚡️ Supported Specifications <ul> <li><a>The BitTorrent Protocol Specification — bep 3</a></li> <li><a>UDP Tracker Protocol — bep 15</a></li> <li><a>Tracker Returns Compact Peer Lists — bep 23</a></li> </ul> Build &amp; Run Requirements <ul> <li>Zig (version 0.13.0)</li> </ul> Instructions To build &amp; run for <strong>Debuging</strong>: <code>zig build run -- info -f ./samples/sample.torrent</code> To build for <strong>Release</strong>: <code>zig build -Doptimize=ReleaseFast</code> and then run from <code>./zig-out/bin/my-torrent</code>. Contribute I'll be happy to review your PR 😎
[]
https://avatars.githubusercontent.com/u/48999343?v=4
abcrypt-zig
sorairolake/abcrypt-zig
2024-12-13T15:56:54Z
A simple, modern and secure file encryption library for Zig
develop
0
1
1
1
https://api.github.com/repos/sorairolake/abcrypt-zig/tags
Apache-2.0
[ "abcrypt", "abcrypt-encryption", "argon2", "argon2id", "blake2", "blake2b", "chacha20", "chacha20-poly1305", "encryption", "poly1305", "xchacha20", "xchacha20-poly1305", "zig", "zig-library", "zig-package", "ziglang" ]
70
false
2025-05-14T10:56:49Z
true
true
0.14.0
github
[]
abcrypt-zig <a></a> <strong>abcrypt-zig</strong> is an implementation of the <a>abcrypt encrypted data format</a>. This package supports version 1 of the abcrypt format. Usage Add this package to your <code>build.zig.zon</code>: <code>sh zig fetch --save git+https://github.com/sorairolake/abcrypt-zig.git</code> Add the following to your <code>build.zig</code>: <code>zig const abcrypt = b.dependency("abcrypt", .{}); exe.root_module.addImport("abcrypt", abcrypt.module("abcrypt"));</code> Documentation To build the documentation: <code>sh zig build doc</code> The result is generated in <code>zig-out/doc/abcrypt</code>. If you want to preview this, run a HTTP server locally. For example: <code>sh python -m http.server -d zig-out/doc/abcrypt</code> Then open <code>http://localhost:8000/</code> in your browser. Zig version This library is compatible with Zig version 0.14.0. Source code The upstream repository is available at <a>https://github.com/sorairolake/abcrypt-zig.git</a>. The source code is also available at: <ul> <li><a>https://gitlab.com/sorairolake/abcrypt-zig.git</a></li> <li><a>https://codeberg.org/sorairolake/abcrypt-zig.git</a></li> </ul> Changelog Please see <a>CHANGELOG.adoc</a>. Contributing Please see <a>CONTRIBUTING.adoc</a>. License Copyright (C) 2024 Shun Sakai (see <a>AUTHORS.adoc</a>) This library is distributed under the terms of either the <em>Apache License 2.0</em> or the <em>MIT License</em>. This project is compliant with version 3.3 of the <a><em>REUSE Specification</em></a>. See copyright notices of individual files for more details on copyright and licensing information.
[]
https://avatars.githubusercontent.com/u/101826448?v=4
libzex
eramoss/libzex
2025-01-15T21:30:11Z
A regex matching library
master
0
1
0
1
https://api.github.com/repos/eramoss/libzex/tags
MIT
[ "forfun", "glibc", "posix", "regexp", "zig" ]
38
false
2025-05-06T00:16:12Z
true
true
unknown
github
[]
libzex <blockquote> <span class="bg-yellow-100 text-yellow-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">WARNING</span> The library is not in production ready state yet </blockquote> initially translated from https://github.com/laurikari/tre/ Introduction libzex is a (not yet functional) POSIX standards regexp matching library with some things that i have done for fun like my own parser and fuzzy search A lot of this work is a rewrite of <a>TRE</a> but made in zig for... well i wanted it :) its just a study library for now, ifyou want a robust library use tre like GNU, dont trust in libzex for now!!
[]
https://avatars.githubusercontent.com/u/125757856?v=4
Data-Structures-Implementation-and-Performance
JaredMijailRE/Data-Structures-Implementation-and-Performance
2024-12-31T19:21:29Z
Data structures written in C++, Python, Zig, and performance comparisons, and excercises solve with this data strucutres
main
0
1
0
1
https://api.github.com/repos/JaredMijailRE/Data-Structures-Implementation-and-Performance/tags
-
[ "cmake", "cpp", "data-structures", "performance-analysis", "pybind11", "zig" ]
27,648
false
2025-05-07T23:42:01Z
false
false
unknown
github
[]
Data Structures Implementation and Performance Analysis This repository implements various data structures in Python, C++, and Zig, including Trees, Lists, Linked Lists, Union-Find, and Hash Tables. It analyzes the complexity of these data structures and compares their performance across different implementations. Features <ul> <li> Implementations of fundamental data structures: </li> <li> Trees (AVL, BST, HEAP) </li> <li>Lists</li> <li>Linked Lists (Single, Double, Tail)</li> <li>Union-Find</li> <li>Hash Tables</li> <li>Complexity analysis of each data structure.</li> <li>Performance comparisons between different implementations.</li> <li>Integration of C++ and Zig code into Python using Pybind11.</li> <li>Compilation of code with CMake.</li> <li>Analysis conducted using Jupyter Notebooks.</li> </ul> Repository Structure <ul> <li><code>Src/</code>: Source code for data structure implementations.</li> <li><code>structures/</code>: Compile code to run in the notebooks.</li> <li><code>Exercise/</code>: Exercises solved using the implemented data structures.</li> <li><code>analisysHash.ipynb</code>: Jupyter Notebook analyzing hash table implementations.</li> <li><code>analisysList.ipynb</code>, <code>analisysList2.ipynb</code>, <code>analisysList3.ipynb</code>: Jupyter Notebooks analyzing the rest of the structures.</li> </ul> Notes <ul> <li>The project utilizes Pybind11 to integrate C++ and Zig code into Python, allowing for seamless performance comparisons.</li> <li>All analyses are conducted within Jupyter Notebooks, providing an interactive environment for exploration.</li> <li>The implementations are executed through the CPython interpreter.</li> </ul> License This project is licensed under the MIT License.
[]
https://avatars.githubusercontent.com/u/86686307?v=4
fyr
zewenn/fyr
2024-11-30T09:54:50Z
Declarative ECS based game engine, written in zig.
master
0
1
0
1
https://api.github.com/repos/zewenn/fyr/tags
Apache-2.0
[ "ecs", "framework", "game-engine", "zig" ]
2,787
false
2025-04-22T11:15:50Z
true
true
unknown
github
[ { "commit": "9d66e23e32cd7208d1becb4fd9352f8a27f89551", "name": "uuid", "tar_url": "https://github.com/r4gus/uuid-zig/archive/9d66e23e32cd7208d1becb4fd9352f8a27f89551.tar.gz", "type": "remote", "url": "https://github.com/r4gus/uuid-zig" }, { "commit": "0de5f8aed0565f2dbd8bc6851499c85df9e...
v0.4 | <a>Docs</a> | <a>Demo Project</a> **fyr** is a wrapper of [Not-Nik](https://github.com/Not-Nik)'s [raylib-zig](https://github.com/Not-Nik/raylib-zig) using [johan0A](https://github.com/johan0A)'s [clay-zig-bindings](https://github.com/johan0A/clay-zig-bindings). **fyr** also contains a fully functional ECS (Entity Component System) and a caching asset handling solution. &gt; <span class="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">IMPORTANT</span> &gt; The project uses zig version `0.14.0` and the latest version of the bindings. &gt; Still in **beta**, some docs may be missing or incomplete! Contributions are welcome. ## Add the `fyr` library You are only a couple of easy steps away fromm building your dream project: 1. Run the following command to save the dependency: ```bash zig fetch --save git+https://github.com/zewenn/fyr#stable ``` 2. Add the following to your `build.zig`: ```zig const fyr_module = b.dependency("fyr", .{ .target = target, .optimize = optimize, }); const fyr = fyr_module.module("fyr"); exe.root_module.addImport("fyr", fyr); ``` 3. You are ready to go! Now you can import fyr with a regular zig `@import()`: ```zig const fyr = @import("fyr"); ``` ## Project Setup Setting up a project with `fyr` is so easy, even your grandma could do it :smile: &gt; <span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span> &gt; You can follow the documentation, or take a look at the [demo project](./src/demo/main.zig) ```zig const window = fyr.window; pub fn main() !void { fyr.project({ window.title("fyr-demo"); window.size.set(fyr.Vec2(1280, 720)); window.fps.setTarget(256); window.resizing.enable(); // Paths for the assets directory fyr.useAssetPaths(.{ .debug = "./src/demo/assets/", }); })({ // The default scene will be automatically loaded. fyr.scene("default")({ fyr.entities(.{ // Add entities here }); fyr.scripts(.{ // Add scripts here }); }); }); } ```
[]
https://avatars.githubusercontent.com/u/115157819?v=4
Zimacs
IWhitebird/Zimacs
2024-10-09T10:39:46Z
Text Editor using raylib ...
master
0
1
0
1
https://api.github.com/repos/IWhitebird/Zimacs/tags
-
[ "codeeditor", "editor", "emacs", "raylib", "text", "texteditor", "vim", "zig" ]
142
false
2025-01-16T17:25:22Z
true
true
unknown
github
[ { "commit": "devel.tar.gz", "name": "raylib-zig", "tar_url": "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Not-Nik/raylib-zig" } ]
404
[]
https://avatars.githubusercontent.com/u/21303918?v=4
vk-zig
nfginola/vk-zig
2025-01-10T03:00:55Z
Vulkan 1.3 in Zig!
main
0
1
0
1
https://api.github.com/repos/nfginola/vk-zig/tags
-
[ "computer-graphics", "game-engine", "vulkan", "zig", "ziglang" ]
653
false
2025-02-04T22:32:39Z
true
true
unknown
github
[ { "commit": null, "name": "mach-glfw", "tar_url": null, "type": "remote", "url": "https://pkg.machengine.org/mach-glfw/affdd6ae6f2ac2c3b9162784bdad345c561eeeea.tar.gz" }, { "commit": "bb470f16dabd8195155ba9e3714dc62d7ad69add.tar.gz", "name": "vulkan_zig", "tar_url": "https://gith...
Zig VK Zigging through VK. Heavy WIP. Current focus: * Fleshing out API Zig commands <ul> <li>zig build<ul> <li>Build the application</li> </ul> </li> <li>zig build run<ul> <li>Build and run the application</li> </ul> </li> <li>zig build btr<ul> <li>Build tracy server </li> </ul> </li> <li>zig build tr<ul> <li>Build and run tracy server </li> </ul> </li> <li>zig build all<ul> <li>Build and run both app and tracy server simultaneously</li> </ul> </li> </ul> Progress List <ul> <li>Autocompile shaders with build.zig</li> <li>Arena allocator for Vulkan resources</li> <li>Vertex Pulling</li> <li>Staging upload context with queue ownership transfer</li> <li>Load texture and generate mips</li> <li>Resizing and swapchain recreation</li> <li>Buffer access with buffer device address</li> <li>Image access with descriptor indexing</li> <li>ImGUI</li> <li>Tracy<ul> <li>Client zig-bindings using ztracy</li> <li>Server using submodule tracking v.0.11.1 </li> </ul> </li> </ul> Used Vulkan Features/Extensions <ul> <li>Vulkan 1.3 </li> <li>Dynamic Rendering </li> <li>Descriptor Indexing </li> <li>Buffer Device Address </li> <li>Timeline Semaphores</li> </ul>
[]
https://avatars.githubusercontent.com/u/132171290?v=4
alpha-html
septechx/alpha-html
2025-01-18T17:58:42Z
Zig library for parsing a superset of html
master
0
1
0
1
https://api.github.com/repos/septechx/alpha-html/tags
LGPL-3.0
[ "html", "parser", "zig" ]
95
false
2025-02-24T23:17:18Z
true
true
unknown
github
[ { "commit": "refs", "name": "mvzr", "tar_url": "https://github.com/mnemnion/mvzr/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/mnemnion/mvzr" } ]
α-html Installing First run: <code>sh zig fetch --save git+https://github.com/septechx/alpha-html#0.2.3</code> Then add this to your <code>build.zig</code> before <code>b.installArtifact(exe)</code>: ```zig const @"alpha-html" = b.dependency("alpha-html", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("alpha-html", @"alpha-html".module("alpha-html")); ```
[]
https://avatars.githubusercontent.com/u/20910059?v=4
zig_sqlite
AS400JPLPC/zig_sqlite
2025-01-02T22:21:54Z
work sqlite
master
0
1
1
1
https://api.github.com/repos/AS400JPLPC/zig_sqlite/tags
NOASSERTION
[ "sqlite", "zig" ]
201
false
2025-04-15T13:17:16Z
false
false
unknown
github
[]
zig-sqlite zig 0.14.0 <strong>The project is under construction</strong> I thank "<a>nDimensional</a>" it is on this basis that I undertook to work, it remains simple, it is not a real duplication, because I updated so that it works from zig 0.14.dev. I added some functions: ``` pub isDir( vdir : []const u8) bool ... pub isDbxist( vdir : []const u8, fn_file_name:[]const u8) bool ... pub open(vdir : []const u8, name: []const u8) !Database ... pub fn open(vdir : []const u8, name: []const u8) !Database ... pub fn openTmp(tDir: std.fs.Dir, name: []const u8) !Database ... pub fn cbool(data : i32 ) bool ... ``` <strong>TEST. Testsql.zig</strong> : a complete test cycle is made available to you and functional. Simple, low-level, explicitly-typed SQLite bindings for Zig. Table of Contents <ul> <li><a>Usage</a></li> <li><a>Methods</a></li> <li><a>Queries</a></li> <li><a>Notes</a></li> <li><a>Build options</a></li> <li> <a>License</a> </li> <li> [Avancement](#avancement </li> <li> [Conditionnement](#conditionnement </li> </ul> Then add <code>sqlite</code> as an import to your root modules in <code>build.zig</code>: ```zig fn build(b: *std.Build) void { const app = b.addExecutable(.{ ... }); // ... <code>const sqlite = b.dependency("sqlite", .{}); app.root_module.addImport("sqlite", sqlite.module("sqlite")); </code> } ``` Usage Open databases using <code>Database.open</code> and close them with <code>db.close()</code>: ```zig const sql3 = @import("sqlite"); { // in-memory database const db = try sql3.open("sqlite", "db.sqlite"); defer db.close(); } { // persistent database const db = try sql3.Database.open(.{ .path = "path/to/db.sqlite" }); defer db.close(); } ``` Text and blob values must not be retained across steps. <strong>You are responsible for copying them.</strong> Notes Crafting sensible Zig bindings for SQLite involves making tradeoffs between following the Zig philosophy ("deallocation must succeed") and matching the SQLite API, in which closing databases or finalizing statements may return error codes. This library takes the following approach: <ul> <li><code>Database.close</code> calls <code>sqlite3_close_v2</code> and panics if it returns an error code.</li> <li><code>Statement.finalize</code> calls <code>sqlite3_finalize</code> and panics if it returns an error code.</li> <li><code>Statement.step</code> automatically calls <code>sqlite3_reset</code> if <code>sqlite3_step</code> returns an error code.</li> <li>In SQLite, <code>sqlite3_reset</code> returns the error code from the most recent call to <code>sqlite3_step</code>. This is handled gracefully.</li> <li><code>Statement.reset</code> calls both <code>sqlite3_reset</code> and <code>sqlite3_clear_bindings</code>, and panics if either return an error code.</li> </ul> These should only result in panic through gross misuse or in extremely unusual situations, e.g. <code>sqlite3_reset</code> failing internally. All "normal" errors are faithfully surfaced as Zig errors. Build options <code>zig struct { SQLITE_ENABLE_COLUMN_METADATA: bool = false, SQLITE_ENABLE_DBSTAT_VTAB: bool = false, SQLITE_ENABLE_FTS3: bool = false, SQLITE_ENABLE_FTS4: bool = false, SQLITE_ENABLE_FTS5: bool = false, SQLITE_ENABLE_GEOPOLY: bool = false, SQLITE_ENABLE_ICU: bool = false, SQLITE_ENABLE_MATH_FUNCTIONS: bool = false, SQLITE_ENABLE_RBU: bool = false, SQLITE_ENABLE_RTREE: bool = false, SQLITE_ENABLE_STAT4: bool = false, SQLITE_OMIT_DECLTYPE: bool = false, SQLITE_OMIT_JSON: bool = false, SQLITE_USE_URI: bool = false, SQLITE_OMIT_DEPRECATED: bool = false, }</code> Set these by passing e.g. <code>-DSQLITE_ENABLE_RTREE</code> in the CLI, or by setting <code>.SQLITE_ENABLE_RTREE = true</code> in the <code>args</code> parameter to <code>std.Build.dependency</code>. For example: ```zig pub fn build(b: *std.Build) !void { // ... <code>const sqlite = b.dependency("sqlite", .{ .SQLITE_ENABLE_RTREE = true,.SQLITE_OMIT_DEPRECATED = true }); </code> } ``` Conditionnment pub const Blob = struct { data: []const u8 }; pub const Text = struct { data: []const u8 }; pub const Numeric = struct { data: []const u8 }; pub const Date = struct { data: []const u8 }; pub const Bool = struct { data: bool}; ex: src-zig/sqlite.zig libsql/sqlite/sqlite.zig <code>switch (binding.type) { .int32 =&gt; try stmt.bindInt32(idx, @intCast(value)), .int64 =&gt; try stmt.bindInt64(idx, @intCast(value)), .float64 =&gt; try stmt.bindFloat64(idx, @floatCast(value)), .blob =&gt; try stmt.bindBlob(idx, value), .text =&gt; try stmt.bindText(idx, value), .numeric =&gt; try stmt.bindNumeric(idx, value), .date =&gt; try stmt.bindDate(idx, value), .boolean =&gt; try stmt.bindBoolean(idx, value), }</code> text = null -&gt; "" date = null -&gt; "" numeric = null -&gt; "" example delivery date null = delivery not processed Avancement → 2025-01-07 01:00 update Implementation of extended procedures of the zig "libsql" lib while respecting the structure of SQLITE3 The Date function is under study.. → 2025-03-10 15:00 Start of lib usage viability (TEXT DECIMAL DATE) → 2025-03-12 06:40 unicode.Decode deprecated change Utf8View → 2025-03-13 11:53 Test viability of Decimal, Text, Date modules with sql, test if SQLite is in phase with sqlite.zig module → 2025-03-14 16:25 Test with SQL of “DEF” structure with DECIMAL DATE, this forced me to harmonize and simplify, “date” with “string” and “decimal”.
[]
https://avatars.githubusercontent.com/u/105171995?v=4
yeeeeem
Sharktheone/yeeeeem
2024-08-13T17:49:24Z
A toy JVM
main
0
1
0
1
https://api.github.com/repos/Sharktheone/yeeeeem/tags
-
[ "java", "jvm", "jvm-bytecode", "vm", "zig", "ziglang" ]
102
false
2024-09-10T22:23:24Z
true
true
unknown
github
[]
yeeeeem A very simple JVM written in zig, supporting a subset of it's instructions and capabilities. Getting started First you need to install zig. If you have it installed, you can run the following command to build yeeeeem: <code>console zig build</code> then you need to have some sort of java class. For a simple hello world, create a file <code>main.java</code> <code>java class Main { public static void main(String[] args) { System.out.println("Hello, world!"); } }</code> then compile it to a class file via <code>console javac main.java</code> you can then run it in yeeeeem <code>console ./zig-out/bin/yeeeeem Main.class</code> Why the name? Well, since we want to make fun of java, we call it yava. So it is a YVM or Yava Virtual Machine, this looks bad, so why not YM. And since we have fun it's yeeeeem! Pronounced more like yeeee-em
[]
https://avatars.githubusercontent.com/u/137664746?v=4
z-scanner
n0thhhing/z-scanner
2024-11-18T22:17:41Z
aob scanner implemented in zig
main
0
1
0
1
https://api.github.com/repos/n0thhhing/z-scanner/tags
MIT
[ "aob-scan", "kmp", "mit", "pattern", "zig" ]
16
false
2025-02-03T05:35:56Z
true
true
0.13.0
github
[]
License This project is licensed under the MIT License. See the <a>LICENSE</a> file for more information.
[]
https://avatars.githubusercontent.com/u/24578855?v=4
zig-say
deatil/zig-say
2024-08-29T10:35:49Z
zig-say 是使用 httpz, myzql 及 zmpl 的 zig 简易匿名社区系统
main
0
1
0
1
https://api.github.com/repos/deatil/zig-say/tags
Apache-2.0
[ "bbs", "luntan", "shequ", "zig", "zig-say" ]
4,785
false
2025-04-17T12:34:57Z
true
true
unknown
github
[ { "commit": null, "name": "myzql", "tar_url": null, "type": "relative", "url": "./lib/myzql" }, { "commit": "master", "name": "httpz", "tar_url": "https://github.com/karlseguin/http.zig/archive/master.tar.gz", "type": "remote", "url": "https://github.com/karlseguin/http.z...
zig-say 匿名社区 <code>zig-say</code> 是使用 <code>httpz</code>, <code>myzql</code> 及 <code>zmpl</code> 的 <code>zig</code> 博客系统 项目介绍 <ul> <li>使用 <code>zig</code> 开发的简易匿名社区系统</li> <li>核心使用 <code>httpz</code>, <code>myzql</code> 及 <code>zmpl</code> 等开发匿名社区系统</li> <li>系统后台使用 <code>pear-admin</code> 后端模板,非前后端分离项目</li> </ul> 环境要求 <ul> <li>zig &gt;= 0.14.0-dev.2851+b074fb7dd</li> <li>Myql</li> </ul> 截图预览 更多截图 <a>zig-say 截图</a> 安装及开发步骤 <ol> <li>首先克隆项目到本地</li> </ol> <code>git clone https://github.com/deatil/zig-say.git</code> <ol> <li>然后配置数据库等信息</li> </ol> <code>/src/utils/config.zig</code> <ol> <li>最后导入 sql 数据到数据库</li> </ol> <code>/docs/zig_say.sql</code> <ol> <li>运行测试</li> </ol> <code>rust zig build run</code> <ol> <li>后台登录账号及密码:<code>admin</code> / <code>123456</code>, 后台登录地址: <code>/admin/index</code></li> </ol> 特别鸣谢 感谢以下的项目,排名不分先后 <ul> <li> <a>httpz</a> </li> <li> <a>myzql</a> </li> <li> <a>zmpl</a> </li> </ul> 开源协议 <ul> <li><code>zig-say</code> 遵循 <code>Apache2</code> 开源协议发布,在保留本系统版权的情况下提供个人及商业免费使用。</li> </ul> 版权 <ul> <li>该系统所属版权归 deatil(https://github.com/deatil) 所有。</li> </ul>
[]
https://avatars.githubusercontent.com/u/56198900?v=4
zc8
gopi487krishna/zc8
2024-11-24T08:01:36Z
A chip 8 emulator written in Zig
main
1
1
0
1
https://api.github.com/repos/gopi487krishna/zc8/tags
MIT
[ "chip8", "chip8-emulator", "zig" ]
10,355
false
2025-04-27T05:14:29Z
true
true
0.11.0
github
[ { "commit": "f6bbe8ac5e7b901db69ba62f017596090c362d84", "name": "sdl", "tar_url": "https://github.com/castholm/SDL/archive/f6bbe8ac5e7b901db69ba62f017596090c362d84.tar.gz", "type": "remote", "url": "https://github.com/castholm/SDL" } ]
zc8 zc8 is a lightweight Chip-8 emulator implemented in Zig, designed to provide a clean and minimal implementation of the classic Chip-8 virtual machine. It is well-suited for experimentation, and running retro games. The emulator is compiled to WebAssembly using Emscripten, allowing it to run directly in the browser. SDL3 is used for handling graphics and input and sound. This project was developed as a way to gain hands-on experience with Zig, WebAssembly, Emscripten, and emulator development. <a>https://zc8.cooldev.in/</a> 📸 Screenshots | | | | :--------------------------------------------: | :------------------------------------: | | | | 🔨 Building zc8 Setting Up Dependencies NixOS <code>bash nix develop</code> <blockquote> <span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span> To Resolve the emscripten cache issue : <a>https://github.com/NixOS/nixpkgs/issues/139943#issuecomment-930432045</a> </blockquote> Non NixOS <ul> <li><a>Setting Up Emscripten</a></li> <li><a>Setting Up Zig</a></li> </ul> Compiling zc8 <code>zig build -Dtarget=wasm32-emscripten -Doptimize=Debug --sysroot "$(em-config CACHE)/sysroot"</code> <ul> <li>Copy over the <code>zc8.js</code> and <code>zc8.wasm</code> to <code>website</code> directory and run <code>emrun index.html</code> inside website directory </li> </ul> Running Tests <code>bash zig build test --summary all</code> 📚 Resources <ul> <li><a>Guide To Making A CHIP-8 Emulator</a></li> <li><a>Revisiting Chip 8</a></li> <li><a>CHIP-8 Research Facility</a></li> <li><a>Cowgod's Chip-8 Technical Reference</a></li> <li><a>https://github.com/castholm/SDL</a></li> <li><a>SDL3 Example: audio/03-load-wav</a></li> <li><a>Emscripten: Interacting With Code</a></li> <li><a>Octo : A Chip 8 IDE</a></li> <li><a>chip-8-test-suite</a></li> <li><a>chip-8-test-rom</a></li> <li><a>Chip-8-Archive</a></li> <li><a>Chip-8-Roms</a></li> <li><a>Building a CHIP-8 Emulator - C++</a></li> </ul> Website Design Ideas <ul> <li><a>RCA COSMAC VIP is working :)</a></li> <li><a>Chip-8-Gallery</a></li> <li><a>Poolsuite.net</a></li> <li><a>WinZip-1997</a></li> </ul> 📥 Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate. 📜 License <a>MIT</a>
[]
https://avatars.githubusercontent.com/u/184568612?v=4
zouter
zigzedd/zouter
2024-10-10T22:11:55Z
[MIRROR] Zig HTTP router library.
main
0
1
0
1
https://api.github.com/repos/zigzedd/zouter/tags
MIT
[ "router", "routing", "routing-engine", "zap", "zig", "zig-library", "zig-package" ]
33
false
2025-04-12T10:35:18Z
true
true
0.14.0
github
[ { "commit": "master", "name": "zap", "tar_url": "https://github.com/zigzap/zap/archive/master.tar.gz", "type": "remote", "url": "https://github.com/zigzap/zap" } ]
<a> </a> Zouter <a>Documentation</a> | <a>API</a> Zig HTTP router library Zouter is part of <a><em>zedd</em></a>, a collection of useful libraries for zig. Zouter for zap <em>Zouter</em> is an HTTP router library for Zig <strong>zap</strong> HTTP server. It's made to ease the use of <strong>zap</strong> to build REST APIs. Versions Zouter 0.2.0 is made for zig 0.14.0 and tested with zap 0.10.1. How to use Install In your project directory: <code>shell $ zig fetch --save https://code.zeptotech.net/zedd/zouter/archive/v0.2.0.tar.gz</code> In <code>build.zig</code>: <code>zig // Add zouter dependency. const zouter = b.dependency("zouter", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zouter", zouter.module("zouter"));</code> Example Here is a quick example of how to set up a router. It is an extract from the full test code at <a><code>example.zig</code></a>. You may want to have a look to <a><code>simple_routes.zig</code></a> which shows more advanced features. ```zig /// GET /foo/:arg/bar request handler. fn get(route: zouter.MatchedRoute, request: zap.Request) !void { var bodyBuffer: [512]u8 = undefined; const body = try std.fmt.bufPrint(&amp;bodyBuffer, "get: {s}", .{route.params.get("arg").?}); try request.sendBody(body); } /// POST /foo/:arg/bar request handler. fn post(route: zouter.MatchedRoute, request: zap.Request) !void { var bodyBuffer: [512]u8 = undefined; const body = try std.fmt.bufPrint(&amp;bodyBuffer, "post: {s}", .{route.params.get("arg").?}); try request.sendBody(body); } /// Setup an example router. fn setupExampleRouter(allocator: std.mem.Allocator) !zouter.Router { // Initialize an example router. var exampleRouter = try zouter.Router.init(allocator, .{}); <code>// Add a route to the example router. try exampleRouter.route(.{ .path = "foo", .children = &amp;[_]zouter.RouteDefinition{ .{ .path = ":arg", .children = &amp;[_]zouter.RouteDefinition{ .{ .path = "bar", .handle = .{ .get = &amp;get, .post = &amp;post, }, } }, } }, }); return exampleRouter; </code> } ``` Route definition A route only has one mandatory field: its path. If any part of a path starts with a <code>':'</code>, the value is taken as a dynamic variable, retrievable later with <code>Route.params</code> <code>HashMap</code>. A route can have: <ul> <li><strong>Children</strong>: sub-routes definitions, with a <code>'/'</code> between the parent and the child. It's useful to prefix a list of routes with the same path / variable.</li> <li><strong>Handle object</strong>: you can define a handle function for each HTTP basic request method. If you don't care about the request method, there is an <code>any</code> field which will be used for all undefined request methods.</li> <li><strong>Handle not found / error</strong>: you can define a custom functions to handle errors or not found pages inside this path.</li> <li><strong>Pre-handle / post-handle</strong>: these functions are started before and after the request handling in this path. It looks like middlewares and can assume the same role as most of them (e.g. a pre-handle function to check for authentication under a specific path).</li> </ul> Full details about route definition fields can be found in the <a>API reference</a>.
[]
https://avatars.githubusercontent.com/u/192897928?v=4
sanctum
sackosoft/sanctum
2024-12-29T16:48:25Z
Sanctum is an event streaming and storage platform which can be scripted by "spells" written in Lua.
main
1
1
0
1
https://api.github.com/repos/sackosoft/sanctum/tags
AGPL-3.0
[ "event-driven", "event-streaming", "lua", "messagepack", "msgpack", "zig" ]
120
false
2025-02-01T19:09:31Z
true
true
unknown
github
[ { "commit": "dcf3a8efe6f2fd41a777be840e88ee1036973a08", "name": "luajit", "tar_url": "https://github.com/sackosoft/zig-luajit/archive/dcf3a8efe6f2fd41a777be840e88ee1036973a08.tar.gz", "type": "remote", "url": "https://github.com/sackosoft/zig-luajit" }, { "commit": "0155a63a7efb64da6c535...
# Sanctum **Welcome, sorcerer, to the Sanctum. Write spells in Lua for transforming and acting on event streams of magical energy.** ![Regression Tests Badge](https://img.shields.io/github/actions/workflow/status/sackosoft/sanctum/regression-tests.yml?label=regression%20tests) ![GitHub License](https://img.shields.io/github/license/sackosoft/sanctum) About Sanctum is an event streaming, storage and processing platform. It lets you, the sorcerer, craft powerful spells in Lua to process and transform streams of events. Sanctum handles the complexities of storage, state and routing these energies across the ethereal planes, so that you can focus on writing the spells for your use case. For more detailed reference information and documentation, refer to the <a><code>docunomicon</code></a>. Features <ul> <li>✨ <strong>Spells</strong>: User-defined Lua code for actions or transformations, invoked with events from the event stream.</li> <li>💾 <strong>Storage</strong>: Write stateful or stateless spells, use the storage system provided by the runtime or bring your own backend.</li> <li>⏩ <strong>Fast</strong>: Written in Zig ⚡ so that you don't have to worry about performance.</li> </ul> Installation Options for installing and hosting Sanctum can be found in the <a><code>docunomicon</code></a>. Usage Sanctum uses the <a><code>just</code></a> command runner. Refer to <a><code>CONTRIBUTING.md</code></a> for more information about dependencies. The commonly used commands are described below. <ul> <li> <code>just test</code> <ul> <li>Runs Sanctum against the regression test suite, compares output against "golden output" files.</li> </ul> </li> <li> <code>just freeze</code> <ul> <li>Runs Sanctum updating the regression test suite "golden output" files with current output.</li> </ul> </li> <li> <code>just debug</code> <ul> <li>Runs Sanctum in <a>GDB - The GNU Project Debugger</a> using a regression test as input.</li> </ul> </li> </ul> Spell Casting Micro Benchmarks Sanctum is designed for realtime event streaming workloads. The switch from Lua 5.4 (provided by <a><code>ziglua</code></a>) to LuaJIT (provided by <a><code>zig-luajit</code></a>) has improved a target spell casting benchmarks by 36%. The overhead for Sanctum to cast Lua spells is around ~500 nanoseconds, based on January 2025 benchmarks. As a result, Sanctum can cast millions of spells per second per core, even on modest hardware like my Intel Xeon E5-2680 -- a processor released in 2013. Sanctum will work best if your workload is bound by the flow of magical energy rather than the processing of those energies. Roadmap v0.1 Proof of Concept - <strong>Active</strong> Demonstrates event processing with Spells on a throw-away runtime. Sanctum runs as a CLI application and covered by a suite of regression tests to enable building and refactoring the core engine. Runs on a single node (no networking, no persistence). <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Docunomicon - Definition and example of Lua spells <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Minimal documentation for spells in the runtime. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spell Casting <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Spells can be loaded dynamically into the sanctum from files. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spells are loaded and unloaded with the prepare and unprepare lifecycle hooks. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Counting loop spell is added with a reusable regression test. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Many reusable regression tests can be defined. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Regression tests are fully self-contained. Seed events, the initial event loop event, can be specified in Lua and loaded by the runtime. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Malformed spells (spell parse failure) are handled gracefully. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Handle parsing failing line number from errors Lua message. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Unstable magic (internal spell failures) is handled gracefully. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Add support to serialize and deserialize magical energies as MessagePack buffers. <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Spells can produce magical energy or act as a terminal action, producing nothing. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spells can be bound to energy streams subscriptions. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Support for topic-based subscriptions <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Support for filter-based subscriptions <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Migrate from Lua 5.4 to LuaJIT. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Build a proof of concept sanctum application for demo/validation. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Should sanctum spells be bundled/packaged into an app? <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Remove this section from the README, create release notes and initial release artifacts. v0.2 Prototype - Pending Upgrades the runtime with persistence for events and spell state. Sanctum can be used for real workloads with no guarantees. Runs on a single node (no networking). <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Storage Engine MVP <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Durable event logging. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Durable spell state <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spells can leverage a library for saving and loading data. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spells can use a key value store. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Spells can leverage range queries (e.g. SELECT * FROM state WHERE v &gt; 10 AND v &lt; 20). I.e. support clustering in state store. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> (Option) Link SQLite? <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> (Option) Provide simple data structures, serialize and save to disk? <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Add initial logging and metrics to identify performance characteristics. v1.0 Beta - Pending Sanctum fully featured as an MVP. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Production Readiness <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Crash recovery guarantees. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Limits defined and scale targets established. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Platform Stability <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> API contracts <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Documentation <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Performance optimization Work Triage <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Wrap the Lua VM so that detailed telemetry can be emitted, per instance. - memory usage, spell execution count+time, event input and output counters. <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Support N:M event inputs and outputs for spells (currently only supports 1:0 and 1:1). Glossary Novice sorcers may struggle to uncover the mysteries of the Sanctum: | Mystical Term | Technical Meaning | |---------------|-------------------| | Sanctum | A scriptable event streaming and storage platform. | | Sorcerers | Developers building on Sanctum. | | Spells | User-defined modules invoked with events in an event stream. Spells may cause new events to be created. | | Energy Streams | Ordered event streams with immutable data. | | Runes | Configuration options. | | Runeset | YAML configuration file of options which can be used by the Sanctum or its Spells. | Want to help? Thank you, brave scholar of the dark arts, please refer to <a>CONTRIBUTING.md</a>. Project Status Incubation. <em>This mystical undertaking is still in its early phases.</em>
[]
https://avatars.githubusercontent.com/u/179981696?v=4
ziglet.sh
ziglana/ziglet.sh
2024-10-24T23:54:15Z
solana zig sdk ⚡️blazigly fast⚡️
main
0
1
0
1
https://api.github.com/repos/ziglana/ziglet.sh/tags
Unlicense
[ "blazigly", "crypto", "smart-contracts", "solana", "solana-blockchain", "zig", "ziglana", "ziglang" ]
1
false
2024-10-27T20:05:21Z
false
false
unknown
github
[]
ziglet.sh bootstrap your ziglana program ⚡️blazigly fast⚡️
[]
https://avatars.githubusercontent.com/u/76430758?v=4
lox-interpreter
lloydlobo/lox-interpreter
2024-09-17T06:48:34Z
Interpreter for the Lox programming language in Zig, that "closely" follows the book Crafting Interpreters by Robert Nystrom.
master
2
1
0
1
https://api.github.com/repos/lloydlobo/lox-interpreter/tags
-
[ "ast", "interpreter", "lox-language", "recursive-descent-parser", "zig" ]
269
false
2025-03-06T03:29:39Z
true
true
unknown
github
[]
Lox interpreter in Zig This extends the <a>"Build your own Interpreter" Challenge</a> with functions, returns, classes, etc using Zig for <a>Lox</a>, a simple scripting language. This implementation of Lox, follows the book <a>Crafting Interpreters</a> by Robert Nystrom, apart from tiny aesthetic tweaks. Challenge Status <a></a> <code>markdown Congratulations! Challenge Complete! Congratulations are in order. Only ~15% of users that attempt this challenge end up completing all stages, and you're one of them!</code> Highlights: <ul> <li>Recursive-descent parser</li> <li>Tokenization</li> <li>ASTs (Zig tagged unions really shine here)</li> <li>tree-walk interpreters and more.</li> </ul>
[]
https://avatars.githubusercontent.com/u/18192844?v=4
advent-of-code-2024
Darkness4/advent-of-code-2024
2024-11-30T02:04:09Z
Advent of code 2024 in Zig.
main
0
1
0
1
https://api.github.com/repos/Darkness4/advent-of-code-2024/tags
-
[ "advent-of-code", "advent-of-code-2024", "zig" ]
542
false
2024-12-21T01:28:41Z
true
true
unknown
github
[ { "commit": null, "name": "zbench", "tar_url": null, "type": "relative", "url": "vendor/zbench" } ]
Advent of code 2024 in Zig Run ```shell zig build zig build day01 ``` Run with docker <code>shell zig() { docker run --ulimit=host --rm -it -v $(pwd):/work -w /work ghcr.io/darkness4/aoc-2024:base "$@" } zig build &lt;dayX&gt;</code> Benchmark results ```shell benchmark runs total time time/run (avg ± σ) (min ... max) p75 p99 p995 day01 p1 4095 1.092s 266.722us ± 2.652us (262.828us ... 335.847us) 268.128us 273.709us 275.742us day01 p2 8191 1.104s 134.854us ± 5.209us (131.389us ... 211us) 135.066us 160.264us 174.851us day02 p1 16383 1.995s 121.798us ± 3.111us (119.255us ... 192.315us) 121.711us 130.688us 135.316us day02 p2 2047 1.773s 866.162us ± 14.705us (859.028us ... 1.186ms) 865.129us 901.678us 947.806us day03 p1 32767 1.648s 50.316us ± 1.344us (49.023us ... 83.969us) 50.205us 54.474us 56.768us day03 p2 32767 1.781s 54.372us ± 2.496us (53.081us ... 110.369us) 54.123us 61.396us 67.628us day04 p1 2047 1.359s 664.178us ± 26.898us (642.377us ... 1.121ms) 663.056us 776.09us 833.7us day04 p2 8191 1.183s 144.548us ± 10.66us (139.675us ... 312.973us) 143.112us 194.288us 237.32us day05 p1 8191 1.609s 196.468us ± 8.94us (187.084us ... 316.42us) 197.173us 238.342us 273.278us day05 p2 1023 989.563ms 967.315us ± 11.878us (946.173us ... 1.053ms) 968.656us 1.003ms 1.014ms day06 p1 5 464.22us 92.844us ± 8.091us (88.157us ... 107.213us) 90.692us 107.213us 107.213us day06 p1 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day06 p2 5 17.277s 3.455s ± 27.297ms (3.43s ... 3.485s) 3.484s 3.485s 3.485s day06 p2 [MEMORY] 2.853MiB ± 0B (2.853MiB ... 2.853MiB) 2.853MiB 2.853MiB 2.853MiB day07 p1 4095 1.221s 298.185us ± 6.122us (290.16us ... 399.226us) 299.317us 321.539us 331.178us day07 p2 4095 1.73s 422.558us ± 12.669us (413.874us ... 631.617us) 422.941us 480.7us 515.216us day08 p1 8191 1.585s 193.54us ± 29.725us (184.489us ... 579.838us) 190.08us 394.257us 409.716us day08 p1 [MEMORY] 18.070KiB ± 0B (18.070KiB ... 18.070KiB) 18.070KiB 18.070KiB 18.070KiB day08 p2 1023 1.885s 1.843ms ± 99.146us (1.771ms ... 2.93ms) 1.855ms 2.204ms 2.716ms day08 p2 [MEMORY] 75.227KiB ± 0B (75.227KiB ... 75.227KiB) 75.227KiB 75.227KiB 75.227KiB day09 p1 8191 5.993s 731.774us ± 10.771us (719.884us ... 1.119ms) 732.929us 750.512us 762.314us day09 p2 7 5.829s 832.723ms ± 3.468ms (828.11ms ... 837.255ms) 835.11ms 837.255ms 837.255ms day10 p1 1023 1.212s 1.185ms ± 29.057us (1.15ms ... 1.72ms) 1.187ms 1.285ms 1.315ms day10 p1 [MEMORY] 1.641KiB ± 0B (1.641KiB ... 1.641KiB) 1.641KiB 1.641KiB 1.641KiB day10 p2 4095 1.91s 466.665us ± 17.689us (447.758us ... 820.103us) 468.338us 521.558us 559.971us day10 p2 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day11 p1 255 1.54s 6.039ms ± 159.548us (5.921ms ... 8.073ms) 6.058ms 6.446ms 6.844ms day11 p1 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day11 p2 31 1.909s 61.588ms ± 167.229us (61.266ms ... 61.978ms) 61.688ms 61.978ms 61.978ms day11 p2 [MEMORY] 340.070KiB ± 0B (340.070KiB ... 340.070KiB) 340.070KiB 340.070KiB 340.070KiB day12 p1 63 1.668s 26.478ms ± 386.572us (25.946ms ... 28.173ms) 26.718ms 28.173ms 28.173ms day12 p1 [MEMORY] 824.570KiB ± 0B (824.570KiB ... 824.570KiB) 824.570KiB 824.570KiB 824.570KiB day12 p2 31 1.417s 45.74ms ± 775.506us (44.858ms ... 48.666ms) 45.967ms 48.666ms 48.666ms day12 p2 [MEMORY] 824.570KiB ± 0B (824.570KiB ... 824.570KiB) 824.570KiB 824.570KiB 824.570KiB day13 p1 16383 1.794s 109.517us ± 2.891us (107.403us ... 167.156us) 109.026us 121.53us 124.966us day13 p2 16383 1.824s 111.385us ± 4.556us (108.846us ... 170.072us) 111.05us 134.956us 149.473us day14 p1 16383 1.374s 83.894us ± 4.239us (81.555us ... 133.833us) 83.187us 108.315us 109.237us day14 p1 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day14 p2 7 1.395s 199.377ms ± 1.477ms (198.108ms ... 201.938ms) 200.719ms 201.938ms 201.938ms day14 p2 [MEMORY] 10.159KiB ± 0B (10.159KiB ... 10.159KiB) 10.159KiB 10.159KiB 10.159KiB day15 p1 2047 1.343s 656.28us ± 107.246us (506.64us ... 1.523ms) 745.273us 864.959us 878.986us day15 p1 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day15 p2 1023 1.521s 1.487ms ± 240.066us (1.148ms ... 2.513ms) 1.683ms 1.989ms 2.009ms day15 p2 [MEMORY] 0B ± 0B (0B ... 0B) 0B 0B 0B day16 p1 31 1.72s 55.489ms ± 824.908us (54.535ms ... 57.502ms) 56.176ms 57.502ms 57.502ms day16 p1 [MEMORY] 1.588MiB ± 0B (1.588MiB ... 1.588MiB) 1.588MiB 1.588MiB 1.588MiB day16 p2 3 1.028s 342.921ms ± 2.97ms (339.649ms ... 345.45ms) 345.45ms 345.45ms 345.45ms day16 p2 [MEMORY] 1.640MiB ± 0B (1.640MiB ... 1.640MiB) 1.640MiB 1.640MiB 1.640MiB day17 p1 65535 60.376ms 921ns ± 68ns (871ns ... 3.878us) 932ns 972ns 982ns day17 p2 8191 1.526s 186.355us ± 3.343us (174.501us ... 228.243us) 187.876us 193.476us 194.559us day18 p1 15 1.1s 73.379ms ± 2.213ms (70.839ms ... 79.203ms) 74.892ms 79.203ms 79.203ms day18 p1 [MEMORY] 509.211KiB ± 0B (509.211KiB ... 509.211KiB) 509.211KiB 509.211KiB 509.211KiB day18 p2 63 1.75s 27.778ms ± 581.294us (26.917ms ... 29.57ms) 27.91ms 29.57ms 29.57ms day18 p2 [MEMORY] 252.531KiB ± 0B (252.531KiB ... 252.531KiB) 252.531KiB 252.531KiB 252.531KiB day19 p1 63 1.197s 19.014ms ± 794.264us (18.146ms ... 22.729ms) 19.527ms 22.729ms 22.729ms day19 p1 [MEMORY] 216.047KiB ± 0B (216.047KiB ... 216.047KiB) 216.047KiB 216.047KiB 216.047KiB day19 p2 15 1.786s 119.114ms ± 1.914ms (117.341ms ... 124.582ms) 120.523ms 124.582ms 124.582ms day19 p2 [MEMORY] 600.047KiB ± 0B (600.047KiB ... 600.047KiB) 600.047KiB 600.047KiB 600.047KiB day20 p1 7 1.685s 240.726ms ± 6.268ms (234.667ms ... 252.922ms) 243.771ms 252.922ms 252.922ms day20 p1 [MEMORY] 401.602KiB ± 0B (401.602KiB ... 401.602KiB) 401.602KiB 401.602KiB 401.602KiB day20 p2 7 1.652s 236.127ms ± 1.795ms (233.837ms ... 239.167ms) 237.109ms 239.167ms 239.167ms day20 p2 [MEMORY] 401.602KiB ± 0B (401.602KiB ... 401.602KiB) 401.602KiB 401.602KiB 401.602KiB ``` Compatibility Tested on <code>0.14.0-dev.2367+aa7d13846</code>.
[]
https://avatars.githubusercontent.com/u/184568612?v=4
zrm
zigzedd/zrm
2024-10-16T12:32:16Z
[MIRROR] Zig relational mapper.
main
0
1
0
1
https://api.github.com/repos/zigzedd/zrm/tags
MIT
[ "database", "mapper", "model", "orm", "relationships", "zig", "zig-library", "zig-package" ]
299
false
2025-01-14T10:52:47Z
true
true
0.13.0
github
[ { "commit": null, "name": "zollections", "tar_url": null, "type": "remote", "url": "https://code.zeptotech.net/zedd/zollections/archive/v0.1.1.tar.gz" }, { "commit": "master", "name": "pg", "tar_url": "https://github.com/karlseguin/pg.zig/archive/master.tar.gz", "type": "remo...
<a> </a> ZRM <a>Documentation</a> | <a>API</a> Zig relational mapper ZRM is part of <a><em>zedd</em></a>, a collection of useful libraries for zig. ZRM <em>ZRM</em> provides a simple interface to relational databases in Zig. Define your repositories and easily write queries to retrieve and save complex Zig structures. Versions ZRM 0.3.1 is made and tested with zig 0.13.0. Work in progress ZRM aims to handle a lot for you, but it takes time to make. Have a look to <a>the issues</a> to see what is currently planned or being worked on. How to use Install In your project directory: <code>shell $ zig fetch --save https://code.zeptotech.net/zedd/zrm/archive/v0.3.1.tar.gz</code> In <code>build.zig</code>: <code>zig // Add zrm dependency. const zrm = b.dependency("zrm", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zrm", zrm.module("zrm"));</code> Documentation A full documentation can be found on <a>zedd.zeptotech.net/zrm</a>. Examples Some examples can be found in <code>tests</code> directory: <ul> <li><a><code>tests/example.zig</code></a></li> <li><a><code>tests/repository.zig</code></a></li> <li><a><code>tests/composite.zig</code></a></li> </ul>
[]
https://avatars.githubusercontent.com/u/3405876?v=4
datetime-zig
ymd-h/datetime-zig
2024-09-16T10:42:39Z
datetime for zig
master
0
1
0
1
https://api.github.com/repos/ymd-h/datetime-zig/tags
MIT
[ "datetime", "zig" ]
87
false
2024-09-27T13:42:40Z
true
true
unknown
github
[]
DateTime.zig Time Zone awared Date Time. <blockquote> <span class="bg-yellow-100 text-yellow-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">WARNING</span> This project is still under development. </blockquote> 1. Usage 1.1 Add dependency <code>shell zig fetch --save git+https://github.com/ymd-h/datetime.zig#v0.0.4</code> In build.zig ```zig pub fn build(b: *b.std.Build) !void { const exe = b.addExecutable( // (omit) ); <code>const datetime = b.dependency("datetime-zig", .{ .target = .target, .optimize = .optimize }); exe.root_module.addImport("datetime", datetime.module("datetime")); </code> } ``` 1.2 Code ```zig const std = @import("std"); const datetime = @import("datetime"); const DateTime = datetime.DateTime; pub fn main(){ // Create from Timestamp and TimeZone const dt = DateTime.fromTimestamp(.{ .s = std.time.timestamp() }, .{}); _ = try DateTime.fromTimestamp(.{ .ms = std.time.milliTimestamp() }, .{}); _ = try DateTime.fromTimestamp(.{ .us = std.time.microTimestamp() }, .{}); _ = try DateTime.fromTimestamp(.{ .ns = std.time.nanoTimestamp() }, .{}); _ = try DateTime.fromTimestamp(.{ .s = std.time.timestamp() }, .{ .hour = 2, .minute = 30 }); <code>// Parse ISO8601 date string const dt2 = try DateTime.parse("2024-09-15T11:15:23.987+09:00"); // Format ISO8601 var w = std.io.bufferedWriter(std.iogetStdOut().writer()); const stdout = bw.writer(); try dt.formatISO8601(stdout, .{ .format = .extended, .resolution = .ms }); try stdout.print("\n", .{}); try bw.flush(); // Custom Format try dt.formatCustom(stdout, "%Y/%m/%d %H:%M:%S.%f %:z\n"); // Compare DateTime _ = try dt.earlierThan(dt2); _ = try dt.laterThan(dt2); _ = try dt.equal(dt2); // Get Timestamp (elapsed time from 1970-01-01T00:00:00Z) _ = try dt.getTimestamp(); // i64 _ = try dt.getMilliTimestamp(); // i64 _ = try dt.getMicroTimestamp(); // i64 _ = try dt.getNanoTimestamp(); // i128 // Get day of week _ = try dt.dayOfWeek(); // enum { .Sunday, .Monday, .Tuesday, .Wednesday, .Thursday, .Friday, .Saturday } // Sort var dates = [_]Date{ dt, dt2 }; try DateTime.sort(&amp;dates, .asc); try DateTime.sort(&amp;dates, .desc); </code> } ``` Since fields can be changed from outside freely, methods validate its values and fail unless it is valid. Leap second (<code>.second = 60</code>) is accepted and can be compared, however, it will be ignored when exporting to UNIX timestamp. 2. Features <ul> <li>Construct <code>DateTime</code> from <code>Timestamp</code> and <code>TimeZone</code></li> <li>Get timestamp with resolution of second, milli second, micro second, and nano second</li> <li>Change <code>TimeZone</code></li> <li>Parse ISO8601 basic and extended format</li> <li>Write ISO8601 basic and extended format, or custom format</li> <li>Compare two <code>DateTime</code></li> <li>Sort <code>DateTime</code> slice</li> <li><code>floor()</code> and <code>ceil()</code> with resolution of century, year, hour, date, hour, minute, second, milli second, micro second, and nano second.</li> </ul>
[]
https://avatars.githubusercontent.com/u/103561195?v=4
zinewave
AndresCarignano/zinewave
2024-11-13T02:21:17Z
Midi player prototype. Currently learing Zig and C.
main
0
1
0
1
https://api.github.com/repos/AndresCarignano/zinewave/tags
-
[ "c", "zig" ]
1,046
false
2025-01-24T20:49:09Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/6793008?v=4
LiveView-PWA
ndrean/LiveView-PWA
2024-12-28T16:37:50Z
A demo of a Phoenix LiveView real-time collaborative with PWA support
main
0
1
0
1
https://api.github.com/repos/ndrean/LiveView-PWA/tags
GPL-3.0
[ "elixir-phoenix", "leafletjs", "phoenix-liveview", "pwa", "valtio", "vitejs", "wasm", "yjs", "zig" ]
21,175
false
2025-05-22T04:23:43Z
false
false
unknown
github
[]
Offline first Phoenix LiveView PWA An example of a real-time, collaborative multi-page web app built with <code>Phoenix LiveView</code>. It is designed for offline-first ready; it is packaged as a <a>PWA</a> and uses op-based CRDTs or local state and reactive components. Offline first solutions naturally offloads most of the reactive UI logic to JavaScript. When online, we use LiveView "hooks", while when offline, we render the reactive components. It uses <code>Vite</code> as the bundler. <blockquote> While it can be extended to support multiple pages, dynamic page handling has not yet been tested nor implemented. </blockquote> <strong>Results</strong>: <ul> <li>deployed on Fly.io at: <a>https://solidyjs-lively-pine-4375.fly.dev/</a></li> <li>standalone Phoenix LiveView app of 2.1 MB</li> <li>memory usage: 220MB</li> <li>image weight: 52MB of Fly.io, 126MB on Docker Hub (<code>Debian</code> based)</li> <li>client code can be updated via the Service Worker lifecycle</li> </ul> QRCode to check multi users, from on a mobile device: Table of Contents <ul> <li><a>Offline first Phoenix LiveView PWA</a></li> <li><a>Table of Contents</a></li> <li><a>What?</a></li> <li><a>Why?</a></li> <li><a>Design goals</a></li> <li><a>Common pitfall of combining LiveView with CSR components</a></li> <li><a>Tech overview</a><ul> <li><a>Implementation highlights</a></li> </ul> </li> <li><a>About the Yjs-Stock page</a></li> <li><a>About PWA</a><ul> <li><a>Updates life-cycle</a></li> </ul> </li> <li><a>Usage</a></li> <li><a>Details of Pages</a><ul> <li><a>Yjs-Stock</a></li> <li><a>Pg-Sync-Stock</a></li> <li><a>FlightMap</a></li> </ul> </li> <li><a>Navigation</a></li> <li><a>Vite</a><ul> <li><a>Configuration and settings</a></li> <li><a>Watcher</a></li> <li><a>Tailwind</a></li> <li><a>Client Env</a></li> <li><a>Static assets</a></li> <li><a>VitePWA plugin and Workbox Caching Strategies</a></li> </ul> </li> <li><a>Yjs</a></li> <li><a>Misc</a><ul> <li><a>Presence through Live-navigation</a></li> <li><a>CSP rules and evaluation</a></li> <li><a>Icons</a></li> <li><a>Manifest</a></li> <li><a>Performance</a></li> <li><a>[Optional] Page Caching</a></li> </ul> </li> <li><a>Publish</a></li> <li><a>Fly volumes</a></li> <li><a>Documentation source</a></li> <li><a>Resources</a></li> <li><a>License</a></li> <li><a>Credits</a></li> </ul> What? <strong>Context</strong>: we want to experiment PWA collaborative webapps using Phoenix LiveView. What are we building? A three pages webap: <ul> <li>Yjs-Stock. On the first page, we mimic a shopping cart where users can pick items until stock is depleted, at which point the stock is replenished. Every user will see and can interact with this counter</li> <li>PgSync-Stock. This page features <code>phoenix_sync</code> in <em>embedded</em> mode streaming logical replicates of a Postgres table. [Building offline features]</li> <li>FlightMap. On the second page, we propose an interactive map with a form with two inputs where <strong>two</strong> users can edit collaboratively a form to display markers on the map and then draw a great circle between the two points.</li> </ul> <blockquote> You need an api key to render the Maptiler vector tiles. You can see the Service Worker in action in the LiveMap page when you go offline as the tiles are cached. This is naturally only true if you already visited these tiles, thus loaded them. </blockquote> Why? Traditional Phoenix LiveView applications face several challenges in offline scenarios: <ol> <li> <strong>no Offline Interactivity</strong>: Some applications need to maintain interactivity even when offline, preventing a degraded user experience. </li> <li> <strong>no Offline Navigation</strong>: User may need to navigate through pages. </li> <li> <strong>WebSocket Limitations</strong>: LiveView's WebSocket architecture isn't naturally suited for PWAs, as it requires constant connection for functionality. When online, we use <code>Phoenix.Channel</code> for real-time collaboration. </li> <li> <strong>State Management</strong>: It is challenging to maintain consistent state across network interruptions between the client and the server. </li> <li> <strong>Build tool</strong>: We need to setup a Service Worker to cache HTML pages and static assets to work offline, out of the LiveView goodies. </li> </ol> Design goals <ul> <li><strong>collaborative</strong> (online): Clients sync via <em>pubsub updates</em> when connected, ensuring real-time consistency.</li> <li><strong>optimistic UI</strong>: The function "click on stock" assumes success and will reconciliate later.</li> <li><strong>database</strong>:</li> <li>We use <code>SQLite</code> as the "canonical" source of truth for the Yjs-Stock counter.</li> <li><code>Postgres</code> is used for the <code>Phoenix_sync</code> process for the PgSync-Stock counter.</li> <li><strong>Offline-First</strong>: The app remains functional offline (through the <code>Cache</code> API and reactive JS components), with clients converging to the correct state on reconnection.</li> <li><strong>PWA</strong>: Full PWA features, meaning it can be <em>installed</em> as a standalone app and can be <em>updated</em>. A <code>Service Worker</code> runs in a separate thread and caches the assets. It is setup with <code>VitePWA</code>.</li> </ul> Common pitfall of combining LiveView with CSR components The client-side rendered components are - when online - mounted via hooks under the tag <code>phx-update="ignore"</code>. These components have they own lifecycle. They can leak or stack duplicate components if you don't cleanup them properly. The same applies to "subscriptions/observers" primitives from (any) the state manager. You must <em>unsubscribe</em>, otherwise you might get multiples calls and weird behaviours. ⭐️ LiveView hooks comes with a handy lifecyle and the <code>destroyed</code> callback is essential. <code>SolidJS</code> makes this easy as it can return a <code>cleanupSolid</code> callback (where you take a reference to the SolidJS component in the hook). You also need to clean <em>subscriptions</em> (when using a store manager). The same applies when you navigate offline; you have to run cleanup functions, both on the components and on the subsriptions/observers from the state manager. Tech overview | Component | Role | | -------------------------- | ----------------------------------------------------------------------------------------------------------------- | | Vite | Build and bundling framework | | SQLite | Embedded persistent storage of latest Yjs document | | Phoenix LiveView | UI rendering, incuding hooks | | PubSub / Phoenix.Channel | Broadcast/notifies other clients of updates / conveys CRDTs binaries on a separate websocket (from te LiveSocket) | | Yjs / Y.Map | Holds the CRDT state client-side (shared) | | Valtio | Holds local ephemeral state | | y-indexeddb | Persists state locally for offline mode | | SolidJS | renders reactive UI using signals, driven by Yjs observers | | Hooks | Injects communication primitives and controls JavaScript code | | Service Worker / Cache API | Enable offline UI rendering and navigation by caching HTML pages and static assets | | Leaflet | Map rendering | | MapTiler | enable vector tiles | | WebAssembly container |  high-performance calculations for map "great-circle" routes use <code>Zig</code> code compiled to <code>WASM</code> | Implementation highlights <ul> <li> <strong>Offline capabilities</strong>: </li> <li> Yjs-Stock page: edits are saved to <code>y-indexeddb</code> </li> <li>PgSync-Stock: edits save in <em>localStorage</em> (TODO)</li> <li> FlightMap: the "airports" list is saved in <em>localStorage</em> </li> <li> <strong>State Management</strong>: We use different approaches based on the page requirements: </li> <li> Yjs-Stock. Client-side: CRDT-based (op-based) synchronization with <code>Yjs</code> featuring <code>IndexedDB</code>. Server-side, it uses an embedded <code>SQLite</code> database as the canonical source of truth, even if Yjs is the local source of truth. </li> <li>PgSync-Stock. Client-side: <em>localStorage</em> persistence, and server-side, <code>Postgres</code> with logical replication.</li> <li> FlightMap. Local state management (<code>Valtio</code>) for the collaborative Flight Map page with no server-side persistence of the state </li> <li> <strong>Build tool</strong>: We use Vite as the build tool to bundle and optimize the application and enable PWA features seamlessly. The Service Worker to cache HTML pages and static assets. </li> <li> <strong>CRDT features used</strong> in Yjs-Stock page: </li> <li> We are using the following features of CRDT: <ul> <li>Local change tracking: All changes are modeled as CRDT ops, so you can always merge them safely if needed.</li> <li>Offline/online merging: If a user has multiple browser tabs, or is offline and comes back, Yjs/CRDT guarantees that the state will be consistent and no changes will be lost.</li> <li>Persistence: Because CRDTs work by merging, you can safely persist and reload state at any time.</li> </ul> </li> <li> <strong>op-based CRDT Synchronization Flow</strong>: This is essentially implementing the operation-based CRDT counter pattern. Each client accumulates local ops (clicks), and only sends its local ops (since last sync) on reconnect. Each client tracks only their local "clicks"/decrements since last sync (not the absolute counter value). On reconnection, client sends the number of pending clicks to the server. Server applies the delta to the shared counter in the database (e.g., counter = counter - clicks). Server responds with the new counter value. Client resets its local clicks to zero, and sets the local counter to the value from the server. If a client has no pending clicks, it doesn't send anything, but receives the current counter from the server. </li> </ul> The client updates his local <code>YDoc</code> with the server responses or from his own changes. <code>YDoc</code> mutations are observed and trigger UI rendering, and reciprocally, UI modifications update the <code>YDoc</code> and propagate mutations to the server. <ul> <li> <strong>FlightMap page</strong>: We use a local state manager (<code>Valtio</code> using proxies). The inputs (selected airports) are saved to a local state. Local UI changes mutate the state and are sent to the server. The server broadcasts the data. We have state observers which update the UI if the origin is not remote. </li> <li> <strong>Data Transport</strong>: </li> <li> Yjs-Stock page: we used <code>Phoenix.Channel</code> to decouples state handling from the LiveSocket. </li> <li> FlightMap page: We use the LiveSocket as the data flow is small. </li> <li> <strong>Component Rendering Strategy</strong>: </li> <li>online: use LiveView hooks</li> <li>offline: hydrate the HTML with cached documents and run reactive JavaScript components</li> </ul> About the Yjs-Stock page ```mermaid sequenceDiagram autonumber participant User participant SolidJS/Yjs Client participant LiveView Hook participant Phoenix Server Note over SolidJS/Yjs Client: CRDT Initialized (Y.Map: {counter, clicks}) Note over SolidJS/Yjs Client, Phoenix Server: Shared topic: "counter" User-&gt;&gt;SolidJS/Yjs Client: Clicks +1 Note over SolidJS/Yjs Client: CRDT 'counter' += 1\nCRDT 'clicks' += 1 (local only) SolidJS/Yjs Client--&gt;&gt;UI: Immediate update (Optimistic) Note over SolidJS/Yjs Client: Yjs triggers <code>ydoc.on("update")</code> SolidJS/Yjs Client-&gt;&gt;LiveView Hook: handleYUpdate(origin="local") LiveView Hook-&gt;&gt;Phoenix Server: push("client-update", {clicks}) Phoenix Server-&gt;&gt;Phoenix Server: counter += clicks Phoenix Server-&gt;&gt;LiveView Hook: reply("ok", {counter}) LiveView Hook-&gt;&gt;SolidJS/Yjs Client: trigger counter-update SolidJS/Yjs Client-&gt;&gt;Yjs: ydoc.transact() to set counter\n&amp; reset clicks = 0 SolidJS/Yjs Client--&gt;&gt;UI: CRDT triggers observer\nUI re-renders Note over SolidJS/Yjs Client: Yjs (CRDT) is reactive and stateful Note over Phoenix Server: Phoenix holds canonical "counter" %% Sync from server on connect SolidJS/Yjs Client-&gt;&gt;LiveView Hook: syncWithServer() LiveView Hook-&gt;&gt;Phoenix Server: push("client-update", {clicks?}) Phoenix Server--&gt;&gt;LiveView Hook: reply("ok", {counter}) LiveView Hook-&gt;&gt;SolidJS/Yjs Client: ydoc.set("counter", counter)\nydoc.set("clicks", 0) %% Broadcasts to others Phoenix Server-&gt;&gt;Other Clients: broadcast "counter-update" Other Clients-&gt;&gt;Yjs: set("counter", counter) Note over Other Clients: Observer triggers UI update ``` About PWA A Progressive Web App (PWA) is a type of web application that provides an app-like experience directly in the browser. It has: <ul> <li>offline support</li> <li>is "instalable":</li> </ul> The core components are setup using <code>Vite</code> in the <em>vite.config.js</em> file. <ul> <li> <strong>Service Worker</strong>: A background script - separate thread - that acts as a proxy: intercepts network requests and enables offline caching and background sync. We use the <code>VitePWA</code> plugin to enable the Service Worker life-cycle (manage updates) </li> <li> Web App <strong>Manifest</strong> (manifest.webmanifest) A JSON file that defines the app’s name, icons, theme color, start URL, etc., used to install the webapp. We produce the Manifest with <code>Vite</code> via in the "vite. </li> <li> HTTPS (or localhost): Required for secure context: it enables Service Workers and trust. </li> </ul> <code>Vite</code> builds the SW for us via the <code>VitePWA</code> plugin by declarations in "vite.config.js". Check <a>Vite</a> The SW is started by the main script, early, and must preload all the build static assets as the main file starts before the SW runtime caching is active. Since we want offline navigation, we precache the rendered HTML as well. Updates life-cycle A Service Worker (SW) runs in a <em>separate thread</em> from the main JS and has a unique lifecycle made of 3 key phases: install / activate / fetch In action: <ol> <li>Make a change in the client code, git push/fly deploy: -&gt; a button appears and the dev console shows a push and waiting stage:</li> </ol> <ol> <li>Click the "refresh needed" -&gt; the Service Worker and client claims are updated seamlessly, and the button is in the hidden "normal" state.</li> </ol> Service Workers don't automatically update unless: <ul> <li> The sw.js file has changed (based on byte comparison). </li> <li> The browser checks periodically (usually every 24 hours). </li> <li> When a new SW is detected: </li> <li> New SW enters installing state. </li> <li> It waits until no existing clients are using the old SW. </li> <li> Then it activates. </li> </ul> ```mermaid sequenceDiagram participant User participant Browser participant App participant OldSW as Old Service Worker participant NewSW as New Service Worker Browser-&gt;&gt;OldSW: Control App App-&gt;&gt;Browser: registerSW() App-&gt;&gt;App: code changes Browser-&gt;&gt;NewSW: Downloads New SW NewSW-&gt;&gt;Browser: waiting phase NewSW--&gt;&gt;App: message: onNeedRefresh() App-&gt;&gt;User: Show onNeedRefresh() User-&gt;&gt;App: Clicks Update Button App-&gt;&gt;NewSW: skipWaiting() NewSW-&gt;&gt;Browser: Activates NewSW-&gt;&gt;App: Takes control (via clients.claim()) ``` Usage ```elixir mix.exs server component of Yjs to manage Y_Doc server-side {:y_ex, "~&gt; 0.7.3"}, SQLite3 {:exqlite, "0.30.1"}, fetching the CSV airports {:req, "~&gt; 0.5.8"}, parsing the CSV airports {:nimble_csv, "~&gt; 1.2"}, ``` Client package are setup with <code>pnpm</code>: check <a>▶️ package.json</a> 1/ <strong>dev</strong> setup with <em>IEX</em> session ```sh install all dependencies including Vite mix deps.get mix ecto.create &amp;&amp; mix ecto.migrate pnpm install --prefix assets start Phoenix server, it will also compile the JS iex -S mix phx.server ``` 2/ Run a local Docker container in <strong>mode=prod</strong> <code>sh docker compose up --build</code> <a>▶️ Dockerfile</a> <a>▶️ docker-compose.yml</a> <blockquote> You can take a look at the build artifacts by running into another terminal </blockquote> ```sh <blockquote> docker compose exec -it web cat lib/solidyjs-0.1.0/priv/static/.vite/manifest.json ``` </blockquote> 3/ Pull from <code>Docker Hub</code>: <code>sh docker run -it -e SECRET_KEY_BASE=oi37wzrEwoWq4XgnSY3VRbKUhNxvdowJ7NOCrCECZ6V7WyPDNHuQp36oat+aqOkS -p 80:4000 --rm ndrean/pwa-liveview:latest</code> and visit <a>http://localhost</a> Details of Pages Yjs-Stock Available at <code>/</code>. You click on a counter and it goes down..! The counter is broacasted and handled by a CRDT backed into a SQLite table. A user can click offline, and on reconnection, all clients will get updated with the lowest value (business rule). Pg-Sync-Stock Available at "/elec" FlightMap Available at <code>/map</code>. It displays an <em>interactive</em> and <em>collaborative</em> (two-user input) route planning with vector tiles. The UI displays a form with two inputs, which are pushed to Phoenix and broadcasted via Phoenix PubSub. A marker is drawn by <code>Leaflet</code> to display the choosen airport on a vector-tiled map using <code>MapTiler</code>. Key features: <ul> <li>collaborative input</li> <li><code>Valtio</code>-based <em>local</em> (browser only) ephemeral state management (no complex conflict resolution needed)</li> <li>WebAssembly-powered great circle calculations: CPU-intensive calculations works offline</li> <li>Efficient map rendering with MapTiler and <em>vector tiles</em> with smaller cache size (vector data vs. raster image files)</li> </ul> <blockquote> [<strong>Great circle computation</strong>] It uses a WASM module. <code>Zig</code> is used to compute a "great circle" between two points, as a list of <code>[lat, long]</code> spaced by 100km. The <code>Zig</code> code is compiled to WASM and available for the client JavaScript to run it. Once the list of successive coordinates are in JavaScript, <code>Leaflet</code> can use it to produce a polyline and draw it into a canvas. We added a WASM module to implement great circle route calculation as a showcase of WASM integration. A JAvascript alternative would be to use <a>turf.js</a>. check the folder "/zig-wasm" [<strong>Airport dataset</strong>] We use a dataset from <a>https://ourairports.com/</a>. We stream download a CSV file, parse it (<code>NimbleCSV</code>) and bulk insert into an SQLite table. When a user mounts, we read from the database and pass the data asynchronously to the client via the liveSocket on the first mount. We persist the data in <code>localStorage</code> for client-side search. The socket "airports" assign is then pruned to free the server's socket. </blockquote> ▶️ <a>Airports</a>, <a>LiveMap</a> <blockquote> The Websocket is configured with <code>compress: true</code> (cf <a>https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#socket/3-websocket-configuration</a>) to enable compression of the 1.1MB airport dataset through the LiveSocket. </blockquote> Below a diagram showing the flow between the database, the server and the client. ```mermaid sequenceDiagram participant Client participant LiveView participant Database <code>Client-&gt;&gt;LiveView: mount (connected) Client-&gt;&gt;Client: check localStorage/Valtio alt cached data exists and valid Client-&gt;&gt;LiveView: "cache-checked" (cached: true) LiveView-&gt;&gt;Client: verify hash else no valid cache Client-&gt;&gt;LiveView: "cache-checked" (cached: false) LiveView-&gt;&gt;Database: fetch_airports() Database--&gt;&gt;LiveView: airports data LiveView-&gt;&gt;Client: "airports" event with data Client-&gt;&gt;Client: update localStorage + Valtio end </code> ``` Navigation The user use "live navigation" when online between two pages which use the same <em>live_session</em>, with no full page reload. When the user goes offline, we have the same smooth navigation thanks to navigation hijack an the HTML and assets caching, as well as the usage of <code>y-indexeddb</code>. <strong>Lifecycle</strong>: <ul> <li>Initial Load: App starts a continous server check. It determines if online/offline and sets up accordingly</li> <li>Going Offline: Triggers component initialization and navigation setup</li> <li>Navigating Offline: cleans up components, <em>fetch</em> the cached pages (request proxied by the SW and the page are cached iva the <code>additionalManifestEntries</code>), parse ahd hydrate the DOM to renders components</li> <li>Going Online: when the polling detects a transistion off-&gt;on, the user expects a page refresh and Phoenix LiveView reinitializes.</li> </ul> <strong>Key point</strong>: <ul> <li>⚠️ <strong>memory leaks</strong>: With this offline navigation, we never refresh the page. As said before, reactive components and subscriptions need to be cleaned before disposal. We store the cleanup functions and the subscriptions.</li> </ul> Vite Configuration and settings All the client code is managed by <code>Vite</code> and done (mostly) in a declarative way in the file <a>vite.config.js</a>. <blockquote> Most declarations are done programatically as it is run by <code>NodeJS</code>. </blockquote> Watcher There is a watcher configured in "config/dev.exs" which replaces, thus removes, <code>esbuild</code> and <code>tailwindCSS</code> (which are also removed from the mix deps). <code>elixir watchers: [ npx: [ "vite", "build", "--mode", "development", "--watch", "--config", "vite.config.js", cd: Path.expand("../assets", __DIR__) ] ]</code> Tailwind ⚠️You can't use v4 but should <em>keep v3.4</em>. Indeed, Tailwind v4 drops the "tailwind.config.js" and there is no proper way to parse the SSR files (.ex, .heex) without it. Tailwind is used as a PostCSS plugin. In the <code>Vite</code> config, it is set with the declaration: <code>js import tailwindcss from "tailwindcss"; [...] // in `defineConfig`, add: css: { postcss: { plugins: [tailwindcss()], }, },</code> and reads automatically the "tailwind.configjs" which sits next to "vite.config.js". <blockquote> Note. We use <code>lightningCSS</code> for further optimze the CSS and <code>autoprefixer</code> is built in (if "-weebkit" for flex/grid or "-moz" for transitions are needed). </blockquote> Client Env The env arguments are loaded with <code>loadEnv</code>. <ol> <li> Runtime access: <code>import.meta.env</code> The client env vars are set in the ".env" placed, placed in the "/assets" folder (origin client code) next to "vite.config.js". They need to be prefixed with <code>VITE_</code>. They is injected by <code>Vite</code> at <em>runtime</em> when you use <code>import.meta.env</code>. In particular, we use <code>VITE_API_KEY</code> for <code>Maptiler</code> to render the vector tiles. </li> <li> Compile access: <code>define</code> it is used at <em>compile time</em> . The directive <code>define</code> is used to get <em>compile time</em> global constant replacement. This is valuable for dead code elimination. For example: </li> </ol> <code>js define: { __API_ENDPOINT__: JSON.stringify( process.env.NODE_ENV === "production" ? "https://example.com" : "http://localhost:4000" ); } [...] // NODE_ENV="prodution" // file.js if (__API__ENDPOINT__ !== "https://example.com") { // =&gt; dead code eliminated }</code> <ol> <li>Docker: In the Docker build stage, you copy the "assets" folder. You therefor copy the ".env" file so the env vars variables are accessible at runtime. When you deploy, we need to set an env variable <code>VITE_API_KEY</code> which will be used to build the image.</li> </ol> Static assets We do not use the step <code>mix phx.digest</code> and removed from the Dockerfile. We fingerprint and compress the static files via <code>Vite</code>. <code>js rollupOptions.output: { assetFileNames: "assets/[name]-[hash][extname]", chunkFileNames: "assets/[name]-[hash].js", entryFileNames: "assets/[name]-[hash].js", },</code> We do this because we want the SW to be able to detect client code changes and update the app. The Phoenix work would interfer. <strong>Caveat</strong>: versioned fils have dynamic so how to pass them to the "root.html.heex" component? When assets are not fingerprinted, Phoenix can serve them "normally" as names are known: <code>elixir &lt;link rel="icon" href="/favicon.ico" type="image/png" sizes="48x48" /&gt; &lt;link rel="manifest" href="/manifest.webmanifest" /&gt;</code> When the asset reference is versioned, we use the <code>.vte/manifest</code> dictionary to find the new name. We used a helper <a>ViteHelper</a> to map the original name to the versioned one (the one in "priv/static/assets"). ```elixir ``` Not all assets need to be fingerprinted, such as "robotx.txt", icons.... To copy these files , we use the plugin <code>vite-plugin-static-copy</code>. We also compress files to <em>ZSTD</em> known for its compression performance and deflating speed. We use the plugin <code>vite-plugin-compression2</code> and use <code>@mongodb-js/zstd</code>. We modify "endpoint.ex" to accept these encodings: <code>elixir plug Plug.Static, encodings: [{"zstd", ".zstd"}], brotli: true, gzip: true, at: "/", from: :liveview_pwa, only: ~w( assets icons robots.txt sw.js manifest.webmanifest sitemap.xml ), headers: %{ "cache-control" =&gt; "public, max-age=31536000" } [...]</code> VitePWA plugin and Workbox Caching Strategies We use the <a>VitePWA</a> plugin to generate the SW and the manifest. The client code is loaded in a <code>&lt;script&gt;</code>. It will load the SW registration when the event DOMContentLoaded fires. All of the hooks are loaded and attached to the LiveSocket, like an SPA. If we don't <em>preload</em> the JS files in the SW, most of the js files will never be cached, thus the app won't work offline. For this, we define that we want to preload all static assets in the directive <code>globPattern</code>. Once the SW activated, you should see (in dev mode): We also cache the rendered HTML pages as we inject them when offline, via <code>additionalManifestEntries</code>. ```js PWAConfig = { // Don't inject to register SW (handled manually) // and there no client generated "index.html" by Phoenix injectRegister: false, // no client generated "index.html" by Phoenix // Let Workbox auto-generate the service worker from config strategies: "generateSW", // App manually prompts user to update SW when available registerType: "prompt", // SW lifecycle --- // Claim control over all uncontrolled pages as soon as the SW is activated clientsClaim: true, // Let app decide when to update; user must confirm or app logic must apply update skipWaiting: false, workbox: {...} } ``` ❗️ It is important <em>not to split</em> the "sw.js" file because <code>Vite</code> produces a fingerprint from the splitted files. However, Phoenix serves hardcoded nmes and can't know the name in advance. ```js workbox: { // Disable to avoid interference with Phoenix LiveView WebSocket negotiation navigationPreload: false // ❗️ no fallback to "index.html" as it does not exist navigateFallback: null // ‼️ tell Workbox not to split te SW as the other is fingerprinted, thus unknown to Phoenix. inlineWorkboxRuntime: true, // preload all the built static assets globPatterns: ["assets/<em><em>/</em>.</em>"], // cached the HTML for offline rendering additionalManifestEntries: [ { url: "/", revision: <code>${Date.now()}</code> }, // Manually precache root route { url: "/map", revision: <code>${Date.now()}</code> }, // Manually precache map route ], } ``` For the Service Worker lifecycle, set: <code>js defineConfig = { // Disable default public dir (using Phoenix's) publicDir: false, };</code> Yjs [TODO something smart...?] Misc Presence through Live-navigation It is implemented using a <code>Channel</code> and a <code>JavaScript</code> snippet used in the main script. The reason is that if we implement it with "streams", it will wash away the current stream used by <code>Phoenix_sync</code>. It also allows to minimise rendering when navigating to the different Liveviews. The relevant module is: <code>setPresenceChannel.js</code>. It uses a reactive JS component (<code>SolidJS</code>). It returns a "dispose" and an "update" function. This snippet runs in "main.js". The key points are: <ul> <li>a simple Channel with <code>Presence.track</code> and a <code>push</code> of the <code>Presence.list</code>,</li> <li>use <code>presence.onSync</code> listener to get a <code>Presence</code> list up-to-date and render the UI with this list</li> <li>a <code>phx:page-loading-stop</code> listener to udpate the UI when navigating between Liveviews because we target DOM elements to render the reactive component.</li> </ul> CSP rules and evaluation The application implements security CSP headers set by a plug: <code>BrowserCSP</code>. We mainly protect the "main.js" file - run as a script in the "root.html" template - is protected with a <strong>dynamic nonce</strong>. Detail of dynamic nonce ```elixir defmodule SoldiyjsWeb.BrowserCSP do @behaviour Plug def init(opts), do: opts def call(conn, _opts) do nonce = :crypto.strong_rand_bytes(16) |&gt; Base.encode16(case: :lower) Plug.Conn.assign(conn, :csp_nonce, nonce) end end ``` ````elixir # root.html.heex // Your inline script here ```elixir defp put_csp_headers(conn) do nonce = conn.assigns[:csp_nonce] || "" csp_policy = """ script-src 'self' 'nonce-#{nonce}' 'wasm-unsafe-eval' https://cdn.maptiler.com; object-src 'none'; connect-src 'self' http://localhost:* ws://localhost:* https://api.maptiler.com https://*.maptiler.com; img-src 'self' data: https://*.maptiler.com https://api.maptiler.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; default-src 'self'; frame-ancestors 'self' http://localhost:*; base-uri 'self' """ |&gt; String.replace("\n", " ") put_resp_header(conn, "content-security-policy", csp_policy) end ```` The nonce-xxx attribute is an assign populated in the plug BrowserCSP. Indeed, the "root" template is rendered on the first mount, and has access to the <code>conn.assigns</code>. ➡️ Link to check the endpoint: <a>https://csp-evaluator.withgoogle.com/</a> The WASM module needs <code>'wasm-unsafe-eval'</code> as the browser runs <code>eval</code>. Icons You will need is to have at least two very low resolution icons of size 192 and 512, one extra of 180 for OSX and one 62 for Microsoft, all placed in "/priv/static". Check <a>Resources</a> Manifest The "manifest.webmanifest" file will be generated from "vite.config.js". Source: check <a>PWABuilder</a> <code>json { "name": "LivePWA", "short_name": "LivePWA", "start_url": "/", "display": "standalone", "background_color": "#ffffff", "lang": "en", "scope": "/", "description": "A Phoenix LiveView PWA demo app", "theme_color": "#ffffff", "icons": [ { "src": "/images/icon-192.png", "sizes": "192x192", "type": "image/png" }, ... ] }</code> ✅ Insert the links to the icons in the (root layout) HTML: ```html [...] [...] [...] ``` Performance Lighthouse results: [Optional] Page Caching Direct usage of Cache API instead of Workbox We can use the `Cache API` as an alternative to `Workbox` to cache pages. The important part is to calculate the "Content-Length" to be able to cache it. &gt; Note: we cache a page only once by using a `Set` ```javascript // Cache current page if it's in the configured routes async function addCurrentPageToCache({ current, routes }) { await navigator.serviceWorker.ready; const newPath = new URL(current).pathname; // Only cache configured routes once if (!routes.includes(newPath) || AppState.paths.has(newPath)) return; if (newPath === window.location.pathname) { AppState.paths.add(newPath); const htmlContent = document.documentElement.outerHTML; const contentLength = new TextEncoder().encode(htmlContent).length; const response = new Response(htmlContent, { headers: { "Content-Type": "text/html", "Content-Length": contentLength, }, status: 200, }); const cache = await caches.open(CONFIG.CACHE_NAME); return cache.put(current, response); } } // Monitor navigation events navigation.addEventListener("navigate", async ({ destination: { url } }) =&gt; { return addCurrentPageToCache({ current: url, routes: CONFIG.ROUTES }); }); ``` Publish The site <a>https://docs.pwabuilder.com/#/builder/android</a> helps to publish PWAs on Google Play, Ios and other plateforms. Fly volumes In the "fly.toml", the settings for the volume are: ```toml [env] DATABASE_PATH = '/mnt/db/main.db' MIX_ENV = 'prod' PHX_HOST = 'solidyjs-lively-pine-4375.fly.dev' PORT = '8080' [[mounts]] source = 'name' destination = '/mnt/db' ``` This volume is made persistent through build with <code>source = 'name'</code>. We set the Fly secret: <code>DATABASE_PATH=mnt/db/main.db</code>. Documentation source <ul> <li>Update API: <a>https://docs.yjs.dev/api/document-updates#update-api</a></li> <li>Event handler "on": <a>https://docs.yjs.dev/api/y.doc#event-handler</a></li> <li>local persistence with IndexedDB: <a>https://docs.yjs.dev/getting-started/allowing-offline-editing</a></li> <li>Transactions: <a>https://docs.yjs.dev/getting-started/working-with-shared-types#transactions</a></li> <li>Map shared type: <a>https://docs.yjs.dev/api/shared-types/y.map</a></li> <li>observer on shared type: <a>https://docs.yjs.dev/api/shared-types/y.map#api</a></li> </ul> Resources Besides Phoenix LiveView: <ul> <li><a>Yex with Channel</a></li> <li><a>Yjs Documentation</a></li> <li><a>Vite PWA Plugin Guide</a></li> <li><a>MDN PWA</a></li> <li><a>PWA builder</a></li> <li><a>Favicon Generator</a> and <a>https://vite-pwa-org.netlify.app/assets-generator/#pwa-minimal-icons-requirements</a></li> <li><a>CSP Evaluator</a></li> <li><a>Haversine formula</a></li> </ul> License <a>GNU License</a> Credits To enhance this project, you may want to use <code>y_ex</code>, the <code>Elixir</code> port of <code>y-crdt</code>. Cf <a>Satoren</a> for <a>Yex</a>
[]
https://avatars.githubusercontent.com/u/37878481?v=4
zig_annotation_system_design
Lking03x/zig_annotation_system_design
2025-01-29T08:36:47Z
public notes on an "annotation system" for the Zig programming language.
master
0
1
0
1
https://api.github.com/repos/Lking03x/zig_annotation_system_design/tags
-
[ "annotations", "ats-lang", "dependent-types", "interpeter", "linear-types", "parser", "software-architecture", "tooling", "typesystem", "wip", "zig", "ziglang" ]
0
false
2025-03-13T00:07:47Z
false
false
unknown
github
[]
zig_annotation_system_design public notes on an "annotation system" for the Zig programming language.
[]
https://avatars.githubusercontent.com/u/175068426?v=4
kdbx
Zig-Sec/kdbx
2024-11-02T22:14:43Z
This Zig module allows you to integrate KDBX support into your application.
master
1
1
0
1
https://api.github.com/repos/Zig-Sec/kdbx/tags
-
[ "kdbx", "kdbx-database", "kdbx-files", "keepass", "zig", "ziglang" ]
1,903
false
2025-04-13T14:30:42Z
true
true
0.14.0
github
[ { "commit": "refs", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/Hejsil/zig-clap" }, { "commit": "refs", "name": "uuid", "tar_url": "https://github.com/r4gus/uuid-zig/archive/refs.tar.gz", "t...
KDBX - Keepass Database XML This Zig module allows you to integrate KDBX support into your application. This format is used by password databases like <a>KeePass</a> and <a>KeePassXC</a> to store passwords, <a>passkeys</a> and other credentials. <blockquote> Currently only KDBX4 is supported. </blockquote> Getting Started First add this project as a dependency to your <code>build.zig.zon</code> file: ```zig .{ // ... <code>.dependencies = .{ // ... .kdbx = .{ .url = "https://github.com/r4gus/kdbx/archive/master.tar.gz", .hash = &lt;hash&gt;, } }, // ... </code> } ``` Then, within your <code>build.zig</code> add the following code: ```zig const kdbx_dep = b.dependency("kdbx", .{ .target = target, .optimize = optimize, }); const kdbx_module = zbor_dep.module("kdbx"); // ... exe.root_module.addImport("kdbx", kdbx_module); ``` Then within your project just use <code>@import("kdbx")</code>. Reading and writing databases <blockquote> When saving, the inner XML data structure is generated from the Zig objects that represent the database, i.e., unsupported fields are lost when reading and then writing a existing database. If in doubt, backup your database! Feel free to open pull requests for missing features. </blockquote> ```zig const std = @import("std"); const kdbx = @import("kdbx"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); pub fn main() !void { var database = try kdbx.Database.new(.{ .allocator = allocator, }); defer database.deinit(); <code>var entry1 = kdbx.Entry.new(allocator); try entry1.set("Title", "Demo Entry", false); try entry1.set("UserName", "max", false); try entry1.set("Password", "supersecret", true); errdefer entry1.deinit(); try database.body.root.addEntry(entry1); const db_key = kdbx.DatabaseKey{ .password = try allocator.dupe(u8, "1234"), .allocator = allocator, }; defer db_key.deinit(); const raw = try database.save( db_key, allocator, ); defer allocator.free(raw); var file = try std.fs.cwd().createFile("db.kdbx", .{}); defer file.close(); try file.writeAll(raw); </code> } ``` <blockquote> Also see <code>main.zig</code> for an example. </blockquote>
[ "https://github.com/Zig-Sec/PassKeeZ" ]
https://avatars.githubusercontent.com/u/11700503?v=4
zibra
braheezy/zibra
2024-11-29T20:05:27Z
Web browser from scratch
main
0
1
0
1
https://api.github.com/repos/braheezy/zibra/tags
-
[ "zig" ]
422
false
2025-05-13T04:32:59Z
true
true
unknown
github
[ { "commit": "4a002763419a34d61dcbb1f415821b83b9bf8ddc", "name": "zg", "tar_url": "https://codeberg.org/atman/zg/archive/4a002763419a34d61dcbb1f415821b83b9bf8ddc.tar.gz", "type": "remote", "url": "https://codeberg.org/atman/zg" }, { "commit": "master", "name": "adazig", "tar_url":...
zibra <blockquote> <span class="bg-yellow-100 text-yellow-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">WARNING</span> This project is actively in work! <code>HEAD</code> usually works but it may be broken or produce nasty results. </blockquote> This repo holds my Zig code for the browser implemented in <a>Web Browser Engineering</a>. Usage You'll need Zig installed. Clone the project <code>sh git clone https://github.com/braheezy/zibra.git</code> To build the project, run: <code>sh zig build cp zig-out/bin/zibra .</code> <code>zibra</code> (optionally) takes one URL and displays the result in a window: <code>sh zibra https://example.org</code> Run without a URL for a default HTML. Supported Features <code>zibra</code> is small but supports the basics: <ul> <li>HTTP/1.1</li> <li>HTTPS</li> <li><code>file://</code> URIs</li> <li><code>data:</code> URIs</li> <li>Entity support:</li> <li><code>&amp;amp;</code> → <code>&amp;</code> (ampersand)</li> <li><code>&amp;lt;</code> → <code>&lt;</code> (less than)</li> <li><code>&amp;gt;</code> → <code>&gt;</code> (greater than)</li> <li><code>&amp;quot;</code> → <code>"</code> (quotation mark)</li> <li><code>&amp;apos;</code> → <code>'</code> (apostrophe)</li> <li><code>&amp;shy;</code> → <code>­</code> (soft hyphen)</li> <li>Connections that live beyond single request for <code>Connection: keep-alive</code> header</li> <li>Redirects</li> <li><code>Cache-Control</code> header</li> <li><code>Content-Encoding: gzip</code> and <code>Transfer-Encoding: chunked</code> headers</li> <li>Emojis and CJK text</li> <li>Various tags for styling:</li> <li><code>&lt;b&gt;Bold&lt;/b&gt;</code></li> <li><code>&lt;i&gt;Italic&lt;/i&gt;</code></li> <li><code>&lt;big&gt;Larger text&lt;/big&gt;</code></li> <li><code>&lt;small&gt;Smaller text&lt;/small&gt;</code></li> <li><code>&lt;sup&gt;Superscript&lt;/sup&gt;</code></li> <li><code>&lt;h1 class="title"&gt;Centered title&lt;/h1&gt;</code>: An <code>h1</code> with <code>class</code> set to <code>title</code> will be centered</li> <li><code>&lt;abbr&gt;Abbreviations&lt;/abbr&gt;</code></li> <li><code>&lt;pre&gt;Preformatted text&lt;/pre&gt;</code>: Including bold and italic variants</li> <li>HTML parsing features:</li> <li>Automatic insertion of implicit <code>&lt;html&gt;</code>, <code>&lt;head&gt;</code>, and <code>&lt;body&gt;</code> tags</li> <li>Proper handling of self-closing tags like <code>&lt;img /&gt;</code>, <code>&lt;br /&gt;</code>, and <code>&lt;input /&gt;</code></li> <li>Support for quoted, unquoted, and boolean HTML attributes</li> </ul> Development There's more Zig commands: ```sh build and run zig build run -- https://example.com Run tests zig build test ``` To test chunked gzip responses, run <code>gzipServer.py</code> locally. Known Issues <ul> <li>On Mac, the content is stretched while the window is being resized. Apparently this is known behavior in SDL2 because Mac blocks the main thread while the mouse is being held down to resize windows, preventing SDL from rendering the content properly...I think.</li> </ul>
[]
https://avatars.githubusercontent.com/u/138496837?v=4
brainfuck-jit-compiler
jla2000/brainfuck-jit-compiler
2025-01-16T14:58:57Z
Zero dependency, blazingly fast brainfuck JIT compiler, written in Zig.
main
0
1
0
1
https://api.github.com/repos/jla2000/brainfuck-jit-compiler/tags
-
[ "brainfuck-transpiler", "jit", "zig" ]
149
false
2025-03-31T15:05:21Z
true
false
unknown
github
[]
brainfuck-jit-compiler Translate any valid brainfuck program into native x86_64 machine code and directly execute it. Try it out now, using nix: <code>$ nix run github:jla2000/brainfuck-jit-compiler</code>
[]
https://avatars.githubusercontent.com/u/61627919?v=4
aoc_zig
nuIIpointerexception/aoc_zig
2024-12-08T06:46:03Z
highly optimized aoc solutions written in zig! 🚀🎄
main
0
1
0
1
https://api.github.com/repos/nuIIpointerexception/aoc_zig/tags
MIT
[ "advent-of-code", "advent-of-code-2024", "aoc", "zig", "ziglang" ]
28
false
2024-12-11T23:51:35Z
true
true
unknown
github
[]
aoc_zig This is my repository for the <a>Advent of Code</a> challenges in <a>Zig</a>. Other than overengineered solutions and highly optimized trash, you will maybe find this also neat build system for fetching and submitting aoc code. Features <ul> <li>Automatic input data fetching</li> <li>Submit your result with a command!</li> <li>Tests and benchmarking!</li> <li>Supports every year and every day!</li> </ul> Usage To fetch the input data for solutions, you need to provide a <code>TOKEN</code> file in the root directory of the repository. This file should contain a single line with your <a>advent of code</a> cookie. Build &amp; Run: <code>bash zig build &lt;day&gt; -Dyear=&lt;year&gt;</code> <code>bash zig build 1</code> If no year is provided, the current year will be used. If no day is provided, the current day will be used. Test: <code>bash zig build test:&lt;day&gt; -Dyear=&lt;year</code> example for day 1 (automatic year detection): <code>bash zig build test:1</code> Submit: <code>bash zig build submit:&lt;day&gt; -Dyear=&lt;year</code> example: <code>bash zig build submit:1</code> Hard reset / clean project: <code>bash zig build clean</code> NOTE: For your own safety you will have to add -Dconfirm=true to confirm this action! Contributing Contributions are welcome! If you have a solution to an existing solution, feel free to submit a PR. License This project is licensed under the MIT License - see the <a>LICENSE</a> file for details
[]
https://avatars.githubusercontent.com/u/27724944?v=4
aoc2024
dhananjaylatkar/aoc2024
2024-12-01T09:41:14Z
https://adventofcode.com/2024
main
0
1
0
1
https://api.github.com/repos/dhananjaylatkar/aoc2024/tags
GPL-3.0
[ "advent-of-code", "advent-of-code-2024", "advent-of-code-in-zig", "aoc", "aoc2024", "aoc2024-in-zig", "zig" ]
25
false
2024-12-01T09:51:38Z
true
true
unknown
github
[]
aoc2024 https://adventofcode.com/2024 Build and Run <ol> <li>Copy input to <code>input/day_&lt;num&gt;.txt</code></li> <li>Run <code>zig build run -- &lt;day&gt;</code></li> </ol>
[]
https://avatars.githubusercontent.com/u/87977742?v=4
zig-ts-mode
Ziqi-Yang/zig-ts-mode
2024-09-23T14:00:34Z
[Mirror] Emacs Zig Tree Sitter Mode
main
0
1
0
1
https://api.github.com/repos/Ziqi-Yang/zig-ts-mode/tags
-
[ "emacs", "tree-sitter", "zig" ]
87
false
2025-02-16T16:03:26Z
false
false
unknown
github
[]
Zig Tree Sitter Mode Official repository is at CodeBerg: <a>meow_king/zig-ts-mode</a>. Target zig tree sitter grammar: <a>github:maxxnino/tree-sitter-zig</a> Installation Elpaca <code>lisp (use-package zig-ts-mode :ensure (:type git :host codeberg :repo "meow_king/zig-ts-mode"))</code> Straight <code>lisp (use-package zig-ts-mode :ensure '(:type git :host codeberg :repo "meow_king/zig-ts-mode"))</code> Configuration Automatically enter <code>zig-ts-mode</code>: <code>lisp (add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-ts-mode))</code>
[]
https://avatars.githubusercontent.com/u/55647468?v=4
jsml.zig
Gaurav-Gosain/jsml.zig
2025-01-14T22:59:49Z
A simple JSON (toy) parser written in Zig, for learning purposes.
main
0
1
0
1
https://api.github.com/repos/Gaurav-Gosain/jsml.zig/tags
MIT
[ "json", "library", "parser", "zig" ]
5,777
false
2025-01-15T08:13:36Z
true
true
unknown
github
[]
jsml.zig A simple JSON (toy) parser written in Zig, for learning purposes. <blockquote> [!TODO] Documentation </blockquote>
[]
https://avatars.githubusercontent.com/u/84762257?v=4
fcm
iamyaash/fcm
2024-12-19T06:04:01Z
(ongoing development) Fedora Container Manager
main
1
1
1
1
https://api.github.com/repos/iamyaash/fcm/tags
GPL-3.0
[ "container", "dashboard", "docker", "fedora", "lighweight", "podman", "zig" ]
406
false
2025-01-13T08:24:07Z
false
false
unknown
github
[]
fcm Fedora Container Manager <ol> <li><strong>Start the Podman API Server</strong>:</li> </ol> <code>sh podman system service tcp:localhost:8080 --time=0 &amp;</code> <blockquote> This starts the API service in background(&amp;) under the port 8080 </blockquote> <ul> <li>In order to communicate with Podman, we need use the Podman's RESTful API to access the container informations.</li> <li>The above command starts the server, which enables to communicate with Podman using http request to send &amp; receive data.</li> <li> This is the first and foremost step complete for API communications. </li> <li> <a><strong>Send HTTP Request using Ziglang</strong></a> </li> </ul> Workflow Back-end: Overview Back-end: Explained 1. When the user clicks any of the sections, JavaScript sends a <strong>GET request</strong> to the Zig application. 2. Zig <strong>receives the HTTP request from JavaScript</strong> and send a <strong>GET Request</strong> to the <strong>Podman API endpoint</strong>. 3. Podman will <strong>fetches &amp; returns the JSON data to Zig</strong> from API endpoint. 4. Zig transforms the unstructured JSON data to structured data and sends it to JavaScript. Front-end
[]
https://avatars.githubusercontent.com/u/194645670?v=4
bimg
InteractiveBin/bimg
2025-01-16T06:17:00Z
Image library.
master
0
1
0
1
https://api.github.com/repos/InteractiveBin/bimg/tags
BSD-2-Clause
[ "zig", "zig-package" ]
3,576
true
2025-01-20T08:49:17Z
true
true
unknown
github
[ { "commit": "23d892161557c20d085a84bd51f59759ebcb2c89", "name": "bx", "tar_url": "https://github.com/InteractiveBin/bx/archive/23d892161557c20d085a84bd51f59759ebcb2c89.tar.gz", "type": "remote", "url": "https://github.com/InteractiveBin/bx" } ]
bimg Image library. <a></a> <a></a> Contact <a>@bkaradzic</a> Project page https://github.com/bkaradzic/bimg <a>License (BSD 2-clause)</a> <a target="_blank"> </a> <code>Copyright 2010-2025 Branimir Karadzic Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </code>
[ "https://github.com/InteractiveBin/bgfx" ]
https://avatars.githubusercontent.com/u/57322933?v=4
CoreX
griush/CoreX
2025-01-16T22:10:02Z
CoreX Framework
main
0
1
0
1
https://api.github.com/repos/griush/CoreX/tags
MIT
[ "game-development", "game-engine", "gamedev", "zig", "zig-package" ]
4,047
false
2025-01-30T19:15:15Z
true
true
unknown
github
[ { "commit": null, "name": "mach-glfw", "tar_url": null, "type": "remote", "url": "https://pkg.machengine.org/mach-glfw/affdd6ae6f2ac2c3b9162784bdad345c561eeeea.tar.gz" }, { "commit": "1c901bef6d312ef1814b8fce3c5a9e9e8e61ac2d", "name": "zigglgen", "tar_url": "https://github.com/ca...
CoreX CoreX framework
[]
https://avatars.githubusercontent.com/u/184568612?v=4
anyascii.zig
zigzedd/anyascii.zig
2025-01-08T18:56:01Z
[MIRROR] Zig port of C implementation of anyascii.
main
0
1
0
1
https://api.github.com/repos/zigzedd/anyascii.zig/tags
MIT
[ "ascii", "emoji", "normalization", "romanization", "slug", "transliteration", "unicode", "unidecode", "utf8", "zig", "zig-library", "zig-package" ]
274
false
2025-04-12T10:37:11Z
true
true
unknown
github
[]
anyascii.zig This repository allows to use anyascii C implementation from zig, with a helper function <code>utf8ToAscii</code> to easily convert any UTF-8 encoded string in an ASCII-only string. Current version of anyascii: <code>2023-08-01</code>. How to use <code>anyascii</code> ```zig const std = @import("std"); const anyascii = @import("anyascii").anyascii; // A single UTF-8 codepoint to its ASCII equivalent. const ascii = try anyascii(allocator, try std.unicode.utf8Decode("Φ")); defer allocator.free(ascii); std.debug.print("{s}", .{ascii}); // Output: "F". ``` <code>utf8ToAscii</code> ```zig const std = @import("std"); const utf8ToAscii = @import("anyascii").utf8ToAscii; // A full string of UTF-8 characters to ASCII characters. const ascii = try utf8ToAscii(allocator, "Blöße"); defer allocator.free(ascii); std.debug.print("{s}", .{ascii}); // Output: "Blosse". ``` Install In your project directory: <code>shell zig fetch --save https://code.zeptotech.net/zedd/anyascii.zig/archive/v1.2.0.tar.gz</code> In <code>build.zig</code>: <code>zig // Add anyascii dependency. const anyascii = b.dependency("anyascii", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("anyascii", anyascii.module("anyascii"));</code> What is anyascii? Taken from <a>official <em>anyascii</em> description</a>. AnyAscii provides ASCII-only replacement strings for practically all Unicode characters. Text is converted character-by-character without considering the context. The mappings for each script are based on popular existing romanization systems. Symbolic characters are converted based on their meaning or appearance. All ASCII characters in the input are left unchanged, every other character is replaced with printable ASCII characters.
[]
https://avatars.githubusercontent.com/u/58223424?v=4
zig-lsp-client-thing
shreyassanthu77/zig-lsp-client-thing
2024-10-19T16:53:50Z
A basic lsp client in zig
main
0
1
0
1
https://api.github.com/repos/shreyassanthu77/zig-lsp-client-thing/tags
-
[ "lsp", "lsp-client", "zig", "ziglang" ]
3
false
2024-10-19T17:41:44Z
true
true
unknown
github
[ { "commit": "6b34887189def7c859307f4a9fc436bc5f2f04c9", "name": "lsp-codegen", "tar_url": "https://github.com/zigtools/zig-lsp-codegen/archive/6b34887189def7c859307f4a9fc436bc5f2f04c9.tar.gz", "type": "remote", "url": "https://github.com/zigtools/zig-lsp-codegen" } ]
404
[]
https://avatars.githubusercontent.com/u/565124?v=4
w4-10k
peterhellberg/w4-10k
2024-09-01T06:06:10Z
null
main
0
1
0
1
https://api.github.com/repos/peterhellberg/w4-10k/tags
-
[ "gamedev", "wasm4", "zig" ]
7
false
2024-09-11T22:57:19Z
true
true
unknown
github
[ { "commit": "refs", "name": "w4", "tar_url": "https://github.com/peterhellberg/w4/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/peterhellberg/w4" } ]
w4-10k :zap: Using <a>Zig</a> to compile a <code>.wasm</code> cart for use in <a>WASM-4</a> Development File watcher can be started by calling: <code>sh zig build spy</code> Running the cart in WASM-4: <code>sh zig build run</code> Deploy: <code>make deploy</code>
[]
https://avatars.githubusercontent.com/u/11077852?v=4
zig-zag-zoe
BitPatty/zig-zag-zoe
2024-12-10T01:15:53Z
An implementation of Tic Tac Toe using Zig and SDL3
master
0
1
0
1
https://api.github.com/repos/BitPatty/zig-zag-zoe/tags
GPL-3.0
[ "sdl3", "zig" ]
72
false
2025-02-21T20:56:30Z
false
false
unknown
github
[]
Zig Zag Zoe Inspired by <a>tsoding</a>, this repository contains an implementation of Tic Tac Toe using <a>Zig</a> and <a>SDL3</a>. Preview Building <blockquote> Note that the build is configured for x86_64 only </blockquote> The project was implemented using zig 0.13.0 and libSDL3.so.0.1.7. As the time of this writing SDL3 has not been released yet and oftentimes must be built <a>"The Unix Way"</a>. The repository includes an SDL submodule that will be built together with the binary. To build the project run the following command: <code>sh make app</code> By default, the binary will be located at <code>.out/app/zig-zag-zoe</code>. For the individual build commands check the <code>Makefile</code>. Flatpak The <code>Makefile</code> contains a <code>flatpak</code> target which builds and bundles a flatpak file to <code>.out/dev.collet.ZigZagZoe</code> that can be installed on flatpak enabled environments. To explore/debug the flatpak the following command can be used post-build: <code>sh flatpak-builder --run .out/flatpak-build/ flatpak/zig-zag-zoe.flatpak.yml sh</code> License See <code>License</code>.
[]
https://avatars.githubusercontent.com/u/30123804?v=4
UEFI-Games
mathjx000/UEFI-Games
2025-01-22T19:37:46Z
Simple games running using UEFI
main
0
1
0
1
https://api.github.com/repos/mathjx000/UEFI-Games/tags
MIT
[ "uefi", "zig" ]
10
false
2025-04-12T17:04:35Z
true
true
0.14.0
github
[]
UEFI Games Simple games re-implemented for <a>UEFI</a> using the <a>Zig</a> programming language, playable directly during boot process. Contains the following games: <ul> <li><a>Connect 4</a> (WIP)</li> </ul> Building Requires <a>Zig</a> version <code>0.14.0</code>. ```sh To build all the games simply use zig build To get more info on what is available zig build --help ``` Running You can place the built <code>efi</code> files in the right place, or you can test using a virtual machine. Linux, using QEMU Example command to run: (You need to be in the right directory, which should contains <code>efi/boot/xxx.efi</code>) <code>sh qemu-system-x86_64 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -hdd fat:rw:.</code> Acknowledgements <ul> <li><a>UEFI examples in Zig</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/46653655?v=4
ascii-to-hex
BitlyTwiser/ascii-to-hex
2024-08-13T22:43:49Z
A random thing to convert ascii to hex using network sockets. Its very basic
main
0
1
0
1
https://api.github.com/repos/BitlyTwiser/ascii-to-hex/tags
-
[ "net", "network-programming", "socketserver", "zig", "ziglang" ]
10
false
2024-08-28T15:51:24Z
true
true
unknown
github
[]
Objective: The primary objetive for this little application was simply to get some exposure to some net programming in Zig. Nothing fancy, just a quick lunch break curation of works Threaded server: The server is using threads to respond to requests Client The client can send data and get back the HEX representation of the ASCII data using the same initial socket that the client connects to (bi-directional data transmissions) Build The zig build steps creates both the main application (server) and the client code.
[]
https://avatars.githubusercontent.com/u/46653655?v=4
nostro
BitlyTwiser/nostro
2024-12-24T21:16:29Z
Nostro recursively searches directories for a given input string
main
0
1
0
1
https://api.github.com/repos/BitlyTwiser/nostro/tags
MIT
[ "file-system", "zig", "ziglang" ]
218
false
2025-01-20T06:11:09Z
true
true
unknown
github
[ { "commit": "refs", "name": "snek", "tar_url": "https://github.com/BitlyTwiser/snek/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/BitlyTwiser/snek" }, { "commit": "refs", "name": "mvzr", "tar_url": "https://github.com/mnemnion/mvzr/archive/refs.tar.gz", "...
# nostro Nostro recursively searches directories for a user provided inputs. # Contents [Inputs](#inputs) | [Usage](#usage) | [Examples](#examples) | [Benchmarks](#benchmarks) | [Corpus](#corpus) | [Limitations](#limitations) | [Honorable Mentions](#honorable-mentions) | Inputs All flags are optional, if no flags (other than the mandatory <code>term</code> flag) are passed, then nostro hunt for any exact matches (strings containing the given term). Otherwise, the flags will be incorporated into the search to refine the findings. Note: <em>all</em> flags are treated as <em>or</em> statements when entered. If you enter <code>-e</code> and <code>-p</code> nostro assumes you desire <em>either</em> of the given elements to be present, so it will match if the prefix or regex match. Nostro uses the following flags to denote search string: Mandatory flags: <code>bash -term="word to search"</code> Optional flags to refine search: ```bash -path="path" // If path is not set, nostro will start from the root of your OS. THis can take a while, so generally its recommended to set a directory. -t="f or d" // Denotes if you are searching for a file or a directory. Default is to search for files unless specified otherwise -e=Optional (optional: true) -i=Optional (optional: true) ``` Usage Regular expression Utilizing the <code>-e=true</code> flag will expect a regular expression in the term field for matching/parsing of files/directories. Example: from the benchmarking code, you can ascertain the following example: <code>bash ./zig-out/bin/nostro -term='[A-Z]\w+' -path="../linux" -e=true -t=f</code> Utilizing <code>-i</code> will lowercase cast the input strings to avoid any case sensitive matching. <code>-t</code> denotes the file type. You can use: <code>t=d</code> for directory searches or just leave the default in place which searches files. Paths You can use either relative paths <code>../</code> or absolute paths <code>/home/user/Documents</code> for the <code>-path</code> argument. Outputs The output is similiar to egrep. The values, if found, are printed on individual lines to be viewed by the user Examples Examples: <code>bash ./zig-out/bin/nostro -term="firm" -path="../linux" -i=true -t=f ./zig-out/bin/nostro -term="licenses" -path="../linux" -i=true -t=d ./zig-out/bin/nostro -term="(fi)" -path="../linux" -e=true</code> Benchmarks Note: I did not make this application in any attempt to beat any existing tools out there (since plenty do this <em>exact</em> thing), but just a quick item to curate over an hour or two to try out different Zig regex engines. I did toss benchmarks in here simply for fun and to satiate my inner data nerd. I did not parake in establishing a fancy benchmarking enviornment, I utilized the following command to run the code with FIFO priority 99 on an Ubuntu liunux system to ensure CPU context switching would not interfere with the code execution: <code>bash sudo chrt -f 99 /usr/bin/time --verbose &lt;benchmark&gt;</code> <code>bash sudo chrt -f 99 /usr/bin/time --verbose ./zig-out/bin/nostro -term='[A-Z]\w+' -path="../linux" -e=true -t=f</code> Results: Corpus The linux kernel code was utilized for these expiriments: https://github.com/BurntSushi/linux It is a rather robust download, but offered a decently sized allotment of data to attempt to parse. Limitations Nostro (currently) does not read files for the given input strings, Nostro simply parses the files on disk to ascertain file names, not contents. If you wish to parse the contents of files, use <a>Ripgrep</a> or a similiar application. Honorable Mentions Initially, I thought I would re-create the wheel and make a regex parsing libary (naturally this seemed like the best idea :3 ). After some rigerous internal debate, I decided to attempt to utilize the existing Zig packages out there to see what would would best for my needs before embarking on that journey. After trying a few I landed on <a>mvzr</a> Go checkout the repo and such if you like the work :) It works well and its pretty quick and efficient <a>Top</a>
[]
https://avatars.githubusercontent.com/u/75046310?v=4
espeak-ng-zig
sweetbbak/espeak-ng-zig
2025-01-13T21:34:11Z
rhasspy phonemize fork of espeak-ng built using the Zig build system
main
0
0
0
0
https://api.github.com/repos/sweetbbak/espeak-ng-zig/tags
-
[ "espeak", "espeak-ng", "phonemes", "tts", "zig", "zig-package" ]
5
false
2025-01-24T06:03:40Z
true
true
unknown
github
[ { "commit": "0f65aa301e0d6bae5e172cc74197d32a6182200f.zip", "name": "espeak-ng", "tar_url": "https://github.com/rhasspy/espeak-ng/archive/0f65aa301e0d6bae5e172cc74197d32a6182200f.zip.tar.gz", "type": "remote", "url": "https://github.com/rhasspy/espeak-ng" } ]
The <a>rhasspy/espeak-ng</a> library packaged for the Zig build system. This build doesn't compile any of the async, audio or ucd tools and features. It is mainly used for phonemizing text. Changes in Fork Add espeak_TextToPhonemesWithTerminator function that allows getting phonemes with punctuation type back (see python_test.py) add to your project: <code>sh zig fetch --save https://github.com/sweetbbak/espeak-ng-zig/archive/refs/heads/main.zip</code> ```zig const espeak = b.dependency("espeak", .{ .target = target, .optimize = optimize, .strip = true, .pie = true, }); <code>// link with the output artifact exe.linkLibrary(espeak.artifact("espeak-ng")); // allow the headers to be included in your project const espeak_include = espeak.path("include"); exe.addIncludePath(espeak_include); </code> ``` import in your executable: <code>zig // provides  encoding.h  espeak_ng.h  speak_lib.h const c = @cImport({ @cInclude("speak_lib.h"); });</code>
[]
https://avatars.githubusercontent.com/u/103538771?v=4
DevImages
kenf1/DevImages
2024-12-04T02:34:37Z
Pre-built Docker dev images
main
0
0
0
0
https://api.github.com/repos/kenf1/DevImages/tags
GPL-3.0
[ "cpp", "cpplang", "devcontainer", "docker", "docker-image", "zig", "ziglang", "ziglings", "ziglings-exercises" ]
32
false
2025-05-20T21:36:47Z
false
false
unknown
github
[]
DevImages: Docker Dev Images Support: |Name|Description|Status| |---|---|---| |Zig|https://ziglang.org/|<a></a>| |C++|https://isocpp.org/|<a></a>| |Ziglings|https://codeberg.org/ziglings/exercises|-| Create template <code>CreateTemplate</code> is CLI tool to create Dockerfile and workflow yaml file. <code>CreateTemplate</code> intended to be run from project base path. Built for UNIX-like OS (Linux &amp; macOS). Windows not tested.
[]
https://avatars.githubusercontent.com/u/633183?v=4
args-lex
knutwalker/args-lex
2024-12-01T09:10:39Z
A commandline arguments lexer for Zig
main
0
0
0
0
https://api.github.com/repos/knutwalker/args-lex/tags
MIT
[ "argparse", "clap", "cli", "zig" ]
143
false
2025-03-22T18:40:32Z
true
true
0.14.0-dev.3445+6c3cbb0c8
github
[]
args_lex <a></a> A lexer to parse command line arguments <blockquote> <span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span> This is not a full CLI parser. A lot of functionality is intentionally missing. </blockquote> Features / Parsing capabilities* <ul> <li>Long arguments: <code>--flag</code><ul> <li>values separated by space or <code>=</code> (<code>--flag=value</code>, <code>--flag value</code>)</li> <li>multiple occurrences: <code>--flag one --flag two</code></li> </ul> </li> <li>Short arguments: <code>-a</code><ul> <li>multiple flags grouped together: <code>-abc</code></li> <li>values separated by space or <code>=</code> (<code>-a=value</code>, <code>-a value</code>, <code>-avalue</code>)</li> <li>repeated flags: <code>-vvvv</code></li> </ul> </li> <li>Positional arguments: <code>arg</code><ul> <li>escaping remaining arguments after <code>--</code></li> </ul> </li> </ul> <em>*</em>: Some of those features are not directly implemented by this library. However, parsers written using the lexer can choose to support those features and are not locked out of anything. Non-Features <ul> <li>help generation</li> <li>arguments to type mapping</li> <li>builder API</li> </ul> Installation Update to latest version: <code>sh zig fetch --save git+https://github.com/knutwalker/args-lex.git</code> Add to <code>build.zig</code>: <code>zig exe.root_module.addImport("args_lex", b.dependency("args_lex", .{}).module("args_lex"));</code> <blockquote> <span class="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">IMPORTANT</span> <code>args_lex</code> tracks Zig <code>0.14.0</code> </blockquote> Examples Demo A simple demo, showing the basics of the API: ```zig const std = @import("std"); const args_lex = @import("args_lex"); pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); <code>var args = try args_lex.Args.init(arena.allocator()); defer args.deinit(); while (args.next()) |arg| { switch (arg) { .escape =&gt; while (args.nextAsValue()) |value| { std.debug.print("POSITIONAL: {s}\n", .{value}); }, .shorts =&gt; |shorts_arg| { var shorts = shorts_arg; while (shorts.next()) |short| switch (short) { .flag =&gt; |flag| std.debug.print("-{u}\n", .{flag}), .suffix =&gt; |s| std.debug.print("non utf8 flag: {any}\n", .{s}), }; }, .long =&gt; |long| { std.debug.print("--{s}", .{long.flag}); if (long.value) |v| std.debug.print("={s}", .{v}); std.debug.print("\n", .{}); }, .value =&gt; |v| std.debug.print("POSITIONAL: {s}\n", .{v}), } } </code> } ``` Usage A more detailed example showing more usage patterns: ```zig const std = @import("std"); const args_lex = @import("args_lex"); pub fn main() !void { var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{}; defer _ = gpa.deinit(); const alloc = gpa.allocator(); <code>// The args should be provided by build.zig as: // `"-a -42 -bcdef --flag --long=value --also yes -- remaining --args"` // The lexer does not map automatically to types, we can do this on our own. const MyOptions = struct { a: i32 = -1, b: bool = false, c: ?[:0]const u8 = null, flag: bool = false, long: [:0]const u8 = "default", also: enum { auto, yes, no } = .auto, remainder: ?[]const [:0]const u8 = null, }; // Args can be read lazily (and on POSIX systems without allocations) // by using `Args`, which uses `std.process.args` internally. var process_args = try args_lex.Args.init(alloc); // This should be a `defer` instead of the `errdefer`. // In this example, we explicitly ``deinit` the args lexer to test for // dangling pointers and use-after-free. errdefer process_args.deinit(); // Process args can be read from an existing allocation with `SliceArgs`. // This can be used for args from `argsAlloc` const args_alloc = try std.process.argsAlloc(alloc); defer std.process.argsFree(alloc, args_alloc); var slice_args = args_lex.SliceArgs.init(args_alloc); errdefer slice_args.deinit(); // One benefit of SliceArgs is that they can be reset with `reset`. // One might, for example, do a first pass to check for `--help`, // then `reset` and do a second pass for the actual parsing. // We can also use `std.os.argv` if it is supported by the OS. var args_impls = if (comptime args_lex.OsArgs.isSupported()) impls: { const os_args = args_lex.OsArgs.init(); break :impls .{ process_args, slice_args, os_args }; } else .{ process_args, slice_args }; inline for (&amp;args_impls) |*args| { // Skip the binary name _ = args.nextAsValue().?; // Initialize the result type with all defaults. // If some args are required, they need to be wrapped in an option // and validated after the loop. var options: MyOptions = .{}; // The main lexing loop. `next` will return an `*Arg`. // Don't store to pointers without making a copy, // every call to `next` will invalidate those pointers. // Calling `next` (or any of its variants) will never fail or panic. // A `null` indicated the end of the arguments list. while (args.next()) |arg| { switch (arg) { // `arg` is the `--` escape. Usually that means that the remaining // args are no longer supposed to be parsed. // That decision is up to the user, and we are doing just that. .escape =&gt; { var remainder = std.ArrayList([:0]const u8).init(alloc); defer remainder.deinit(); // `nextAsValue` will return the next args without any parsing while (args.nextAsValue()) |arg_value| { // The slices returned by any "value" like access are // invalidated when `deinit` is called. // It is recommended to `dupe` any slice that should // remain valid after the parsing is done. const value = try alloc.dupeZ(u8, arg_value); try remainder.append(value); } options.remainder = try remainder.toOwnedSlice(); }, // `arg` is one or more short flags, or a negative number. // That is, it starts with `-`, but not with `--`. .shorts =&gt; |shorts_arg| { // Command line parsers often do not support negative numbers, // because it is ambiguous. We can choose to look for negative // numbers and treat is as a `value` instead. In this example, // we imply that any negative number must be for the `a` flag. if (shorts_arg.looks_like_number()) { // `value` will return everything *after* the leading `-`, // so we need to negate the number on our own. options.a = -(try std.fmt.parseInt(i32, shorts_arg.peekValue(), 10)); continue; } // Iterate over any short flag. There is no special handling // of `=` done in `next`. var shorts = shorts_arg; while (shorts.next()) |short| switch (short) { // The typical case, where the short flag is a valid // Unicode codepoint (`flag` here is a `u21`). .flag =&gt; |flag| switch (flag) { // allow, but ignore a flag 'a' =&gt; {}, // flag is given, here we set the option to `true` 'b' =&gt; options.b = true, // short flags can also take a value, optionally separated // with a `=`. When we see the `c` flag, we take the // remainder as its value. 'c' =&gt; options.c = try alloc.dupeZ(u8, shorts.value()), else =&gt; return error.UnknownFlag, }, // In case we encounter an invalid Unicode sequence as // short flags, the parser bails and returns the remainder // as an unparsed suffix. It is up to the user to decide // what to do in this case. .suffix =&gt; return error.UnknownFlag, }; }, // `arg` is a long flag. // That is it starts with `--` and is not just `--` (`.escape`). .long =&gt; |long| { // we can check for the actual arg using `flag` and `value`. if (std.mem.eql(u8, long.flag, "flag")) { // Some flags are not allowed to take values, // we can check for that. if (long.value) |_| { return error.UnexpectedValue; } options.flag = true; } else if (std.mem.eql(u8, long.flag, "long")) { // the provided `value` is only set if it was given using the // `--flag=value` syntax, but often `--flag value` should // also be allowed. We can use `nextAsValue` to take the next // argument as value, no matter how it looks. // Here, the flag also requires a value. const value = long.value orelse (args.nextAsValue() orelse return error.MissingValue); options.long = try alloc.dupeZ(u8, value); } else if (std.mem.eql(u8, long.flag, "also")) { // Here, the flag has an optional value. const value = long.value orelse args.nextAsValue(); // If there is a value, we can validate it. // Here, we only allow values that are enum tags. // A missing value will default to the `.auto` option. options.also = if (value) |v| (std.meta.stringToEnum(@TypeOf(options.also), v) orelse return error.UnknownValueForEnumFlag) else .auto; } else { return error.UnknownFlag; } }, // Any plain value that is not a `-` short flag, `--` long flag // or the special value `--` (`.escape`). // It is up to the user to decide what to do. // Those might be a subcommand, a freestanding/positional args, // or - depending on how the parsing loop is written - values for // a previous short or long option. // Here, we don't allow those args. .value =&gt; return error.UnexpectedValueBeforeEscape, } } // print the result so that we can see something in the example std.debug.print( \\Parsed options using {s}: \\ --a: {} \\ --b: {} \\ --c: {?s} \\ --flag: {} \\ --long: {s} \\ --also: {s} \\ --remainder: {?s} \\ , .{ @typeName(@TypeOf(args.*)), options.a, options.b, options.c, options.flag, options.long, @tagName(options.also), options.remainder, }); // explicit call to test that we don't have values pointing to the args buffer. // Usually, this would be done by `defer args.deinit()`. args.deinit(); // validate that we parsed into the same result for any impl const expected = MyOptions{ .a = -42, .b = true, .c = "def", .flag = true, .long = "value", .also = .yes, .remainder = &amp;[_][:0]const u8{ "remaining", "--args" }, }; defer { if (options.c) |c| alloc.free(c); alloc.free(options.long); if (options.remainder) |remainder| { for (remainder) |value| alloc.free(value); alloc.free(remainder); } } try std.testing.expectEqualDeep(expected, options); } </code> } ``` License args_lex is licensed under the <a>MIT License</a>
[]
https://avatars.githubusercontent.com/u/77182807?v=4
npzigloc
hansalemaos/npzigloc
2024-09-09T08:58:13Z
Zig for Numpy
main
0
0
0
0
https://api.github.com/repos/hansalemaos/npzigloc/tags
MIT
[ "numpy", "python", "zig" ]
35
false
2024-09-09T09:20:32Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/32679919?v=4
base64
vkondratiuk482/base64
2024-11-01T23:42:12Z
Base64 encoder / decoder
main
2
0
0
0
https://api.github.com/repos/vkondratiuk482/base64/tags
-
[ "base64", "encoding", "zig" ]
5
false
2024-11-16T02:04:05Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/152508846?v=4
ffmpegz
haha-systems/ffmpegz
2025-01-16T04:11:52Z
an example of binding to ffmpeg in zig
main
0
0
0
0
https://api.github.com/repos/haha-systems/ffmpegz/tags
-
[ "ffmpeg", "zig", "ziglang" ]
6
false
2025-01-16T04:23:01Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/80978939?v=4
tasai-zig
Didas-git/tasai-zig
2025-01-07T20:17:39Z
A set of tools for dealing with the terminal.
main
1
0
0
0
https://api.github.com/repos/Didas-git/tasai-zig/tags
-
[ "zig", "zig-library", "zig-package", "ziglang" ]
228
false
2025-02-11T22:54:00Z
true
true
0.13.0
github
[]
Tasai Tasai is a zig library that provides multiple comptime utilities to colorize your terminal messages, logs, and much more, if it supports <a>ANSI escape codes</a> then tasai will work. Let's make our terminals more colorful (多彩). If you are looking for the javascript/typescript version, it can be found <a>here</a>. Installation Tasai is available using the <code>zig fetch</code> command. <code>sh zig fetch --save git+https://github.com/Didas-git/tasai-zig</code> To add it yo your project, after running the command above add the following to your build file: <code>zig const tasai = b.dependency("tasai", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("tasai", tasai.module("tasai"));</code> Usage Tasai provides 2 different comptime apis String API The available tags are documented on the function itself. ```zig const print = @import("std").debug.print; const SGR = @import("tasai").SGR; // Print "hello" in pink (with a hex code) and "world" in bold blue (the blue comes from the 8bit ANSI codes) print(SGR.parseString("hello <b>world\n"), .{}); // Escaping '&lt;' print(SGR.parseString("This will print \&lt; in red\n"), .{}); ``` Verbose API While this API is rather overkill it can be rather useful given it includes all* the SGR codes and is not limited to a few set of them. * all the ones documented <a>here</a>. ```zig const print = @import("std").debug.print; const SGR = @import("tasai").SGR; // // Print "hello" in pink (with a hex code) and "world" in bold blue print("{s} {s}\n", .{ SGR.verboseFormat("Hello", &amp;.{ .{ .Color = .{ .Foreground = .{ .@"24bit" = .{ .r = 255, .g = 0, .b = 239 } } } }, }, &amp;.{ .{ .Attribute = .Default_Foreground_Color }, }), SGR.verboseFormat("World", &amp;.{ .{ .Attribute = .Bold }, .{ .Color = .{ .Foreground = .{ .@"8bit" = 33 } } }, }, &amp;.{ .{ .Attribute = .Not_Bold_Or_Dim }, .{ .Attribute = .Default_Foreground_Color }, }), }); ```</b>
[]
https://avatars.githubusercontent.com/u/111981004?v=4
zeld
vishruth-thimmaiah/zeld
2024-12-19T11:40:03Z
A (WIP) linker built with zig, for x86-64 elf binaries.
master
0
0
0
0
https://api.github.com/repos/vishruth-thimmaiah/zeld/tags
BSD-3-Clause
[ "elf64", "linker", "zig" ]
165
false
2025-05-20T17:54:58Z
true
true
0.11.0
github
[]
Zeld A basic linker built with zig, that can link Elf64 files. <a></a> <blockquote> <strong>Project Naming and Inspiration</strong> This project is named after <a>The Legend of Zelda game series</a>, and its aptly named protagonist, Link. In keeping with the common convention for linker names to end in 'ld'(examples: ld, lld, gold, mold), this project follows a similar pattern. Additionally, since it is written in Zig, the name begins with 'z'. <span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span> This is a small project I made to learn the basics of linking ELF files. </blockquote> Build: <code>bash zig build</code> Run: <code>bash zig build run -- &lt;path to files&gt;</code> Running the given examples Generating relocatables <code>bash gcc -o examples/2/test.o examples/2/test.c -c gcc -o examples/2/main.o examples/2/main.c -c zig build run -- -r examples/2/test.o examples/2/main.o -o output.o gcc -o output output.o # Build an executable from the generated relocatable.</code> Generating executables <code>bash gcc -o examples/3/main.o examples/3/main.s -c zig build run -- examples/3/main.o -o output</code> Using clang as your compiler <em>should</em> also work. Running tests <code>bash zig build test</code> ELF specification <a>elf.pdf</a> You can also check out <code>/usr/include/elf.h</code>. Projects that I've referenced <ul> <li><a>byo-linker</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/89275?v=4
mup
dgv/mup
2024-08-30T22:47:51Z
A micro file uploader written in Zig to easily share files over LAN
main
0
0
0
0
https://api.github.com/repos/dgv/mup/tags
MIT
[ "download", "upload", "upload-file", "uploader", "zig", "ziglang" ]
70
false
2025-03-11T10:49:14Z
true
true
0.13.0
github
[ { "commit": "refs", "name": "httpz", "tar_url": "https://github.com/karlseguin/http.zig/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/karlseguin/http.zig" }, { "commit": "refs", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/refs.tar.g...
μploader - Micro Uploader <a></a> <a></a> <a></a> <a></a> Rewritten of <a>mup</a>, a simple file uploader that can be used to easily move and share files across the local network between devices with a web browser. It only uses <a>httpz</a> and <a>zig-clap</a> as dependencies and provide a statically linked binary. Motivation <a>@aziis98</a>: <em>Sometimes I want to move files between my pc and a device I do not own that has an old browser version (that generally means expired https certificates, oh and without any cables). When I try to search for a tool like this I always find random outdated projects that aren't easy to setup. So I made this tool that can be easily installed on all linux systems.</em> <a>@dgv</a>: <em>size comparison</em> ```bash go binary striping symbol and debug info..tinygo? $ go build -ldflags "-s -w"; du mup 16704 mup ... zig binary -65x $ zig build --release=small; du zig-out/bin/mup 256 zig-out/bin/mup ``` Git ```bash $ git clone https://github.com/dgv/mup $ cd mup Run the server $ zig build run Build the binary $ zig build ``` Dockerfile I provide this just to easily deploy on a local server. I <strong>do not recomend to expose this publicly</strong> on the web as there is no auth or password and there is no upload limit to the number of files and all files in the <code>Uploads/</code> folder are public by default for now. <code>bash shell $ docker build -t mup . $ docker run -p 5000:5000 -v $PWD/uploads:/uploads mup</code> Usage ```bash $ mup --help -h, --help Display this help and exit. <code>-s, --size &lt;usize&gt; Maximum upload size in MB. -p, --port &lt;u16&gt; Port to run the server on. -a, --addr &lt;str&gt; Address to run the server on. -d, --dir &lt;str&gt; Upload directory to serve files. </code> ```
[]
https://avatars.githubusercontent.com/u/24510271?v=4
advent_of_code_2015
andreiyard/advent_of_code_2015
2025-01-22T12:31:21Z
My solutions to 2015 Advent of Code (https://adventofcode.com/2015) written in Zig
main
0
0
0
0
https://api.github.com/repos/andreiyard/advent_of_code_2015/tags
-
[ "advent-of-code", "zig" ]
19
false
2025-01-25T17:56:35Z
true
true
unknown
github
[]
Advent of Code 2015 in Zig Usage: <ol> <li>Use init_day.sh to init solution directory in <code>src/</code></li> <li>Put your task input to <code>src/dayXX/input.txt</code></li> <li>Write your code solutions in <code>src/dayXX/main.zig</code></li> <li>Build and run (see <a>Build and run</a>)</li> </ol> Build and run: <ul> <li>To build all days run <code>zig build --summary all</code> Arg <code>run</code> can be added, to also run all compiled solutions</li> <li>To build and run single day use <code>zig build -Dday=&lt;day_number&gt; run</code></li> </ul> TODO: <ul> <li>~~init_day.sh script to create default day dir layout~~</li> <li>~~init_day.sh change all path to be relative to script, not cwd~~</li> <li>~~build.zig that iterates over all day dirs, compiles and runs solutions~~</li> <li>~~build option <code>-Dday=&lt;daynum&gt;</code> to compile and run single day~~</li> <li>~~day1 solution~~</li> <li>~~what is the best way to read an input? (I choose @embedFile)~~</li> <li>build option <code>-Dexample=&lt;examplenum&gt;</code> that shows that we need to use example input with some number instead of main input</li> <li>build option <code>-Dseq</code> to run solutions sequentially (1,2,3...)</li> </ul>
[]
https://avatars.githubusercontent.com/u/48863749?v=4
noice
Dan149/noice
2024-12-01T16:39:07Z
OTP (one-time pad) encryption CLI tool.
main
0
0
0
0
https://api.github.com/repos/Dan149/noice/tags
MIT
[ "blazingly-fast", "cipher", "cli", "cryptography", "encryption", "encryption-decryption", "one-time-pad", "open-source", "otp", "zig", "ziglang" ]
12
false
2024-12-07T17:48:26Z
true
true
unknown
github
[ { "commit": "master", "name": "zarginator", "tar_url": "https://github.com/Dan149/zarginator//archive/master.tar.gz", "type": "remote", "url": "https://github.com/Dan149/zarginator/" } ]
Noice: A One-Time Pad (OTP) Encryption CLI Tool Noice is a command-line interface (CLI) tool designed to implement One-Time Pad (OTP) encryption. Written in the Zig programming language, Noice provides a fast, secure, and reliable way to cipher and decipher messages using the OTP encryption scheme. It also includes a token generator to facilitate the secure sharing of the encryption key, which is crucial for the OTP method. What is One-Time Pad (OTP)? One-Time Pad (OTP) is a symmetric encryption technique where a plaintext message is combined with a random key (or pad) of the same length. Each character in the plaintext is XORed with the corresponding character in the key, resulting in ciphertext that is completely random and theoretically unbreakable, provided certain conditions are met: <ol> <li><strong>The key is truly random</strong>: The key must be generated in such a way that it cannot be predicted or reproduced.</li> <li><strong>The key is as long as the plaintext</strong>: For OTP to be secure, the key must be at least as long as the message being encrypted.</li> <li><strong>The key is used only once</strong>: The key must never be reused for another message, hence the name "one-time."</li> </ol> OTP encryption provides perfect secrecy and has been proven mathematically to be secure if the above conditions are met. Why Zig? Zig is a systems programming language designed for simplicity, safety, and performance. Choosing Zig to implement Noice provides several benefits: <ul> <li><strong>Performance</strong>: Zig is a compiled language that generates highly optimized binaries. It is known for its low overhead and minimal runtime, which is ideal for cryptographic applications where performance is crucial.</li> <li><strong>Memory Safety</strong>: Zig provides strong compile-time checks that reduce the risk of bugs, such as buffer overflows, which are especially important in security-critical applications.</li> <li><strong>Cross-compilation</strong>: Zig makes it easy to compile to various platforms, making Noice easily portable to different operating systems and architectures without requiring complex setup.</li> <li><strong>Simplicity</strong>: Zig's syntax is straightforward, and it avoids unnecessary abstractions, providing a clear and concise implementation that is easy to understand and maintain.</li> </ul> By using Zig, Noice leverages the power of a low-level language while benefiting from strong safety features, speed, and portability. Key Security Note Since OTP encryption relies on the secrecy of the key, it is essential that the key is never transmitted in plaintext over insecure channels. Use secure methods (e.g., physical transfer, encrypted communication) to share the one-time pad between the sender and the recipient.
[]
https://avatars.githubusercontent.com/u/62800118?v=4
zregex
thng292/zregex
2025-02-01T10:30:33Z
Zig bindings for POSIX's regex
main
0
0
0
0
https://api.github.com/repos/thng292/zregex/tags
MIT
[ "regex", "zig" ]
5
false
2025-02-01T14:00:27Z
true
true
unknown
github
[]
zregex: POSIX's regex bindings for zig This library wraps the C regex library and provides a convenient API. Compatible with zig version <code>0.13.0</code> Note: This library used the C's allocator to allocate the memory for <code>regex_t</code> struct. More info at <a>adapter.c</a> Installation <ol> <li>Run <code>zig fetch --save git+https://github.com/thng292/zregex.git</code></li> <li>In your <code>build.zig</code></li> </ol> ```zig const zregex = b.dependency("zregex", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zregex", zregex.module("zregex")); ``` Usage / Quick start guide 1. Initialize ```zig const Regex = @import("zregex"); const regex = try Regex.init("[0-9]\{1\}", .{}); defer regex.deinit(); ``` 2. Check if some input matches pattern <code>zig try std.testing.expect(regex.match("12312", .{})); try std.testing.expect(!regex.match("abc", .{}));</code> 3. Exec iterator ```zig const regex = try Regex.init("[ab]c", .{}); defer regex.deinit(); var iter = regex.exec("bc cc", .{}); if (iter.next()) |matched| { try std.testing.expectEqualStrings("bc", matched); } if (iter.next()) |matched| { try std.testing.expectEqualStrings("cc", matched); } if (iter.next()) |_| { unreachable; } ``` 4. Get number of sub-expressions ```zig const regex = try Regex.init("\([ab]c\)", .{}); defer regex.deinit(); try std.testing.expectEqual(1, regex.getNumSubexpression()); ``` Error map <code>zig fn cerrToZig(err_num: c_int) Error { return switch (err_num) { c.REG_NOMATCH =&gt; error.NoMatch, c.REG_BADPAT =&gt; error.InvalidRegex, c.REG_ECOLLATE =&gt; error.InvalidCollate, c.REG_ECTYPE =&gt; error.InvalidClassType, c.REG_EESCAPE =&gt; error.TrailingBackSlash, c.REG_ESUBREG =&gt; error.InvalidNumberInDigit, c.REG_EBRACK =&gt; error.BracketImbalance, c.REG_EPAREN =&gt; error.ParenthesisImbalance, c.REG_EBRACE =&gt; error.BraceImbalance, c.REG_BADBR =&gt; error.InvalidContentInBrace, c.REG_ERANGE =&gt; error.InvalidEndpoint, c.REG_ESPACE =&gt; error.OutOfMemory, c.REG_BADRPT =&gt; error.InvalidRepeatQuantifier, c.REG_ENOSYS =&gt; error.NotImplemented, else =&gt; error.Unknown, }; }</code> References <ul> <li>https://cookbook.ziglang.cc/15-01-regex.html</li> <li>https://github.com/skota-io/libregex-z</li> <li>https://pubs.opengroup.org/onlinepubs/7908799/xsh/regexec.html</li> </ul>
[]
https://avatars.githubusercontent.com/u/58193253?v=4
debt-profit
epilif3sotnas/debt-profit
2024-08-19T18:56:15Z
A calculator to see if it is profitable to get debt to invest.
main
0
0
0
0
https://api.github.com/repos/epilif3sotnas/debt-profit/tags
Apache-2.0
[ "debt", "financial", "investment", "zig" ]
29
false
2024-12-05T07:29:15Z
true
true
0.13.0
github
[ { "commit": "e9293645250e2bc172f100bb0467aea55b1d4f3e", "name": "yazap", "tar_url": "https://github.com/prajwalch/yazap/archive/e9293645250e2bc172f100bb0467aea55b1d4f3e.tar.gz", "type": "remote", "url": "https://github.com/prajwalch/yazap" } ]
404
[]
https://avatars.githubusercontent.com/u/54745129?v=4
advent_of_code_2024
krish-r/advent_of_code_2024
2024-12-01T14:42:20Z
Advent of Code 2024
main
0
0
0
0
https://api.github.com/repos/krish-r/advent_of_code_2024/tags
MIT
[ "zig" ]
3
false
2024-12-01T14:44:53Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/2773256?v=4
zig-libarchive
dasimmet/zig-libarchive
2024-12-22T22:36:35Z
www.libarchive.org
main
0
0
0
0
https://api.github.com/repos/dasimmet/zig-libarchive/tags
MIT
[ "zig", "zig-package" ]
19
true
2025-03-29T00:16:29Z
true
true
unknown
github
[]
libarchive This is <a>libarchive</a>, packaged for <a>Zig</a>.
[]
https://avatars.githubusercontent.com/u/3868549?v=4
zig-present
sea-grass/zig-present
2024-08-09T18:11:40Z
A command-line tool for running interactive TUI presentations.
main
0
0
0
0
https://api.github.com/repos/sea-grass/zig-present/tags
MIT
[ "presentation", "tui", "zig" ]
115
false
2025-04-20T15:41:19Z
true
false
unknown
github
[]
zig-present <code>zig-present</code> is a command-line tool for creating interactive TUI presentations. ![Demo video of running the zig-present software in a terminal session](./doc/demo.gif) Example Presentations are expressed in a simple text format. Here's an example presentation: ```txt !zig-present Coffee Brewing How to brew coffee with a french press /next_slide What you'll need: <ul> <li>French press</li> <li>Ground coffee beans</li> <li>Boiling water</li> </ul> /next_slide Steps <ol> <li>Add ground coffee beans to the french press</li> <li>Add 1 cup of boiling water to the french press, per 7g of coffee beans</li> <li>Cover the french press with the lid</li> <li>Wait 8 minutes</li> <li>Push the plunger down slowly</li> <li>Pour and enjoy ```</li> </ol> Requirements <ul> <li>Officially supported Zig: <code>Zig 0.13.0-dev.351+64ef45eb0</code> (you can get it from the <a>Zig Releases page</a>)</li> </ul> Installation Use Zig to build the application binary. With a shell open in this project's directory: <code>zig build -Doptimize=ReleaseSafe</code> The binary will be available at <code>zig-out/bin/zig-present</code>. Usage See the <a>Example</a> for a sample presentation file or the <a>Presentation</a> section for info on the available presentation commands. Store this in a file with the .txt extension, like <code>presentation.txt</code>. Then, you can start the presentation like this: <code>$ zig-present presentation.txt</code> Presentation Every zig-present file must start with the line <code>!zig-present</code>. Lines starting with a <code>/</code> denote a command. All other lines are interpreted as text to print (empty lines and whitespace are preserved). The most important command is <code>/next_slide</code>, which effectively creates a new slide within the presentation. See <a>Commands</a> for all of the commands. Commands A presentation file can contain pre-defined commands. See the following table for a glossary: | Command | Description | Example Usage | |----|---|---| | <code>/next_slide</code> | Adds a pause in the presentation, waiting for the user to press enter. Then, will clear the screen and continue the presentation. You may optionally provide a prompt to be displayed beside the cursor. | <code>/next_slide Go to next slide</code> | | <code>/docker</code> | Run the docker command, for example to provide the user with an interactive shell. | <code>/docker run -it busybox sh</code> | | <code>/stdout</code> | Run the shell command and print the result. | <code>/stdout date</code> | | <code>/pause</code> | Adds a pause in the presentation, waiting for the user to press enter. Does not clear the screen when the user hits enter. You may optionally provide a prompt to be displayed beside the cursor. | <code>/pause Hit enter when you know the answer.</code> |
[]
https://avatars.githubusercontent.com/u/117922632?v=4
zzd
lvkolb/zzd
2024-12-28T16:40:56Z
Project to give an introduction and start learning Zig for a university course. A hexdump utility built with Zig that helps you inspect binary content in a human-readable format.
main
0
0
0
0
https://api.github.com/repos/lvkolb/zzd/tags
MIT
[ "beginner-code", "hexdump", "learning-exercise", "learning-project", "zig", "ziglang" ]
5,907
false
2024-12-28T18:06:14Z
true
false
unknown
github
[]
zzd <a></a> Project to give an introduction and start learning Zig for a university course. A hexdump utility built with Zig that helps you inspect binary content in a human-readable format. Features <ul> <li>Cross-platform support (Windows, Linux, macOS)</li> <li>Flexible display options and number formats</li> <li>Pattern highlighting capabilities</li> <li>Customizable output formatting</li> </ul> Prerequisites Before installing <code>zzd</code>, ensure you have <a>Zig</a> installed on your system. Installation 1. Clone the Repository <code>bash git clone https://github.com/lvkolb/zzd.git cd zzd</code> 2. Build and Install Choose one of the following installation methods: Method A: Global Installation ```bash Build and install to /usr/local/bin (requires admin privileges) zig build install-to-bin ``` Method B: Local Build ```bash Just build the project zig build ``` Usage Basic Command <code>bash zzd &lt;filename&gt; [options]</code> Platform-Specific Paths Windows <code>bash zig-out\bin\zzd &lt;filename&gt; [options]</code> Linux/macOS <code>bash zig-out/bin/zzd &lt;filename&gt; [options]</code> Command-Line Options Display Options <code>--line-length=&lt;n&gt; Set the number of bytes per line (default: 16, max: 64) --group=&lt;n&gt; Group bytes in sets of n (default: 1) --no-ascii Don't display ASCII representation --no-offset Don't display offset column --color=&lt;n&gt; Set color display mode</code> Number Format Options <code>(default: hex) Display numbers in hexadecimal --decimal Display numbers in decimal --octal Display numbers in octal --binary Display numbers in binary</code> Data Selection <code>--limit=&lt;n&gt; Limit the number of bytes displayed --skip=&lt;n&gt; Skip first n bytes of input</code> Pattern Matching <code>--highlight=&lt;hex&gt; Highlight specific byte sequences (can be used multiple times)</code> Examples Basic File Analysis ```bash Display a file in default hexadecimal format zzd sequence.bin zig-out\bin\zzd zzd sequence.bin zig-out/bin/zzd zzd sequence.bin Display with custom line length and grouping zzd sequence.bin --line-length=32 --group=4 zig-out\bin\zzd zzd sequence.bin --line-length=32 --group=4 zig-out/bin/zzd zzd sequence.bin --line-length=32 --group=4 Show only decimal values without ASCII zzd sequence.bin --decimal --no-ascii zig-out\bin\zzd zzd sequence.bin --decimal --no-ascii zig-out/bin/zzd zzd sequence.bin --decimal --no-ascii ``` Advanced Usage ```bash Skip first 100 bytes and limit output to 500 bytes zzd large_file.bin --skip=100 --limit=500 zig-out\bin\zzd zzd large_file.bin --skip=100 --limit=500 zig-out/bin/zzd zzd large_file.bin --skip=100 --limit=500 Highlight specific byte patterns zzd firmware.bin --highlight=FF00 --highlight=A5 zig-out\bin\zzd zzd firmware.bin --highlight=FF00 --highlight=A5 zig-out/bin/zzd zzd firmware.bin --highlight=FF00 --highlight=A5 Custom formatting with binary output zzd data.bin --binary --line-length=8 --group=4 zig-out\bin\zzd zzd data.bin --binary --line-length=8 --group=4 zig-out/bin/zzd zzd data.bin --binary --line-length=8 --group=4 ``` License This project is licensed under the MIT License - see the <a>LICENSE</a> file for details
[]
https://avatars.githubusercontent.com/u/30217066?v=4
advent-of-code-zig
pesnik/advent-of-code-zig
2025-01-07T15:31:20Z
This repository contains my solutions to the Advent of Code problems, written in Zig. The project is structured to support development, testing, benchmarking, performance analysis, and visualization.
master
0
0
0
0
https://api.github.com/repos/pesnik/advent-of-code-zig/tags
-
[ "advent-of-code", "zig", "ziglang" ]
2,365
false
2025-01-31T13:21:30Z
true
true
unknown
github
[]
Advent of Code Zig Solutions This repository contains my solutions to the Advent of Code problems, written in Zig. The project is structured to support development, testing, benchmarking, performance analysis, and visualization. Project Structure <code>plaintext advent-of-code-zig/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows/ │ ├── ci.yml │ ├── release.yml │ ├── security.yml │ ├── performance.yml │ └── docs.yml ├── .vscode/ │ ├── settings.json │ ├── tasks.json │ └── launch.json ├── src/ │ ├── common/ │ │ ├── parsing.zig │ │ ├── grid.zig │ │ ├── math.zig │ │ └── testing.zig │ ├── year2023/ │ │ ├── solutions/ │ │ │ ├── day01.zig │ │ │ └── day02.zig │ │ ├── main.zig │ │ └── solutions.zig │ ├── year2022/ │ ├── platform/ │ │ ├── windows.zig │ │ ├── linux.zig │ │ └── darwin.zig │ └── main.zig ├── bench/ │ ├── bench.zig │ └── benchmarks/ │ ├── year2023/ │ │ └── day01_bench.zig │ └── year2022/ │ └── day01_bench.zig ├── fuzz/ │ ├── fuzz.zig │ └── fuzzers/ │ ├── year2023/ │ │ └── day01_fuzz.zig │ └── year2022/ │ └── day01_fuzz.zig ├── tools/ │ ├── scripts/ │ │ ├── new-day.zig │ │ ├── benchmark.zig │ │ └── generate-docs.zig │ ├── lint/ │ │ └── custom-checks.zig │ ├── test/ │ │ ├── coverage.zig │ │ └── runner.zig │ ├── perf/ │ │ ├── trace.zig │ │ └── analyze.zig │ ├── debug/ │ │ ├── heap.zig │ │ └── logger.zig │ ├── release/ │ │ ├── changelog.zig │ │ └── versioning.zig │ └── ci/ │ ├── metrics.zig │ └── report.zig ├── input/ │ ├── 2023/ │ │ ├── day01.txt │ │ └── day01_test.txt │ └── 2022/ ├── deps/ │ └── helpful-lib/ ├── docs/ │ ├── api/ │ ├── algorithms/ │ ├── performance/ │ ├── design/ │ └── tutorials/ ├── examples/ │ ├── algorithms/ │ ├── optimizations/ │ └── patterns/ ├── test/ │ ├── integration/ │ ├── benchmark/ │ ├── fuzz/ │ └── fixtures/ ├── profile/ │ ├── memory/ │ ├── cpu/ │ └── reports/ ├── perf/ │ ├── benchmarks/ │ ├── flamegraphs/ │ └── optimization/ ├── debug/ │ ├── memory/ │ ├── trace/ │ └── logs/ ├── visualization/ │ ├── graphs/ │ ├── images/ │ ├── interactive/ │ └── scripts/ ├── .gitignore ├── .editorconfig ├── build.zig ├── build.zig.zon ├── gyro.zzz ├── zig.mod ├── CONTRIBUTING.md └── README.md</code> Key Features <ul> <li><strong>Solutions</strong>: Advent of Code solutions organized by year and day.</li> <li><strong>Benchmarks</strong>: Microbenchmarks for individual solutions.</li> <li><strong>Performance Analysis</strong>: Tools for profiling, optimization, and visualization.</li> <li><strong>Visualization</strong>: Graphs, images, and interactive models to explore solutions.</li> <li><strong>Testing</strong>: Unit tests, integration tests, and fuzz tests.</li> <li><strong>Documentation</strong>: API docs, design decisions, and tutorials.</li> <li><strong>CI/CD</strong>: Automated testing, security scanning, and release management.</li> </ul> How to Use <ol> <li> <strong>Build the Project</strong>: <code>bash zig build</code> </li> <li> <strong>Run a Solution</strong>: <code>bash zig build run -Dyear=2023 -Dday=1</code> </li> <li> <strong>Run Benchmarks</strong>: <code>bash zig build bench -Dyear=2023 -Dday=1</code> </li> <li> <strong>Generate Visualizations</strong>: <code>bash zig build visualize -Dyear=2023 -Dday=1</code> </li> <li> <strong>View Documentation</strong>: <code>bash zig build docs</code> </li> </ol> Contributing Please read <a>CONTRIBUTING.md</a> for details on how to contribute to this project. License This project is licensed under the MIT License. See the <a>LICENSE</a> file for details.
[]
https://avatars.githubusercontent.com/u/24510271?v=4
network-programming
andreiyard/network-programming
2025-01-09T23:24:43Z
Repository to try and learn network programming using C and Zig
main
0
0
0
0
https://api.github.com/repos/andreiyard/network-programming/tags
-
[ "c", "network-programming", "sockets", "zig" ]
10
false
2025-01-13T21:48:44Z
true
true
unknown
github
[]
Network programming This is my small repository to try and learn network programming using C and Zig programming languages How to build and run? <code>zig build -Dtarget_exe=&lt;source file name&gt; run -- &lt;args...&gt;</code> For example: <code>zig build -Dtarget_exe=showip.zig run -- example.com</code>
[]
https://avatars.githubusercontent.com/u/51441307?v=4
zig-bgfx-sdl2
siddhantmadhur/zig-bgfx-sdl2
2024-09-02T06:50:16Z
Template to get started with using BGFX and SDL2 in Zig
main
0
0
0
0
https://api.github.com/repos/siddhantmadhur/zig-bgfx-sdl2/tags
MIT
[ "bgfx", "graphics", "sdl", "sdl2", "zig" ]
20,188
false
2024-09-14T02:13:20Z
true
true
unknown
github
[]
BGFX w/ SDL2 in Zig This is a blank "hello triangle" project that links the static libraries for bgfx and SDL2 and renders a very basic triangle. I found it very difficult to accomplish this because I had very little knowledge about toolchains, libraries, or compiling C libraries, and then using them with Zig. Hopefully, this provides some ease of use. I've furthermore documented the process I used to set it up so I remember the exact steps I took. Libraries used: <ul> <li><a>SDL2</a>: This was very easy to get working as they upload the latest release compiled in a static library on their <a>github releases</a>.</li> <li><a>BGFX</a>: This was more cumbersome to download and get working as the resources online are very few, and further implementing it in Zig is even more sparse. </li> </ul> How to compile the static library I've only used these steps for Windows, and there could be better more efficient ways, but this is how I did it and got it working. Prerequisites <ol> <li>Zig</li> <li><a>make</a></li> </ol> These are listed from the BGFX official documentation so I'd recommend installing them as well <ol> <li><a>coreutils</a></li> <li><a>libiconv</a></li> <li><a>libintl</a></li> </ol> Steps <ol> <li>First download the three repositories required for bgfx</li> </ol> <code>git clone https://github.com/bkaradzic/bx.git git clone https://github.com/bkaradzic/bimg.git git clone https://github.com/bkaradzic/bgfx.git</code> <ol> <li>Once these are downloaded, <code>cd</code> into the <code>bgfx</code> folder. This is where you'll be running the tools.</li> <li>Run the following command to generate the required makefiles <code>..\bx\tools\bin\windows\genie.exe --gcc=mingw-gcc --with-sdl --with-tools gmake</code></li> <li><code>cd</code> into the <code>.build\projects\gmake-mingw-gcc</code> folder. If you are on an Arm chip, or a different operating system this will be different.</li> <li>I didn't want to go through the process of installing and setting up MINGW so I used Zig's drop-in C and C++ compiler</li> </ol> <code>make config=release64 CC="zig cc" CXX="zig c++" AR="zig ar" bx bimg bgfx shaderc</code> This should take a few minutes and compile everything you need for the project in the <code>.build\win64_mingw-gcc</code> folder
[]
https://avatars.githubusercontent.com/u/7878777?v=4
Chartdown
even-wei/Chartdown
2025-01-07T14:31:28Z
A blazingly fast markdown-to-PDF converter that transforms CSV data into beautiful charts, written in Zig. Create data-rich documents with simple syntax.
main
0
0
0
0
https://api.github.com/repos/even-wei/Chartdown/tags
MIT
[ "charts", "cli-tool", "csv", "data-visualization", "markdown", "pdf", "zig" ]
6
false
2025-01-08T01:11:23Z
true
true
unknown
github
[]
Chartdown A markdown to PDF converter with embedded charts, written in Zig. Features <ul> <li>📈 Convert markdown files containing chart definitions to beautiful PDFs</li> <li>📊 Generate line and bar charts from CSV data</li> <li>🚀 Single binary with no runtime dependencies</li> <li>⚡ Fast and efficient Zig implementation</li> </ul> Installation Requires Zig 0.11.0 or later. <code>bash git clone git@github.com:even-wei/Chartdown.git cd Chartdown zig build</code> Usage <code>bash chartdown input.md output.pdf</code> Syntax Charts are embedded in markdown using code blocks with the <code>chart</code> identifier: ``` Sales Report Our quarterly sales: chart { type: "line", data: "sales.csv", x: "date", y: "revenue", title: "Quarterly Revenue" } ``` Chart Configuration Basic options: - <code>type</code>: Chart type ("line", "bar") - <code>data</code>: Path to CSV file (relative to markdown file) - <code>x</code>: Column name for X axis - <code>y</code>: Column name for Y axis - <code>title</code>: Chart title (optional) Additional options: - <code>width</code>: Chart width in pixels (default: 800) - <code>height</code>: Chart height in pixels (default: 400) - <code>color</code>: Line/bar color (default: "#2E86C1") Development Project Structure <code>src/ ├── main.zig # Entry point ├── parser/ # Markdown and chart parsing ├── chart/ # Chart generation ├── pdf/ # PDF generation └── utils/ # Common utilities</code> Building from source ```bash Build the project zig build Run tests zig build test Install locally zig build install ``` Contributing Contributions are welcome! Please feel free to submit a Pull Request. License MIT License - see <a>LICENSE</a> for details
[]
https://avatars.githubusercontent.com/u/179981696?v=4
zig13-metal
ziglana/zig13-metal
2025-01-03T15:34:15Z
Zig 0.13 bindings for Apple's Metal API.
main
0
0
0
0
https://api.github.com/repos/ziglana/zig13-metal/tags
MIT
[ "apple-metal", "metal", "zig", "zig-lib", "zig-package" ]
1,633
true
2025-01-03T15:35:22Z
true
false
unknown
github
[]
zig-metal - Zig Bindings to the Metal API This library is currently in alpha stage, don't use it in any serious projects! Bindings are automatically generated using zig and libclang, but there are still some issues with the code generation. The source code for the generator can be found here: https://github.com/dmbfm/zig-metal-gen. In the examples folder you can find a few samples which were directly translated from apple's metal-cpp samples. Usage Copy or clone <code>zig-metal</code> to a subdirectory of your project. For instance, if you copy it to <code>libs/zig-metal</code> you should add this to your <code>build.zig</code>: ```zig const zig_metal = @import("libs/zig-metal/build.zig"); pub fn build(b: *std.Build) void { ... <code>const zig_metal_pkg = zig_metal.package(b); zig_metal_pkg.link(exe); exe.linkFramework("Foundation"); exe.linkFramework("Metal"); exe.linkFramework("AppKit"); // If on macOS exe.linkFramework("MetalKit"); // If using MTKView ... </code> } ``` What is included All of the metal API and parts of the Foundation API which Metal depends on can are directly imported in the root zig-metal namespace, so you can access them via <code>@import("zig-metal").MTLDevice, @import("zig-metal").NSString</code>, etc. Additionally some basic AppKit bindings can be found in the <code>extras.appkit</code> namespace, and basic MetalKit bindings in the <code>extras.metalkit</code> namespace. Examples You can find some usage examples in the <code>examples</code> folder. These are translations from Apple's samples for metal-cpp. <ol> <li>Window sample: <code>zig build run-window</code></li> </ol> <ol> <li>Primitive sample: <code>zig build run-primitive</code></li> </ol> <ol> <li>Argument Buffer sample: <code>zig build run-argbuffers</code></li> </ol> <ol> <li>Animation sample: <code>zig build run-animation</code></li> </ol> <ol> <li>Instancing sample: <code>zig build run-instancing</code></li> </ol> <ol> <li>Perspective sample: <code>zig build run-perspective</code></li> </ol> <ol> <li>Lighting sample: <code>zig build run-lighting</code></li> </ol> <ol> <li>Texturing sample: <code>zig build run-texturing</code></li> </ol> <ol> <li>Compute sample: <code>zig build run-compute</code></li> </ol> <ol> <li>Compute to render sample: <code>zig build run-compute-to-render</code></li> </ol>
[]
https://avatars.githubusercontent.com/u/558581?v=4
zig-x-compositing-manager
MadLittleMods/zig-x-compositing-manager
2024-09-27T17:56:10Z
A basic "compositing manager" for the X Window System written in Zig
main
0
0
0
0
https://api.github.com/repos/MadLittleMods/zig-x-compositing-manager/tags
-
[ "compositing-manager", "compositor", "window-manager", "x-composite-extension", "x-compositing-manager", "x-window-manager", "x-window-system", "x11", "xephyr", "xvfb", "zig", "ziglang" ]
219
false
2025-02-12T04:56:13Z
true
true
unknown
github
[]
A basic "compositing manager" for the X Window System that adds transparency/alpha blending (compositing) to windows. Normally, you'd get this same functionality for free via your desktop environment's window manager which probably includes a "compositing manager". This project is useful to use when you're running in a virtual X environment like <code>Xvfb</code> (X virtual framebuffer) or <code>Xephyr</code> and need to work with multiple windows that overlay on top of each other. To paraphrase from the <a><em>Adding Transparency</em></a> page in the Xplain series by Jasper St. Pierre; a "compositing manager" is needed because by default, every pixel on the screen is owned by a single window at a time. At any given point in time, you can point to a pixel, and the X server can tell you which window is responsible for painting it. Windows in the X11 protocol sense, aren't a tangible thing. They simply make their mark on the X server's front "root" buffer, as a series of pixels which they own. The issue is that when the bottommost window is being clipped by another window on top, we don't have access to the pixels that are being occluded at all; they simply don't exist anymore. The topmost window owns that pixel. To accomplish transparency, we redirect the output of all windows to off-screen buffers and then composite them together to form the final image.
[]
https://avatars.githubusercontent.com/u/89344810?v=4
base64
Gamawn/base64
2024-10-16T14:51:01Z
A simple Base64 decoder/encoder on Zig
main
0
0
0
0
https://api.github.com/repos/Gamawn/base64/tags
Apache-2.0
[ "base64", "zig" ]
16
false
2024-11-09T06:12:59Z
true
true
unknown
github
[]
base64 Example: ```zig const in = "Ym9hcmRmZA=="; const expect = "boardfd"; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); const b = Base64.init(); const in_result = try b.decode(allocator, in); try testing.expectEqualDeep(expect, in_result); ```
[]
https://avatars.githubusercontent.com/u/576065?v=4
snowballstem.zig
thekorn/snowballstem.zig
2025-01-01T17:22:48Z
zig wrapper for the snowball stemmer
main
1
0
0
0
https://api.github.com/repos/thekorn/snowballstem.zig/tags
Apache-2.0
[ "bindings", "snowball", "stemmer", "zig", "zig-package" ]
289
false
2025-03-15T02:58:43Z
true
true
unknown
github
[ { "commit": "b72b71fd51e633cb7a63d9f1883266b3d4acac11", "name": "snowball", "tar_url": "https://github.com/snowballstem/snowball/archive/b72b71fd51e633cb7a63d9f1883266b3d4acac11.tar.gz", "type": "remote", "url": "https://github.com/snowballstem/snowball" } ]
zig wrapper for the snowball stemmer <strong>NOTE</strong>: this is a work in progress, and not yet ready for use. Requirements <ul> <li>zig &gt;= 0.14</li> </ul> how to use? Add this package to your zig project: <code>bash $ zig fetch --save=snowballstem git+https://github.com/thekorn/snowballstem.zig.git#main</code> Add dependency and import to the <code>build.zig</code> file: <code>zig ... const snowballstem = b.dependency("snowballstem", .{ .target = target, .optimize = optimize, }); ... exe.root_module.addImport("snowballstem", snowballstem.module("snowballstem"));</code> And then, just use it in the code: ```zig const std = @import("std"); const Stemmer = @import("snowballstem"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer std.debug.assert(gpa.deinit() == .ok); const alloc = gpa.allocator(); <code>const stemmer = try Stemmer.list(alloc); defer alloc.free(stemmer); std.debug.print("&gt;&gt;&gt; {s}\n", .{stemmer}); </code> } ``` Tests Using <code>nix</code> tests can be run like <code>bash $ nix develop -c zig build test --summary all</code> TODOS <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> the build is not correct, first build sometimes fails <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> implement the stemmer <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> make wasm buildable <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> how to handle german umlauts? <br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> write test for german stemmer to check against the <a>upstream test suite</a> <br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> add other languages to tests (esp english) reference <ul> <li><a>snowball stemmer</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/565124?v=4
zig-dos-like-rotozoom
peterhellberg/zig-dos-like-rotozoom
2024-09-07T01:03:43Z
Zig port of Mattias Gustavssons port of rotozoom code by seancode
main
0
0
0
0
https://api.github.com/repos/peterhellberg/zig-dos-like-rotozoom/tags
NOASSERTION
[ "gamedev", "zig" ]
1,718
false
2025-04-11T08:48:34Z
true
true
unknown
github
[ { "commit": "2b9c90641f81e19f692866601effdaa8ff79b435.zip", "name": "dos", "tar_url": "https://github.com/mattiasgustavsson/dos-like/archive/2b9c90641f81e19f692866601effdaa8ff79b435.zip.tar.gz", "type": "remote", "url": "https://github.com/mattiasgustavsson/dos-like" } ]
zig-dos-like-rotozoom :floppy_disk: Getting the <a>rotozoom</a> example from <a>dos-like</a> to build in <a>Zig</a> :zap: <blockquote> [!Note] <code>zig translate-c -lc rotozoom.c &gt; rotozoom.zig</code> was used as a starting point of the port. Most of the time was spent figuring out how to setup the build :joy: </blockquote> Rotozoom effect This image is used in the rotozoom effect. Requirements A fairly recent version of <a>Zig master</a> (which would be <code>0.14.0-dev.1472</code> when this was written) <ul> <li><code>SDL2</code></li> <li><code>GLEW</code></li> <li><code>pthread</code></li> </ul> Compilation You should hopefully be able to compile the binary by calling <code>zig build</code> <blockquote> [!Note] As a convenience you can compile and run the binary via <code>zig build run</code> (or <code>zig build run -- -w</code> if you want to start in windowed mode) </blockquote> Links <ul> <li>https://mattiasgustavsson.itch.io/dos-like</li> <li>https://ziglang.org/</li> <li>https://seancode.com/demofx/</li> </ul>
[]
https://avatars.githubusercontent.com/u/124872?v=4
zig-bkdf
jedisct1/zig-bkdf
2024-12-27T19:40:45Z
An implementation of the BKDF key derivation function.
master
0
0
0
0
https://api.github.com/repos/jedisct1/zig-bkdf/tags
-
[ "bkdf", "crypto", "zig", "zig-package" ]
4
false
2025-04-17T23:54:38Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/173285554?v=4
zig.docs
wizard-lgtm/zig.docs
2024-09-20T03:38:29Z
the new ziglang docs
main
0
0
0
0
https://api.github.com/repos/wizard-lgtm/zig.docs/tags
-
[ "doc", "zig", "ziglang" ]
3
false
2024-09-20T03:41:56Z
false
false
unknown
github
[]
zig.docs A collection of good documentation and examples of Ziglang. Introduction 'Your path trought to be a ziglang master' Ziglang is an a really amazing programming language. But the documentation of ziglang is kinda basic and giving you not so much examples. (For example check out here:) So my goal is creating the best educative ziglang documentation ever created. Some of textes are directly copied from ziglang.org offical documentation or any other resources. You can check references section at the bottom of the post.
[]
https://avatars.githubusercontent.com/u/73903007?v=4
zig-bpe
dbtreasure/zig-bpe
2024-08-17T04:57:01Z
Byte Pair Encoding (BPE) in the Zig programming language (0.13.0)
main
0
0
0
0
https://api.github.com/repos/dbtreasure/zig-bpe/tags
MIT
[ "bytepairencoding", "tiktoken", "zig" ]
1,925
false
2024-09-12T06:03:01Z
true
true
unknown
github
[ { "commit": "devel.tar.gz", "name": "raylib-zig", "tar_url": "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Not-Nik/raylib-zig" } ]
⚡️ zig-bpe This project implements a basic tokenizer in Zig, focusing on text processing and Byte Pair Encoding (BPE) concepts. What is Byte Pair Encoding Byte Pair Encoding (BPE) is a data compression algorithm originally described by Philip Gage in 1994 <a>1</a>. It's also known as digram coding <a>2</a>. BPE works by iteratively replacing the most frequent pair of bytes in a sequence with a single, unused byte. This process continues until no byte pair occurs more than once. In recent years, BPE has gained popularity in natural language processing, particularly for tokenization in large language models. The modified version used in NLP starts with a vocabulary of individual characters and iteratively merges the most frequent adjacent pairs to form new tokens. This allows the algorithm to effectively handle both single characters and entire words, making it particularly useful for processing text data <a>3</a>. BPE is notable for its simplicity and effectiveness in compressing data. It's especially useful in scenarios where the input data contains repeated sequences of bytes. The algorithm's ability to adapt to the specific patterns in the input data makes it a versatile choice for various compression tasks. Zig Version This project is developed using Zig version 0.13.0. Make sure you have this version installed to build and run the project successfully. Features <ul> <li>Read input from a file</li> <li>Convert text to initial tokens</li> <li>Expand vocabulary using a simplified BPE-like approach</li> <li>Train the tokenizer on input text</li> <li>Measure and report performance statistics</li> <li>Encode and decode text using the trained tokenizer</li> <li>Serialize and deserialize merge operations</li> </ul> File Structure <ul> <li><code>src/main.zig</code>: Main entry point and example usage</li> <li><code>src/basic_tokenizer.zig</code>: Core implementation of the BasicTokenizer</li> <li><code>src/utils/read_file.zig</code>: Utility function for reading files</li> <li><code>src/utils/time_statistics.zig</code>: Performance measurement utilities</li> </ul> Running the Project To run the main program: <code>zig run src/main.zig</code> Limitations The current implementation works with UTF-8 encoded text but may not handle all edge cases of UTF-8 encoding. Future updates may focus on improving Unicode support and handling more complex scenarios. Current Implementation (basic_tokenizer.zig) The <code>basic_tokenizer.zig</code> file provides the core implementation of the tokenizer. Key features include: <ol> <li><strong>Modular Structure</strong>: The code is organized into a <code>BasicTokenizer</code> struct, encapsulating all tokenization-related functionality.</li> <li><strong>Memory Management</strong>: Uses Zig's allocator interface for efficient memory management.</li> <li><strong>UTF-8 Handling</strong>: The implementation handles UTF-8 encoded text, supporting a wide range of input data.</li> <li><strong>Vocabulary Management</strong>: Includes methods for creating and managing the tokenizer's vocabulary.</li> <li><strong>Flexible Token Type</strong>: Uses appropriate types for tokens, allowing for customizable vocabulary sizes.</li> <li><strong>Error Handling</strong>: Implements error handling throughout the tokenization process.</li> <li><strong>Training Functionality</strong>: Includes a <code>train</code> method to learn from input text.</li> <li><strong>Encoding and Decoding</strong>: Provides methods to encode text into tokens and decode tokens back into text.</li> <li><strong>Clear API</strong>: Offers a clear and easy-to-use API for tokenization, training, and serialization.</li> </ol> Serialization and Deserialization The tokenizer supports serializing and deserializing merge operations, allowing you to save and load the trained model. Testing The project includes several unit tests to ensure the correct functionality of the tokenizer. These tests cover various aspects of the <code>BasicTokenizer</code> implementation: <ol> <li><strong>generateInitialTokens</strong>: Tests the initial tokenization of a string into individual characters.</li> <li><strong>encode</strong>: Verifies the encoding process, including the application of learned merges.</li> <li><strong>decode</strong>: Checks the decoding process, ensuring encoded tokens are correctly converted back to text.</li> <li><strong>train</strong>: Tests the training process, including merge operations and vocabulary expansion.</li> <li><strong>serializeMerges and deserializeMerges</strong>: Ensures that merge operations can be correctly saved to and loaded from a file.</li> </ol> Running the Tests To run all the tests for the project, use the following command in the root directory of the project: <code>zig test src/basic_tokenizer.zig</code> This command will compile and run all the tests defined in the <code>basic_tokenizer.zig</code> file. To run tests for other specific files, replace <code>zig test src/basic_tokenizer.zig</code> This command will compile and run all the tests defined in the <code>basic_tokenizer.zig</code> file. Test Output When you run the tests, Zig will compile the code and execute each test function. The output will show which tests passed or failed, along with any debug information printed during the tests. If all tests pass, you'll see a message indicating success. If any tests fail, Zig will provide detailed information about the failure, including the line number and the nature of the assertion that failed.
[]
https://avatars.githubusercontent.com/u/3986971?v=4
RESTettaStone
darren277/RESTettaStone
2024-09-28T13:26:12Z
Showcase of REST API functionality, Dockerized, for 30+ programming languages and 40+ frameworks.
master
8
0
0
0
https://api.github.com/repos/darren277/RESTettaStone/tags
-
[ "bash", "cpp", "csharp", "dlang", "docker", "fsharp", "go", "haskell", "java", "javascript", "lisp", "perl", "php", "prolog", "python", "ruby", "swift", "zig" ]
2,583
false
2025-03-24T15:55:54Z
false
false
unknown
github
[]
TOC <ul> <li><a>About</a></li> <li><a>Parts</a><ul> <li><a>Database</a></li> </ul> </li> <li><a>History</a></li> <li><a>Current Status</a><ul> <li><a>Backend</a></li> <li><a>Frontend</a></li> <li><a>Other</a></li> </ul> </li> <li><a>Standing on the Shoulders of Giants</a></li> <li><a>Future</a></li> <li><a>See Also</a><ul> <li><a>Theoretical</a></li> <li><a>Practical</a></li> </ul> </li> <li><a>How to Use</a></li> <li><a>Configuring Environment Variables</a><ul> <li><a><code>.env</code> File</a></li> <li><a>Setting Environment Variables in Redis and Nginx</a></li> </ul> </li> <li><a>Using the Makefile</a><ul> <li><a>Overview of Commands</a></li> <li><a>Docker</a></li> </ul> </li> <li><a>Using Docker Compose</a></li> <li><a>Testing</a><ul> <li><a>Simple Endpoint Testing with <code>Make</code></a></li> <li><a>Using Python Script for More Advanced Testing</a></li> </ul> </li> <li><a>Performance Testing with Locust</a></li> <li><a>Monitoring</a><ul> <li><a>Prometheus and Grafana</a></li> </ul> </li> <li><a>Cloud Deployment</a><ul> <li><a>AWS</a></li> <li><a>EC2</a><ul> <li><a>Some Docker Notes</a></li> <li><a>Docker Permissions</a></li> <li><a>Testing Endpoint with Curl</a></li> <li><a>Some Notes About Make and SSH Commands</a></li> <li><a>SSH Keys</a></li> <li><a>Key File Permissions</a></li> <li><a>Key Format</a></li> </ul> </li> </ul> </li> <li><a>RabbitMQ</a></li> <li><a>Lessons</a></li> <li><a>DevOps Gotchas</a><ul> <li><a>Nginx Gotchas</a></li> <li><a>Environment Variables</a></li> <li><a>Docker Gotchas</a></li> <li><a>ARGS and Multi Stage Builds</a></li> <li><a>Exec Form vs Shell Form for ENTRYPOINT:</a></li> <li><a>Docker Compose Gotchas</a></li> <li><a>Dynamic Build Args</a></li> <li><a>Make Gotchas</a></li> <li><a>Tabs vs Spaces</a></li> </ul> </li> <li><a>Language and Framework Gotchas</a><ul> <li><a>Symfony (PHP)</a></li> <li><a>Headers vs Body and the Whitespace Issue</a></li> <li><a>CLI Race Condition</a></li> <li><a>Rocket (Rust)</a></li> <li><a>Pear Codegen Dependency</a></li> <li><a>Django (Python)</a></li> <li><a>Project Structure</a></li> <li><a>URL Routing</a></li> <li><a>Django REST Framework</a></li> <li><a>Zig</a></li> <li><a>Postgres Connection Pool Inconsistency Problem</a></li> <li><a>Fat Free (PHP)</a></li> <li><a>Dependency Source</a></li> </ul> </li> <li><a>Database Gotchas</a><ul> <li><a>Postgres</a></li> <li><a>pg_stat_activity Locks</a></li> </ul> </li> <li><a>Other General Lessons</a><ul> <li><a>Branch Protection</a></li> </ul> </li> <li><a>Comparisons</a><ul> <li><a>Projects by Language</a></li> <li><a>Classic</a></li> <li><a>Performant</a></li> <li><a>Procedural</a></li> <li><a>Object Oriented</a></li> <li><a>Functional</a></li> <li><a>Multi-Paradigm</a></li> <li><a>Versatile or Other</a></li> <li><a>JavaScript</a></li> <li><a>Metrics</a></li> <li><a>Qualitative</a><ul> <li><a>Simplicity</a></li> </ul> </li> <li><a>Quantitative</a><ul> <li><a>Performance</a></li> </ul> </li> <li><a>Both Qualitative and Quantitative</a><ul> <li><a>Security</a></li> <li><a>Safety</a></li> </ul> </li> </ul> </li> <li><a>Optimization</a></li> <li><a>Docker Image Size</a><ul> <li><a>Table Sorted Alphabetically</a></li> <li><a>Table Sorted by Image Size</a></li> </ul> </li> </ul> About This is a project I started back in Fall of 2022. The purpose is to have a repository showcasing basic REST API functionality, Dockerized, for a multitude of programming languages and frameworks. Parts This repository consists of a <code>backend</code> and <code>frontend</code> folder, each in turn consisting of subdirectories for each framework or server implementation. I also include a <code>Dockerfile</code> inside of each subdirectory so that each mini app can be run in its own container. Furthermore, I use Nginx to route requests to each backend. There is also a <code>Makefile</code> with the commands to build and run each container, as well as some general purpose commands for creating the network, handling logs and simple container interaction tests, etc. Database This project uses a single Postgres database for all backends to interact with. History I started this back in 2022 and made a lot of headway with it in the beginning, but ended up putting it aside in November of 2022 as I just started a new job and simply did not have the time to continue adding to it. I found myself dusting it off a couple of times, briefly, during 2024. I've decided to set out to complete as much of what's left as I can now, hoping to maybe finish it before the year is out. Current Status This table represents the status of the project as of November 2022. I'm leaving the Python options (Flask and Django) until last as they will be by far the easiest to implement for me. I break down the barriers I've faced into a few fundamental categories: * <strong>Language</strong>: A lack of experience with the language and some of its specific nuances. This barrier is especially prevalent with languages that use non-object-oriented paradigms (for example, Lisp, Haskell, Prolog, etc). * <strong>Libraries</strong>: Since I'm using Postgres for the universal database that all the backends are accessing, I need an existing library or implementation for accessing a Postgres database. I think the only place where this was a total blocker was Bun.js. I started looking into the feasibility of writing my own super simple implementation, but abandoned that due to a lack of available time. It turns out, after a couple years have passed, that there is now Postgres support for Bun.js. * <strong>Networking</strong>: This is a case where I have difficulties accessing the endpoint for some reason. I recall a particular scenario where <code>0.0.0.0</code> was not doing what it was supposed to be doing, and I just hit a wall with it and gave up at the time. Looking at the table, it looks like that was one of the Rust frameworks. I plan to revisit that and troubleshoot it further. * <strong>Build</strong>: This is where the Dockerfile fails to execute every step and the application simply does not run. It looks like Zig was the only such scenario. This is another one I will try revisiting after all this time. Note that I use <code>✅</code> to indicate that the task is completed, tested, and merged into <code>main</code>. I use <code>❌</code> to indicate that it is yet to be completed and pushed into <code>main</code>. ~~I use <code>'</code> to indicate that the task was completed at some point (likely two years ago), and is going through a testing stage before a PR is made.~~ I also have two asterisks (<code>*</code>) but I can't remember what those were for. I'm leaving them in for now. Backend | | Dockerized | REST Responses | Postgres Interaction | Full CRUD | Current Barrier | |----------------------------------------------------------------------------------------------------------|------------|----------------|----------------------|-----------|----------------------| | <strong>BASH</strong> | | | | | | | <a>Bash</a> | ✅ | ✅ | ✅ | ✅ | | | <strong>C</strong> | | | | | | | <a>C</a><strong> | ✅ | ✅ | ❌ | ❌ | | | </strong>C++<strong> | | | | | | | <a>Crow (C++)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>C#<strong> | | | | | | | <a>Asp.Net (C#)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>CLOJURE<strong> | | | | | | | <a>Kit (Clojure)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>COBOL<strong> | | | | | | | <a>Cobol</a></strong> | ✅ | ✅ | ✅ | ❌ | Language | | <strong>D</strong> | | | | | | | <a>Vibe (D)</a> | ✅ | ✅ | ✅ | ✅ | ~~Networking~~ | | <strong>DART</strong> | | | | | | | <a>Shelf (Dart)</a> | ✅ | ✅ | ✅ | ✅ | | | <strong>ELIXIR</strong> | | | | | | | <a>Phoenix (Elixir)</a> | ✅ | ✅ | ✅ | ✅ | | | <strong>FORTRAN</strong> | | | | | | | <a>Fortran</a><strong> | ❌ | ❌ | ✅ | ❌ | Language | | </strong>F#<strong> | | | | | | | <a>F#</a> | ✅ | ✅ | ✅ | ✅ | ~~Language~~ | | </strong>GO<strong> | | | | | | | <a>Go</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>HASKELL<strong> | | | | | | | <a>Spock</a> | ✅ | ✅ | ✅ | ✅ | ~~Language~~ | | </strong>JAVA<strong> | | | | | | | <a>Tomcat (Java)</a> | ✅ | ✅ | ✅ | ✅ | | | <a>SpringBoot (Java)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>JAVASCRIPT<strong> | | | | | | | <a>Bun (JS)</a> | ✅ | ✅ | ✅ | ✅ | ~~Libraries~~ | | <a>Firebase (JS)</a> | ✅ | ✅ | N/A | ✅ | | | <a>Node (JS)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>JULIA<strong> | | | | | | | <a>Genie (Julia)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>KOTLIN<strong> | | | | | | | <a>Http4k (Kotlin)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>LISP<strong> | | | | | | | <a>Hunchentoot (Lisp)</a> | ✅ | ✅ | ✅ | ✅ | ~~Language~~ | | </strong>LUA<strong> | | | | | | | <a>Lua / OpenResty</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>PASCAL<strong> | | | | | | | <a>Pascal</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>PERL<strong> | | | | | | | <a>Perl</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>PHP<strong> | | | | | | | <a>Fat Free (PHP)</a> | ✅ | ✅ | ✅ | ✅ | | | <a>Laravel (PHP)</a> | ✅ | ✅ | ✅ | ✅ | | | <a>PHP</a> | ✅ | ✅ | ✅ | ✅ | | | <a>Symfony (PHP)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>PROLOG<strong> | | | | | | | <a>Prolog</a> | ✅ | ✅ | ✅ | ✅ | ~~Language~~ | | </strong>PYTHON<strong> | | | | | | | <a>Django (Python)</a> | ✅ | ✅ | ✅ | ✅ | | | <a>Flask (Python)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>R<strong> | | | | | | | <a>Plumber (R)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>RUBY<strong> | | | | | | | <a>Rails (Ruby)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>RUST<strong> | | | | | | | <a>Actix (Rust)</a> | ✅ | ✅ | ✅ | ✅ | ~~Language~~ | | <a>Rocket (Rust)</a> | ✅ | ✅ | ✅ | ✅ | ~~Networking~~ ~~Build~~ | | </strong>SCALA<strong> | | | | | | | <a>Play (Scala)</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>SWIFT<strong> | | | | | | | <a>Swift</a> | ✅ | ✅ | ✅ | ✅ | | | </strong>ZIG*<em> | | | | | | | <a>Zig</a> | ✅ | ✅ | ✅ | ✅</em> | ~~Build~~ | (*) Zig app has full CRUD functionality, but there is an issue with connection pooling that causes it to behave inconsistently. <a>See notes below</a>. (**) The COBOL and Fortran apps are a work in progress that are in separate repos while I build them out. The C web application is also a work in progress and is in its own repo. Frontend | | Dockerized | Backend Integration | Full CRUD | |----------------------------------------------------------------------------------------------|------------|---------------------|-----------| | <a>Angular</a> | ✅ | ✅ | ✅ | | <a>Blazor (C#)</a> | ✅ | ✅ | ✅ | | <a>Gatsby</a> | ✅ | ✅ | ✅ | | <a>Next</a> | ✅ | ✅ | ✅ | | <a>React</a> | ✅ | ✅ | ✅ | | <a>React (Python)</a> | ✅ | ✅ | ✅ | | <a>React Fiber</a> | ✅ | ✅ | ✅ | | <a>Svelte</a> | ✅ | ✅ | ✅ | | <a>Vue</a> | ✅ | ✅ | ✅ | | <a>Yew (Rust)</a><strong> | ✅ | ✅</strong> | ❌ | (<em><em>) The Yew app is in a separate repo. It does not currently connect to </em>this</em> backend, but it integrates just fine with its own backend web server built in Rust, with a SurrealDB database. Other | | Dockerized | Backend Integration | Full CRUD | |---------------------------------------------------------------------------------------------|-----------|---------------------|-----------| | <a>Electron</a> | N/A | ✅ | ✅ | | <a>Expo / React Native</a> | N/A | ✅ | ✅ | | <a>Flutter</a> | N/A | ✅ | ✅ | | <a>Chalice</a> | N/A | N/A | ✅ | | <a>Monitoring</a> | ✅ | ✅ | N/A | | <a>gRPC</a> | ✅ | N/A | ✅ | | <a>RabbitMQ</a> | ✅ | N/A | N/A | Servers | | Dockerized | Backend Integration | Frontend Integration | |--------------------------------------------------------------------------------------|------------|---------------------|----------------------| | <a>Nginx</a> | ✅ | ✅ | ✅ | | <a>Apache Httpd</a> | ✅ | ✅ | ✅ | Standing on the Shoulders of Giants In many cases, I made use of some existing projects out there as templates or boilerplate. I wound up modifying many of the Dockerfiles I found, for example, quite substantially, to suit my custom needs. There were also a few repositories I found on GitHub that helped guide my initial efforts for some of the languages where I significantly lacked direct experience. One major example of this was the <a>COBOL backend</a>. I'd have had no idea where to even begin for something like that (well, other than the language specifications and documentation, I suppose - but that would have been unecessarily time consuming, and why reinvent the wheel?). Future The first immediate steps to carry out will be gradually adding each subdirectory as I test them and maybe clean them up a bit by removing unecessary comments and so on. See Also What follows in this section are some other projects I have worked on that are at various stages of completion. They relate to this one in that they explore other aspects of web and desktop application development that do not necessarily fit directly into this repository, or are simply much bigger projects and deserve to stand in their own right. Theoretical <ul> <li><a>Series of tubes</a> is a repository where I analyze the underlying structure of Internet protocols and various constituent parts that compose the various kinds of Internet traffic that make up the World Wide Web. It is a work in progress with many more parts to come.</li> <li><a>byodb</a> is an implementation of a SQLite like database from the ground up in C. It is based on a tutorial referenced inside the repository.</li> </ul> Practical <ul> <li><a>Python to JS/JSX Transpiler</a> is a project for transpiling Python code into either JavaScript or JSX code. Theoretically, it could potentially be leveraged to write entire React applications in Python.</li> <li><a>Wasm-FRP</a> is a project that uses Rust at every level of the stack.</li> <li>The back end uses Tokio to construct a REST based web server.</li> <li>The front end uses Yew to construct a WebAssembly based front end that is compiled and then served client side.</li> <li>The database it interacts with is even a Rust based technology called SurrealDB. It is a multimodal database with a lot of fun potential.</li> </ul> How to Use Configuring Environment Variables <code>.env</code> File You will need a <code>.env</code> file in the root directory with quite a few custom defined environment variables. The universal environment variables for the central control mechanism(s) would look something like this: ```sh PG_USER=someusername PG_PASS=somepassword NGINX_VERSION=1.17.3 NGINX_IP=172.18.0.20 NGINX_PORT=8084 LUA_JIT_VERSION=2.0.5 SUBNET_NAME=restetta SUBNET_CIDR=172.18.0.0/16 PG_IP=172.18.0.21 PG_HOST=172.18.0.21 PG_PORT=5432 PG_DB=postgres REDIS_IP=172.18.0.19 REDIS_PORT=6379 ``` And then individual environment variables for each subproject would look something like this: <code>sh CROWAPP_IP=172.18.0.22 CROWAPP_PORT=18080</code> Please note that a lot of these are quite arbitrary. The CIDR subnet that you use, and the IP addresses for each Docker container can almost be randomly generated. The same applies to the ports. Setting Environment Variables in Redis and Nginx The Nginx configuration process here currently requires knowledge of each container's IP address and port. You'll notice the following command in the <code>Makefile</code>: <code>sh redis-set-variable: docker exec -it redis_container redis-cli set $(REDIS_KEY) $(REDIS_VALUE)</code> On Windows (for example), you simply need to open a terminal and execute the following type of command (using a particular illustrative example): <code>shell $env:REDIS_KEY='CROWAPP_PORT'; $env:REDIS_VALUE='18080'; make redis-set-variable</code> Take note, as well, of the following command inside the <code>server/nginx/entrypoint.sh</code> script: <code>sh envsubst '${NGINX_PORT},${CROWAPP_IP},${CROWAPP_PORT}' &lt; /usr/local/openresty/nginx/conf/nginx.conf.template &gt; /usr/local/openresty/nginx/conf/nginx.conf</code> I will be adding each environment variable pair (IP and port) for each subproject as I add them to the repository. This will, of course, become rather long and cumbersome over time, so I will likely implement a more elegant solution in the future. Using the Makefile The Makefile, which requires installation of <code>make</code> if you do not already have it, is provided to facilitate the execution of many of the commands needed to run the different pieces of this project. Using Docker Compose <strong>NOTE</strong>: I've abandoned this route as I absolutely refuse to hardcode the build args directly inside of the <code>docker-compose.yml</code> file. For a project of this size, with dozens of subprojects each with their own <code>Docker</code> container specifications, it just doesn't make sense if Docker Compose won't accommodate dynamic build arg interpolation. See also: <a>The build arg gotcha</a>. For the sake of posterity, I still include the existing <code>docker-compose.yml</code> file in the root directory for anyone who would like to build upon it. If you'd like to try using the <code>docker-compose.yml</code> file, you can do so by running the following command from the CLI: <code>shell docker-compose up</code> Two things to note: 1. I have not yet added every single subproject to the <code>docker-compose.yml</code> file. This would be rather tedious, very repetitive, and essentially unnecessary for the time being. The <code>Makefile</code> and each individual <code>Dockerfile</code> do the job just fine. 2. Since the YAML keys cannot be interpolated with environment variables, I had to hardcode the network name which bothers me in an OCD kind of way. It's obviously not a huge deal, but it irks me just a smidge. See also: <a>Build args gotcha</a>. Overview of Commands Docker Most of the commands in the Makefile(s) are calling the <code>docker</code> CLI tool. This includes tasks such as creating the network, building images from individual <code>Dockerfile</code>s, running these Docker images, and, in some cases, interacting with them. I also recently separated the original single <code>Makefile</code> into two separate files (with a third to come - namely, <code>Makefile.frontend</code>). To run a command from the main central <code>Makefile</code>, you simply enter something like the following into the terminal: <code>shell make docker-subnet make docker-psql make nginx-build make nginx-run</code> As for the <code>Makefile.backend</code>, the recurring pattern looks as follows: <code>shell make b actixapp-build make b actixapp-run</code> Or: <code>shell make b cobolapp-build make b cobolapp-run</code> Note that the <code>b</code> is a shorthand I created to simplify referencing the <code>Makefile.backend</code> file. Don't forget to define your environment variables in a <code>.env</code> file, as they are used by these <code>Makefile</code> commands. See above section on environment variables for details. Testing Simple Endpoint Testing with <code>Make</code> I created a Dockerfile for a new container that can be used for testing endpoints. I've also included one example usage: <code>shell crowapp-test: docker exec -it debugger curl http://$(CROWAPP_IP):$(CROWAPP_PORT)/users</code> The next thing I'd like to add to this generalized debugger container is a logging system that can create logs either on the host machine or at least be very easily accessible via another <code>Make</code> command. Or, better yet, perhaps create some kind of visual user interface for viewing these logs (or leveraging something like <code>Kibana</code> or <code>Grafana</code>). Using Python Script for More Advanced Testing I've also included a <a>Python script</a> that can be used to define some more advanced test cases, including testing for specifics about the returned content. This script also allows you to test every container with the same command: <code>shell make run-tests</code> Performance Testing with Locust I've added a container definition and Locust file and configuration options for performance testing. There are <code>make</code> commands in the <code>Makefile</code>: ```shell locust-build: cd other/performance &amp;&amp; docker build --build-arg TARGET_HOST=$(TARGET_HOST) --build-arg TARGET_PORT=$(TARGET_PORT) -t locust-$(NAME):1 . locust-run: docker run -d -it --rm -p 8089:8089 --name locust-$(NAME) --network $(SUBNET_NAME) locust-$(NAME):1 ``` You can manually run the <code>docker build</code> command as follows: <code>shell locust-build NAME=crowapp TARGET_HOST=127.420.69.42 TARGET_PORT=2024</code> And then run the container with the following command: <code>shell locust-run NAME=crowapp</code> <strong><em>Or</em></strong>, more preferably... You will likely want to define your own tailored <code>Make</code> commands, following the given Flask example already in the <code>Makefile</code>: ```shell locust-build-flask: $(MAKE) locust-build NAME=flask TARGET_HOST=$(FLASKAPP_IP) TARGET_PORT=$(FLASKAPP_PORT) locust-run-flask: $(MAKE) locust-run NAME=flask ``` I may add a separate <code>Makefile</code> in the future that is defined to calling all the different performance testing configurations. In the meantime, however, I will leave that as an exercise for the reader. Monitoring Prometheus and Grafana There is a <code>docker-compose.yml</code> file in the <code>other/monitoring</code> directory that can be used to start a Prometheus monitoring and alerting system with Grafana configured for some very simple dashboard visuals. To access the Prometheus dashboard, navigate to <code>http://localhost:9090</code>. To access the Grafana dashboard, navigate to <code>http://localhost:3050</code>. The username is <code>admin</code>, and the password is set as an environment variable in the root <code>.env</code> file as <code>GF_SECURITY_ADMIN_PASSWORD</code>. It is currently connected to the <code>flaskapp</code> Flask back end. I will leave connecting it to other sub projects as an exercise for the reader. Note: Unlike the root project and it's <code>Makefile</code> configurations, the ports and other configuration values are currently hardcoded, which I don't particularly like, but I'll likely revisit that later. Also be aware that, currently, the volume mount for the Prometheus container is the same as the source folder, so it currently modifies the source <code>prometheus.yml</code> file each time it's run. This is not ideal, but it's another thing I'm leaving for another day. Cloud Deployment AWS EC2 This procedure is going to be making a lot of assumptions regarding preparatory work on the part of the reader. There are lots of resources out there on how to do these things, so I won't add to the noise out there with my own take on an oft repeated process. 1. Sign up for an AWS account. 2. Provision an EC2 instance that is within your budget. 3. Install and configure Docker on this EC2 instance. 4. Add all required environment variables to your <code>.env</code> file (see <code>Makefile</code> for reference). 5. Install the <code>aws</code> CLI tool locally. 6. Configure the <code>aws</code> CLI tool with your AWS credentials. 7. Install and configure the necessary SSH tools on your local machine. 8. Obtain the right private key file for your EC2 instance security group and point to it using <code>PEM_KEY_PATH</code> in the <code>.env</code> file. 9. Ensure that Postgres is installed and running on the EC2 instance <code>sudo apt install postgresql</code>. 10. Ensure that you have Python installed on the EC2 instance <code>sudo apt install python3</code>. 11. And also ensure you have the <code>python3-dev</code> package installed <code>sudo apt install python3-all-dev</code>. 12. And yet another prerequisite for Postgres is <code>sudo apt install libpq-dev</code>. An alternative to the last four steps would be to slightly modify the <code>populate_pg_db.py</code> script to run locally while connecting to the remote Dockerized Postgres database. I'll leave this as an exercise for the reader for the time being. Some Docker Notes Docker Permissions If you face any Docker permissions issues right from the get go, there are a few ways to go about resolving that. The method I went with was: <code>sudo chown $USER /var/run/docker.sock</code>. Be warned that this particular method carries some degree of security risk. To test: <code>docker run hello-world</code>. It may require a <code>reboot</code>, but if <code>reboot</code> is not ideal, you can restart the Docker service with <code>sudo systemctl restart docker</code>, or if that doesn't work, use <code>sudo systemctl list-units --type=service</code> to list the services and find the Docker service name. In my case, it was <code>snap.docker.dockerd.service</code> so I had to run <code>sudo systemctl restart snap.docker.dockerd.service</code>. See also: https://stackoverflow.com/questions/48957195/how-to-fix-docker-got-permission-denied-issue Testing Endpoint with Curl This step also has a couple of prerequisites: 1. You must of course have <code>curl</code> installed locally. 2. You must have the IP address or hostname of your EC2 instance stored in your <code>.env</code> file as <code>EC2_HOST</code>. 3. You must also have the desired port number allowed access via the security group settings for that EC2 instance (configured via AWS Console, or from the CLI if you're familiar with the process). Some Notes About Make and SSH Commands There are likely better equipped tools out there for accomplishing a lot of what I am doing with a <code>Makefile</code> and a few SSH related commands. Ansible, although my experience with it is limited so far, sounds like it might be a good fit for this kind of thing. I'll be exploring that in a future iteration. SSH Keys Key File Permissions If you happen to encounter something like the following: <code>The authenticity of host 'ec2-X-X-X-X.compute-1.amazonaws.com (X.X.X.X)' can't be established. ED25519 key fingerprint is SHA256:rZEy5qUlf9lEj3pDN6b2mWx9XEzilKDkeykF/tpuZKL. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? Warning: Permanently added 'ec2-X-X-X-X.compute-1.amazonaws.com' (ED25519) to the list of known hosts. Bad permissions. Try removing permissions for user: NT AUTHORITY\\Authenticated Users (S-1-5-11) on file C:/Users/Darren/.ssh/my_key.ppk. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions for 'C:/Users/Darren/.ssh/my_key.ppk' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "C:/Users/Darren/.ssh/publicwebsite.ppk": bad permissions ubuntu@ec2-X-X-X-X.compute-1.amazonaws.com: Permission denied (publickey). C:\Windows\System32\OpenSSH\scp.exe: Connection closed</code> You may have to modify the permissions for the file to be more exclusive to a particular user. There is a discussion with some suggestions and guidance on how to do that here: https://stackoverflow.com/questions/49926386/openssh-windows-bad-owner-or-permissions Just keep in mind the usual caveats when it comes to fiddling with file permissions. Key Format The key format needed for the <code>Makefile</code> commands that use SSH from the command line need to be in the following format: <code>shell -----BEGIN RSA PRIVATE KEY----- UAixppRe3O2ib7z7R9bsYFAjnMG+hMJ4qxTSZUcNaa0rzPnEtmNeCdprl6Ta2f/2t8+l3TYRthXyI +TBwFYZ0l/Bo5dJ1J9uZ5wXy94ce0TdCZIlPClYP7xXvGnf23OsNgsV2aZf3sr1llgLTepAbRjuXU K5tyzRaAYH+O4S3+D9t3guGyFMZlF8mZNux4LrcRYMn0czmA3gjS23Fj7IFhZtaBO95jw2Mh3cRYl qiiqGtt/+j1lsqDvztwpxdrE/jWMnXLDMptWq/BCyVYp1uzIBm0gRwGvXsv+yj+OFhJ9l84P2vKCM du5HW3mdIlX5ivpdepPWENvi3ubzrW80fzcs3idHMqoXVguf+go/nS2FwFaJLUhm55IDr0EmB8hZB b8JGRlX8zSnkOXUQb7vlmk4PpoAINbEzedKVEct06Gt7vGbNRNnyha3h0sW6N3FXYyQjeANwHHxNU 1z1yWWkWUlnne8h5N3B52mNjBZgXI6JhWNxgTvUWM5GmsxPHeciqS7sXYyyNUA+Nlad2fDiBOEirC z7bpU9hVgEVNXnYBzzhgMHe44lTV8rwRXK28JCsdmO00wunxrDvkGKfznwqqCWFHEBCUEzsXYDetx t+iQsvG0kY7dAgkwvR/b+FiW03OVbap4IK3UWkYJgwwiy1Qu3iPGBTFE3KzM6HSPRTEfH2K5GKjD1 TuCK4SU/H75c4imbFExawWa1w2o69PdxOU8Gv3f4nwfEwN4bNgkpNajBmLyII2pq4j8I9G+vLQUso EnL7XrQzkQse99YYf8FGQsZG/umgRc7Ggxzjfsj34GWehnupE4Q3b5hJNh0qC6F919Q9NJqJ9y3hh XEOMsmAeGC3XxMxoByn2cG+G/7UQnCamN7vzru9qKo37vwcPhOu45CIpml88bZ9CUa4AKpjLXuEym aXU5bC8mlK0ZcCSTN/WvcuM1bXo/uMx8O8RIzf6ilbtQ6nzMiNVx0tTh4YFGRX2CtrKIzxQIRqrLp zz/uPGvR1w7YbRFaUSmqSTqBdbetpvszo6qld/7dK2rT/LAF4oUAzD130wvD8TnxbY5U4kkFgo51y ZUoeKrlXdRZgFa26EQjV5GYVjsciVb9kjcbjAYRaIN/ErcEycliFvFblEL7D2WSUKMybJh8y7ZuxG 6G8UE8X3DPbWDqZ7WBlz8GHgnRATID24GpCYZlW3sTuBiHfRasvhijA8w/5tjN+71cdrF977gmEyD 3MRlDEXT9ZxT9SHEjsWD/AlPf7UGyvzAP0M5r70WMeQROXV1oI8Ilk5yqVKGmAvbrgBiVOvy6zerh 1d9bZVNsim0IrsdqtgG5DTH5gXDZ+aNOKIKCYAvFIuSQoDufxNr4j88XaO6D21D0dSsaHCug1a3pm QOAgxGEsvTh6nlXYK72ZNXkYYCiZiYM3+ukhdDSPGnpXkY6tmh9pNbYvmM4kAYvyfh8dfClImG/HA sii3ECAGfZE3rNddvuyhUdR6FyOduKMHyp7MvMF5u2QO9h0oG/nBKw5HgYCDl3g8WLlhqq50Lq9iy Ic5iLbk1/Bon5VKG8LOs/MJyIFA8TnpEgUZ2afd38ZwpPpckXitTmXtFFtgze26LGqOpiKB= -----END RSA PRIVATE KEY-----</code> Not this format: <code>shell PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: imported-openssh-key Public-Lines: 6 7FQOxsna4r3cvUluR3IlvYYmcblZcO06deS0auu3j5xTBr2G3+JrFpxsPPVLWR6lJ jUhAcjsfJuUeToeCIubdrVWX4kbFvfjLm0ZylkJw6lnC1tsugPE6KnjUv4TnOMNZJ mxPXoQUr/X22gHuQgcycG65jgwZ9NS000YW4F22DcUHvgibiwytPYThberPczi8zo QSKi0HSQ6OgoDfzy5o7Lj8HB5cyS4HIQ8t6ckiPv9EXQMoqGbvEjHJJqBOJYX1uO8 NG6MWBrZEy5qUlf9lEj3pDNCLGK6b2mWx9XEzilKDkekvyykFL/tpuZKLfAPDUtF5 yJLAUpcGEj96/RUdYvCvqONzDSllTOq5iRPBIVIpqTqfeqU8f+vx Private-Lines: 14 cOwOdky2eprrY5HmskdNERB0Q3G8AFb+fAwCnv8ijUddw/PtLrpthFflaxoSWfubT 70NzZ5Q85He6o/b4ciEMVVor5+P+NrzBMYap3MigAykBEkW9eN/v//WnZ8C/YaNhs Xwq8dCJA4uWVnWYPRuPjI+n56IPYw+0Yf/eWQsES+2CO8Ut9A9gn+i09ziZrRzFOT 79rdwTVjY77KBqxbL/yjHZ/nEBzXWUT9EI2aXWHdDcPrKGP9K1NpTAef8KKQ4S/0j pO0Sh9j2BKIDdvMn0xvkXCuxcbp0Hb9IpVQMmjF+Hnp+3EA5MUvGJZMMgCr/Fvhqn W/FrFtbYrqdItJMb6aXbBCPQhATPNSu4B0w9QSGvmvJEEtu0Uv2nnKZX2tupVL7tq KYLMo/iB/Qcq4y36ANEVfw/t7js47kFCNe5ERPVnR4/vXkhzmRZ7DiuHr6+Y1xWw4 1G1CVKNJwQZchuQy+cdX2YfFVk6pUCIcsl928zzV/7BSEBfnfRB/0X1iJbkLLoWpc dP2v6wI4Ey9eTCFKs7iSvqwhI2DxL0WjwNo9SLZxip8joEQoLUWGaMwTxQ52TjfQB 0QQ1CtRYYgPt8TZD6wSdnBrm5s1SsZr4L4DDRPDONbbbTCDvpaarS24AqDd++iOS0 ifV4OXD1nzMlSxh6o9zUeF/sXvlHdH+g99K4nyQJnRIG1VkTIYMeghNO2GZkRwVUI bxXiJsM6iwXnvtlDLmNyIw7RdLCQQgt1yL72VZzwcATjPy6D8E7cpvXZctLoSDqjV ZPWzm0TNfBWqbg/t379hgSsU0cI2QnN8684Z6gLOvm4xTUx6LQOsrWQrF0irQCWPD oyx6vgyLpS37kVhrRnnx093cXzFYzhfSl8RN5zSur/JY/LD= Private-MAC: f6624c2b7933e85f536d0020fe519821074a415c</code> There are conversion tools out there. I believe <a>PuTTYgen</a> does the trick. By the way, do not share your private keys in public places. The above two examples are not actual key files of mine, but rather generated with a script to look nearly identical to actual key files of each type. And why would I go to the trouble of writing a script to do such a thing? Well, <a>why not</a>? RabbitMQ In a browser, navigate to http://localhost:8080 and enter <code>guest</code> for both the username and password. There are some <code>Makefile</code> commands for RabbitMQ as well. To build and run the RabbitMQ container, you can use the following commands: <code>shell make mq run</code> To test the container, run the following command: <code>shell make mq test</code> To interact with the RabbitMQ container, there are quite a few commands in the <code>Makefile</code>, such as: <code>shell make mq create-queue queue=my_queue make mq publish-message queue=my_queue msg="Hello, World!"</code> Lessons DevOps Gotchas Nginx Gotchas Environment Variables When trying to assign a variable port to the <code>listen</code> directive, I discovered that Nginx simply does not allow for that, even when using leveraging lua. I had to use an <code>envsubst</code> call in the Dockerfile as a work around. Docker Gotchas ARGs and Multi Stage Builds I kept ending up with empty strings for my ENV vars when trying to construct variable rich strings. It turns out that build <code>ARG</code> values passed in via the Docker CLI are reset with each build when it comes to multi stage builds. Refer to: https://stackoverflow.com/a/68061457/10973023 Exec Form vs Shell Form for ENTRYPOINT: When including ENV vars inside of a <code>Dockerfile</code>, it is important to note that <code>ENTRYPOINT</code> commands will be unable to interprete these values when written in the <code>exec form</code> format. Does NOT work (<code>exec form</code>): <code>ENTRYPOINT ["dotnet", "aspnetapp.dll", "--urls", $URL]</code> DOES work (<code>shell form</code>): <code>ENTRYPOINT dotnet aspnetapp.dll --urls $URL</code> Refer to: https://stackoverflow.com/questions/37904682/how-do-i-use-docker-environment-variable-in-entrypoint-array Docker Compose Gotchas Dynamic Build Args Wow, just wow. After hours of trial and error and revisiting the docs and various StackOverflow discussions, it turns out there's really no way to dynamically populate build args from a file. This is incredibly disappointing, as the only workarounds are either: 1. Passing the build args in manually via the CLI, which of course would be utterly redundant with respect to the <code>Makefile</code> protocol I'm already using. 2. Writing some kind of script to generate the <code>docker-compose.yml</code> file, which, again, would simply be completely redundant. 3. Hardcoding the values in the <code>docker-compose.yml</code> file, which I'm just plain not a fan of. So I'm pretty much abandoning the Docker compose route here. For posterity's sake, I'm going to include the <code>docker-compose.yml</code> file that I had started on, even though it won't work unless you use one of the three mechanisms I just mentioned for injecting the build args, which I just refuse to do on principle. But feel free to give it a go if you're up for it. Make Gotchas Tabs vs Spaces Makefiles require tabs and will throw an error if you use spaces instead. For instance, the following will throw an error: <strong>Makefile</strong>: <code>shell nginx-v2-build: cd server/nginx-v2 &amp;&amp; docker build --build-arg NGINX_VERSION=$(NGINX_VERSION) --build-arg LUA_JIT_VERSION=$(LUA_JIT_VERSION) --build-arg ENTRYPOINT_VERSION=2 --build-arg NGINX_PORT=$(NGINX_PORT) -t nginx-v2:latest .</code> <strong>Error</strong>: <code>shell (venv) PS C:\Users\Darren\PycharmProjects\Miniprojects\RESTettaStone&gt; make nginx-v2-build Makefile:43: *** multiple target patterns. Stop.</code> Whereas this next snippet will work just fine: <code>shell nginx-v2-build: cd server/nginx-v2 &amp;&amp; docker build --build-arg NGINX_VERSION=$(NGINX_VERSION) --build-arg LUA_JIT_VERSION=$(LUA_JIT_VERSION) --build-arg ENTRYPOINT_VERSION=2 --build-arg NGINX_PORT=$(NGINX_PORT) -t nginx-v2:latest .</code> So Makefiles are picky about this... so what, right? It's the completely ambiguous error message that makes this particularly frustrating. The message <em>"multiple target patterns"</em> seems to indicate another root cause altogether, so if you don't already associate that error in your mind with a case of using the wrong whitespace for indentation, it can be perplexing indeed. Just something to keep in mind. Language and Framework Gotchas Symfony (PHP) Headers vs Body and the Whitespace Issue I struggled with the fact that I was receiving a response in plain text while I was setting the <code>Content-Type</code> header to <code>application/json</code>. I quadruple checked that the string I was sending was perfectly structured to the satisfaction of the JSON specifications, but it just kept showing up as <code>text/html</code>. It turned out that there was some extra whitespace finding its way into the response. The solution to that, as it turns out, is to wrap the entire construction of the response inside of a pair of functions that deal with <em>output buffering</em> (<code>ob_start()</code> and <code>ob_end_clean()</code>). Here is an example of how that looks: ```php class UserController extends AbstractController { #[Route('/users', name: 'users')] public function hello(EntityManagerInterface $entityManager, SerializerInterface $serializer): Response { ob_start(); // Start output buffering <code> $repository = $entityManager-&gt;getRepository(User::class); $response = new Response();$users = $repository-&gt;findAll(); $jsonContent = $serializer-&gt;serialize($users, 'json'); $response = new Response($jsonContent, Response::HTTP_OK, ['Content-Type' =&gt; 'application/json',]); ob_end_clean(); // End output buffering return $response; } </code> } ``` CLI Race Condition I encountered a very bizarre peculiarity with running Symfony in a Docker container that I have not encountered in any of the other subprojects. After a lot of trial and error, it eventually came down to adding a 5 second delay to wait for the application to be fully up and running. The following <code>ENTRYPOINT</code> command resulted in the container exiting immediately: <code>shell ENTRYPOINT symfony serve --port=$PORT</code> Whereas, during my debugging, I was able to get it to work just fine by replacing that line with <code>ENTRYPOINT bash</code> and then accessing the internal CLI and entering <code>symfony serve --port=$PORT</code>. Ultimately, the following <code>ENRTYPOINT</code> ended up working: <code>shell ENTRYPOINT bash -c "sleep 5 &amp;&amp; symfony serve --port=${PORT}"</code> A note on one of the techniques I was able to use to help ensure at least that the application was executing successfully and not throwing any errors was the following command: <code>shell docker run -it symfony_app:1 /bin/bash</code> This super helpful command will likely come in handy in the future when I'm looking to troubleshoot containers that close immediately. Rocket (Rust) Pear Codegen Dependency I encountered a somewhat silly error when trying to build the Rocket app. The message was something to the effect of "failed to run custom build command for <code>pear_codegen v0.1.5</code>". I had tried explicitly specifying a newer version of <code>pear_codegen</code> in my <code>Cargo.toml</code> configuration file, but it was a dependency of a dependency, so that might be why I was unable to override it. Interestingly, others have encounters problems with this exact scenario going back about six years: https://github.com/SergioBenitez/Pear/issues/13 The solution that ultimately worked was adding the following command to the <code>Dockerfile</code> (even though I explicity define the Rust version to be <code>nightly</code> in several places): <code>shell RUN /usr/local/cargo/bin/rustup override set nightly</code> Django (Python) Project Structure I'll be honest, I struggled a bit with Django. I had worked with the framework many years ago, so it has been a while. There's that, and then the fact that I have a general preference for working with frameworks that are a lot less rigidly structured. I will always prefer Flask over Django, for example. In order to use the framework, one is instructed that they must run a couple of code generation steps, and then modify the generated boilerplate as needed. Well, I kind of skipped that step, to make it more like working with Flask (where you build from bottom up). This led to some initial difficulties while I was getting to know exactly how the files are meant to be named and structured throughout. URL Routing I faced similar challenges with URL routing as I did with the project structure. This might have been exacerbated by my Docker container networking and Nginx configurations for this particular project. For example, I disabled i18n in the <code>settings.py</code> to avoid any <code>en</code> prefixes. Django REST Framework It is pretty clear that Django proper is meant to be server HTML files (in the form of templates). This particular use case here though is REST endpoints exclusively (for the backend portion, at least). For these reasons, I'd likely go with the official Django REST framework over traditional Django for such use cases. In fact, I may add such a subproject to the ever-growing collection here. Zig Postgres Connection Pool Inconsistency Problem Full CRUD works, however, there is a problem with it behaving inconsistently and sometimes throwing errors about the database being closed. I'm leaving this as a problem to solve in the future. Fat Free (PHP) Dependency Source So I had an interesting experience with getting Fat Free to work right. I kept getting 500 errors automatically with every endpoint. It turned out that there was an issue with <code>E_STRICT</code> being used but deprecated for the latest versions of PHP. I had the option to downgrade PHP, but didn't really want to go that route. Another option I had was to patch the code directly in the downloaded package. In fact, I started adding a few <code>sed</code> commands to my <code>Dockerfile</code> to accomplish just that: ```shell Patch the offending line in FatFree framework's base.php RUN sed -i 's/error_reporting((E_ALL|E_STRICT)/error_reporting(E_ALL/' vendor/bcosca/fatfree-core/base.php ``` And I was using various <code>grep</code> calls to find other issues including a nullable parameter thing: ```shell grep -Po "function \w+((.*?))" vendor/bcosca/fatfree-core/base.php Patch the Preview::render() method to fix implicit nullable parameter Patch the functions referencing $hive RUN sed -i 's/array $hive=NULL/?array $hive=NULL/g' vendor/bcosca/fatfree-core/base.php ``` But I also kept wondering how these simple fixes hadn't already been done by the maintainers of the repo. Well, it turns out that the changes <em>had been made</em>. I searched inside of GitHub for the offending bits of code, and they were all fixed! So I spend a bit of time just absolutely puzzled as to what was going on. Of course, I double, even triple, checked that the version number specified in my <code>Dockerfile</code> and in my <code>composer.json</code> file reflected the latest release according to GitHub. Suddenly, at some point, I noticed that the repository I was searching through on the GitHub.com website was at <code>f3-factory/fatfree-core</code>, not <code>bcosca/fatfree-core</code>. I of course remedied that immediately and everything worked! So the moral of the story here - the actual "Gotcha!" - is to keep an eye out for scenarios where there can be more than one conflicting repository, probably due to a forking or something like that. Database Gotchas Postgres pg_stat_activity Locks I encountered my first case of unfinished processes locking my Postgres database. In order to determine which processes are causing the locks, you can run the following query: <code>sql SELECT * FROM pg_stat_activity;</code> And then to remove the locks, you can run the following query: ```sql REVOKE CONNECT ON DATABASE postgres FROM PUBLIC, myusername; SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE -- don't kill my own connection! pid &lt;&gt; pg_backend_pid() -- don't kill the connections to other databases AND datname = 'postgres' ; ``` For some additional background: * https://stackoverflow.com/questions/48783188/postgres-table-queries-not-responding * https://stackoverflow.com/questions/17654033/how-to-use-pg-stat-activity * https://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection As for what specifically kept causing the locks in the first place, I have a few theories, but I did not test any of them out directly (there were over 20 different locks by the time I noticed they were causing problems). They did occur when I started adding database interaction during the running of the <a>full scale CRUD testing suites</a>. Other General Lessons Branch Protection Well, a little over 600 commits in with this project and I slipped up and pushed three commits directly to the main branch before realizing that I hadn't branched off. <a>The first one</a>. On work projects, if there aren't already protections in place, I always insist on them, because mistakes can happen rather easily. I guess I kind of figured I wouldn't make that type of slip up, but, alas, I did. I of course went right ahead and added some branch protection rules for the main branch, and I advise anyone else out there to do the same, whether it's a professional repo or just a fun little side project like this, it's best to follow good practices with consistency. Comparisons Projects by Language Please note that some of these categorizations are a bit arbitrary and open to debate. I simply wanted to cluster them for readability sake (refer to the concept of <a>"chunking"</a> in cognitive psychology research into working memory). Classic See also: <a>Performant</a> <ul> <li><strong>C</strong>: See <a>Series of Tubes repo</a>.</li> <li><strong>C++</strong>:</li> <li><a>Crow</a>.</li> </ul> Performant See also: <a>C and C++</a> These are the languages frequently used for compiled system level applications, where memory management and type safety are of critical concern. <ul> <li><strong>Rust</strong>:</li> <li><a>Actix</a>.</li> <li><a>Rocket</a>.</li> <li>See also: <a>Wasm-FRP repo</a>.</li> <li>Yew (Front end framework): See <a>Wasm-FRP repo</a>.</li> <li><strong>Zig</strong>:</li> <li><a>Zig</a>.</li> <li><strong>Go</strong>:</li> <li><a>Go</a>.</li> <li><strong>D</strong>:</li> <li><a>Vibe</a>.</li> </ul> Object Oriented This category is pretty straight forward. These are the primarily object-oriented languages. (PS: As a personal aside, these are by far my least favorite languages to work with. I frequently refer to them as the boilerplate languages as it takes so many lines of code to write the equivalent to other languages. And it's not even that I dislike object oriented programming. Python, JavaScript, and Ruby also allow for OOP without all the excessive boilerplate. See also: The <a>discussion regarding language simplicity</a>) <ul> <li><strong>C#</strong>:</li> <li><a>Asp.Net</a>.</li> <li><strong>Java</strong>:</li> <li><a>SpringBoot</a>.</li> <li><a>Tomcat</a>.</li> </ul> Procedural <ul> <li><strong>Fortran</strong>:</li> <li>(Still incoming) <a>Fortran</a>.</li> <li><strong>Pascal</strong>:</li> <li>(Still incoming) <a>Pascal</a>.</li> <li><strong>COBOL</strong>:</li> <li>(Still incoming) <a>COBOL</a>.</li> </ul> Functional These languages are the prototypical functional programming languages. <ul> <li><strong>Lisp</strong>:</li> <li>(Still incoming) <a>Lisp</a>.</li> <li><strong>Haskell</strong>:</li> <li>(Still incoming) <a>Haskell</a>.</li> <li>(Still incoming) <a>Spock</a>.</li> </ul> Multi-Paradigm With these languages, you get to have the best of both worlds. You can write object-oriented code, or you can write functional code. Or you can mix the two. <ul> <li><strong>Scala</strong>:</li> <li><a>Play</a>.</li> <li><strong>Swift</strong>:</li> <li><a>Swift</a>.</li> <li><strong>F#</strong>:</li> <li><a>F#</a>.</li> </ul> Versatile or Other This category is almost a catch all of sorts. These are languages that can be written with different paradigms in mind, perhaps have loose typing, and are generally more flexible. While I created a dedicated section for Scala, Swift, and F# as the "multi-paradigm" languages, they could just as easily fit into this cluster. However, <a>as mentioned above</a>, I am categorizing these mostly for the sake of readability. Some of these languages are frequently categorized as "scripting languages." I'm a not a big fan of that particular characterization as it gives the impression that they are less capable than the others, when in fact, their versatility makes them that much more powerful. They are all Turing complete languages, so if you find them particularly limiting, that's just a skill issue. And then there's Prolog. Prolog is a truly unique language as it falls under the rare category of logic programming. Note that I consider <a>JavaScript</a> to fall into this category as well, but it gets its own section because there are so many frameworks built for it. <ul> <li><strong>Lua</strong>:</li> <li><a>Lua</a>.</li> <li><strong>Perl</strong>:</li> <li><a>Perl</a>.</li> <li><strong>PHP</strong>:</li> <li><a>Fat Free</a>.</li> <li><a>Laravel</a>.</li> <li><a>Symfony</a>.</li> <li><strong>Python</strong>:</li> <li><a>Django</a>.</li> <li><a>Flask</a>.</li> <li>(Still incoming) <a>Chalice</a>.</li> <li><strong>Ruby</strong>:</li> <li><a>Rails</a>.</li> <li><strong>Prolog</strong>:</li> <li><a>Prolog</a>.</li> </ul> JavaScript This language gets its own category simply because it is so frequently used in front end frameworks. <ul> <li><strong>Back End JS</strong>:</li> <li><a>Bun</a>.</li> <li><a>Firebase</a>.</li> <li><a>Node</a>.</li> <li><strong>Front End JS</strong>:</li> <li><a>Angular</a>.</li> <li><a>Gatsby</a>.</li> <li><a>Next</a>.</li> <li><a>React</a>.</li> <li><a>React Fiber</a>.</li> <li><a>Vue</a>.</li> <li><a>Expo / React Native</a>.</li> <li><a>Electron</a>.</li> </ul> Metrics <strong>NOTE</strong>: <strong>This section is a work in progress.</strong> This is where I will discuss the various trade offs between the different languages and frameworks. Qualitative Simplicity This is where I will discuss the trade-off between simplicity and complexity of code (from a human readability standpoint, not in terms of, say, cyclic complexity, which is a more quantitative measure). This includes factors such as intuitiveness, ease of use, and the number of lines of code needed to accomplish a given task. Quantitative Performance TBD... Both Qualitative and Quantitative Security TBD... Safety Type safety, memory safety, etc. Optimization Latency TBD... Docker Image Size Table Sorted Alphabetically | App | Image Size | |-----------|-------------| | actix_app | 1.88 GB | | angular_app | 1.88 GB | | aspnet_app | 223.67 MB | | bun_app | 226.27 MB | | clojure_app | 623.15 MB | | cobol_app | 243.88 MB | | crow_app | 932.74 MB | | debugger | 11.05 MB | | django_app | 1.07 GB | | fatfree_app | 618.25 MB | | firebase_app | 1.84 GB | | flask_app | 1.03 GB | | fortran_app | 508.85 MB | | fsharp_app | 1.12 GB | | gatsby_app | 1.59 GB | | go_app | 852.56 MB | | grpc_client | 1.07 GB | | grpc_server | 1.4 GB | | haskell_app | 8.12 GB | | laravel_app | 707.13 MB | | lisp_app | 1.26 GB | | lua_app | 413.29 MB | | next_app | 888.96 MB | | nginx | 405.53 MB | | node_app | 1.13 GB | | pascal_app | 1.72 GB | | perl_app | 1.86 GB | | php_app | 649.19 MB | | play_app | 288.35 MB | | postgres | 377.36 MB | | postgres | 373.13 MB | | postgres | 212.85 MB | | prolog_app | 577.73 MB | | rails_app | 1.16 GB | | react_app | 541.67 MB | | reactfiber_app | 1.85 GB | | rocket_app | 2.37 GB | | spock_app | 5.83 GB | | springboot_app | 809.8 MB | | swift_app | 345.7 MB | | symfony_app | 4.65 GB | | tomcat_app | 681.22 MB | | vibe_app | 1.49 GB | | vue_app | 577.67 MB | | zig_app | 567.78 MB | Table Sorted by Image Size | App | Image Size | |-----------|-------------| | haskell_app | 8.12 GB | | spock_app | 5.83 GB | | symfony_app | 4.65 GB | | rocket_app | 2.37 GB | | actix_app | 1.88 GB | | angular_app | 1.88 GB | | perl_app | 1.86 GB | | reactfiber_app | 1.85 GB | | firebase_app | 1.84 GB | | pascal_app | 1.72 GB | | gatsby_app | 1.59 GB | | vibe_app | 1.49 GB | | grpc_server | 1.4 GB | | lisp_app | 1.26 GB | | rails_app | 1.16 GB | | node_app | 1.13 GB | | fsharp_app | 1.12 GB | | grpc_client | 1.07 GB | | django_app | 1.07 GB | | flask_app | 1.03 GB | | clojure_app | 623.15 MB | | crow_app | 932.74 MB | | next_app | 888.96 MB | | go_app | 852.56 MB | | springboot_app | 809.8 MB | | laravel_app | 707.13 MB | | tomcat_app | 681.22 MB | | php_app | 649.19 MB | | fatfree_app | 618.25 MB | | prolog_app | 577.73 MB | | react_app | 541.67 MB | | vue_app | 577.67 MB | | zig_app | 567.78 MB | | fortran_app | 508.85 MB | | lua_app | 413.29 MB | | nginx | 405.53 MB | | postgres | 377.36 MB | | postgres | 373.13 MB | | swift_app | 345.7 MB | | play_app | 288.35 MB | | cobol_app | 243.88 MB | | bun_app | 226.27 MB | | aspnet_app | 223.67 MB | | postgres | 212.85 MB | Some Potential Solutions Multi-Stage Builds TBD...
[]
https://avatars.githubusercontent.com/u/5776125?v=4
db_listener
jmatth11/db_listener
2024-10-01T21:59:22Z
experiment with listening to table updates in postgres
main
0
0
0
0
https://api.github.com/repos/jmatth11/db_listener/tags
GPL-3.0
[ "db", "notifications", "postgres", "zig" ]
68
false
2025-03-21T17:37:45Z
true
true
0.13.0
github
[ { "commit": "master", "name": "pg", "tar_url": "https://github.com/karlseguin/pg.zig/archive/master.tar.gz", "type": "remote", "url": "https://github.com/karlseguin/pg.zig" }, { "commit": "master", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/master.tar....
DB listener Sets up listeners on all tables in a postgres database to be notified of insert/update/delete. The program tears down listeners once brought down. You can use this info to display new or updated entries happening to your database in real time as a kind of local monitoring system. This was driven by the desire to debug DB changes easier for local development. This program also spins up a small server that allows for a websocket connection to get updates on the DB notifications. You can find a default implementation <a>here</a> Demo https://github.com/user-attachments/assets/e6ab4dd6-138d-4afb-b002-115766010c2f
[]