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/12786150?v=4
vscode-ext-zig-main-runner
hedzr/vscode-ext-zig-main-runner
2024-06-20T01:13:57Z
run or debug a zig main function in-place
master
0
1
0
1
https://api.github.com/repos/hedzr/vscode-ext-zig-main-runner/tags
Apache-2.0
[ "runner", "vscode-extension", "zig", "ziglang" ]
132
false
2025-02-11T06:06:22Z
false
false
unknown
github
[]
zig-main-runner README Run or Debug zig main function in-place. Also, Run or Debug test cases, build the whole workspace. What's New? See the <a>CHANGELOG</a>. <ul> <li>v1.0.2</li> <li>NOTE while you're debugging main(), kept its binary target name samed with its directory name.</li> <li>Fix debugType === 'auto'</li> </ul> Features This extension adds few <a>commands</a> for Zig development: <ul> <li>Run/Debug main()</li> <li>Run/Debug a Single Test</li> <li>Run tests in a file</li> <li>Run tests in the workspace</li> <li>Build workspace</li> <li>Debug test</li> </ul> We add some codelens links at the top of function main(), tests, and first line of a zig file, like the following Our inspirations are from <a>go-main-runner</a>, and <a>zig-language-extras</a>. Requirements <ul> <li>Visual Studio Code 1.79 or newer (or editors compatible with VS Code 1.79+ APIs)</li> <li>Zig ~~0.10 or newer~~ any version and Zls</li> <li>Visual Studio Code Extensions:</li> <li><a>VS Code Zig Language extension</a></li> </ul> Extension Settings Enable Code Lens You may disable or enable vscode codelens totally. With settings: <code>json "zig-main-runner.main.enableCodeLens": false,</code> Default is true. Enable Code Lens You may enable or disable vscode codelen for test cases. With settings: <code>json "zig-main-runner.main.enableCodeLensForTests": true,</code> Default is false(disabled). Test Args You may add additional test command arguments. With settings <code>json { "zig-main-runner.test.args": "--deps zlib=zlib --mod zlib::../zig-zlib/src/main.zig --library z", }</code> But why? Guide The launching of main() function will be emitted to a Terminal window (as a vscode Task or a normal terminal session). By default, launching it as a Task allows you reinvoke it easily (by using vscode command <code>Tasks: Rerun Last Task</code>) <blockquote> <strong>TIP</strong> Requesting a keybinding to it is a good hit. Our private <code>keybindings.json</code> is a reference: <code>json [ { "key": "cmd+; cmd+;", "command": "workbench.action.tasks.reRunTask" } ]</code> It is useful while you are invoking <code>main.zig</code> again and again. </blockquote> When you're debugging with Zig build.zig, only a main() whom has same name with its directory name can be supported because we have no plan to analysis <code>build.zig</code> for multiple executables. This structure is good: <code>bash &lt;root&gt; - src/ - example/ main.zig # exe target should be named to 'example' main.zig # exe target should be named to '&lt;root&gt;' build.zig</code> Build the Workspace This works by running <code>zig build</code>. Test the Workspace This works by running <code>zig build test</code>. Debugging We assume the debugger is in your <code>PATH</code> to debug main() function or test cases. To avoid unnecessary dependencies, our extension has only one dep to <code>zig laguage</code>. Here's some extensions for debugging: <ul> <li><a>Native Debug</a> for debugging on Linux</li> <li><a>CodeLLDB</a> for debugging on MacOS</li> <li><a>C/C++</a> for debugging on Windows</li> </ul> But, you could manage the debuggers with OS package managers. The default debugger types for each platform are as follows: <ul> <li>"lldb" for darwin platform</li> <li>"cppvsdbg" for win32 platform</li> <li>"gdb" for other platforms</li> </ul> Release Notes Users appreciate release notes as you update your extension. 1.0.1 First public release REFs <ul> <li><a>https://code.visualstudio.com/api/working-with-extensions/publishing-extension</a></li> <li><a>VS Code Extension Guidelines</a></li> <li><a>Visual Studio Code's Markdown Support</a></li> <li><a>Markdown Syntax Reference</a></li> </ul> <strong>Enjoy!</strong>
[]
https://avatars.githubusercontent.com/u/69123925?v=4
zig-book
pedropark99/zig-book
2024-05-27T23:06:42Z
An open, technical and introductory book for the Zig programming language 📚📖
main
21
1,457
86
1,457
https://api.github.com/repos/pedropark99/zig-book/tags
NOASSERTION
[ "book", "course", "programming", "programming-language", "tutorial", "tutorial-course", "zig", "ziglang" ]
29,314
false
2025-05-21T15:51:04Z
false
false
unknown
github
[]
Introduction to Zig <a></a> Hey! This is the official repository for the book "Introduction to Zig: a project-based book", written by Pedro Duarte Faria. To know more about the book, checkout the <a>About this book</a> section below. You can read the current version of the book in your web browser: <a>https://pedropark99.github.io/zig-book/</a>. The book is built using the publishing system <a>Quarto</a> in conjunction with a little bit of R code (<code>zig_engine.R</code>), that is responsible for calling the Zig compiler to compile and run the Zig code examples. Support the project! If you like this project, and you want to support it, you can buy a PDF, eBook or a physical copy of the book, either at Amazon, or at Leanpub: <ul> <li>Amazon: <a>https://www.amazon.com/dp/B0DJYMDRLP</a></li> <li>Leanpub: <a>https://leanpub.com/introductiontozigaproject-basedbook</a></li> </ul> Sending donations directly You can also donate some amount directly to the author of the project via: <ul> <li>PayPal Donation.</li> <li>Revolut.</li> </ul> These are good ways to support directly the author of the project, which helps to foster more contents like this, and it makes possible for the author to keep writing helpful tools and materials for the community. PayPal <a></a> Revolut You can send money via Swift Payment with the following bank and Swift details: <code>Recipient: Pedro Duarte Faria BIC/SWIFT Code: REVOSGS2 Account number: 6124512226 Name and address of the bank: Revolut Technologies Singapore Pte. Ltd, 6 Battery Road, Floor 6-01, 049909, Singapore, Singapore Corresponding BIC: CHASGB2L</code> If you do have a Revolut account, you can scan the following QR code: <a>http://revolut.me/pedroduartefaria</a> About this book This is an open (i.e., open-source), technical and introductory book for the <a>Zig programming language</a>, which is a new general purpose, and low-level programming language for building optimal and robust software. Official repository of the book: <a>https://github.com/pedropark99/zig-book</a>. This book is designed for both beginners and experienced developers. It explores the exciting world of Zig through small and simple projects (in a similar style to the famous "Python Crash Course" book from Eric Matthes). Some of these projects are: a Base64 encoder/decoder, a HTTP Server and an image filter. As you work through the book, you will learn: <ul> <li>The syntax of the language, and how it compares to C, C++ and Rust.</li> <li>Data structures, memory allocators, filesystem and I/O.</li> <li>Optionals as a new paradigm to handle nullability.</li> <li>How to test and debug a Zig application.</li> <li>Errors as values, and how to handle them.</li> <li>How to build C and Zig code with the build system that is embedded into the language.</li> <li>Zig interoperability with C.</li> <li>Parallelism with threads and SIMD.</li> <li>And more.</li> </ul> How to build the book This book depends on the three main pieces of software: <ol> <li>The <a>Zig compiler</a>, which is responsible for compiling most of the code examples exposed in the book.</li> <li>The <a>R programming language</a>, which provides some useful tools to collect the code examples exposed across the book, and send them to the zig compiler to be compiled and executed, and also, collect the results back to include them in the book.</li> <li>The <a>Quarto publishing system</a>, which provides the useful tools to compile the book, creating internal links, references, a chapters structure, the HTML content of the book, etc.</li> </ol> So, you first need to install these three pieces of software in your current machine. You can find instructions on how to install these pieces of software by clicking in the above hyperlinks. Install R packages After you installed the three pieces of software listed above, you should run the <code>dependencies.R</code> R script, to install some R packages that are used across the book. Just run the command below in your terminal, and you should be fine. OBS: If you are on Linux or MacOS, this command will probably take some time to run, because every single dependency gets built from source. In Windows, this usually doesn't take that long because pre-built binaries are usually available. <code>bash Rscript dependencies.R</code> Render the book If you installed Quarto correctly in your computer , you should be able to build the book by simply executing the following command in the terminal. <code>bash quarto render</code> How the Zig compiler is found Some R code (<code>zig_engine.R</code>) is used to collect the Zig code examples found across the book, and send them to the Zig compiler, so that they can be compiled and executed. But in order to do that, this R code needs to find the Zig compiler installed in your machine. This search process is done in two stages. First, it uses the <a><code>Sys.which()</code> function</a> to find the path to the Zig compiler in your computer, which is just a R interface to the <code>which</code> command line tool. This is a fast and easy approach, but, it doesn't work in all situations, specially if your Zig compiler is not installed in a "standard location" in your computer. That is why, a second strategy is applied, which is to search through the PATH environment variable. It gets the value of your PATH environment variable, and iterates through the directories listed in this variable, trying to find the Zig compiler in one of them. This approach is much slower than the first one, but is more garanteed to work. License Copyright © 2024 Pedro Duarte Faria. This book is licensed by the CC-BY 4.0 Creative Commons Attribution 4.0 International Public License. <a></a>
[]
https://avatars.githubusercontent.com/u/1552770?v=4
flow
neurocyte/flow
2024-02-25T20:11:11Z
Flow Control: a programmer's text editor
master
32
911
54
911
https://api.github.com/repos/neurocyte/flow/tags
MIT
[ "language-server-client", "language-server-protocol", "text-editor", "tree-sitter", "tui", "zig" ]
2,779
false
2025-05-20T21:29:02Z
true
true
0.14.0
github
[ { "commit": null, "name": "syntax", "tar_url": null, "type": "relative", "url": "src/syntax" }, { "commit": "372501d1576b5723829bcba98e41361132c7b618.tar.gz", "name": "flags", "tar_url": "https://github.com/n0s4/flags/archive/372501d1576b5723829bcba98e41361132c7b618.tar.gz.tar.gz...
Flow Control: a programmer's text editor This is my Zig text editor. It is under active development, but usually stable and is my daily driver for most things coding related. <a></a> Requirements <ul> <li>A modern terminal with 24bit color and, ideally, kitty keyboard protocol support. Kitty, Foot and Ghostty are the only recommended terminals at this time. Most other terminals will work, but with reduced functionality.</li> <li>NerdFont support. Either via terminal font fallback or a patched font.</li> <li>Linux, MacOS, Windows, Android (Termux) or FreeBSD.</li> <li>A UTF-8 locale</li> </ul> Download / Install Binary release builds are found here: <a>neurocyte/flow/releases</a> Fetch and install the latest release to <code>/usr/local/bin</code> with the installation helper script: <code>shell curl -fsSL https://flow-control.dev/install | sh</code> Nightly binary builds are found here: <a>neurocyte/flow-nightly/releases</a> Install latest nightly build and (optionally) specify the installation destination: <code>curl -fsSL https://flow-control.dev/install | sh -s -- --nightly --dest ~/.local/bin</code> See all avalable options for the installer script: <code>curl -fsSL https://flow-control.dev/install | sh -s -- --help</code> Or check your favorite local system package repository. <a></a> Building Make sure your system meets the requirements listed above. Flow builds with zig 0.14.0 at this time. Build with: <code>shell zig build -Doptimize=ReleaseSafe</code> Zig will by default build a binary optimized for your specific CPU. If you get illegal instruction errors add <code>-Dcpu=baseline</code> to the build command to produce a binary with generic CPU support. Thanks to Zig you may also cross-compile from any host to pretty much any target. For example: <code>shell zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-windows --prefix zig-out/x86_64-windows zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-macos-none --prefix zig-out/x86_64-macos zig build -Doptimize=ReleaseSafe -Dtarget=aarch64-linux-musl --prefix zig-out/aarch64-linux</code> When cross-compiling zig will build a binary with generic CPU support. Running Flow Control The binary is: <code>shell zig-out/bin/flow</code> Place it in your path for convenient access: <code>shell sudo cp zig-out/bin/flow /usr/local/bin</code> Or if you prefer, let zig install it in your home directory: <code>shell zig build -Doptimize=ReleaseSafe --prefix ~/.local</code> Flow Control is a single statically linked binary. No further runtime files are required. You may install it on another system by simply copying the binary. <code>shell scp zig-out/bin/flow root@otherhost:/usr/local/bin</code> Configuration is mostly dynamically maintained with various commands in the UI. It is stored under the standard user configuration path. Usually <code>~/.config/flow</code> on Linux. %APPDATA%\Roaming\flow on Windows. Somewhere magical on MacOS Logs, traces and per-project most recently used file lists are stored in the standard user application state directory. Usually <code>~/.local/state/flow</code> on Linux and %APPDATA%\Roaming\flow on Windows. Files to load may be specifed on the command line: <code>shell flow fileA.zig fileB.zig</code> The last file will be opened and the previous files will be placed in reverse order at the top of the recent files list. Switch to recent files with Ctrl-e. Common target line specifiers are supported too: <code>shell flow file.txt:123</code> Or Vim style: <code>shell flow file.txt +123</code> Use the --language option to force the file type of a file: <code>shell flow --language bash ~/.bash_profile</code> Show supported language names with <code>--list-languages</code>. See <code>flow --help</code> for the full list of command line options. Key bindings and commands Press <code>F2</code> to switch the current keybinding mode. (flow, vim, emacs, etc.) Press <code>ctrl+shift+p</code> or <code>alt+x</code> to show the command palette. Press <code>ctrl+F2</code> to see a full list of all current keybindings and commands. Run the <code>Edit keybindings</code> command to save the current keybinding mode to a file and open it for editing. Save your customized keybinds under a new name in the same directory to create an entirely new keybinding mode. Keybinding changes will take effect on restart. Terminal configuration Kitty, Ghostty and most other terminals have default keybindings that conflict with common editor commands. I highly recommend rebinding them to keys that are not generally used anywhere else. For Kitty rebinding <code>kitty_mod</code> is usually enough: <code>kitty_mod ctrl+alt</code> For Ghostty each conflicting binding has to be reconfigured individually. Features <ul> <li>fast TUI interface. no user interaction should take longer than one frame (6ms) (even debug builds)</li> <li>tree sitter based syntax highlighting</li> <li>linting (diagnostics) and code navigation (goto definition) via language server</li> <li>multi cursor editing support</li> <li>first class mouse support (yes, even with a scrollbar that actually works properly!) (Windows included)</li> <li>vscode compatible keybindings (thanks to kitty keyboard protocol)</li> <li>vim compatible keybindings (the standard vimtutor bindings, more on request)</li> <li>user configurable keybindings</li> <li>excellent unicode support including 2027 mode</li> <li>hybrid rope/piece-table buffer for fast loading, saving and editing with hundreds of cursors</li> <li>theme support (compatible with vscode themes via the flow-themes project)</li> <li>infinite undo/redo (at least until you run out of ram)</li> <li>find in files</li> <li>command palette</li> <li>stuff I've forgotten to mention...</li> </ul> Features in progress (aka, the road to 1.0) <ul> <li>completion UI/LSP support for completion</li> <li>persistent undo/redo</li> <li>file watcher for auto reload</li> </ul> Features planned for the future <ul> <li>multi tty support (shared editor sessions across multiple ttys)</li> <li>multi user editing</li> <li>multi host editing</li> </ul> Community Join our <a>Discord</a> server or use the discussions section here on GitHub to meet with other Flow users!
[]
https://avatars.githubusercontent.com/u/499?v=4
spice
judofyr/spice
2024-08-03T07:56:34Z
Fine-grained parallelism with sub-nanosecond overhead in Zig
main
4
844
15
844
https://api.github.com/repos/judofyr/spice/tags
0BSD
[ "concurrency", "parallelism", "threads", "zig", "zig-package" ]
79
false
2025-05-20T05:12:10Z
true
true
0.11.0
github
[ { "commit": "229fa709c1fc2e94490a736e17151cb85a328a81.tar.gz", "name": "parg", "tar_url": "https://github.com/judofyr/parg/archive/229fa709c1fc2e94490a736e17151cb85a328a81.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/judofyr/parg" } ]
Spice: Parallelism with sub-nanosecond overhead <strong>Spice</strong> uses <a><em>heartbeat scheduling</em></a> to accomplish extremely efficient parallelism in Zig: <ul> <li><strong>Sub-nanosecond overhead:</strong> Turning your function into a parallelism-enabled function adds less than a nanosecond of overhead.</li> <li><strong>Contention-free:</strong> Threads will never compete (i.e. spin) over the same work. Adding more threads to the system will not make your program any slower, but the extra threads might be completely idle since there's nothing useful to do.</li> </ul> <em>(Update, September 2024: <a>Chili</a> is a Rust port of the ideas presented here. Check it out!)</em> The benchmark in the figure above (summing over the nodes in a binary tree) is typically one of the worst cases for parallelism frameworks: The actual operation is extremely fast so any sort of overhead will have a measurable impact. Here's the <em>exact</em> same benchmark in <a>Rayon</a>, an excellent library in Rust for doing parallelism. Both implementations follow the same fork/join API which gives code that is very easy to read and reason about. None of the findings here would surprise anyone who deeply knows Rayon and there are ways of getting better performance out of Rayon by using different techniques. This comes at cost of the code becoming more complicated and/or behaving subpar on different types of input. The purpose of this benchmark is to not discourage use of Rayon (on the contrary!), but rather demonstrate that it <em>is</em> possible to have both simple code and good parallelism. See <a>issue #5</a> for a longer discussion. The overhead here is roughly ~15 ns (from 7.48 ns to 22.99 ns) which means that at 4 threads we're "back" to the sequential performance - just using four times as much CPU. Luckily we <em>are</em> able to get linear speed-up (in terms of threads) initially. These benchmarks were ran on a <code>c4-standard-16</code> instance in Google Cloud with 16 cores. Rayon itself shows a nice ~14x speed-up (from 22.99 ns to 1.64 ns) at 16 threads, but compared to the <em>baseline</em> this ends up only being ~4.5x due to the overhead. In comparison, Spice scales slightly worse: It only got ~11x speed-up when going from 1 to 16 threads. However, due its low overhead this is also essentially the speed-up compared to the baseline. (It's not entirely clear why the Zig baseline implementation is twice as fast as the Rust implementation. The <a>compiled assembly (godbolt)</a> show that Rust saves five registers on the stack while Zig only saves three, but why? For the purpose of this benchmark it shouldn't matter since we're only comparing against the baseline of each language.) It becomes even more interesting if we're summing the nodes of a much smaller tree: In this scenario we have a very short duration of our program: The baseline implementation takes a few microseconds in total to run. For some reason the overhead is a bit higher (~19 ns), but more concerningly we see that performance becomes <em>worse</em> the <em>more</em> threads we're adding. At 32 threads it's in total <strong>60 times slower</strong>. (In this case we're using 32 threads on a machine which only has 16 cores. It's not given that we would see the same slowdown for a machine with 32 cores. Nonetheless, this scaling behavior is concerning.) The conventional wisdom for parallelism therefore ends up being "it's not worth it unless you have <em>enough work</em> to parallelize". The example above is typically presented as a "bad fit for parallelism". This is understandable and pragmatic, but in practice it makes it a lot more difficult to <em>actually</em> parallelize your code: <ul> <li>What exactly is "enough work"? You might need to do a lot of benchmarking with different types of input to understand this.</li> <li>It might be difficult to detect how much work a certain input does. For instance, in our binary tree we don't know the full size of it. There's no obvious way for us to say "if the tree is small enough, don't run the parallelized code" since by only looking at the root we don't the size of it.</li> <li>As we've seen, the potential slowdown can be extreme. What if 90% of your workload is like this?</li> <li>As your program evolves and your code does more (or less) <em>things</em>, the definition of "enough work" will also naturally change.</li> </ul> The goal of Spice is for you <strong>to never have to worry about your program becoming slower by making it parallel</strong>. If you're looking to maximize the performance you should of course do elaborate benchmarking, but <em>generally</em> with Spice you can add parallelism and there will be <em>practically</em> no overhead. The last example of summing over 1000 nodes behaves as follows in Spice: What's happening here is that it's discovering that the duration is too short so none of the multi-threading kicks in. All the extra threads here are sleeping, giving the cores time to execute other programs. Spice is <strong>primarily a research project</strong>. Read along to learn more about it, but if you're considering using it in production you should be aware of its <a>many limitations</a>. <em>(See the <a>bench/</a> directory for more details about these specific benchmarks.)</em> Table of Contents <ul> <li><a>Using Spice</a></li> <li><a>Work-stealing and its inefficiencies</a></li> <li><a>Implementation details</a></li> <li><a>Optimizing for static dispatch</a></li> <li><a>Low-overhead heartbeating signaling</a></li> <li><a>Global mutex is fine when there's no contention</a></li> <li><a>Branch-free doubly-linked list</a></li> <li><a>Minimizing the stack usage</a></li> <li><a>Passing values around in registers</a></li> <li><a>Benchmarks</a></li> <li><a>Acknowledgments</a></li> <li><a>Limitations</a></li> <li><a>FAQ</a></li> </ul> Using Spice The following example demonstrates how Spice works: ```zig const spice = @import("spice"); // (1) Add task as a parameter. fn sum(t: <em>spice.Task, node: </em>const Node) i64 { var res: i64 = node.val; <code>if (node.left) |left_child| { if (node.right) |right_child| { var fut = spice.Future(*const Node, i64).init(); // (3) Call `fork` to set up work for another thread. fut.fork(t, sum, right_child); // (4) Do some work yourself. res += t.call(i64, sum, left_child); if (fut.join(t)) |val| { // (5) Wait for the other thread to complete the work. res += val; } else { // (6) ... or do it yourself. res += t.call(i64, sum, right_child); } return res; } res += t.call(i64, sum, left_child); } if (node.right) |right_child| { // (2) Recursive calls must use `t.call` res += t.call(i64, sum, right_child); } return res; </code> } ``` <ol> <li>Every parallel function needs to take a <em>task</em> as a parameter. This is used to coordinate the work.</li> <li>You should never call your function directly, but instead use <code>t.call</code> which will call it for you (in the right way).</li> <li>Call <code>fork</code> to set up a piece of work which can be done by a different thread. This can be called multiple times to set up multiple pieces of work.</li> <li>After that your function should do some meaningful work itself.</li> <li>Call <code>join</code> to wait for the work done by the other thread.</li> <li><em>However</em>, <code>join</code> might return <code>null</code> and this signals that <em>no other thread picked up the work</em>. In this case you must do the work yourself.</li> </ol> Here we repeat ourselves in step 3 and 6: Both places we refer to <code>sum</code> and <code>right_child</code>. It's possible to hide this duplication by some helper function, <em>but</em> this example demonstrates a core idea behind Spice: <strong>Not every piece of work comes from the queue.</strong> You call <code>fork</code> to signal that there's something which <em>can</em> be executed by another thread, but if all the other threads are busy then you fallback to executing it as if the fork never happened. This principle is core to how Spice achieves its low and predictable overhead: If there's no parallelism possible then all Spice is doing on the hot path is pushing and popping the queue (without ever looking at any of the items). The actually coordination with other threads happens on a <em>fixed heartbeat</em>: Every 100 microsecond or so a thread will look at its current work queue and dispatch the top-most item to another waiting thread. Since the heartbeat happens very infrequently (compared to the clock speed) we also don't need to worry so much about what we're doing during the heartbeat. Even if we spend <em>hundreds</em> of nanoseconds the <em>total</em> overhead becomes small since we do it rarely. Work-stealing and its inefficiencies Spice provides the <a>fork/join model</a> which has typically been implementing by using <a><strong>work-stealing</strong></a>. Let's have a look at work-stealing: <ul> <li>Every thread have their own local <em>work queue</em>. Every piece of work in the system gets put onto this queue.</li> <li>The same thread will pick up work from this queue and execute it. This might lead to more work being added (onto the same queue).</li> <li>At some point, the local work queue for a thread will become empty. The thread will then attempt to <em>steal</em> work from another thread: It takes a chunk of the work from the <em>end</em> of another thread's queue and places it into its own.</li> <li>Since each thread pulls work from the <em>beginning</em> of its queue and other thread steals from the <em>end</em>, we expect there to be little contention on these queues.</li> </ul> However, there's three major sources of inefficiencies in this design: <strong>Every piece of work is a <em>dynamic dispatch</em>.</strong> In compiled languages (such as C) function calls are "practically" free due to the capability of statically knowing everything about the called function. This is a scenario which compilers and CPUs have been optimized for <em>decades</em> to execute efficiently. Work-stealing systems <em>don't</em> use this functionality, but instead puts every piece of work into generic "call this dynamic function". It's a small piece of overhead, but it does add up. <strong>The "local" work queue isn't really local.</strong> Yes, it's true that every thread have a single queue that they will push work onto, <em>but</em> this is far from a "local" queue as is typically described in concurrent algorithms. This is a queue in which <em>every</em> thread at <em>every</em> point might steal from. In reality, work-stealing systems with N threads have N global queues, where each queue only has a single producer, but everyone is a consumer. Why does this distinction matter? <em>Because all operations on these queues have to use atomic operations.</em> Atomic operations, especially stores, are far more expensive than regular, <em>local</em> stores. <strong>Spinning works great … until it doesn't.</strong> The queues in work-stealing systems are typically implemented using <em>spinning</em>: Every thread will optimistically try to acquire a single item from the queue, and if there's a contention with another thread it will <em>try again</em> in a loop. This typically gives great performance … <strong>until it doesn't</strong>. It can be very hard to reason about this or replicate it since under one set of conditions everything is fine, but <em>suddenly</em> during contention the system will slow down to a halt (i.e. 10x-100x slower). Spice directly tackles all of these inefficiencies: <ol> <li>The dynamic dispatch of the work queue is only used when work is sent to another thread. Work done <em>within</em> a single thread will use regular function calls outside of the work queue.</li> <li>The work queue is truly local: Pushing to it involves (1) one memory store to a pointer to somewhere on the stack, (2) one memory store to the current stack frame, (3) one register store. None of these operations need to synchronize with other threads.</li> <li>There isn't a single <code>while</code>-loop in Spice which doesn't also contain a <code>wait()</code>-call which will suspend the thread. There is no spinning.</li> </ol> Implementation details Let's dive further into how Spice is implemented to achieve its efficient parallelism. Optimizing for static dispatch A fork/join program has a set of code blocks which are executed in parallel and once they finish the <code>join</code> action completes: <code>join( fork { code1 } fork { code2 } fork { code3 } )</code> In Spice this is represented as: ``` job1 = fork { code1 } // Place on the queue job2 = fork { code2 } // Place on the queue code3 // Run right away if (job2.isExecuting()) { // Job was picked up by another thread. Wait for it. job2.wait() } else { code2 } if (job1.isExecuting()) { // Job was picked up by another thread. Wait for it. job1.wait() } else { code1 } ``` Notice that <code>code1</code> and <code>code2</code> has been duplicated_inside the function. This is actually a <em>good</em> thing. Most of the time the job will <em>not</em> be picked up by another thread. In this case, our program nicely turns into the sequential version (although in reverse order) with a few extra branches which are all very predictable. This is friendly both for the code optimizer (e.g. it can now inline the function call) and the CPU. Low-overhead heartbeating signaling The core idea of heartbeat scheduling is to do scheduling <em>locally</em> and at a <em>low frequency</em>: Every 100 microsecond or so we'd like every thread to look at it local work queue and send work to a different thread. The low frequency is key to eliminating overall overhead. If we're only doing something every 100 microsecond we can actually spend 100 nanoseconds (an eternity!) and still only introduce 0.1% overhead. Operating systems have built-in support for <em>signaling</em>, but these are very hard to reason about. The user code gets paused at <em>any</em> random point and it's hard to safely continue running. For this reason, Spice uses a cooperative approach instead: The user code have to call <code>tick()</code> and this detects whether a heartbeat should happen. This function call is automatically called for you whenever you use the <code>call</code>-helper. It's critical that this function is efficient when a heartbeat <strong>isn't</strong> happening. This is after all the common case (as the heartbeat is only happening every ~100 microsecond). <code>zig pub inline fn tick(self: *Task) void { if (self.worker.heartbeat.load(.monotonic)) { self.worker.pool.heartbeat(self.worker); } }</code> In Spice we spawn a separate heartbeat thread whose sole purpose is to periodically flip the thread's atomic heartbeat value from <code>false</code> to <code>true</code>. The <code>tick()</code> function then reads this atomic value and starts its heartbeat code when it's <code>true</code>. A key part of reducing the overhead of the ticking is to make sure the heartbeat function itself is marked as <em>cold</em>. This causes the presence of this function call to not use up any registers. Without this the overhead is significantly higher. Global mutex is fine when there's no contention If you look inside the codebase of Spice you will find that each thread pool has a single mutex which is locked all over the place. An immediate reaction would be "oh no, a global mutex is terrible" and you might be tempted to replace it. <em>However</em>, there's no problem with a global mutex <em>until you're being blocked</em>. And you can only be blocked if two conditions occur: <ol> <li>A thread is holding the lock for a <em>long</em> time.</li> <li>There's concurrent threads trying to acquire the lock at the same time.</li> </ol> <strong>None</strong> of these are true for Spice. The heartbeating ensures that typically only a single thread is executing a heartbeat. In addition, no user code is executed while the lock is held. We're only protecting trivial simple memory reads/writes which will complete in constant time. Branch-free doubly-linked list We're using a doubly-linked list to keep track of the work queue: <code>fork()</code> appends to the end, <code>join()</code> pops from the end (if it's still there), and we pop from the <em>beginning</em> when we want to send work to a background worker. <a>Appending into a doubly-linked list</a> typically looks like this: <code>zig pub fn append(list: *Self, new_node: *Node) void { if (list.last) |last| { // Insert after last. list.insertAfter(last, new_node); } else { // Empty list. list.prepend(new_node); } }</code> Notice that there's a conditional here: If the list is empty we need to do something special. Most of the time the list will of course <em>not</em> be empty. To eliminate the branch we can make sure that the list is <em>never</em> empty. We define a sentinel node (the "head") which always represents the beginning of the list. The tail pointer will start by pointing to this head node. This means that both pushing and popping is completely branch-free and these are operations we do at <em>every</em> recursive function call. Minimizing the stack usage A <code>Future</code> in Spice has two possible states: It's either <em>queued</em> or <em>executing</em>. The heartbeat is responsible for taking a <em>queued</em> future and start <em>executing</em> it. And as we already know: Heartbeating happens rarely so we expect many futures to be queued without executing. An early prototype of Spice used a <em>tagged union</em> to store the future on the stack. This turns out to be suboptimal because (1) stack usage matters for performance (at least in this benchmark) and (2) there's quite a lot of additional state needed to keep track of futures which are <em>executing</em>. To minimize stack usage Spice therefore uses two techniques: <ol> <li>Execution state is placed in a separate (pool-allocated) struct. The queued (but not executed) futures therefore does not need to consume any of this space.</li> <li>We manually create a tagged union where we use the fact that the <em>executing</em> state only needs a single pointer while the <em>queued</em> state is guaranteed to have a <code>prev</code> pointer. Whether the first field is <code>null</code> therefore decides which of these it is. (Maybe a smart enough compiler would be able to this optimization for us.)</li> </ol> ```zig const Future = struct { prev_or_null: ?<em>anyopaque, next_or_state: ?</em>anyopaque, } // A future which is <em>queued</em> has: // prev_or_null = pointer to prev future // next_or_state = pointer to next future // A future which is <em>executing</em> has: // prev_or_null = null // next_or_state = ExecuteState const ExecuteState = struct { requester: *Worker, done: std.Thread.ResetEvent = .{}, result: ResultType, // Any number of fields. } ``` Passing values around in registers Spice works with a <code>Task</code> struct which has two fields: A pointer to the owning worker and a pointer to tail of the work queue. For optimal performance these should be passed as registers across all function boundaries. However, with LLVM, passing a struct will very often cause it be passed on the stack. To work around this we define a <em>separate</em> function where <code>worker</code> and <code>job_tail</code> are actual parameters. We place the parameters into a struct and pass a pointer to this into the user-defined function. This function call we make sure is always being inlined: <code>zig fn callWithContext( worker: *Worker, job_tail: *Job, comptime T: type, func: anytype, arg: anytype, ) T { var t = Task{ .worker = worker, .job_tail = job_tail, }; return @call(.always_inline, func, .{ &amp;t, arg, }); }</code> This causes the <code>callWithContext</code>-function to be the <em>actual</em> function which LLVM works on, and since this has pointers are parameters it will happily pass these directly into registers. Benchmarks The initial development of Spice has been focused around a single benchmark which is described in detail in <a>bench/</a>. Acknowledgments Spice was made possible thanks to the research into <em>heartbeat scheduling</em>: <a>"The best multicore-parallelization refactoring you've never heard of"</a> gives an <em>excellent</em> introduction into the concepts of heartbeat scheduling. It's a very short paper which focuses entirely on a single use case, but describes everything in a manner which can be generalized. The solution presented in this paper is based around turning all the code into continuation-passing style which enables switching between sequential and parallel execution. Spice started out as an experiment of this approach, but this turned out to have quite high overhead (&gt;10 nanosecond). Going backwards in time, <a>"Heartbeat scheduling: provable efficiency for nested parallelism"</a> was the first paper introducing "heartbeat scheduling". This paper provides excellent information about the concepts, but the implementation is based around integrating this into an interpreter and focus is primarily on the theoretical guarantees as opposed to raw performance. <a>"Task parallel assembly language for uncompromising parallelism"</a> is a follow-up paper which improves the performance by defining a custom assembly language and using OS signaling for heartbeats. This is a fascinating line of research, but it's difficult to integrate into an existing language. Limitations There's <em>many</em> limitations of the current implementation of Spice: <ul> <li><strong>Rough edges when you're using it wrong:</strong> Spice is quite peculiar about how it should be used (most notably about <code>fork</code> and <code>join</code>). If you're using it wrong now then weird things could happen. This should be improved by adding more compile-time checking, debug-mode assertions, or changing the overall API.</li> <li><strong>Lack of tests:</strong> Spice contains a lot of gnarly concurrent code, but has zero testing coverage. This would have be improved before Spice can be responsibly used for critical tasks.</li> <li><strong>Lack of support for arrays/slices:</strong> Probably <em>the</em> most common use case for fine-grained parallelism is to do something for every element of an array/slice. There should be native, efficient support for this use case.</li> <li><strong>Lack of documentation:</strong> There's no good documentation of how to use it.</li> <li><strong>Lack of further benchmarks:</strong> This has only been tested on a single small benchmark. This benchmark <em>should</em> be quite representative (see <a>bench/</a> for more details), but further benchmarks are needed to validate these findings.</li> <li><strong>@panic-heavy:</strong> Spice is quite optimistic in its error handling and uses <code>@panic</code> extensively. To be considered a proper Zig library there needs to be way more consideration of how error cases are handled.</li> <li><strong>Lack of testing with ReleaseSafe:</strong> <code>ReleaseSafe</code> is an extremely nice feature of Zig. Further benchmarking and testing is needed to understand how well Spice can work here.</li> </ul> Luckily the whole codebase is ~500 lines so it shouldn't be <em>too</em> difficult to make progress on these areas. There's currently no plans of doing any active development on Spice to improve this (as the original author don't have the time). Any improvements in forks and/or re-implementations in other languages are highly encouraged! FAQ <strong>Question: Why is it called "Spice"?</strong> Answer: This project enables <em>fine-grained</em> parallelism. Sand is extremely fine-grained. Sand forms in dunes. <a>Spice</a>. Also: It's a hot take on parallelism. <strong>Question: Why is it implemented in Zig?</strong> Answer: Why not? This describes a <em>generic approach</em> to parallelism that should be possible to implement in multiple languages. Maybe I'll end up implementing something similar in another language as well? I don't know yet. If you think this is interesting for <em>your</em> language of choice I would encourage you to explore this area. <strong>Question: But if you did it in Rust we could have <em>safe</em> parallelism?</strong> Answer: Yeah, that sounds very cool. I'm not at all opposed to it. <em>That said</em>, I've been exploring many different techniques and variants while developing Spice. Many of my initial ideas were definitely not "safe" by any means, but I was able to express these ideas in Zig, look at the assembly and measure the performance in benchmarks. I'd probably only be able to explore a fraction of the ideas if I was limited by Rust's strict semantics in the <em>initial</em> phase of this project. If I have to turn this into a production-ready system I might decide to use Rust.
[ "https://github.com/0xrinegade/apz", "https://github.com/ziglana/gRPC-zig" ]
https://avatars.githubusercontent.com/u/196498040?v=4
zzz
tardy-org/zzz
2024-06-28T21:52:37Z
A framework for writing performant and reliable networked services.
main
11
566
20
566
https://api.github.com/repos/tardy-org/zzz/tags
MPL-2.0
[ "http", "http-server", "https", "tardy", "tls", "zig", "zig-package", "zzz" ]
959
false
2025-05-22T00:50:55Z
true
true
0.14.0
github
[ { "commit": "master", "name": "tardy", "tar_url": "https://github.com/tardy-org/tardy/archive/master.tar.gz", "type": "remote", "url": "https://github.com/tardy-org/tardy" }, { "commit": "master", "name": "secsock", "tar_url": "https://github.com/tardy-org/secsock/archive/master....
zzz Installing Compatible Zig Version: <code>0.14.0</code> Compatible <a>tardy</a> Version: <code>v0.3.0</code> Latest Release: <code>0.3.0</code> <code>zig fetch --save git+https://github.com/tardy-org/zzz#v0.3.0</code> You can then add the dependency in your <code>build.zig</code> file: ```zig const zzz = b.dependency("zzz", .{ .target = target, .optimize = optimize, }).module("zzz"); exe.root_module.addImport(zzz); ``` zzz? zzz is a framework for writing performant and reliable networked services in Zig. It supports both HTTP and HTTPS. zzz currently supports Linux, Mac and Windows. Linux is currently the recommended target for deployments. <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> zzz is currently <strong>alpha</strong> software and there is still a lot changing at a fairly quick pace and certain places where things are less polished. </blockquote> It focuses on modularity and portability, allowing you to swap in your own implementations for various things. Consumers can provide an async implementation, allowing for maximum flexibility. This allows for use in standard servers as well as embedded/bare metal domains. For more information, look here: 1. <a>Getting Started</a> 2. <a>HTTPS</a> Optimization zzz is <strong>very</strong> fast. Through a combination of methods, such as allocation at start up and avoiding thread contention, we are able to extract tons of performance out of a fairly simple implementation. zzz is quite robust currently but is still early stage software. It's currently been running in production, serving my <a>site</a>. With the recent migration to <a>tardy</a>, zzz is about as fast as gnet, the fastest plaintext HTTP server according to <a>TechEmpower</a>, while consuming only ~22% of the memory that gnet requires. <a>Raw Data</a> <a>Raw Data</a> On the CCX63 instance on Hetzner with 2000 max connections, we are 70.9% faster than <a>zap</a> and 83.8% faster than <a>http.zig</a>. We also utilize less memory, using only ~3% of the memory used by zap and ~1.6% of the memory used by http.zig. zzz can be configured to utilize minimal memory while remaining performant. The provided <code>minram</code> example only uses 256 kB! Features <ul> <li>Built on top of <a>Tardy</a>, an asynchronous runtime.</li> <li><a>Modular Asynchronous Implementation</a><ul> <li><code>io_uring</code> for Linux (&gt;= 5.1.0).</li> <li><code>epoll</code> for Linux (&gt;= 2.5.45).</li> <li><code>kqueue</code> for BSD &amp; Mac.</li> <li><code>poll</code> for Linux, Mac and Windows.</li> </ul> </li> <li>Layered Router, including Middleware</li> <li>Single and Multithreaded Support</li> <li>TLS using <a>secsock</a> </li> <li>Memory Pooling for minimal allocations </li> </ul> Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in zzz by you, shall be licensed as MPL2.0, without any additional terms or conditions.
[ "https://github.com/bernardassan/imagination" ]
https://avatars.githubusercontent.com/u/74420131?v=4
pgzx
xataio/pgzx
2024-02-12T19:03:32Z
Create PostgreSQL extensions using Zig.
main
6
530
15
530
https://api.github.com/repos/xataio/pgzx/tags
Apache-2.0
[ "extens", "extensions", "hacktoberfest", "pgrx", "postgres", "postgresql", "zig", "ziglang" ]
9,128
false
2025-05-20T05:32:33Z
true
true
unknown
github
[]
<a></a>&nbsp; <a></a> &nbsp; <a></a> &nbsp; <a> </a> pgzx - Create Postgres Extensions with Zig! <code>pgzx</code> is a library for developing PostgreSQL extensions written in Zig. It provides a set of utilities (e.g. error handling, memory allocators, wrappers) as well as a development environment that simplifies integrating with the Postgres code base. Why Zig? <a>Zig</a> is a small and simple language that aims to be a "modern C" and make system-level code bases easier to maintain. It provides safe memory management, compilation time code execution (comptime), and a rich standard library. Zig can interact with C code quite naturally: it supports the C ABI, can work with C pointers and types directly, it can import header files and even translate C code to Zig code. Thanks to this interoperability, a Postgres extension written in Zig can, theoretically, accomplish anything that a C extension can. This means you get full power AND a modern language and standard library to write your extension. While in theory you can write any extension in Zig that you could in C, in practice you will need to make sense of a lot of Postgres internals in order to know how to correctly use them from Zig. Also, Postgres makes extensive use of macros, and not all of them can be translated automatically. This is where pgzx comes in: it provides a set of Zig modules that make the development of Postgres Extensions in Zig much simpler. Examples The following sample extensions (ordered from simple to complex) show how to use pgzx: | Extension | Description | |--------------------------------------------|-------------| | <a>char_count_zig</a> | Adds a function that counts how many times a particular character shows up in a string. Shows how to register a function and how to interpret the parameters. | | <a>pghostname_zig</a> | Adds a function that returns the database server's host name. | | <a>pg_audit_zig</a> | Inspired by the pgaudit C extension, this one registers callbacks to multiple hooks and uses more advanced error handling and memory allocation patterns. | Docs The reference documentation is available at <a>here</a>. We recommend checking the examples in the section above to understand how to use pgzx. The next sections contain a high-level walkthrough of the most important utilities and how they relate to the Postgres internals. Getting Started This project uses <a>Nix flakes</a> to manage build dependencies and provide a development shell. We provide a template for you to initialize a new Zig based Postgres extension project which allows you to reuse some of the utilities we're using. Before getting started we would recommend you familiarize yourself with the projects setup first. To do so, please start with the <a>Contributing</a> section. We will create a new project folder for our new extension and initialize the folder using the projects template: <code>$ mkdir my_extension $ cd my_extension $ nix flake init -t github:xataio/pgzx</code> This step will create a working extension named 'my_extension'. The extension exports a hello world function named <code>hello()</code>. The templates <a>README.md</a> file already contains instructions on how to enter the development shell, build, and test the extension. You can follow the instructions and verify that your setup is functioning. Do not forget to use <code>pgstop</code> before quitting the development shell. The development shell declares a few environment variables used by the project (see <a>devshell.nix</a>): - <code>PRJ_ROOT</code>: folder of the current project. If not set some shell scripts will ask <code>git</code> to find the projects folder. Some scripts use this environment variable to ensure that you can run the script from within any folder within your project. - <code>PG_HOME</code>: Installation path of your postgres instance. When building postgres from scratch this matches the path prefix used by <code>make install</code>. When using the development shell we will relocate/build the postgres extension into the <code>./out</code> folder and create a symlink <code>./out/default</code> to the local version. If you plan to build and install the extension with another PostgreSQL installation set <code>PG_HOME=$(dirname $(pg_config --bindir))</code>. Next we want to rename the project to match our extension name. To do so, update the file names in the <code>extension</code> folder, and replace <code>my_extension</code> with your project name in the <code>README.md</code>, <code>build.zig</code>, <code>build.zig.zon</code>, and extensions SQL file. Logging and error handling Postgres <a>error reporting functions</a> are used to report errors and log messages. They have typical logging functionality like log levels and formatting, but also Postgres specific functionality, like error reports that can be thrown and caught like exceptions. <code>pgzx</code> provides a wrapper around these functions that makes it easier to use from Zig. Simple logging can be done with functions like <a>Log</a>, <a>Info</a>, <a>Notice</a>, <a>Warning</a>, for example: <code>zig elog.Info(@src(), "input_text: {s}\n", .{input_text});</code> Note the <code>@src()</code> built-in which provides the file location. This will be stored in the error report. To report errors during execution, use the <a>Error</a> or <a>ErrorThrow</a> functions. The latter will throw an error report, which can be caught by the Postgres error handling system (explained below). Example with <code>Error</code>: <code>zig if (target_char.len &gt; 1) { return elog.Error(@src(), "Target char is more than one byte", .{}); }</code> The elog module also exports functions that resemble the C API including functions like <code>ereport</code>, <code>errcode</code>, or <code>errmsg</code>. If you browse through the Postgres source code, you'll see the <a>PG_TRY / PG_CATCH / PG_FINALLY</a> macros used as a form of "exception handling" in C, catching errors raised by the <a>ereport</a> family of functions. These macros make use of long jumps (i.e. jumps across function boundaries) to the "catch/finally" destination. This means we need to be careful when calling Postgres functions from Zig. For example, if the called C function raises an <code>ereport</code> error, the long jump might skip the Zig code that would have cleaned up resources (e.g. <code>errdefer</code>). pgzx offers an alternative Zig implementation for the PG_TRY family of macros. This typically looks in code something like this: <code>zig var errctx = pgzx.err.Context.init(); defer errctx.deinit(); if (errctx.pg_try()) { // zig code that calls several Postgres C functions. } else { return errctx.errorValue(); }</code> The above code pattern makes sure that we catch any errors raised by Postgres functions and return them as Zig errors. This way, we make sure that all the <code>defer</code> and <code>errdefer</code> code in the caller(s) are executed as expected. For more details, see the documentation for the <a>pgzx.err.Context</a> struct. The above code pattern is implemented in a <a>wrap</a> convenience function which takes a function and its arguments, and executes it in a block like the above. For example: <code>zig try pgzx.err.wrap(myFunction, .{arg1, arg2});</code> Memory context allocators Postgres uses a <a>memory context system</a> to manage memory. Memory allocated in a context can be freed all at once (for example, when a query execution is finished), which simplifies memory management significantly, because you only need to track contexts, not individual allocations. Contexts are also hierarchical, so you can create a context that is a child of another context, and when the parent context is freed, all children are freed as well. pgzx offers custom wrapper Zig allocators that use Postgres' memory context system. The <a>pgzx.mem.createAllocSetContext</a> function creates an <a>pgzx.mem.MemoryContextAllocator</a> that you can use as a Zig allocator. For example: <code>zig var memctx = try pgzx.mem.createAllocSetContext("zig_context", .{ .parent = pg.CurrentMemoryContext }); const allocator = memctx.allocator();</code> In the above, note the use of <code>pg.CurrentMemoryContext</code> as the parent context. This is the context of the current query execution, and it will be freed when the query is finished. This means that the memory allocated with <code>allocator</code> will be freed at the same time. It's also possible to register a callback for when the memory context is destroyed or reset. This is useful to free or close resources that are tied to the context (e.g. sockets). pgzx provides an utility to register a callback: <code>zig try memctx.registerAllocResetCallback( queryDesc.*.estate.*.es_query_cxt, pgaudit_zig_MemoryContextCallback, );</code> Function manager pgzx has utilities for registering functions, written in Zig, that are then available to call over SQL. This is done, for example, via the <a>PG_FUNCTION_V1</a> function: <code>comptime { pgzx.PG_FUNCTION_V1("my_function", myFunction); }</code> The parameters are received from Postgres serialized, but pgzx automatically deserializes them into Zig types. Testing your extension pgzx provides two types of automatic tests: pg_regress tests and unit tests. The <a>pg_regress tests</a> work similar with the way they work for C extensions. You provide inputs in a <code>sql</code> folder and expected outputs in the <code>expected</code> folder, and then you can run them like this: <code>sh zig build pg_regress</code> Under the hood, this calls the <code>pg_regress</code> tool from the Postgres build. For unit tests, we would like to run tests in a Postgres instance, so that the unit tests compile in the same environment as the tested code, and so that the tests can call Postgres APIs. In order to do this, pgzx registers a custom <code>run_tests</code> function via the Function manager. This function can be called from SQL (<code>SELECT run_tests();</code>) and it will run the unit tests. A test suite is a Zig struct for which each function whose name starts with <code>test</code> is a unit test. To register a test suite, you would typically do something like this: <code>zig comptime { pgzx.testing.registerTests(@import("build_options").testfn, .{Tests}); }</code> The <code>build_options.testfn</code> options should be defined via <code>build.zig</code>. For an example on how to do that, check out the <code>char_count_zig</code> or the <code>pgaudit_zig</code> sample extensions. Note that you can only call the <code>pgzx.testing.registerTests</code> function once per extension. If your extension has multiple modules/files, you should call it like this: <code>zig comptime { pgzx.testing.registerTests(@import("build_options").testfn, .{ @import("module1.zig").Tests, @import("module2.zig").Tests, @import("module2.zig").Tests, }); }</code> To run the unit tests, provided that you are using our sample <code>build.zig</code>, you can run: <code>sh zig build unit -p $PG_HOME</code> Behind the scenes, this builds the extension with the <code>testfn</code> build option set to <code>true</code>, deploys it in the Postgres instance, and then calls <code>SELECT run_tests();</code> to run the tests. Status/Roadmap pgzx is currently under heavy development by the <a>Xata</a> team. If you want to try Zig for writing PostgreSQL extensions, it is easier with pgzx than without, but expect breaking changes and potential instability. If you need help, join us on the <a>Xata discord</a>. <ul> <li>Utilities</li> <li>[ ] Postgres versions (compile and test)<ul> <li>[ ] Postgres 14</li> <li>[ ] Postgres 15</li> <li>[ ] Postgres 16</li> <li>[x] Postgres 17</li> </ul> </li> <li>[x] Logging</li> <li>[x] Error handling</li> <li>[x] Memory context allocators</li> <li>[x] Function manager</li> <li>[x] Background worker process</li> <li>[x] LWLocks</li> <li>[x] Signals and interrupts</li> <li>[x] String formatting</li> <li>[ ] Shared memory</li> <li>[ ] SPI</li> <li>Postgres data structures wrappers:<ul> <li>Array based list (List)<ul> <li>[x] Pointer list</li> <li>[ ] int list</li> <li>[ ] oid list</li> <li>...</li> </ul> </li> <li>[ ] Single list</li> <li>[ ] Double list</li> <li>[x] Hash tables</li> </ul> </li> <li>Development environment</li> <li>[ ] Download and vendor Postgres source code</li> <li>[x] Compile example extensions against the Postgres source code</li> <li>[x] Build target to run Postgres regression tests</li> <li>[x] Run unit tests in the Postgres environment</li> <li>[ ] Provide a standard way to test extensions from separate repos</li> <li>Packaging</li> <li>[x] Add support for Zig packaging</li> </ul> Contributing Develpment shell and local installation We use Nix to provide a local development shell. This ensures that we have a stable environment with all dependencies available in the expected versions. This is especially important with Zig, which is still in active development. For this purpose it is possible to use this project as input in downstream flake files as well. The tools we use also require some environment variables set, which are already pre-configured in the develpment shell. We would recommend the <a>nix-installer from DeterminateSystems</a>. The installer enables Nix Flakes (used by this project) out of the box and also provides an uninstaller. If you want to try out the project without having to install Nix on your system, you can do so using Docker. You can build the docker image by running the <code>dev/docker/build.sh</code> script. The docker image is named <code>pgzx:latest</code>. To enter the develpment shell run: <code>$ nix develop</code> If you want to use docker instead, run: <code>$ ./dev/docker/run.sh</code> NOTE: We also provide a <code>.envrc</code> file to automatically enter the development shell when entering the projects folder. If you use direnv you can enable the environment via <code>direnv allow</code>. The nix configuration already installs PostgreSQL, but for testing we want to have a local postgres installation where we can install our test extensions in. We use <code>pglocal</code> to relocate the existing installation into our development environment: ``` $ pglocal ... $ ls out 16 default ``` The <code>out/default</code> folder is a symlink to the postgres installation currently in use. Having a local installation we want to create a local database and user: <code>$ pginit ...</code> This creates a local database named <code>postgres</code>. The script allows us to configure an alternative name for the cluster, database, or user. This allows us to create multiple clusters within our current installation. We can start and stop the database using <code>pgstart</code> and <code>pgstop</code>. Let's test our current setup: ``` $ pgstart $ psql -U postgres -c 'select version()' version PostgreSQL 16.1 on aarch64-apple-darwin22.6.0, compiled by clang version 16.0.6, 64-bit (1 row) ``` This project has a few example extensions. We will install and test the <code>char_count_zig</code> extension next: ```sh $ cd examples/char_count_zig $ zig build -freference-trace -p $PG_HOME $ psql -U postgres -c 'CREATE EXTENSION char_count_zig;' CREATE EXTENSION $ psql -U postgres -c "SELECT char_count_zig('aaabc', 'a');" INFO: input_text: aaabc INFO: target_char: a INFO: Target char len: 1 char_count_zig <code> 3 </code> (1 row) ``` The sample extension also supports pg_regress bases testing: ``` $ zig build pg_regress --verbose using postmaster on Unix socket, port 5432 ok 1 - char_count_test 10 ms 1..1 All 1 tests passed. ``` Debugging the unit tests Because Postgres manages the actual processes and starts a new process for each client we must attach our debugger to an existing session. To debug an extension that exposes a function, like the unit tests, first start a SQL session: <code>$ psql -U postgres</code> In order to attach our debugger to the session we need the PID for your current process: ``` postgres=# select pg_backend_pid(); pg_backend_pid <code> 14985 </code> (1 row) ``` If we want to set breakpoints we must also ensure that our extensions library has been loaded. You might have to drop and re-create an the test function in case you can't set a breakpoint (this will force Postgres to load the library): <code>postgres=# DROP FUNCTION run_tests; CREATE FUNCTION run_tests() RETURNS INTEGER AS '$libdir/pgzx_unit' LANGUAGE C IMMUTABLE;</code> Now we can attach our debugger and set a breakpoint (See your debuggers documentation on how to attach): <code>$ lldb -p 14985 (lldb) b hsearch.zig:117 ... (lldb) c</code> You can set breakpoints in your Zig based extension in C sources given you have all debug symbols available. With our breakpoints set we want to start the testsuite: <code>postgres=# SELECT run_tests();</code> Postgres debug build The default development shell and scripts relocated the Nix postgres installation into the <code>out</code> folder only. When debugging an extension in isolation this is normally all you need. But in case you need to debug and step into the Postgres sources as well it is helpful to have a debug build available. This project provides a second development shell type that provides tooling to fetch and build Postgres in debug mode. Select the <code>debug</code> shell to start a shell with required development tools: <code>nix develop '.#debug'</code> The <code>pgbuild</code> script will fetch the Postgres sources and build a local debug build that you can use for development, testing, and debugging: <code>$ pgbuild</code> This will checkout Postgres into the <code>out/postgresql_src</code> directory. The build files will be stored in <code>out/postgresql_src/build</code>. We use <a>meson</a> and <a>Ninja</a> to build Postgres. Ninja speeds up the compilation by parallelizing compilation tasks as much as possible. Compilation via Ninja also emits a <code>compile_commands.json</code> file that you can use with your editors LSP to improve navigating the Postgres source code if you wish to do so. Optionally symlink the <code>compile_commands.json</code> file: <code>$ ln -s ./out/postgresql_src/build/compile_commands.json ./out/postgresql_src/compile_commands.json</code> The local build will be installed in <code>out/local</code>. To switch to the local Postgres build and ensure that your extension builds against it use: ``` $ pguse local ``` Note: Delete the <code>zig-cache</code> folder when switching to another Postgres installation to ensure that you extension is rebuilt properly against the new version. Debugging Zig standard library and build script support To debug Zig build scripts or the standard library all you need is the original sources. No additional build step is required. Anyways, it is recommended to use the same library version as the zig compiler ships with. You can query the current version or Git commit of a nightly build using the <code>zig</code> tool: <code>$ zig version 0.13.0-dev.28+3c5e84073</code> The version shown here for example indicates that we use a nightly build. The commit ID of that build is <code>0b744da84</code>. You can clone and checkout the repository by yourself. We also have a small script <code>ziglocal</code> to checkout and even build the compiler. You can use the script to just checkout the correct version into your development environment: <code>$ ziglocal clone --commit 0b744da84</code> This command clones the master branch only into the <code>./out/zig</code> directory. Now when building the test extensions you can use the <code>--zig-lib-dir</code> CLI flag to tell the compiler to use an alternative library: <code>$ zig build unit -p $PG_HOME --zig-lib-dir $PRJ_ROOT/out/zig/lib</code> The zig compiler will now use the local checkout to build the <code>build.zig</code> file and your project. Debugging Zig compiler/linker As Zig is still in development, you might have the need to build the Zig toolchain yourself, maybe in debug mode. The <code>debug</code> shell installs the additional dependencies that you need to build Postgres or the Zig compiler yourself. <code>nix develop '.#debug'</code> Optionally we might want to debug the actual version that we normally use: <code>$ zig version 0.12.0-dev.3154+0b744da84</code> Next we checkout and compile the toolchain (Note: the <code>--commit</code> option is optional): <code>$ ziglocal --commit 0b744da84</code> This step will take a while. You will find the compiler and library of your local debug build in the <code>out/zig/build/stage3</code> directory. Q&amp;A Which Zig version do you support? The Zig toolchain, including the compiler, build system, and standard library, is still in development and breaking changes do happen every now and then. For this reason this project follows the <a>Zig master branch</a>. The Nix based development shell uses <a>zig-overlay</a> in conjunction with the <code>flake.lock</code> file to pin the zig toolchain version to a recent commit ID. The dependency is updated by us every so often and we try to test and fix breaking changes when updating the toolchain version. We highly recommend to use the projects develoment shell when testing the example extensions provided, otherwise you might have problems compiling the extensions at all. We understand not everyone is keen to install Nix locally. For getting to know the environment you can build and run a development shell in a local docker container. Use <code>./dev/docker/build.sh</code> to build the container and <code>./dev/docker/run.sh</code> to start the dockerized development shell. The current stable release is verion 0.12. As the build system APIs and package management system are undergoing heavy development recently we chose to stick with the <code>master</code> branch for now. Where is my extension installed? By default the zig build system installs all artifacts into the local <code>zig-out</code> folder. For example we can see that behavior when building the <code>char_count_zig</code> extension: <code>$ cd examples/char_count_zig $ zig build $ find zig-out zig-out zig-out/lib zig-out/lib/char_count_zig.dylib zig-out/share zig-out/share/postgresql zig-out/share/postgresql/extension zig-out/share/postgresql/extension/char_count_zig.control zig-out/share/postgresql/extension/char_count_zig--0.1.sql</code> If you are not sure whether the build system puts all files into the correct location or in case you generate code it can be helpful to debug your build scripts to install into <code>zig-out</code>. To install the extension with your local Postgres instance you need to pass the path prefix where postgres was installed to using the <code>-p</code> flag: <code>$ zig build -p &lt;path/to/postgres&gt;</code> You can run <code>dirname $(pg_config --bindir)</code> from your shell to find the installation prefix. We set <code>PG_HOME</code> to the expected path in the development shell, assuming you use the <code>pglocal</code> or <code>pgbuild</code> scripts to prepare a local postgres installation for development. See also <ul> <li><a>pgrx</a> - Similar project but for Rust, it served as an inspiration for this project. </li> <li><a>pg_tle</a> - Trusted Language Extensions for PostgreSQL.</li> </ul> License This project is licensed under the Apache License 2.0 - see the <a>LICENSE</a> file for details. Support If you have any questions, encounter issues, or need assistance, open an issue in this repository or join our <a>Discord</a>, and our community will be happy to help. Made with :heart: by <a>Xata 🦋</a>
[]
https://avatars.githubusercontent.com/u/180864418?v=4
Zigistry
Zigistry/Zigistry
2024-06-22T11:48:13Z
A place where you can find all the libraries that suit your Zig lang needs. ⭐️ Please star to support this work!
main
2
405
9
405
https://api.github.com/repos/Zigistry/Zigistry/tags
AGPL-3.0
[ "zig", "zig-programming-language", "ziglang" ]
128,698
false
2025-05-22T08:13:41Z
false
false
unknown
github
[]
Zigistry 🦎 [![Website](https://img.shields.io/website?url=https%3A%2F%2Fzigistry.dev&amp;up_message=zigistry.dev&amp;down_message=offline&amp;label=website)](https://zigistry.dev) What is Zigistry? Zigistry is an index for both packages and programs written in the Zig programming language. It serves as a central hub where Zig developers can discover useful libraries and applications created by the community. The platform makes it simple to find Zig projects, whether looking for library dependencies or complete programs. Adding to the Index Zigistry automatically indexes GitHub repositories based on topics: Libraries <ul> <li>Add the <code>zig-package</code> topic to index a library</li> <li>Examples: parsing libraries, networking tools, testing frameworks</li> </ul> Programs <ul> <li>Add the <code>zig</code> topic to index a program</li> <li>Examples: command-line tools, applications, games</li> </ul> The project will appear on <a>zigistry.dev</a> automatically after adding the appropriate topic. Community Interaction The Zig community can: <ul> <li>Share and discover both libraries and programs</li> <li>Explore different approaches to Zig code</li> <li>Ask questions and share Zig development knowledge</li> <li>Participate in technical discussions</li> </ul> Contributing Contributions to improve Zigistry are welcome through: <ul> <li>Bug reports and feature suggestions via issues</li> <li>Code improvements via pull requests</li> <li>Technical discussions about the project</li> <li>Helping other developers with questions</li> </ul> Technical Details Zigistry is a polyglot project that leverages multiple programming languages and technologies to provide a robust package and program index. Check the <a>issue tracker</a> for current development tasks and feature requests. License Notice The Zigistry codebase is open source. The <code>database</code> directory contains files automatically generated through GitHub's API and is subject to GitHub's terms of service. Build something great with Zig! ⚡
[]
https://avatars.githubusercontent.com/u/480330?v=4
zig-aio
Cloudef/zig-aio
2024-06-16T04:10:30Z
io_uring like asynchronous API and coroutine powered IO tasks for zig
master
20
329
14
329
https://api.github.com/repos/Cloudef/zig-aio/tags
MIT
[ "aio", "async", "asynchronous", "coroutines", "io", "io-uring", "zig" ]
6,340
false
2025-05-20T17:42:09Z
true
true
unknown
github
[ { "commit": "0d804dce7632d0912245b1a7aa0384a21629f453", "name": "zigwin32", "tar_url": "https://github.com/marlersoft/zigwin32/archive/0d804dce7632d0912245b1a7aa0384a21629f453.tar.gz", "type": "remote", "url": "https://github.com/marlersoft/zigwin32" } ]
zig-aio zig-aio provides io_uring like asynchronous API and coroutine powered IO tasks for zig <ul> <li><a>Documentation</a></li> </ul> <a></a> Project is tested on zig version 0.15.0-dev.386+2e35fdd03 Support matrix | OS | AIO | CORO | |---------|-----------------|-----------------| | Linux | io_uring, posix | x86_64, aarch64 | | Windows | iocp | x86_64, aarch64 | | Darwin | posix | x86_64, aarch64 | | *BSD | posix | x86_64, aarch64 | | WASI | posix | ❌ | <ul> <li>io_uring AIO backend is a light wrapper, where most of the code is error mapping</li> <li>WASI may eventually get coro support <a>Stack Switching Proposal</a></li> </ul> Example ```zig const builtin = @import("builtin"); const std = @import("std"); const aio = @import("aio"); const coro = @import("coro"); const log = std.log.scoped(.coro_aio); pub const std_options: std.Options = .{ .log_level = .debug, }; fn server(startup: *coro.ResetEvent) !void { var socket: std.posix.socket_t = undefined; try coro.io.single(.socket, .{ .domain = std.posix.AF.INET, .flags = std.posix.SOCK.STREAM | std.posix.SOCK.CLOEXEC, .protocol = std.posix.IPPROTO.TCP, .out_socket = &amp;socket, }); <code>const address = std.net.Address.initIp4(.{ 0, 0, 0, 0 }, 1327); try std.posix.setsockopt(socket, std.posix.SOL.SOCKET, std.posix.SO.REUSEADDR, &amp;std.mem.toBytes(@as(c_int, 1))); if (@hasDecl(std.posix.SO, "REUSEPORT")) { try std.posix.setsockopt(socket, std.posix.SOL.SOCKET, std.posix.SO.REUSEPORT, &amp;std.mem.toBytes(@as(c_int, 1))); } try std.posix.bind(socket, &amp;address.any, address.getOsSockLen()); try std.posix.listen(socket, 128); startup.set(); var client_sock: std.posix.socket_t = undefined; try coro.io.single(.accept, .{ .socket = socket, .out_socket = &amp;client_sock }); var buf: [1024]u8 = undefined; var len: usize = 0; try coro.io.multi(.{ aio.op(.send, .{ .socket = client_sock, .buffer = "hey " }, .soft), aio.op(.send, .{ .socket = client_sock, .buffer = "I'm doing multiple IO ops at once " }, .soft), aio.op(.send, .{ .socket = client_sock, .buffer = "how cool is that?" }, .soft), aio.op(.recv, .{ .socket = client_sock, .buffer = &amp;buf, .out_read = &amp;len }, .unlinked), }); log.warn("got reply from client: {s}", .{buf[0..len]}); try coro.io.multi(.{ aio.op(.send, .{ .socket = client_sock, .buffer = "ok bye" }, .soft), aio.op(.close_socket, .{ .socket = client_sock }, .soft), aio.op(.close_socket, .{ .socket = socket }, .unlinked), }); </code> } fn client(startup: *coro.ResetEvent) !void { var socket: std.posix.socket_t = undefined; try coro.io.single(.socket, .{ .domain = std.posix.AF.INET, .flags = std.posix.SOCK.STREAM | std.posix.SOCK.CLOEXEC, .protocol = std.posix.IPPROTO.TCP, .out_socket = &amp;socket, }); <code>try startup.wait(); const address = std.net.Address.initIp4(.{ 127, 0, 0, 1 }, 1327); try coro.io.single(.connect, .{ .socket = socket, .addr = &amp;address.any, .addrlen = address.getOsSockLen(), }); while (true) { var buf: [1024]u8 = undefined; var len: usize = 0; try coro.io.single(.recv, .{ .socket = socket, .buffer = &amp;buf, .out_read = &amp;len }); log.warn("got reply from server: {s}", .{buf[0..len]}); if (std.mem.indexOf(u8, buf[0..len], "how cool is that?")) |_| break; } try coro.io.single(.send, .{ .socket = socket, .buffer = "dude, I don't care" }); var buf: [1024]u8 = undefined; var len: usize = 0; try coro.io.single(.recv, .{ .socket = socket, .buffer = &amp;buf, .out_read = &amp;len }); log.warn("got final words from server: {s}", .{buf[0..len]}); </code> } pub fn main() !void { if (builtin.target.os.tag == .wasi) return error.UnsupportedPlatform; // var mem: [4096 * 1024]u8 = undefined; // var fba = std.heap.FixedBufferAllocator.init(&amp;mem); var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{}; defer _ = gpa.deinit(); var scheduler = try coro.Scheduler.init(gpa.allocator(), .{}); defer scheduler.deinit(); var startup: coro.ResetEvent = .{}; _ = try scheduler.spawn(client, .{&amp;startup}, .{}); _ = try scheduler.spawn(server, .{&amp;startup}, .{}); try scheduler.run(.wait); } ``` Syscall overhead <code>strace -c</code> output from the <code>examples/coro.zig</code> without <code>std.log</code> output and with <code>std.heap.FixedBufferAllocator</code>. This is using the <code>io_uring</code> backend. <code>posix</code> backend emulates <code>io_uring</code> like interface by using a traditional readiness event loop, thus it will have larger syscall overhead. Posix backend may still be faster than io_uring depending on usage. ``` % time seconds usecs/call calls errors syscall 0.00 0.000000 0 2 close 0.00 0.000000 0 4 mmap 0.00 0.000000 0 4 munmap 0.00 0.000000 0 5 rt_sigaction 0.00 0.000000 0 1 bind 0.00 0.000000 0 1 listen 0.00 0.000000 0 2 setsockopt 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 arch_prctl 0.00 0.000000 0 1 gettid 0.00 0.000000 0 2 prlimit64 0.00 0.000000 0 2 io_uring_setup 0.00 0.000000 0 6 io_uring_enter 0.00 0.000000 0 1 io_uring_register 100.00 0.000000 0 33 total ```
[]
https://avatars.githubusercontent.com/u/34946442?v=4
terminal-doom
cryptocode/terminal-doom
2024-07-22T14:55:50Z
Play DOOM in modern terminals
main
2
292
12
292
https://api.github.com/repos/cryptocode/terminal-doom/tags
-
[ "doom", "game", "terminal", "zig" ]
14,177
false
2025-05-21T11:37:53Z
true
true
unknown
github
[ { "commit": "master", "name": "vaxis", "tar_url": "https://github.com/rockorager/libvaxis/archive/master.tar.gz", "type": "remote", "url": "https://github.com/rockorager/libvaxis" } ]
Terminal Doom enables Doom-based games to play smoothly in modern terminals with original graphics and sound. It also works over fast ssh connections. Demo with sound: <a>![Demo]</a> Building There are no system dependencies, so just clone and build with Zig v0.14: <code>zig build -Doptimize=ReleaseFast</code> Run with <code>zig-out/bin/terminal-doom</code> To build with older versions of Zig, please use the corresponding git tag. Terminal Doom uses the <a>libvaxis Zig library</a> to render and handle keyboard and mouse events. If you ever want to make a TUI app, I highly recommend this library. Sound support Sound is enabled by default. Add the <code>-Dsound=false</code> if you want to compile without sound support (like when running on a remote server via ssh) All sound effects are included, and a few music tracks. You can download and add additional music tracks (mp3) yourself. Terminal Doom will automatically pick them up from the <code>sound</code> directory. See the sound section for naming. Where does it run? Tested on macOS and Linux. Compiles on Windows as well, but no terminal there seems to run it (WezTerm likely gets closest in ssh local mode) Currently works best in <a>Ghostty</a> and <a>Kitty</a> as these have solid implementations of the required specs. <a>WezTerm</a> works if you use 'f' instead of ctrl keys for firing the gun. Playing You can play keyboard-only (recommended) or in combination with a mouse. You can disable/enable mouse at any time by pressing <code>m</code>. This is useful when playing with keyboard on a laptop to avoid spurious input from the trackpad. When using a mouse, make sure you adjust sensitivity in the Options menu if it's too fast or slow. Also try adjusting sensitivity on your mouse if it has buttons for this. Once sensitivity is right, playing with a mouse/keyboard combo is pretty efficient. Keep in mind that mouse support in terminals comes with limitations, as apps are not able to capture the mouse. | Action | Keys/Mouse Actions | |---------------------------|-------------------------------------| | Menu | ESC to open/close, Enter to select | | Walk / rotate | Arrow keys or mouse. <code>j</code>, <code>l</code> also rotates.| | Walk / strafe | <code>wasd</code> | | Fire | <code>f</code>, <code>i</code>, control keys, mouse click | | Use/open | Spacebar, right mouse click | | Strafe left/right | Alt+arrow keys, <code>a</code>, <code>d</code> | | Quit | <code>Ctrl+c</code> | | Disable/enable mouse | <code>m</code> | | Disable/enable scaling | <code>u</code> | Most other Doom keys should work as well, such as Tab for map and F5 for adjusting detail level. How it works Rendering While the Kitty graphics protocol is primarily intended to display images, modern terminals and computers are <em>fast</em>, with high memory bandwidth, SIMD support, and discrete GPUs. There's plenty of juice available to run this classic game smoothly over a text protocol. Here's how it works: on every frame, doomgeneric calls <code>DG_DrawFrame</code>. Our job is now to turn the pixel data into a base64 encoded payload. This payload is then split into 4K chunks, each chunk wrapped by the Kitty protocol envelope. Actually, some terminals work without chunking, which is even faster, but that's not spec compliant and e.g. Kitty itself fails without chunking (thanks to rockorager for pointing this out) With the encoded message ready, we now: <ol> <li>Set synchronized output (mode 2026)</li> <li>Clear the screen</li> <li>Display the frame by sending the Kitty graphics message</li> <li>Reset synchronized output to flush updates to screen</li> <li>Handle any keyboard input</li> </ol> With the latest version, all of this is outsourced to libvaxis. This sequence repeats for every frame. While this is enough to run Doom smoothly in a modern terminal, there are many optimizations that can be done, including SIMDifying pixel encoding. Sound The history of Doom has many interesting facets, and its sound library is no different. You can read about it <a>here</a> Terminal Doom's sound support originally worked by calling out to SDL2, but that had a couple of problems. First of all, the implementation from doomgeneric was complicated and large. Second, depending on SDL2 made building harder on some systems. This is the solution I came up with: <ol> <li>Ditch all the complex midi sequencing and mixing logic.</li> <li>Make the wav and mp3 files part of the project</li> <li>Outsource playback to <em>miniaudio</em></li> </ol> While large, miniaudio is a single header file, it's portable, and has a straightforward API. Adding additional music tracks Terminal Doom ships with a few tracks, such as for the intro and the first level. You can add additional mp3's to the <code>sound</code> directory. For Terminal Doom to pick these up, they must be named according to the Doom convention: <code>d_e1m1.mp3 d_e1m2.mp3 d_e1m3.mp3 d_e1m4.mp3 d_e1m5.mp3 d_e1m6.mp3 d_e1m7.mp3 d_e1m8.mp3 d_e1m9.mp3 d_inter.mp3 d_intro.mp3 d_victor.mp3</code> The actual content of these can obviously be anything you want, not just the orginal music. Supported games <code>doom1.wad</code> is included in the repository and other wad files are available on various online sites. These should all work: <code>doom2.wad plutonia.wad tnt.wad doom.wad doom1.wad chex.wad hacx.wad freedm.wad freedoom2.wad freedoom1.wad</code> Credits <ul> <li>The engine is based on the amazing <a>doomgeneric</a> project</li> <li>Rendering and input is handled by <a>libvaxis</a>, a TUI library written in Zig</li> <li>Sound is handled by <a>miniaudio</a>, a single-file sound playback library</li> <li>Build system (and the main input/rendering loop) is all <a>Zig</a></li> <li>Testing and debugging in Ghostty's terminal inspector, Kitty, and WezTerm</li> </ul> LICENSE As Terminal Doom is based on the doomgeneric project, the project as a whole is licensed under GPL2. The Zig-based renderer/handler, build file, and miniaudio bridge are licensed under MIT.
[]
https://avatars.githubusercontent.com/u/21952395?v=4
tuile
akarpovskii/tuile
2024-04-29T18:32:20Z
A cross-platform Text UI (TUI) library in Zig
main
4
200
6
200
https://api.github.com/repos/akarpovskii/tuile/tags
MIT
[ "ncurses", "terminal", "tui", "zig", "zig-package" ]
2,264
false
2025-05-04T06:01:27Z
true
true
0.12.0
github
[ { "commit": "c425c9c8511bf92e14b8b612d1d16e774b186f2e.tar.gz", "name": "zg", "tar_url": "https://codeberg.org/dude_the_builder/zg/archive/c425c9c8511bf92e14b8b612d1d16e774b186f2e.tar.gz.tar.gz", "type": "remote", "url": "https://codeberg.org/dude_the_builder/zg" } ]
<a name="readme-top"></a> Tuile A Text User Interface library for Zig. Breaking changes are possible. <a><strong>Explore the docs »</strong></a> <a>View Examples</a> · <a>Report Bug</a> · <a>Request Feature</a> Table of Contents <ol> <li> <a>About The Project</a> </li> <li> <a>Getting Started</a> <ul> <li><a>Prerequisites</a></li> <li><a>Installation</a></li> </ul> </li> <li><a>Usage</a></li> <li><a>Cross-compilation</a></li> <li><a>Roadmap</a></li> <li><a>Contributing</a></li> <li><a>License</a></li> <li><a>Contact</a></li> <li><a>Acknowledgments</a></li> </ol> About The Project Tuile is a Text User Interface library written in Zig. Tuile uses <a><code>crossterm</code></a> backend by default which works on all UNIX and Windows terminals and supports cross-compilation (powered by <a><code>build.crab</code></a>). See <a><code>Backends</code></a> for the list of supported backends, or file a <a>feature request</a> if you want to have another one added. Checkout the other examples <a>here</a>. (<a>back to top</a>) Getting Started Prerequisites <ul> <li> Zig 0.12.0+ </li> <li> Non-default <a><code>backends</code></a> may have additional requirements. </li> </ul> Installation <ol> <li>Add dependency to your <code>build.zig.zon</code></li> </ol> <code>sh zig fetch --save https://github.com/akarpovskii/tuile/archive/refs/tags/v0.1.3.tar.gz</code> <ol> <li>Import Tuile in <code>build.zig</code>:</li> </ol> <code>zig const tuile = b.dependency("tuile", .{}); exe.root_module.addImport("tuile", tuile.module("tuile"));</code> (<a>back to top</a>) Usage ```zig const tuile = @import("tuile"); pub fn main() !void { var tui = try tuile.Tuile.init(.{}); defer tui.deinit(); <code>try tui.add( tuile.block( .{ .border = tuile.Border.all(), .border_type = .rounded, .layout = .{ .flex = 1 }, }, tuile.label(.{ .text = "Hello World!" }), ), ); try tui.run(); </code> } ``` You can find more examples in the <a>examples folder</a> (<a>back to top</a>) Cross-compilation To compile an application that uses Tuile for another target, just add <code>-Dtarget=&lt;desired target&gt;</code> when building your app and make sure to forward it to Tuile: <strong><code>build.zig</code></strong> <code>zig const target = b.standardTargetOptions(.{}); const tuile = b.dependency("tuile", .{ .target = target });</code> (<a>back to top</a>) Roadmap In no particular order: <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> Grid layout <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> Windows and dialogs <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> Menu bar <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> More widgets See the <a>open issues</a> for a full list of proposed features (and known issues). (<a>back to top</a>) Contributing If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks! <ol> <li>Fork the Project</li> <li>Create your Feature Branch (<code>git checkout -b feature/amazing-feature</code>)</li> <li>Commit your Changes (<code>git commit -m 'Add some Amazing Feature'</code>)</li> <li>Push to the Branch (<code>git push origin feature/amazing-feature</code>)</li> <li>Open a Pull Request</li> </ol> (<a>back to top</a>) License Distributed under the MIT License. See <a><code>LICENSE</code></a> for more information. (<a>back to top</a>) Acknowledgments <ul> <li><a>Best-README-Template</a></li> </ul> (<a>back to top</a>)
[]
https://avatars.githubusercontent.com/u/6756180?v=4
zig-esp-idf-sample
kassane/zig-esp-idf-sample
2024-03-01T13:59:37Z
Run Zig on esp-idf (Xtensa/RISC-V)
main
7
134
14
134
https://api.github.com/repos/kassane/zig-esp-idf-sample/tags
Apache-2.0
[ "clang", "embedded", "embedded-systems", "esp-idf", "esp-idf-framework", "esp-idf-sample", "esp-idf-sys", "esp32-idf", "espressif", "freertos", "libcxx", "zig" ]
393
false
2025-05-19T03:48:31Z
true
true
0.12.0
github
[]
Using Zig Language &amp; Toolchain with ESP-IDF | Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | | ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | STATUS: Experimental Description This project aims to integrate Zig language and toolchain with the <a>Espressif IoT Development Framework</a> for enhanced development capabilities on ESP32 and its variants. More information about building and using Zig with ESP-IDF can be found in the <a>documentation</a>. Prerequisites <ul> <li><a>Zig</a> toolchain - v0.13.0 or master</li> <li><a>ESP-IDF</a> - v4.4.x or v5.x or master</li> </ul> Targets Allowed | target | commands | | ------ | -------- | | esp32 | <code>-Dtarget=xtensa-freestanding-none -Dcpu=esp32</code> | | esp32-s2 | <code>-Dtarget=xtensa-freestanding-none -Dcpu=esp32s2</code> | | esp32-s3 | <code>-Dtarget=xtensa-freestanding-none -Dcpu=esp32s3</code> | | esp32-c2/c3 | <code>-Dtarget=riscv32-freestanding-none -Dcpu=generic_rv32+c+m+zicsr+zifencei</code> | | esp32-h2/c5/c6 | <code>-Dtarget=riscv32-freestanding-none -Dcpu=generic_rv32+a+c+m+zicsr+zifencei</code> | | esp32-p4 | <code>-Dtarget=riscv32-freestanding-eabihf -Dcpu=esp32p4</code> | <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> <a>Zig</a> upstream (LLVM-Codegen) does not have xtensa support. Like <a>esp-rs</a>, it is necessary to use the <a>zig-xtensa</a> - <strong>toolchain forked</strong>. </blockquote> Key Features: <ul> <li> <strong>Zig Language Integration</strong>: Use the Zig programming language to write firmware code. It provides modern language features such as comptime, meta-programming, and error handling. </li> <li> <strong>Zig Toolchain Integration</strong>: The Zig toolchain can be used to build zig libraries and executables, and can also be integrated with the ESP-IDF build system. Also, system compiler and linker can be replaced to <code>zig cc</code>/<code>zig c++</code>. </li> <li> <strong>Note:</strong> For C++ support, zig toolchain uses <code>llvm-libc++</code> ABI by default. </li> <li> <strong>ESP-IDF Compatibility</strong>: Seamlessly integrate Zig with the ESP-IDF framework, allowing developers to leverage the rich set of APIs and functionalities provided by ESP-IDF for IoT development. </li> <li> <strong>Build System Configuration</strong>: Using CMake to build Zig libraries allows easy integration with existing ESP-IDF projects while providing efficient dependency management and build configuration. </li> <li> <strong>Cross-Platform Development</strong>: Facilitate development across various ESP32 variants including ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-H2, ESP32-P4, ESP32-S2, and ESP32-S3, ensuring broad compatibility and versatility. </li> </ul> About Allocators <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> Asserts allocations are within <code>@alignOf(std.c.max_align_t)</code> and directly calls <code>malloc</code>/<code>free</code>. Does not attempt to utilize <code>malloc_usable_size</code>. <ul> <li> <code>std.heap.raw_c_allocator</code> allocator is safe to use as the backing allocator with <code>std.heap.ArenaAllocator</code> for example and is more optimal in such a case than <code>std.heap.c_allocator</code>. - ref.: <a>std-doc</a> </li> <li> <code>std.heap.ArenaAllocator</code> takes an existing allocator, wraps it, and provides an interface where you can allocate without freeing, and then free it all together. - ref.: <a>std-doc</a> </li> </ul> <strong>Custom Allocators</strong> (based on <code>std.heap.raw_c_allocator</code>) <ul> <li><code>idf.heap.HeapCapsAllocator</code> - ref.: <a>espressif-doc</a></li> <li><code>idf.heap.MultiHeapAllocator</code> - ref.: <a>espressif-doc</a></li> <li><code>idf.heap.vPortAllocator</code> - ref.: <a>FreeRTOS-doc</a></li> </ul> </blockquote> License This project is licensed twice: - <a>Apache</a> - <a>MIT-0</a>
[]
https://avatars.githubusercontent.com/u/110174416?v=4
zbind
nelipuu/zbind
2024-02-09T20:35:47Z
Zig-TypeScript binding generator 🟦 🦎
main
1
132
3
132
https://api.github.com/repos/nelipuu/zbind/tags
0BSD
[ "bun", "javascript", "node", "typescript", "wasm", "zig", "ziglang" ]
110
false
2025-04-12T19:12:50Z
true
false
unknown
github
[]
zbind <code>zbind</code> generates TypeScript bindings for calling Zig code compiled to native code or Wasm, in Node.js or Bun or browsers. Supported Zig versions are 0.11.0 - 0.13.0 (and at least some 0.14.0 dev versions as well). Zig 0.13.0 seems to have an issue linking with C++ code when targeting Wasm, that has been fixed in later development versions. Example Zig code <a><code>lib/main.zig</code></a>: ```Zig const std = @import("std"); const zbind = @import("zbind"); pub fn hello(name: []const u8) void { std.debug.print("Hello, {s}!\n", .{ name }); } comptime { zbind.init(@This()); } ``` It exports a Zig function <code>hello</code>, callable from TypeScript. A wrapper function will be exported that receives a string pointer and length in memory shared between Zig and the JavaScript engine. Example TypeScript code <a><code>src/index.ts</code></a> to call it: ```TypeScript import { hello } from './greet.js'; hello('World'); ``` The automatically generated TypeScript function will encode the string as UTF-8 in a buffer directly accessible by both languages. The Zig code requires a <a><code>build.zig</code></a> script to compile it: ```Zig const std = @import("std"); const zbind = @import("node_modules/zbind/zbind.zig"); pub fn build(builder: *std.Build) !void { const lib = try zbind.build(.{ // .builder = builder, .main = "lib/main.zig", .out = "dist/addon" }); <code>lib.linkLibC(); </code> } ``` The <code>zbind.build</code> call returns a <code>*std.Build.Step.Compile</code> object for linking with other libraries if needed. Run these shell commands to compile the code and generate TypeScript bindings: ```bash npm install --save zbind npm install --save-dev node-api-headers For native zig build -Doptimize=ReleaseFast npx zbind dist/addon.node src/greet.ts For Wasm zig build -Doptimize=ReleaseSmall -Dtarget=wasm32-wasi npx zbind dist/addon.wasm src/greet.ts ``` The commands compile the Zig code to a native or Wasm binary and then call a TypeScript-based tool to inspect it and generate wrapper functions in <code>src/greet.ts</code> with matching types and necessary marshalling. To install Zig from NPM you can do: <code>npm install --save-dev @oven/zig</code> Supported data types | Zig | TypeScript | Notes | |--------------|---------------------|-------| | <code>bool</code> | <code>boolean</code> | | | <code>u8</code> - <code>u32</code> | <code>number</code> | Conversion from <code>number</code> rounds down, throws if outside range. | | <code>i8</code> - <code>i32</code> | <code>number</code> | Conversion from <code>number</code> rounds towards 0, throws if outside range. | | <code>f32</code>, <code>f64</code> | <code>number</code> | | | <code>u64</code>, <code>i64</code> | <code>bigint</code> | | | <code>[]u8</code> | <code>Slice</code>, <code>string</code> | <code>Slice</code> of <code>u8</code> has a <code>toString</code> method for automatic coercion.Strings are passed through a stack. | | <code>struct</code> | <code>OpaqueStruct</code> | TypeScript takes ownership of opaque structs passed by valuesuch as <code>std.mem.Allocator</code> | | <code>?</code>any above | any above <code>\| null</code> | | Support is planned for more slice types, pointers, error unions, callbacks and accessing struct fields and methods. Architecture Generated TypeScript bindings are identical for Wasm and Node-API. Values are marshalled using a separate one-megabyte stack mostly accessed through a <code>[]f64</code> / <code>Float64Array</code>. Since <code>f64</code> can represent 53-bit integers, it fits pointers to memory as well. <code>null</code> is passed as a special NaN bit pattern. When compiled, <code>zbind.zig</code> analyzes argument and return types of Zig functions at comptime, stores the metadata in a compact binary representation and defines special endpoints for querying functions and types. It generates Zig wrapper functions for Zig methods to handle type marshalling and reports a list of pointers to those functions when initialized. The <code>zbind</code> command line tool loads the compiled binary and queries its metadata endpoints to generate a TypeScript wrapper for each Zig function which calls it automatically converting types. The tool writes out TypeScript source code defining and exporting the wrapper functions. After importing the generated file in your own TypeScript code and making the first call to Zig code through it, the bindings load the compiled binary. License 0BSD, which means use as you wish and no need to mention this project or its author. Consider it public domain in practice.
[]
https://avatars.githubusercontent.com/u/29507195?v=4
fex
18alantom/fex
2024-03-25T06:51:59Z
A command-line file explorer prioritizing quick navigation.
master
3
131
7
131
https://api.github.com/repos/18alantom/fex/tags
GPL-3.0
[ "cli", "file-explorer", "tool", "tui", "unix", "zig", "zsh" ]
353
false
2025-05-18T07:32:31Z
true
true
0.13.0
github
[]
<strong>A command-line file explorer.</strong> <code>fex</code> is a command-line file explorer inspired by <a>Vim</a>, <a>exa</a> and <a>fzf</a>, built with quick exploration and navigation in mind. By using Vim-like keybindings, <code>fex</code> ends up being a near-effortless tool to zip around a file system: <ul> <li><code>j</code>, <code>k</code> to move to the previous and next item</li> <li><code>h</code>, <code>l</code> to move up or drop down a directory</li> <li><code>/</code> to search for items</li> <li><code>:</code> to run commands on the selected item</li> </ul> <strong>Show Fex Demo</strong> [Fex Demo.webm](https://github.com/18alantom/fex/assets/29507195/04bb6078-c8f0-4e27-88db-79b81c1e6429) Index <ul> <li><a>Installation</a></li> <li><a>Using <code>install.sh</code></a></li> <li><a>From Source</a><ul> <li><a>macOS</a></li> <li><a>Linux</a></li> </ul> </li> <li><a>Setup</a></li> <li><a>Zsh Setup</a></li> <li><a>fex Default Command</a></li> <li><a>Config</a></li> <li><a>Display Config</a></li> <li><a>Search Config</a></li> <li><a>Other Args</a></li> <li><a>Controls</a></li> <li><a>Navigation Controls</a></li> <li><a>Action Controls</a></li> <li><a>File System Controls</a></li> <li><a>Search Mode Controls</a></li> <li><a>Command Mode Controls</a></li> <li><a>Display Toggle Controls</a></li> <li><a>Sort Controls</a></li> <li><a>Platform Support</a></li> </ul> Installation The most convenient way is by running the following bash one-liner: <code>bash curl -O https://raw.githubusercontent.com/18alantom/fex/master/install.sh &amp;&amp; bash install.sh</code> Getting <code>fex</code> running involves: <ol> <li>Installing the <code>fex</code> executable.</li> <li>Setting up the shell integration.</li> </ol> To get install the <code>fex</code> executable follow this section. For the shell integration go to the <a>Setup</a> section. <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> 🚧 Installation using package managers (Homebrew, apt, etc) will be added. </blockquote> Using <code>install.sh</code> You can use the <a><code>install.sh</code></a> script to <a>download</a> and setup the latest version of fex. Run the following bash one-liner to setup fex: <code>bash curl -O https://raw.githubusercontent.com/18alantom/fex/master/install.sh &amp;&amp; bash install.sh</code> <blockquote> [!TIP] The same bash one-liner can be used to update your fex install. <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 uninstall fex: <ol> <li>Remove the <code>$HOME/.fex</code> directory.</li> <li>Delete the lines pertaining to fex from your <code>.bashrc</code> or <code>.zshrc</code> file.</li> </ol> </blockquote> From Source To install fex from source, you will need version <code>zig</code> version 0.13.0 installed. You can get it from <a>here</a>. Once you had done that, compile the executable by using the following commands: ```bash Clone the fex repository git clone https://github.com/18alantom/fex &amp;&amp; cd fex ``` macOS ```bash Compile the fex executable for your system zig build-exe -O ReleaseSafe main.zig Move the executable to usr bin mv main /usr/local/bin/fex ``` Linux ```bash To be able to open files, you will need xdg-open from xdg-utils sudo apt install xdg-utils ``` ```bash Compile the fex executable for your system zig build-exe -O ReleaseSafe main.zig -lc Move the executable to usr bin mv main /usr/bin/fex ``` Setup To use <code>fex</code> to its full extent it needs to be set up as a shell widget. This allows fex to: <ul> <li>Be invoked using a key binding.</li> <li>Execute shell commands. For example <code>cd</code> to quit and change directory.</li> </ul> These are shell specific so you will need to set it up separately depending on the shell you use. <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> 🚧 bash shell support will be added. </blockquote> Zsh Setup To setup the Zsh widget for fex, first copy the file <a><code>shell/.fex.zsh</code></a> to your home directory. Then copy the following lines into your <code>.zshrc</code>: ```bash Source .fex.zsh if it's present [ -f ~/.fex.zsh ] &amp;&amp; source ~/.fex.zsh Bind CTRL-F to invoke fex (key binds can be custom) bindkey '^f' fex-widget ``` <blockquote> [!TIP] You can change which shortcut is used to invoke <code>fex</code> by using the Zsh <code>bindkey</code> command. For example if you use Zsh vi mode, you can use <code>bindkey -a 'f' fex-widget</code> to invoke <code>fex</code> using the <code>'f'</code> key when in command mode. Reference: <ul> <li>ZLE manpage (<code>man zshzle</code>), the ZLE BUILTINS section.</li> <li><a>Binding Keys and handling keymaps</a></li> </ul> </blockquote> Fish Setup To setup the fex key bind for Fish, copy <a><code>shell/.fex.fish</code></a> into to home directory. Then copy the following lines below into your <code>$HOME/.config/fish/config.fish</code>. ```bash Source .fex.fish if it's present [ -f ~/.fex.fish ] &amp;&amp; source ~/.fex.fish Bind CTRL-F to invoke fex (key binds can be custom) bind \cf fex-widget ``` Once you're done, restart your shell to see it working! <blockquote> [!TIP] You can change which shortcut is used to invoke <code>fex</code> by using the Fish <code>bind</code> command. Reference: <a>bind - handle fish key bindings</a> </blockquote> <code>fex</code> Default Command After you have set up fex for your shell, you can <code>FEX_DEFAULT_COMMAND</code> to change what flags <code>fex</code> is invoked using. For example: ```bash Sets time displayed to access time and hides icons export FEX_DEFAULT_COMMAND="fex --time-type accessed --no-icons" ``` Config You can configure <code>fex</code> by passing it args. <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> Config is picked up from the <code>FEX_DEFAULT_COMMAND</code> envvar and CLI args passed when calling <code>fex</code>. CLI args take precedence. </blockquote> Display Config Changes values displayed in an item line. | arg | description | | :------------------ | :------------------------------------------------------------------------------------------------------ | | <code>--[no-]dotfiles</code> | Show or hide dotfiles (hidden by default). | | <code>--[no-]icons</code> | Show or hide icons. Note: icons need a <a>patched font</a> to work. | | <code>--[no-]size</code> | Show or hide item sizes | | <code>--[no-]time</code> | Show or hide time | | <code>--[no-]perm</code> | Show or hide permission info | | <code>--[no-]link</code> | Show or hide link target | | <code>--[no-]user</code> | Show or hide user name | | <code>--[no-]group</code> | Show or hide group name | | <code>--time-type VALUE</code> | Set which time is displayed. VALUE: modified, accessed, changed. Default: modified | | <code>--[no-]fullscreen</code> | Enable or disable full screen mode. Previous screen is restored on quit. | Search Config This changes search behavior. | arg | description | | :--------------- | :------------------------------------------- | | --regular-search | Uses regular search, instead of fuzzy search | | --match-case | Match search query case, instead of ignoring | <blockquote> [!TIP] <code>fex</code> uses smart case matching by default i.e case is ignored until you enter an upper case character. </blockquote> Other Args | arg | description | | :---------- | :--------------------------------- | | <code>--help</code> | Prints the help message and quits. | | <code>--version</code> | Prints the version and quits. | Controls <code>fex</code> has three modes: <ul> <li><strong>Default</strong>: used to navigate around a file system and enter one of the other modes.</li> <li><strong>Search</strong>: toggled with <code>/</code>, used to accept a query and find matching items in expanded directories.</li> <li><strong>Command</strong>: toggled with <code>:</code>, used to accept a shell command that is executed on <code>enter</code>. <code>fex</code> needs to be setup as a shell widget for this to work, see <a>Setup</a>.</li> </ul> <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> Keys mentioned in angle-brackets such as <code>&lt;enter&gt;</code> show which key has to be pressed. Keys mentioned without such as <code>cd</code> are sequences that have to be typed. </blockquote> Navigation Controls | key | action | | :------------------- | :--------------------------------------- | | <code>j</code>, <code>&lt;down-arrow&gt;</code> | Cursor down | | <code>k</code>, <code>&lt;up-arrow&gt;</code> | Cursor up | | <code>h</code>, <code>&lt;left-arrow&gt;</code> | Up a dir | | <code>l</code>, <code>&lt;right-arrow&gt;</code> | Down a dir (if item is a dir) | | <code>gg</code> | Jump to first item in the list | | <code>G</code> | Jump to last item in the list | | <code>{</code> | Jump to prev item with a different level | | <code>}</code> | Jump to next item with a different level | Action Controls | key | action | | :-------------- | :---------------------------------------- | | <code>&lt;enter&gt;</code> | Toggle directory or open file | | <code>o</code> | Open item | | <code>E</code> | Expand all directories under root | | <code>C</code> | Collapse all directories | | <code>R</code> | Change root to item under cursor (if dir) | | <code>I</code> | Toggle item stat info | | <code>1..9</code> | Expand all directories up to $NUM depth | | <code>q</code>, <code>&lt;ctrl-d&gt;</code> | Quit | | <code>&lt;tab&gt;</code> | Toggle item selection under cursor | | <code>/</code> | Toggle search mode | | <code>:</code> | Toggle command mode | File System Controls | key | action | | :--- | :--------------------------------------------------------------------- | | <code>cd</code> | Quit and change directory to item under cursor (needs <a>setup</a>) | Search Mode Controls Type <code>/</code> in regular mode to initiate search mode. | key | action | | :--------- | :------------------------------------------------- | | <code>&lt;escape&gt;</code> | Quit search, restore cursor to pre-search position | | <code>&lt;enter&gt;</code> | Quit search, cursor stays on found item | Command Mode Controls Type <code>:</code> in regular mode to initiate command mode. | key | action | | :--------- | :--------------------------------------------------------------------------- | | <code>&lt;escape&gt;</code> | Quit command mode | | <code>&lt;enter&gt;</code> | Quit fex, execute command with selected items or item under cursor as arg(s) | Display Toggle Controls Toggle displayed information. | key | action | | :--- | :----------------------------- | | <code>.</code> | Toggle dotfile display | | <code>I</code> | Toggle item stat info | | <code>ti</code> | Toggle icon display | | <code>tp</code> | Toggle permission info display | | <code>ts</code> | Toggle size display | | <code>tt</code> | Toggle time display | | <code>tl</code> | Toggle link target display | | <code>tu</code> | Toggle user name display | | <code>tg</code> | Toggle group name display | | <code>tm</code> | Display modified time | | <code>ta</code> | Display accessed time | | <code>tc</code> | Display changed time | Sort Controls Sort entries in a directory. | key | action | | :---- | :----------------------------------------- | | <code>sn</code> | Sort in ascending order by name | | <code>ss</code> | Sort in ascending order by size | | <code>st</code> | Sort in ascending order by displayed time | | <code>sdn</code> | Sort in descending order by name | | <code>sds</code> | Sort in descending order by size | | <code>sdt</code> | Sort in descending order by displayed time | Platform Support <code>fex</code> should ideally compile and run on all macOS and Linux targets supported by Zig. Some features such as opening fs items work only on macOS for now. Portions of <code>fex</code> code is platform specific and Windows compatibility has not been accounted for. This may be added in later. | arch | macOS | Linux | Windows | | ---- | ------- | ---------------- | ---------------- | | arm | works | does not compile | does not compile | | x86 | works* | works | does not compile | Currently fex only has shell integration for Zsh. Fish and Bash integrations will be added. <em>works*: uses stat instead of lstat for macOS x86 so links may not be shown.</em>
[]
https://avatars.githubusercontent.com/u/476352?v=4
zeit
rockorager/zeit
2024-03-16T13:42:09Z
a date and time library written in zig. Timezone, DST, and leap second aware
main
0
109
9
109
https://api.github.com/repos/rockorager/zeit/tags
MIT
[ "date", "datetime", "library", "time", "timezone", "zig", "zig-package" ]
187
false
2025-05-21T21:55:21Z
true
true
unknown
github
[]
zeit A time library written in zig. Usage <a>API Documentation</a> ```zig const std = @import("std"); const zeit = @import("zeit"); pub fn main() void { const allocator = std.heap.page_allocator; var env = try std.process.getEnvMap(allocator); defer env.deinit(); <code>// Get an instant in time. The default gets "now" in UTC const now = try zeit.instant(.{}); // Load our local timezone. This needs an allocator. Optionally pass in a // *const std.process.EnvMap to support TZ and TZDIR environment variables const local = try zeit.local(alloc, &amp;env); // Convert our instant to a new timezone const now_local = now.in(&amp;local); // Generate date/time info for this instant const dt = now_local.time(); // Print it out std.debug.print("{}", .{dt}); // zeit.Time{ // .year = 2024, // .month = zeit.Month.mar, // .day = 16, // .hour = 8, // .minute = 38, // .second = 29, // .millisecond = 496, // .microsecond = 706, // .nanosecond = 64 // .offset = -18000, // } // Format using strftime specifier. Format strings are not required to be comptime try dt.strftime(anywriter, "%Y-%m-%d %H:%M:%S %Z"); // Or...golang magic date specifiers. Format strings are not required to be comptime try dt.gofmt(anywriter, "2006-01-02 15:04:05 MST"); // Load an arbitrary location using IANA location syntax. The location name // comes from an enum which will automatically map IANA location names to // Windows names, as needed. Pass an optional EnvMap to support TZDIR const vienna = try zeit.loadTimeZone(alloc, .@"Europe/Vienna", &amp;env); defer vienna.deinit(); // Parse an Instant from an ISO8601 or RFC3339 string const iso = try zeit.instant(.{ .source = .{ .iso8601 = "2024-03-16T08:38:29.496-1200", }, }); const rfc3339 = try zeit.instant(.{ .source = .{ .rfc3339 = "2024-03-16T08:38:29.496706064-1200", }, }); </code> } ```
[ "https://github.com/Ratakor/axe", "https://github.com/TemariVirus/zig-holodex", "https://github.com/fjebaker/zorro", "https://github.com/kristoff-it/zine", "https://github.com/neurocyte/flow", "https://github.com/reykjalin/todui", "https://github.com/rockorager/comlink", "https://github.com/sam701/slo...
https://avatars.githubusercontent.com/u/163546630?v=4
zinc
zon-dev/zinc
2024-03-19T12:40:08Z
Zinc is a web framework written in pure Zig with a focus on high performance, usability, security, and extensibility.
main
2
108
6
108
https://api.github.com/repos/zon-dev/zinc/tags
MIT
[ "api", "epoll", "framework", "io-uring", "iouring", "kqueue", "performance", "resetful", "rest-api", "usability", "web", "web-development", "web-framework", "zig", "zig-package", "zig-zinc", "ziglang", "zinc" ]
311
false
2025-05-18T05:30:50Z
true
true
0.14.0
github
[ { "commit": "refs", "name": "url", "tar_url": "https://github.com/zon-dev/url/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/zon-dev/url" } ]
zinc Zinc is a framework written in pure Zig with a focus on high performance, usability, security, and extensibility. <strong>:construction: It's still under development. Built on std.net. Not the fastest zig framework in the universe, but fast enough.</strong> <strong>In the works</strong>: * Remove std.http.Server * Blocking mode auto change to kqueue for MacOS and BSD * Non-blocking mode auto change to io_uring for Linux A basic example: ```zig const zinc = @import("zinc"); pub fn main() !void { var z = try zinc.init(.{ .port = 8080 }); defer z.deinit(); var router = z.getRouter(); try router.get("/", helloWorld); <code>try z.run(); </code> } fn helloWorld(ctx: *zinc.Context) anyerror!void { try ctx.text("Hello world!", .{}); } ``` Some features are: <ul> <li><strong>Fast</strong></li> <li><strong>Custom allocator</strong></li> <li><strong>Multithreading</strong></li> <li><strong>Middleware</strong></li> <li><strong>Routes grouping</strong></li> <li><strong>Rendering built-in</strong></li> <li><strong>Extensible</strong></li> <li><strong>Suite of unit tests</strong></li> <li><strong>Usability</strong></li> </ul> Documentation See more at https://zinc.zon.dev/ Quick Start Learn and practice with the Zinc <a>Quick Start</a>, which includes API examples and builds tag. Examples A number of examples demonstrating various use cases of Zinc in the <a>zinc-examples</a> repository.
[ "https://github.com/zon-dev/oauth2", "https://github.com/zon-dev/zinc-examples" ]
https://avatars.githubusercontent.com/u/465519?v=4
hypergraphz
yamafaktory/hypergraphz
2024-07-25T21:03:49Z
HypergraphZ - A Hypergraph Implementation in Zig
main
0
105
1
105
https://api.github.com/repos/yamafaktory/hypergraphz/tags
MIT
[ "graph", "graph-algorithms", "hypergraph", "zig", "zig-library", "zig-package", "ziglang" ]
105
false
2025-03-31T20:39:05Z
true
true
0.14.0
github
[]
HypergraphZ - A Hypergraph Implementation in Zig HypergraphZ is a directed hypergraph implementation in Zig (https://en.wikipedia.org/wiki/Hypergraph): <ul> <li>Each hyperedge can contain zero, one (unary) or multiple vertices.</li> <li>Each hyperedge can contain vertices directed to themselves one or more times.</li> </ul> Usage Add <code>hypergraphz</code> as a dependency to your <code>build.zig.zon</code>: <code>sh zig fetch --save https://github.com/yamafaktory/hypergraphz/archive/&lt;commit-hash&gt;.tar.gz</code> Add <code>hypergraphz</code> as a dependency to your <code>build.zig</code>: <code>zig const hypergraphz = b.dependency("hypergraphz", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("hypergraphz", hypergraphz.module("hypergraphz"));</code> Documentation The latest online documentation can be found <a>here</a>.
[]
https://avatars.githubusercontent.com/u/125416817?v=4
zignal
bfactory-ai/zignal
2024-04-13T06:47:14Z
Image processing library
master
0
96
4
96
https://api.github.com/repos/bfactory-ai/zignal/tags
MIT
[ "image-processing", "webassembly", "zig", "zig-package" ]
417
false
2025-05-21T14:51:56Z
true
true
0.14.0
github
[]
Zignal <a></a> <a></a> Zignal is an image processing library heavily inspired by the amazing <a>dlib</a>. Disclaimer This library is in early stages of development and being used internally. As a result, the API might change often. Installation <code>console zig fetch --save https://github.com/bfactory-ai/zignal/archive/&lt;commit-hash&gt;.tar.gz</code> or <code>console zig fetch --save https://github.com/bfactory-ai/zignal/archive/master.tar.gz</code> Then, in your <code>build.zig</code> <code>zig const zignal = b.dependency("zignal", .{ .target = target, .optimize = optimize }); // And assuming that your b.addExecutable `exe`: exe.root_module.addImport("zignal", zignal.module("zignal")); // If your creating a `module` using b.createModule, then: module.addImport("zignal", zignal.module("zignal"));</code> Motivation This library is used by <a>Ameli</a> for their makeup virtual try on. Features Initially, the features in this library are the ones required to get the virtual try on for makeup working. However, we hope that it can be a foundation from which we can build a high quality image processing library, collaboratively. Current features include: <ul> <li>color space conversions</li> <li>simple matrix struct with common linear algebra operations</li> <li>singular value decomposition (SVD) ported from dlib</li> <li>geometry</li> <li>points and rectangles</li> <li>projective, affine and similarity transforms</li> <li>convex hull</li> <li>simple image struct with common operations</li> <li>resize</li> <li>rotate</li> <li>crop</li> <li>blur</li> <li>sharpen</li> <li>views (called <code>sub_image</code> in dlib or <code>roi</code> in OpenCV.)</li> <li>drawing and filling functions</li> <li>lines</li> <li>circles</li> <li>polygons</li> </ul> Examples One of the greatest things about dlib is the large amount of examples illustrating how to use many of that library features. I plan to showcase most of the features of this library as simple HTML/JS + Wasm examples, which can be accessed from <a>here</a>. Currently, there are examples for: - <a>Color space conversions</a> - <a>Face alignment</a> - <a>Perlin noise generation</a> - <a>Seam carving</a> Acknowledgements First of all, this project would not have been possible without the existence of <a>dlib</a>. In fact, the first version of the virtual makeup try on was written in C++ with dlib and Emscripten. However, we decided to give Zig a go, even if that meant rewriting the world, but we have no dependencies now. Finally, <a>B factory, Inc</a>, which is my employer and graciously agreed to release this library to the public.
[]
https://avatars.githubusercontent.com/u/200686?v=4
ziglang-set
deckarep/ziglang-set
2024-05-05T23:44:23Z
A generic and general purpose Set implementation for the Zig language
main
5
78
4
78
https://api.github.com/repos/deckarep/ziglang-set/tags
MIT
[ "datastructures", "generics", "set", "standard-library", "zig", "zig-package", "ziglang" ]
10,918
false
2025-04-29T15:25:54Z
true
true
0.14.0
github
[]
Ziglang Set Ziglang-Set: a generic and general-purpose Set implementation for Zig. 🚧 BETA 🚧 <a></a> Zig currently <a>does not have</a> a built-in, general purpose Set data structure at this point in time. Until it does, try this! Rationale: It may be common knowledge that a dictionary, map or hashset can be used as a set with a value of <code>void</code>. While this is true, there's a lot to think about in terms of supporting all the common set operations in a performant and correct way and there's no good reason why a common module for this shouldn't exist. After studying the Zig stdlib, I'm hoping this implementation can fill that gap and provide some value. This module offers a Set implementation built in the same vein and spirit of the other data structures within the Zig standard library. This is my attempt to model one that can get better over time and grow with community interest and support. See a problem, file a bug! Or better yet contribute and let's build the best implementation together. I am the original author of the popular Go based set package: <a>golang-set</a> that is used by software components built by Docker, 1Password, Ethereum, SendGrid, CrowdStrike and HashiCorp. At just shy of <code>4.5k stars</code>, I figured I'd take a crack at building a comprehensive and generic Zig-based set that goes above and beyond the original Go implementation. After using Zig for over 3+ years on personal projects, I thought it was time that Zig had a robust Set implementation for itself. This implementation gives credit and acknowledgement to the <a>Zig language</a> and powerful <a>Std Library</a> <a>HashMap</a> data structure of which this set implementation is built on top of. Without that, this probably wouldn't exist. Efforts will be made to keep the Ziglang Set code fast and straightforward but this Set's raw speed will largely be bounded by the performance of the Zig HashMap of which it is built on top of. Features <ul> <li>Offers idiomatic, generic-based Zig API - allocator support, iterators, capacity hints, clearing, resizing, etc.</li> <li>A few flavors to choose from<ul> <li>NOTE: Future versions of Zig will be deprecating the <code>managed</code> variants, and this repo will be following suit.</li> <li>Hash-based: everyday usecase, optimized for lookups primarily, insertion/removal secondarily - <a>further reading</a></li> <li>HashSetManaged - initializes with an allocator and holds it internally (built on top of unmanaged)</li> <li>HashSetUnmanaged - does not hold an allocator, smaller footprint</li> <li>Array-based: more specialized, iteration much faster, insertion order preserved, indexing into underylying data - <a>further reading</a></li> <li>ArrayHashSetManaged - initializes with an allocator and holds it internally (built on top of unmanaged)</li> <li>ArrayHashSetUnmanaged - does not hold an allocator, smaller footprint</li> </ul> </li> <li>Common set operations<ul> <li>add, append, appendSlice</li> <li>remove, removeAll</li> <li>containsOne, containsAny, containsAll</li> <li>clone, cloneWithAllocator</li> <li>equals, isEmpty, cardinality</li> <li>intersection, intersectionUpdate (in-place variant)</li> <li>union, unionUpdate (in-place variant)</li> <li>difference, differenceUpdate (in-place variant)</li> <li>symmetricDifference, symmetricDifferenceUpdate (in-place variant)</li> <li>isDisjoint</li> <li>isSubset</li> <li>isSuperset</li> <li>isProperSubset</li> <li>isProperSuperset</li> <li>pop</li> </ul> </li> <li>Fully documented and robustly tested</li> <li>Performance aware to minimize unecessary allocs/iteration internally</li> <li>Custom hash function support</li> <li>"string" support</li> <li>Benchmarks</li> </ul> Why use a set? <ul> <li>A set offers a fast way to manipulate data and avoid excessive looping. Look into it as there is already tons of literature on the advantages of having a set in your arsenal of tools.</li> </ul> Example ```zig // import the namespace. const set = @import("ziglangSet"); <code>// Create a set of u32s called A var A = set.Set(u32).init(std.testing.allocator); defer A.deinit(); // Add some data _ = try A.add(5); _ = try A.add(6); _ = try A.add(7); // Add more data; single shot, duplicate data is ignored. _ = try A.appendSlice(&amp;.{ 5, 3, 0, 9 }); // Create another set called B var B = set.Set(u32).init(std.testing.allocator); defer B.deinit(); // Add data to B _ = try B.appendSlice(&amp;.{ 50, 30, 20 }); // Get the union of A | B var un = try A.unionOf(B); defer un.deinit(); // Grab an iterator and dump the contents. var iter = un.iterator(); while (iter.next()) |el| { std.log.debug("element: {d}", .{el.*}); } </code> ``` Output of <code>A | B</code> - the union of A and B (order is not guaranteed) ```sh <blockquote> element: 5 element: 6 element: 7 element: 3 element: 0 element: 9 element: 50 element: 30 element: 20 ``` </blockquote> Custom Hash Function To use a custom hash function, you can use the following types: <ul> <li><code>HashSetUnmanagedWithContext</code></li> <li><code>HashSetManagedWithContext</code></li> </ul> Example: ```zig const SimpleHasher = struct { const Self = @This(); pub fn hash(<em>: Self, key: u32) u64 { return @as(u64, key) *% 0x517cc1b727220a95; } pub fn eql(</em>: Self, a: u32, b: u32) bool { return a == b; } }; <code>const ctx = SimpleHasher{}; var set = HashSetUnmanagedWithContext(u32, SimpleHasher, 75).initContext(ctx); defer set.deinit(testing.allocator); _ = try set.add(testing.allocator, 123); try expect(set.contains(123)); try expect(!set.contains(456)); </code> ``` Installation of Module To add this module, update your applications build.zig.zon file by adding the <code>.ziglang-set</code> dependency definition. <code>zig .{ .name = "your-app", .version = "0.1.0", .dependencies = .{ .ziglangSet = .{ .url = "https://github.com/deckarep/ziglang-set/archive/$COMMIT_YOU_WANT_TO_USE.tar.gz", }, }, }</code> When running zig build now, Zig will tell you you need a hash for the dependency and provide one. Put it in your dependency so it looks like: <code>zig .{ .ziglangSet = .{ .url = "https://github.com/deckarep/ziglang-set/archive/$COMMIT_YOU_WANT_TO_USE.tar.gz", .hash = "$HASH_ZIG_GAVE_YOU", }, }</code> With the dependency in place, you can now put the following in your build.zig file: <code>zig const ziglangSet = b.dependency("ziglangSet", .{}); exe.root_module.addImport("ziglangSet", ziglangSet.module("ziglangSet"));</code> In the above change <code>exe</code> to whatever CompileStep you are using. For an executable it will probably be exe, but <code>main_tests</code> or lib are also common. With the build file in order, you can now use the module in your zig source. For example: ```zig const std = @import("std"); const set = @import("ziglangSet"); pub fn main() void { // 1. This datastructure requires an allocator. // Setup and choose your respective allocator. // See: https://zig.guide/standard-library/allocators <code>// 2. Go to town! var A = set.Set(u32).init(allocator); defer A.deinit(); // Now do something cool with your set! // ... </code> } ``` Check the tests for more comprehensive examples on how to use this package. Testing <code>sh zig build test</code> Docs Generation ```sh With Zig installed: zigup build docs &amp;&amp; cp -a zig-out/docs/. docs/ Alternatively, using Zigup: zigup run build docs &amp;&amp; cp -a zig-out/docs/. docs/ ```
[]
https://avatars.githubusercontent.com/u/231785?v=4
mvzr
mnemnion/mvzr
2024-07-16T00:02:45Z
Minimum Viable Zig Regex
trunk
1
74
2
74
https://api.github.com/repos/mnemnion/mvzr/tags
MIT
[ "pattern-matching", "regex", "regular-expressions", "zig", "zig-package" ]
221
false
2025-05-05T18:31:25Z
true
true
0.12.0
github
[]
mvzr: The Minimum Viable Zig Regex Library Finding myself in need of a regular expressions library for a Zig project, and needing it to build regex at runtime, not just comptime, I ended up speedrunning a little library for just that purpose. This is that library. It's a simple bytecode-based Commander Pike-style VM. Under 2000 lines of load-bearing code, no dependencies other than <code>std</code>. The provided Regex type allows 64 'operations' and 8 unique ASCII character sets. If you would like more, or less, you can call <code>SizedRegex(num_ops, num_sets)</code> to customize the type. Installation Drop the file into your project, or use the Zig build system: <code>zig zig fetch --save "https://github.com/mnemnion/mvzr/archive/refs/tags/v0.3.4.tar.gz"</code> I'll do my best to keep that URL fresh, but it pays to check over here: ➔ For the latest release version. Features <ul> <li>Zero allocation, comptime and runtime compiling and matching</li> <li>X operations per regex</li> <li>Y character sets per regex</li> <li>Greedy qualifiers: <code>*</code>, <code>+</code>, <code>?</code></li> <li>Lazy qualifiers: <code>*?</code>, <code>+?</code>, <code>??</code></li> <li>Possessive/eager qualifiers: <code>*+</code>, <code>++</code>, <code>?+</code></li> <li>Alternation: <code>foo|bar|baz</code></li> <li>Grouping <code>foo|(bar|baz)+|quux</code></li> <li>Sets: <code>[abc]</code>, <code>[^abc]</code>, <code>[a-z]</code>, <code>[^a-z]</code>, <code>[\w+-]</code>, <code>[\x04-\x1b]</code></li> <li>Built-in character groups (ASCII): <code>\w</code>, <code>\W</code>, <code>\s</code>, <code>\S</code>, <code>\d</code>, <code>\D</code></li> <li>Escape sequences: <code>\t</code>, <code>\n</code>, <code>\r</code>, <code>\xXX</code> hex format<ul> <li>Same set as Zig: if you need the weird C ones, use <code>\x</code> format</li> </ul> </li> <li>Begin and end <code>^</code> and <code>$</code></li> <li>Word boundaries <code>\b</code>, <code>\B</code></li> <li><code>{M}</code>, <code>{M,}</code>, <code>{M,N}</code>, <code>{,N}</code></li> </ul> Limitations and Quirks <ul> <li>Minimal multibyte / Unicode support<ul> <li>This has improved somewhat. A regex like <code>λ?</code> now matches an optional lambda, not just an optional final byte. Additionally, ranges of bytes greater than 0x7f are now supported, this (with some care) can match certain sets: for instance <code>(\xce[\x91-\xa9])+</code> will match a string of uppercase Greek letters, <code>\xc2[\x80-\x9f]</code> matches a C1 control code, and so on. But you'll still need to work at the byte level, and use <code>\x</code> format, to do these tasks.</li> </ul> </li> <li>No fancy modifiers (you want case-insensitive, great, lowercase your string)</li> <li><code>.</code> matches any one byte. <code>[^\n\r]</code> works fine if that's not what you want<ul> <li>Or split into lines first, divide and conquer</li> <li>Note: <code>$</code> permits a final newline, but <code>^</code> must be the beginning of a string, and <code>$</code> <em>only</em> matches a final newline.</li> </ul> </li> <li>Backtracks (sorry. For this design to work without backtracking, we need async back)</li> <li>Compiler does some best-effort validation but I haven't really pounded on it</li> <li>No capture groups. Divide and conquer</li> </ul> As long as you color within the lines, it should be fine. This library is not intended for use where an attacker could conceivably control the regex pattern. Much like managing your own memory, if you know your tools and are smart about it, you can get a lot done with <code>mvzr</code>. Interface <code>mvzr.Regex</code> is available at <code>comptime</code> or runtime, and returns an <code>mvzr.Match</code>, consisting of a <code>.slice</code> field containing the match, as well as the <code>.start</code> and <code>.end</code> locations in the haystack. This is a borrowed slice, to own it, call <code>match.toOwnedMatch(allocator)</code>, and deallocate later with <code>match.deinit(allocator)</code>, or just free the <code>.slice</code>. Similarly, if you need to store a <code>Regex</code> or <code>SizedRegex</code> for later, call <code>regex.toOwnedRegex(allocator)</code>, freeing later with <code>allocator.destroy(heap_regex)</code>. ```zig // aka SizedRegex(64, 8) const regex: mvzr.Regex = mvzr.compile(patt_str).?; // or mvzr.Regex.compile(patt_str) const match: mvzr.Match = regex.match(haystack).?; const match2: mvzr.Match = match(haystack, patt_str).?; const did_match: bool = regex.isMatch(haystack); const iter: mvzr.RegexIterator = regex.iterator(haystack); while (iter.next()) |m| { // ... } // Comptime-only const ops, const sets = mvzr.resourcesNeeded("abc?d*[^efgh]++2"); // I suggest adding the values directly here once they're established const SlimmedDownRegex = mvzr.SizedRegex(ops, sets); ``` Compile Errors If a regex string is unable to compile, <code>mvzr</code> will return <code>null</code>. It will also log an informative error message. While this is useful, it may not be desirable, so <code>mvzr</code> uses a <a>scoped logger</a> with the scope <code>.mvzr</code>, to make it easy for a custom logging function to filter those messages out. Bugs Fewer over time, I hope. The test suite never shrinks. Bug Reports Always welcome. Ideally, presented as a failing test block, with a note on expected behavior.
[ "https://github.com/BitlyTwiser/nostro", "https://github.com/haha-systems/phage", "https://github.com/mnemnion/obelizmo", "https://github.com/mnemnion/ohsnap", "https://github.com/septechx/alpha-html" ]
https://avatars.githubusercontent.com/u/57322933?v=4
zm
griush/zm
2024-06-01T15:15:45Z
zm - Fast, Zig math library, fully cross-platform
master
0
67
4
67
https://api.github.com/repos/griush/zm/tags
MIT
[ "game-development", "gamedev", "math", "zig", "zig-package" ]
125
false
2025-05-14T21:31:31Z
true
true
0.15.0-dev.516+abbead1fb
github
[]
zm - Fast math library zm is a Zig math library. It is fast, easy to use and cross-platform. 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> This library is tracking Zig's master branch. Last tested with <code>0.15.0-dev.516+abbead1fb</code>. It may not compile with newer or older versions. </blockquote> Run <code>zig fetch --save git+https://github.com/griush/zm</code> on the directory of your <code>build.zig</code> and <code>build.zig.zon</code>. Then in the <code>build.zig</code> add: <code>zig const zm = b.dependency("zm", .{}); exe_mod.addImport("zm", zm.module("zm"));</code> Now, in your code, you can use: <code>zig const zm = @import("zm");</code> Getting Started For an example using Zig's build system see: <a>example</a>. There is a working example using OpenGL and GLFW <a>here</a>. Simple example for game development. ```zig const zm = @import("zm"); const std = @import("std"); pub fn main() !void { // Initialize window (with GLFW for example) <code>// Create OpenGL/Vulkan... context const projection = zm.Mat4.perspective(zm.toRadians(60.0), 16.0 / 9.0, 0.05, 100.0); const view = zm.Mat4.translation(0.0, 0.75, 5.0); const view_proj = projection.multiply(view); // Upload data. Matrix should be transposed in OpenGL as they use column-major matrices. gl.NamedBufferSubData(ubo, 0, @sizeOf(zm.Mat4), &amp;view_proj); // Render loop // Cleanup </code> } ``` Benchmarks See <a>benchmarks</a>.
[ "https://github.com/griush/CoreX", "https://github.com/griush/zig-opengl-example" ]
https://avatars.githubusercontent.com/u/231785?v=4
ohsnap
mnemnion/ohsnap
2024-07-20T20:08:03Z
Oh Snap! Easy Snapshot Testing for Zig
trunk
3
54
4
54
https://api.github.com/repos/mnemnion/ohsnap/tags
MIT
[ "snapshot-testing", "test", "testing-library", "unit-test", "zig", "zig-package" ]
105
false
2025-05-17T16:37:08Z
true
true
0.14.0
github
[ { "commit": "refs", "name": "diffz", "tar_url": "https://github.com/mnemnion/diffz/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/mnemnion/diffz" }, { "commit": "refs", "name": "mvzr", "tar_url": "https://github.com/mnemnion/mvzr/archive/refs.tar.gz", "typ...
Oh Snap! Easy Snapshot Testing for Zig It's hard to know if a program, or part of one, actually works. But it's easy to know if it doesn't: if there isn't a test for some part of the program, then that part doesn't work. <a>Snapshot testing</a> is a great way to get fast coverage for <em>data invariants</em> in a program or library. The article I just linked to goes into great detail about the advantages of snapshot testing, and you should read it. <code>ohsnap</code> is a Zig library for doing snapshot testing, one which is, in fact, based on the <a>TigerBeetle library</a> used in that post. It includes some features not found in the original. TigerBeetle has a no-dependencies policy, and I'm confident that what they have serves their needs just fine. But a library like this is a dependency by definition, and I didn't mind adding a couple more. Let me show you its features! Installation The best way to use <code>ohsnap</code> is to install it using the <a>Zig Build System</a>. From your project repo root, use <code>zig fetch</code> like this: <code>sh zig fetch --save "https://github.com/mnemnion/ohsnap/archive/refs/tags/v0.4.0.tar.gz"</code> Then add it to your test artifact like so: <code>zig if (b.lazyDependency("ohsnap", .{ .target = target, .optimize = optimize, })) |ohsnap_dep| { lib_unit_tests.root_module.addImport("ohsnap", ohsnap_dep.module("ohsnap")); }</code> That should be it! Now you're ready to write some snaps! Using <code>ohsnap</code> The interface will be familiar if you read the linked blog post, which, really, you should. One difference between <code>ohsnap</code> and the original, is that <code>ohsnap</code> includes <a>pretty</a>, a clever pretty-printer for arbitrary data structures. So you don't need to write a custom <code>.format</code> method to use <code>ohsnap</code>, although if you have one, you can use that instead. Or both. Belt and suspenders kinda thing. Writing a snap is simple, to get started, do something like this: ```zig const OhSnap = @import("ohsnap"); test "snap something" { const oh = OhSnap{}; // You can configure <code>pretty</code> by using <code>var oh</code> and changing settings // in <code>oh.pretty_options</code>. const snap_me = someFn(); try oh.snap(@src(), \ , ).expectEqual(snap_me); } ``` Note that the call to <code>@src()</code> has to be directly above the string, and the string has to be multi-line style, with the double backslashes: <code>\\</code>. Both this: <code>zig try oh.snap(@src(), \\ etc ,).expectEqual(snap_me);</code> And this: <code>zig try oh.snap( @src(), \\ etc ,).expectEqual(snap_me);</code> Will work just fine. This test will fail, because the snapshot generated by <code>pretty</code> won't be equal to the empty string. <code>ohsnap</code> will diff that empty string with what it gets out of <code>snap_me</code>, and print what it got in all-green, because that's what happens when you diff an empty string against a string which isn't empty. If you like what you see, updating is simple. Change the file to the following: ```zig const OhSnap = @import("ohsnap"); test "snap something" { const oh = OhSnap{}; // You can configure <code>pretty</code> by using <code>var oh</code> and changing settings // in <code>oh.pretty_options</code>. const snap_me = someFn(); try oh.snap(@src(), \&lt;!update&gt; , ).expectEqual(snap_me); } ``` The snaptest will see the <code>&lt;!update&gt;</code>, which must be the beginning of the string, and replace it in your file with the output of the pretty printing. Easy! If your data structure has a <code>.format</code> method, and you'd prefer to use that as a basis, simply use <code>.expectEqualFmt</code> instead of <code>.expectEqual</code>. If, down the road, the snapshot doesn't compare to the expected string, <code>ohsnap</code> will use <a>diffz</a>[^1], a Zig port of <a>diff-match-patch</a>, to produce a terminal-colored character-level diff of the expected string with the actual string, making it easy to see exactly what's changed. These changes are either a bug, or a new feature. If it's the former, fix it, if it's the latter, just add <code>&lt;!update&gt;</code> to the head of the string again, and <code>ohsnap</code> will oblige. Pattern-Matching Snapshots This is fine and dandy, if the data structure, exactly as it prints, will always be the same on every test run. But what if that's only true of some of the data? Consider this example. We have a struct which looks like this: <code>zig const StampedStruct = struct { message: []const u8, tag: u64, timestamp: isize, pub fn init(msg: []const u8, tag: u64) StampedStruct { return StampedStruct{ .message = msg, .tag = tag, .timestamp = std.time.timestamp(), }; } };</code> Which we want to snapshot test, like this: <code>zig test "snap with timestamp" { const oh = OhSnap{}; const with_stamp = StampedStruct.init( "frobnicate the turbo-encabulator", 31337, ); try oh.snap( @src(), \\ohsnap.StampedStruct \\ .message: []const u8 \\ "frobnicate the turbo-encabulator" \\ .tag: u64 = 31337 \\ .timestamp: isize = 1721501316 , ).expectEqual(with_stamp); }</code> But of course, the next time we run the test, the timestamp will be different, so the test will fail. We care about the message and the tag, we care that there <em>is</em> a timestamp, but we don't care what the timestamp is, because we know it will be changing. For cases like this, <code>ohsnap</code> includes <a>mvzr</a>, the Minimum Viable Zig Regex library, which I wrote specifically for this purpose. Simply replace the timestamp like so: <code>zig try oh.snap( @src(), \\ohsnap.StampedStruct \\ .message: []const u8 \\ "frobnicate the turbo-encabulator" \\ .tag: u64 = 31337 \\ .timestamp: isize = &lt;^\d+$&gt; , ).expectEqual(with_stamp);</code> Through the magic of diffing, <code>ohsnap</code> will identify the part of the new string which matches <code>&lt;^\d+$&gt;</code>, and try to match the regular expression against that part of the string. Since this matches, the test now passes. Note that the regex must be in the form <code>&lt;^.+?$&gt;</code> (the exact regex we use is <code>&lt;\^[^\n]+?\$&gt;</code>, in fact), the <code>^</code> and <code>$</code> are essential and are load-bearing parts of the expression. This prevents partial matches, as well as making the regex portions of a snapshot test easier for <code>ohsnap</code> to find. Note that because this is a multi-line string, you don't have to do double-backslashes: its <code>&lt;^\d+$&gt;</code>, not <code>&lt;^\\d+$&gt;</code>. To be very clear, the <code>&lt;</code> and <code>&gt;</code> demarcate the regex, they aren't part of it. Let's say you make a change: <code>zig const with_stamp = StampedStruct.init( "thoroughly frobnicate the encabulator", 31337, );</code> The test will now fail: the word "thoroughly" will be highlighted in green, <code>turbo-</code> will be marked in red, and the timestamp will be cyan, indicating that the regex is still matching the pattern string. If a change in the test data means that the regex no longer matches, then the part of the test string which should match is highlighted in magenta. Since this was an intentional change, we need to update the snap: <code>zig try oh.snap( @src(), \\&lt;!update&gt; \\ohsnap.StampedStruct \\ .message: []const u8 \\ "frobnicate the turbo-encabulator" \\ .tag: u64 = 31337 \\ .timestamp: isize = &lt;^\d+$&gt; , ).expectEqual(with_stamp);</code> Once again, through the magic of diffing, <code>ohsnap</code> will locate the regexen in the old string, and patch them over the new one. <code>zig try oh.snap( @src(), \\ohsnap.StampedStruct \\ .message: []const u8 \\ "thoroughly frobnicate the encabulator" \\ .tag: u64 = 31337 \\ .timestamp: isize = &lt;^\d+$&gt; , ).expectEqual(with_stamp);</code> Voila! Usage note: in some cases, the changes to the new string will displace the regex, you can tell because some part of the regex itself will be exposed in red. When that happens, the update may not apply correctly either: the regex will always be moved to the new string intact, but it may or may not be in the correct place (usually, not). This can generally be fixed by making changes to the expected-value string until whatever part of the regex was sticking out of the diff is no longer exposed. Sometimes running <code>&lt;!update&gt;</code> twice will fix it as well. Developing With Snapshots When we're programming, there are always points in the process where a data structure is in flux, and <code>ohsnap</code> can help you out with that as well. Instead of <code>.expectEqual(var)</code>, use <code>.show(var)</code>, or <code>.showFmt(var)</code>. This will print the snapshot, whether it diffs or not, and it doesn't count as a test. <code>&lt;!update&gt;</code> continues to work in the same way, but an updated <code>.show</code> snapshot counts as a failed test. The update logic is fairly simple, and updating often changes the line numbering of the file, so this helps update one at a time. Note that you can add the <code>&lt;!update&gt;</code> string to any number of snapshots, and just keep recompiling the test suite until they all pass. Also, if <code>ohsnap</code> can't find the snapshot because it moved, nothing untoward will happen, it will just report a failed test, and running it again will fix the problem if it was caused by a previous update. This also works as a minimalist way to regress a snapshot test, when you aren't sure what the final value will be. Whenever you're satisfied with the output, just change <code>.show</code> to its <code>.expect</code> cousin, and now you've got a test. Unusual Directory Structures Zig 0.14 changed some values in <code>SourceLocation</code>, which is returned by <code>@src()</code>. In particular, the filenames are now relative to the module root file's directory, not the repository root directory. This has required some changes to <code>ohsnap</code>. In the majority of cases, a module is rooted in the <code>/src</code> directory, and in those cases, nothing further needs to be done. The library will make that assumption and updates will proceed on that basis. However, in the event that a test module is rooted in some other directory, or even that there are several test modules rooted in several distinct directories, <code>ohsnap</code> must be configured to find those directories given those roots. The most satisfactory solution I was able to work out is two options, <code>module_name</code> and <code>root_directory</code>. Both have the type <code>[]const []const u8</code>. Given a test called <code>"root"</code> in the directory <code>/test</code>, <code>ohsnap</code> can be passed those values like so: ```sh <blockquote> zig build test -Dmodule_name=root -Droot_directory=test <code>`` In this case, updating a snapshot will look for files in</code>root<code>in the directory</code>./test<code>. If</code>module_name<code>doesn't contain the name of the module, this will still fall back to</code>./src`. </blockquote> This can be repeated for as many test modules and associated directories as is needed. You can find what the build system names a module by adding a test like this to that module: <code>zig test "print module name" { std.debug.print("module name is {s}\n", .{@src.module}); }</code> This will only change if certain changes to the build script take place, so there's no need to leave the test running once the name is obtained. These values can be provided from the build script as well, like so: <code>zig if b.lazyDependency("ohsnap", .{ .target = target, .optimize = optimize, // etc module_name = .{ "root", "root1"}, root_directory = .{ "test", "src/subdir"}, }) |ohsnap_mod| { // Module imported in the usual fashion lib_unit_tests.root_module.addImport("ohsnap", ohsnap_dep.module("ohsnap")); lib_submodule_unit_tests.root_module.addImport("ohsnap", ohsnap_dep.module("ohsnap")); }</code> This solution is not perfectly satisfactory, but it retains the generality of the library with a minimum of fussing about. I hope subsequent work on Zig will restore the ability to reliably open a file, given the return value of <code>@src()</code>, in some fashion. That's It! One of the great advantages of snapshot testing is that it's easy, so <code>ohsnap</code>, like the library it's based upon, is intentionally quite simple. Simple, yet versatile, the latter to a large degree is owed to <code>pretty</code>, which can handle anything I've thrown at it, types, unions, you name it. It's a new library, but I expect the core interface to remain stable. It's meant to do one thing, well, and otherwise stay out of the way. I'm willing to consider suggestions for ways to make <code>ohsnap</code> better at what it already does, however. That said, the regex library <code>mvzr</code> is pretty new, and so is the added code in <code>diffz</code>, so version-bumps to fix any bugs in those can be expected over time. The build system doesn't currently do update checks, so you'll need to check for updates manually, for now. I hope you enjoy it! Test early, test often, and do it the easy way. [^1]: The link is to a fork of the library which has the necessary changes for terminal printing. That branch is in code review, and these things take time. <code>ohsnap</code> will be updated to fetch from the <a>main repo</a> when that's possible.
[ "https://github.com/mnemnion/obelizmo" ]
https://avatars.githubusercontent.com/u/1552770?v=4
zat
neurocyte/zat
2024-02-20T16:58:33Z
zat is a syntax highlighting cat like utility using tree-sitter and with support for vscode themes
master
0
54
5
54
https://api.github.com/repos/neurocyte/zat/tags
MIT
[ "cat", "tree-sitter", "tui", "zig" ]
76
false
2025-05-12T03:12:19Z
true
true
unknown
github
[ { "commit": "0.10.0.tar.gz", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/0.10.0.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Hejsil/zig-clap" }, { "commit": "master", "name": "themes", "tar_url": "https://github.com/neurocyte/flow-themes...
zat zat is a syntax highlighting cat like utility. It uses tree-sitter and supports for vscode themes. Build with the provided zig wrapper: <code>shell ./zig build -Doptimize=ReleaseSmall</code> The zig wrapper just fetches a known good version of zig nightly and places it in the .cache directory. Or use your own version of zig. Run with: <code>shell zig-out/bin/zat</code> Place it in your path for convenient access. Supply files to highlight on the command line. Multiple files will be appended like with cat. If no files are on the command line zat will read from stdin. Override the language with --language and select a different theme with --theme. The default theme will be read from ~/.config/flow/config.json if found. See <code>scripts/fzf-grep</code> for an example of using zat to highlight fzf previews. See --help for full command line.
[]
https://avatars.githubusercontent.com/u/9116281?v=4
mailbox
g41797/mailbox
2024-07-31T05:20:32Z
Zig Mailbox is convenient inter-thread communication mechanizm.
main
0
53
2
53
https://api.github.com/repos/g41797/mailbox/tags
MIT
[ "actor-model", "channel-on-steroids", "fan-in", "fan-out", "inter-thread-communication", "mailbox", "thread-safe", "zig", "zig-library", "zig-package" ]
376
false
2025-05-21T04:57:13Z
true
true
0.14.0
github
[]
Mailbox - old new way of inter-thread communication. <a></a> &nbsp; &nbsp; &nbsp; A bit of history, a bit of theory Mailboxes are one of the fundamental parts of the <a>actor model originated in <strong>1973</strong></a>: <blockquote> An actor is an object that carries out its actions in response to communications it receives. Through the mailbox mechanism, actors can decouple the reception of a message from its elaboration. A mailbox is nothing more than the data structure (FIFO) that holds messages. </blockquote> I first encountered MailBox in the late 80s while working on a real-time system: <blockquote> "A <strong>mailbox</strong> is object that can be used for inter-task communication. When task A wants to send an object to task B, task A must send the object to the mailbox, and task B must visit the mailbox, where, if an object isn't there, it has the option of <em>waiting for any desired length of time</em>..." <strong>iRMX 86™ NUCLEUS REFERENCE MANUAL</strong> _Copyright @ 1980, 1981 Intel Corporation. </blockquote> Since than I have used it in: | OS | Language(s) | |:-----------:|:-----------:| | iRMX | <em>PL/M-86</em> | | AIX | <em>C</em> | | Windows | <em>C++/C#</em> | | Linux | <em>Go</em> | <strong>Now it's Zig time!!!</strong> Why? If your thread runs in "Fire and Forget" mode, you don't need Mailbox. But in real multithreaded applications, threads communicate with each other as members of a work team. <strong>Mailbox</strong> provides a convenient and simple inter-thread communication: - thread safe - asynchronous - non-blocking - cancelable - no own allocations - unbounded - fan-out/fan-in Example of usage - 'Echo' ```zig // Mbx is Mailbox with usize letter(data) const Mbx = mailbox.MailBox(usize); <code>// Echo - runs on own thread // It has two mailboxes // "TO" and "FROM" - from the client point of the view // Receives letter via 'TO' mailbox // Replies letter without change (echo) to "FROM" mailbox const Echo = struct { const Self = @This(); to: Mbx = undefined, from: Mbx = undefined, thread: Thread = undefined, // Mailboxes creation and start of the thread // Pay attention, that client code does not use // any thread "API" - all embedded within Echo pub fn start(echo: *Self) void { echo.to = .{}; echo.from = .{}; echo.thread = std.Thread.spawn(.{}, run, .{echo}) catch unreachable; } // Echo thread function fn run(echo: *Self) void { // Main loop: while (true) { // Receive - exit from the thread if mailbox was closed const envelope = echo.to.receive(100000000) catch break; // Reply to the client // Exit from the thread if mailbox was closed _ = echo.from.send(envelope) catch break; } } // Wait exit from the thread pub fn waitFinish(echo: *Self) void { echo.thread.join(); } // Close mailboxes // As result Echo should stop processing // and exit from the thread. pub fn stop(echo: *Self) !void { _ = echo.to.close(); _ = echo.from.close(); } }; var echo = try std.testing.allocator.create(Echo); // Start Echo(on own thread) echo.start(); defer echo.stop(); defer { // Wait finish of Echo echo.waitFinish(); std.testing.allocator.destroy(echo); } // because nothing was send to 'TO' mailbox, nothing should be received // from 'FROM' mailbox try testing.expectError(error.Timeout, echo.from.receive(100)); // Create wrapper for the data const envl = try std.testing.allocator.create(Mbx.Envelope); defer std.testing.allocator.destroy(envl); // Send/Receive loop for (0..6) |indx| { // Set value for send [0-5] envl.letter = indx; // Send to 'TO' mailbox try echo.to.send(envl); // Wait received data from OUT mailbox const back = echo.from.receive(1000000); if (back) |val| { // Expected value == index [0-5] try testing.expect(val.letter == indx); } else |_| { try testing.expect(false); } } </code> ``` Boring details Mailbox of <em>[]const u8</em> 'Letters': <code>zig const Rumors = mailbox.MailBox([]const u8); const rmrsMbx : Rumors = .{};</code> <strong>Envelope</strong> is a wrapper of actual user defined type <strong>Letter</strong>. <code>zig pub const Envelope = struct { prev: ?*Envelope = null, next: ?*Envelope = null, letter: Letter, };</code> In fact Mailbox is a queue(FIFO) of Envelope(s). MailBox supports following operations: - send <em>Envelope</em> to MailBox (<em>enqueue</em>) and wakeup waiting receiver(s) - receive <em>Envelope</em> from Mailbox (<em>dequeue</em>) with time-out - close Mailbox: - disables further operations - first close returns List of non-processed <em>Envelope(s)</em> for free/reuse etc. Feel free to suggest improvements in doc and code. License <a>MIT</a> Installation You finally got to installation! Submodules Create folder <em>'deps'</em> under <em>'src'</em> and mailbox submodule: <code>bash mkdif src/deps git submodule add https://github.com/g41797/mailbox src/deps/mailbox</code> Import mailbox: <code>zig const mailbox = @import("deps/mailbox/src/mailbox.zig");</code> Use mailbox: ```zig const MsgBlock = struct { len: usize = undefined, buff: [1024]u8 = undefined, }; const Msgs = mailbox.MailBox(MsgBlock); var msgs: Msgs = .{}; ................... _ = msgs.close(); ``` Periodically update submodule(s): <code>bash git submodule update --remote</code> Package Manager With an existing Zig project, adding Mailbox to it is easy: <ol> <li>Add mailbox to your <code>build.zig.zon</code></li> <li>Add mailbox to your <code>build.zig</code></li> </ol> To add mailbox to <code>build.zig.zon</code> simply run the following in your terminal: <code>sh cd my-example-project zig fetch --save=mailbox git+https://github.com/g41797/mailbox</code> and in your <code>build.zig.zon</code> you should find a new dependency like: ```zig .{ .name = "My example project", .version = "0.0.1", <code>.dependencies = .{ .mailbox = .{ .url = "git+https://github.com/g41797/mailbox#3f794f34f5d859e7090c608da998f3b8856f8329", .hash = "122068e7811ec1bfc2a81c9250078dd5dafa9dca4eb3f1910191ba060585526f03fe", }, }, .paths = .{ "", }, </code> } ``` Then, in your <code>build.zig</code>'s <code>build</code> function, add the following before <code>b.installArtifact(exe)</code>: ```zig const mailbox = b.dependency("mailbox", .{ .target = target, .optimize = optimize, }); <code>exe.root_module.addImport("mailbox", mailbox.module("mailbox")); </code> ``` From then on, you can use the Mailbox package in your project. Last warning First rule of multithreading: <blockquote> <strong>If you can do without multithreading - do without.</strong> </blockquote> <em>Powered by</em> <a></a>
[ "https://github.com/g41797/syslog" ]
https://avatars.githubusercontent.com/u/476352?v=4
comlink
rockorager/comlink
2024-05-31T01:17:58Z
An experimental IRC client
main
11
53
8
53
https://api.github.com/repos/rockorager/comlink/tags
MIT
[ "irc", "irc-client", "zig", "zig-package" ]
2,190
false
2025-05-03T01:43:36Z
true
true
unknown
github
[ { "commit": "a379a185fb5414c3f0545121deda73aef6adac15", "name": "vaxis", "tar_url": "https://github.com/rockorager/libvaxis/archive/a379a185fb5414c3f0545121deda73aef6adac15.tar.gz", "type": "remote", "url": "https://github.com/rockorager/libvaxis" }, { "commit": "44bebf856693332b168d8ba2...
comlink An experimental IRC client written in zig. Join the discussion in #comlink on libera.chat. Installation Arch Linux <a>comlink</a> is available as a package in the AUR. It can be installed using an AUR helper (e.g. paru). <code>sh paru -S comlink</code> Zig Build System <code>comlink</code> is written in zig and can be installed using the zig build system, version 0.14.0. <code>sh git clone https://github.com/rockorager/comlink cd comlink zig build -Doptimize=ReleaseSafe --prefix ~/.local</code> Configuration Configuration is loaded from <code>$HOME/.config/comlink/init.lua</code> Works best with <code>soju</code>. <a>irctoday</a> runs a paid instance of <code>soju</code>, and another paid alternative is <a>pico.sh</a> ```lua local comlink = require("comlink") local config = { server = "chat.sr.ht", user = "rockorager", nick = "rockorager", password = "password", real_name = "Tim Culverhouse", tls = true, } -- Pass the server config to connect. Connect to as many servers as you need comlink.connect(config) -- Bind a key to an action comlink.bind("ctrl+c", "quit") ``` Storing passwords in configuration files is generally considered a poor security practice. The following example reads the password from an external password manager: ```lua local comlink = require("comlink") local proc = assert(io.popen("hiq -dFpassword proto=irc address=irc.example.com nickname=alex", "r")) local password = proc:read("*l") proc:close() local config = { -- …other fields here… password = password, } ``` Contributing Patches accepted on the <a>mailing list</a> Pull requests accepted on <a>Github</a> Pull requests accepted on <a>tangled.sh</a>
[]
https://avatars.githubusercontent.com/u/57362253?v=4
cimgui.zig
tiawl/cimgui.zig
2024-02-12T13:28:17Z
dear imgui packaged for @ziglang
trunk
1
53
7
53
https://api.github.com/repos/tiawl/cimgui.zig/tags
Unlicense
[ "binding", "cimgui", "imgui", "spaceporn", "zig", "zig-package", "ziglang" ]
3,212
false
2025-05-21T09:19:51Z
true
true
0.14.0
github
[ { "commit": "master", "name": "glfw_zig", "tar_url": "https://github.com/tiawl/glfw.zig/archive/master.tar.gz", "type": "remote", "url": "https://github.com/tiawl/glfw.zig" }, { "commit": "0ab7c9830bf17c1a2404461a88c0fdedf95309a4", "name": "sdl", "tar_url": "https://github.com/ca...
cimgui.zig This is a fork of <a>ocornut/imgui</a> packaged for <a>Zig</a> Why this fork ? The intention under this fork is to package <a>ocornut/imgui</a> for <a>Zig</a>. So: * Unnecessary files have been deleted, * The build system has been replaced with <code>build.zig</code>, * <a>dearimgui/dear_bindings</a> generates the C binding, * A cron runs every day to check <a>ocornut/imgui</a> and <a>dearimgui/dear_bindings</a>. Then it updates this repository if a new release is available. How to use it The goal of this repository is not to provide a <a>Zig</a> binding for <a>ocornut/imgui</a>. There are at least as many legit ways as possible to make a binding as there are active accounts on Github. So you are not going to find an answer for this question here. The point of this repository is to abstract the <a>ocornut/imgui</a> compilation process with <a>Zig</a> (which is not new comers friendly and not easy to maintain) to let you focus on your application. So you can use <strong>cimgui.zig</strong>: - as raw (see the <a>examples directory</a>), - as a daily updated interface for your <a>Zig</a> binding of <a>ocornut/imgui</a> (see <a>here</a> for a private usage). cimgui.zig as a library If you want to add <code>cimgui.zig</code> as a library to your project, you can do the following (do know that it requires a zig version <code>&gt;0.13</code>) : Fetch this repository : <code>sh $ zig fetch --save git+https://github.com/tiawl/cimgui.zig</code> Add it to your <code>build.zig</code> : ```diff const std = @import("std"); +const cimgui = @import("cimgui_zig"); pub fn build(b: *std.Build) void { // -- snip -- <ul> <li>const cimgui_dep = b.dependency("cimgui_zig", .{</li> <li>.target = target,</li> <li>.optimize = optimize,</li> <li>.platform = cimgui.Platform.GLFW,</li> <li>.renderer = cimgui.Renderer.Vulkan,</li> <li> }); // Where <code>exe</code> represents your executable/library to link to + exe.linkLibrary(cimgui_dep.artifact("cimgui")); // -- snip -- } ``` </li> </ul> And that's it ! You're ready to go ! See the <code>examples</code> directory on how to move forward from there. Backends The backends are separated in two categories : the platforms (handling windows, events, ...) and the renderers (draw to screen, ..). Platform <ul> <li><a>GLFW</a></li> <li><a>SDL3</a></li> <li><a>SDLGPU3</a> (technically a renderer but needs linkage againt OpenGL/Vulkan)</li> </ul> Renderers <ul> <li><a>Vulkan</a></li> <li><a>OpenGL</a></li> </ul> <blockquote> As you can see, these backends do not support all of those supported by ImGUI. Adding a backend is a bit of work because of the needed <em>maintenance</em>. Please do not ask for backends to be added if you don't feel like adding them yourselves ! </blockquote> Dependencies The <a>Zig</a> part of this package is relying on the latest <a>Zig</a> release (0.14.0) and will only be updated for the next one (so for the 0.14.1). Here the repositories' version used by this fork: * <a>ocornut/imgui</a> Currently there are no tags/release for <a>dearimgui/dear_bindings</a> so <strong>cimgui.zig</strong> is relying on the last commit. For backends see <a>the build.zig.zon</a> CICD reminder These repositories are automatically updated when a new release is available: * <a>tiawl/spaceporn</a> This repository is automatically updated when a new release is available from these repositories: * <a>ocornut/imgui</a> * <a>dearimgui/dear_bindings</a> * <a>tiawl/toolbox</a> * <a>tiawl/vulkan.zig</a> * <a>tiawl/glfw.zig</a> * <a>castholm/SDL</a> * <a>castholm/zigglgen</a> <code>zig build</code> options These additional options have been implemented for maintainability tasks: <code>-Dfetch=[bool] Update .references folder and build.zig.zon then stop execution -Dupdate=[bool] Update binding -Drenderer=[enum] Specify the renderer backend Supported Values: Vulkan OpenGL3 -Dplatform=[enum] Specify the platform backend Supported Values: GLFW SDL3 SDLGPU3</code> License This repository is not subject to a unique License: The parts of this repository originated from this repository are dedicated to the public domain. See the LICENSE file for more details. <strong>For other parts, it is subject to the License restrictions their respective owners choosed. By design, the public domain code is incompatible with the License notion. In this case, the License prevails. So if you have any doubt about a file property, open an issue.</strong>
[]
https://avatars.githubusercontent.com/u/56034786?v=4
mdsf
hougesen/mdsf
2024-02-18T17:01:41Z
Format markdown code blocks using your favorite tools
main
16
50
1
50
https://api.github.com/repos/hougesen/mdsf/tags
MIT
[ "cli", "codeblocks", "codeformatter", "command-line", "documentation", "elixir", "formatter", "gleam", "go", "hacktoberfest", "json", "markdown", "md", "pretty-printer", "python", "rust", "typescript", "zig" ]
3,611
false
2025-05-20T13:30:48Z
false
false
unknown
github
[]
mdsf Format, and lint, markdown code snippets using your favorite tools. <a></a> <a></a> <a></a> Table of contents <ul> <li><a>Table of contents</a></li> <li><a>Installation</a></li> <li><a>Linux &amp; MacOS</a></li> <li><a>Windows</a></li> <li><a>Cargo</a></li> <li><a>npm/npx</a></li> <li><a>Homebrew</a></li> <li><a>Conda</a></li> <li><a>Usage</a></li> <li><a>Formatting code</a><ul> <li><a>Caching formatting results</a></li> <li><a>Removing old caches</a></li> </ul> </li> <li><a>Verifying code</a></li> <li><a>GitHub Action</a></li> <li><a>Visual Studio Code</a></li> <li><a>Vim / NeoVim</a><ul> <li><a>conform.nvim</a></li> </ul> </li> <li><a>treefmt</a></li> <li><a>Configuration</a></li> <li><a>Language aliases</a></li> <li><a>Newlines</a></li> <li><a>Tools</a></li> <li><a>Commands</a></li> <li><a>Shell completions</a></li> <li><a>Bash</a></li> <li><a>Zsh</a></li> <li><a>Fish</a></li> <li><a>PowerShell</a></li> <li><a>Elvish</a></li> <li><a>Nushell</a></li> <li><a>Acknowledgement</a></li> <li><a>Alternatives to mdsf</a></li> </ul> Installation The latest version of <code>mdsf</code> can be downloaded directly from <a>github.com/hougesen/mdsf/releases</a>. Linux &amp; MacOS <code>shell curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hougesen/mdsf/releases/latest/download/mdsf-installer.sh | sh</code> Windows <code>powershell powershell -ExecutionPolicy ByPass -c "irm https://github.com/hougesen/mdsf/releases/latest/download/mdsf-installer.ps1 | iex"</code> Cargo Install using the <a>published crate</a>: <code>shell cargo install mdsf --locked</code> or directly from source: ```shell git clone git@github.com:hougesen/mdsf.git cargo install --path ./mdsf --bin mdsf ``` If you do not have Cargo installed, you need to <a>install it first</a>. npm/npx You can install <code>mdsf</code> using <a>npm</a>: ```shell npm install -g mdsf-cli mdsf format . ``` or run it directly using npx: <code>shell npx mdsf-cli format .</code> Homebrew <code>shell brew install hougesen/tap/mdsf</code> Conda An <em>unofficial</em> (and unsupported) Conda package can be found at <a>https://anaconda.org/conda-forge/mdsf</a>. <code>shell conda install conda-forge::mdsf</code> Usage ``` mdsf 0.9.5 Format, and lint, markdown code snippets using your favorite tools Mads Hougesen <a>&#109;&#97;&#100;&#115;&#64;&#109;&#104;&#111;&#117;&#103;&#101;&#46;&#100;&#107;</a> Usage: mdsf [OPTIONS] Commands: format Run tools on input files verify Verify files are formatted init Create a new mdsf config completions Generate shell completion cache-prune Remove caches help Print this message or the help of the given subcommand(s) Options: --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help -V, --version Print version ``` Formatting code The <code>format</code> command, as the name implies, is used to format documents. <code>shell mdsf format file.md</code> ``` Run tools on input files Usage: mdsf format [OPTIONS] [INPUT]... Arguments: [INPUT]... Path to files and/or directories Options: --stdin Read input from stdin and write output to stdout <code> --config &lt;CONFIG&gt; Path to config file --debug Log stdout and stderr of formatters --threads &lt;THREADS&gt; Amount of threads to use. Defaults to 0 (auto). --cache Cache results --log-level &lt;LOG_LEVEL&gt; [possible values: trace, debug, info, warn, error, off] --timeout &lt;TIMEOUT&gt; Tool timeout in seconds. Defaults to no timeout. --on-missing-language-definition &lt;ON_MISSING_LANGUAGE_DEFINITION&gt; What to do when a codeblock language has no tools defined [possible values: ignore, fail, fail-fast] --on-missing-tool-binary &lt;ON_MISSING_TOOL_BINARY&gt; What to do when the binary of a tool cannot be found [possible values: ignore, fail, fail-fast] </code> -h, --help Print help (see a summary with '-h') -V, --version Print version ``` Caching formatting results To speed formatting caching can be enabled by supplying the <code>format</code> command with the <code>--cache</code> argument. <code>shell mdsf format --cache docs/</code> Removing old caches Old caches can be removed by running the <code>mdsf cache-prune</code> command. ``` Remove caches Usage: mdsf cache-prune [OPTIONS] Options: --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help -V, --version Print version ``` Verifying code You can verify that the document is formatted using the <code>mdsf verify</code> command. <code>shell mdsf verify docs/</code> ``` Verify files are formatted Usage: mdsf verify [OPTIONS] [INPUT]... Arguments: [INPUT]... Path to files and/or directories Options: --stdin Read input from stdin and write output to stdout <code> --config &lt;CONFIG&gt; Path to config file --debug Log stdout and stderr of formatters --threads &lt;THREADS&gt; Amount of threads to use. Defaults to 0 (auto). --timeout &lt;TIMEOUT&gt; Tool timeout in seconds. Defaults to no timeout. --log-level &lt;LOG_LEVEL&gt; [possible values: trace, debug, info, warn, error, off] --on-missing-language-definition &lt;ON_MISSING_LANGUAGE_DEFINITION&gt; What to do when a codeblock language has no tools defined [possible values: ignore, fail, fail-fast] --on-missing-tool-binary &lt;ON_MISSING_TOOL_BINARY&gt; What to do when the binary of a tool cannot be found [possible values: ignore, fail, fail-fast] </code> -h, --help Print help (see a summary with '-h') -V, --version Print version ``` GitHub Action There are a lot of different ways to run <code>mdsf</code> using GitHub actions. The easiest way, in my opinion, is to use the official GitHub action to install mdsf. After that you can run the binary like you would in your terminal. <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> mdsf is not a package manager. You must also install the tools you wish to use in your GitHub action. </blockquote> ```yaml name: mdsf on: push jobs: format: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 <code> - name: Install mdsf uses: hougesen/mdsf@main - name: Run mdsf run: mdsf format --log-level warn . - name: Commit changes uses: EndBug/add-and-commit@v9 with: message: "style: formatted markdown code blocks" </code> ``` Visual Studio Code <a></a> <a></a> mdsf can be run using the VSCode extension. <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> The mdsf VS Code extension does currently not support installing mdsf. Which means mdsf must be installed using other means. </blockquote> Vim / NeoVim conform.nvim <a>conform.nvim</a> has native support for running mdsf. ```lua local conform = require("conform") conform.setup({ formatters_by_ft = { markdown = { "mdsf" }, -- ... }, -- ... }) ``` treefmt Add the following to your <code>treefmt.toml</code> to run mdsf using <a>treefmt</a>. ```toml treefmt.toml [formatter.mdsf] command = "mdsf" options = ["format"] includes = ["*.md"] ``` Configuration The default configuration of <code>mdsf</code> aims to as simple as possible. For that reason the default formatter for each language is the one most people have installed. If you are interested in customizing which formatter is run, you can create a new <code>mdsf</code> configuration file by running <code>mdsf init</code>. ``` Create a new mdsf config Usage: mdsf init [OPTIONS] Options: --force Create config even if one already exists in current directory --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help -V, --version Print version ``` <code>mdsf</code> supports running multiple formatters on the save code snippet. <code>``json { "languages": { // Only run</code>ruff<code>on Python snippets, "python": "ruff:format", // Run</code>usort<code>on file and then</code>black<code>"python": ["usort", "black"], // Run</code>usort<code>, if that fails run</code>isort<code>, finally run</code>black` "python": [["usort", "isort"], "black"], <code>// Formatters listed under "*" will be run on any snippet. "*": ["typos"], // Formatters listed under "_" will only be run when there is not formatter configured for the file type OR globally ("*"). "_": "prettier" </code> } } ``` Language aliases Multiple languages can easily be mapped to the same tools using the <code>language_aliases</code> option. <code>json { "language_aliases": { "language": "is_alias_of" } }</code> In the example below <code>bash</code> and <code>zsh</code> would use the tools defined under <code>languages.shell</code>. <code>json { "languages": { "shell": "shfmt" }, "language_aliases": { "bash": "shell", "zsh": "shell" } }</code> Newlines By default LF (<code>\n</code>) is used for newlines. That can be changed by specifying the <code>newline</code> config option. <code>json { "newline": "lf" // "lf" | "cr" | "crlf" }</code> Tools <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> mdsf is not a package manager. Only tools that are already installed will be used. </blockquote> <code>mdsf</code> currently supports 313 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 | Name | Description | Categories | Languages | | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | <a>actionlint</a> | Static checker for GitHub Actions workflow files | <code>linter</code> | <code>yaml</code> | | <a>air</a> | R formatter and language server | <code>formatter</code> | <code>r</code> | | <a>alejandra</a> | The Uncompromising Nix Code Formatter | <code>formatter</code> | <code>nix</code> | | <a>alex</a> | Catch insensitive, inconsiderate writing | <code>spell-check</code> | <code>markdown</code> | | <a>ameba</a> | A static code analysis tool for Crystal | <code>linter</code> | <code>crystal</code> | | <a>ansible-lint</a> | ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you | <code>linter</code> | <code>ansible</code> | | <a>asmfmt</a> | Go Assembler Formatter | <code>formatter</code> | <code>go</code> | | <a>astyle</a> | A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective-C, C#, and Java Source Code | <code>formatter</code> | <code>c#</code>, <code>c++</code>, <code>c</code>, <code>java</code>, <code>objective-c</code> | | <a>atlas</a> | Manage your database schema as code | <code>formatter</code> | <code>hcl</code> | | <a>auto-optional</a> | Adds the Optional type-hint to arguments where the default value is None | <code>formatter</code> | <code>python</code> | | <a>autocorrect</a> | A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK (Chinese, Japanese, Korean) | <code>spell-check</code> | | | <a>autoflake</a> | Removes unused imports and unused variables as reported by pyflakes | <code>linter</code> | <code>python</code> | | <a>autopep8</a> | A tool that automatically formats Python code to conform to the PEP 8 style guid | <code>formatter</code> | <code>python</code> | | <a>bashate</a> | Code style enforcement for bash programs | <code>formatter</code> | <code>bash</code> | | <a>beancount-black</a> | Opinionated code formatter, just like Python's black code formatter but for Beancount | <code>formatter</code> | <code>beancount</code> | | <a>beautysh</a> | A Bash beautifier for the masses | <code>formatter</code> | <code>bash</code>, <code>shell</code> | | <a>bibtex-tidy</a> | Cleaner and Formatter for BibTeX files | <code>formatter</code> | <code>bibtex</code> | | <a>bicep</a> | Bicep is a declarative language for describing and deploying Azure resources | <code>formatter</code> | <code>bicep</code> | | <a>biome</a> | One toolchain for your web project | <code>formatter</code>, <code>linter</code> | <code>javascript</code>, <code>json</code>, <code>typescript</code>, <code>vue</code> | | <a>black</a> | The uncompromising Python code formatter | <code>formatter</code> | <code>python</code> | | <a>blade-formatter</a> | An opinionated blade template formatter for Laravel that respects readability | <code>formatter</code> | <code>blade</code>, <code>laravel</code>, <code>php</code> | | <a>blue</a> | The slightly less uncompromising Python code formatter | <code>formatter</code> | <code>python</code> | | <a>bpfmt</a> | A formatter for Blueprint files | <code>formatter</code> | <code>blueprint</code> | | <a>brittany</a> | A Haskell source code formatter | <code>formatter</code> | <code>haskell</code> | | <a>brunette</a> | A best practice Python code formatter | <code>formatter</code> | <code>python</code> | | <a>bsfmt</a> | A code formatter for BrightScript and BrighterScript | <code>formatter</code> | <code>brighterscript</code>, <code>brightscript</code> | | <a>bslint</a> | A linter for BrightScript and BrighterScript | <code>linter</code> | <code>brightscript</code>, <code>brightscripter</code> | | <a>buf</a> | The best way of working with Protocol Buffers | <code>formatter</code> | <code>protobuf</code> | | <a>buildifier</a> | A bazel BUILD file formatter and | <code>formatter</code> | <code>bazel</code> | | <a>cabal-fmt</a> | An experiment of formatting .cabal files | <code>formatter</code> | <code>cabal</code> | | <a>cabal-prettify</a> | Prettify your Cabal package configuration files | <code>formatter</code> | <code>cabal</code> | | <a>cabal</a> | Cabal is a system for building and packaging Haskell libraries and programs | <code>formatter</code> | <code>cabal</code> | | <a>caddy</a> | Formats or prettifies a Caddyfile | <code>formatter</code> | <code>caddy</code> | | <a>caramel</a> | Formatter for the Caramel programming language | <code>formatter</code> | <code>caramel</code> | | <a>cfn-lint</a> | CloudFormation Linter | <code>linter</code> | <code>cloudformation</code>, <code>json</code>, <code>yaml</code> | | <a>checkmake</a> | Experimental linter/analyzer for Makefiles | <code>linter</code> | <code>makefile</code> | | <a>clang-format</a> | A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code | <code>formatter</code> | <code>c#</code>, <code>c++</code>, <code>c</code>, <code>java</code>, <code>javascript</code>, <code>json</code>, <code>objective-c</code>, <code>protobuf</code> | | <a>clang-tidy</a> | clang-tidy is a clang-based C++ “linter” tool | <code>linter</code> | <code>c++</code> | | <a>clj-kondo</a> | Static analyzer and linter for Clojure code that sparks joy | <code>linter</code> | <code>clojure</code>, <code>clojurescript</code> | | <a>cljfmt</a> | A tool for formatting Clojure code | <code>formatter</code> | <code>clojure</code> | | <a>cljstyle</a> | A tool for formatting Clojure code | <code>formatter</code> | <code>clojure</code> | | <a>cmake-format</a> | cmake-format can format your listfiles nicely so that they don't look like crap | <code>formatter</code> | <code>cmake</code> | | <a>cmake-lint</a> | Lint CMake files | <code>linter</code> | <code>cmake</code> | | <a>codeql</a> | Format queries and libraries with CodeQL | <code>formatter</code> | <code>codeql</code> | | <a>codespell</a> | Check code for common misspellings | <code>spell-check</code> | | | <a>coffeelint</a> | Lint your CoffeeScript | <code>linter</code> | <code>coffeescript</code> | | <a>cppcheck</a> | Cppcheck is a static analysis tool for C/C++ code | <code>linter</code> | <code>c++</code>, <code>c</code> | | <a>cpplint</a> | Static code checker for C++ | <code>linter</code> | <code>c++</code> | | <a>crlfmt</a> | Formatter for CockroachDB's additions to the Go style guide | <code>formatter</code> | <code>go</code> | | <a>crystal</a> | Tools for the Crystal programming language | <code>formatter</code> | <code>crystal</code> | | <a>csharpier</a> | An Opinionated Code Formatter for C# | <code>formatter</code> | <code>c#</code> | | <a>css-beautify</a> | A css formatter | <code>formatter</code> | <code>css</code> | | <a>csscomb</a> | CSS coding style formatter | <code>formatter</code> | <code>css</code> | | <a>csslint</a> | Automated linting of Cascading Stylesheets | <code>linter</code> | <code>css</code> | | <a>cue</a> | Validate and define text-based and dynamic configuration | <code>formatter</code> | <code>cue</code> | | <a>cueimports</a> | CUE tool that updates your import lines, adding missing ones and removing unused ones | <code>formatter</code> | <code>cue</code> | | <a>curlylint</a> | Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid | <code>linter</code> | <code>django</code>, <code>html</code>, <code>jinja</code>, <code>liquid</code>, <code>nunjucks</code>, <code>twig</code> | | <a>d2</a> | A modern language that turns text to diagrams | <code>formatter</code> | <code>d2</code> | | <a>dart</a> | Formatter and linter for Dart | <code>formatter</code>, <code>linter</code> | <code>dart</code>, <code>flutter</code> | | <a>dcm</a> | Code Quality Tool for Flutter Developers | <code>formatter</code>, <code>linter</code> | <code>dart</code>, <code>flutter</code> | | <a>deadnix</a> | Scan Nix files for dead code | <code>linter</code> | <code>nix</code> | | <a>deno</a> | Formatter and linter for JavaScript and TypeScript | <code>formatter</code>, <code>linter</code> | <code>javascript</code>, <code>json</code>, <code>typescript</code> | | <a>dfmt</a> | Dfmt is a formatter for D source code | <code>formatter</code> | <code>d</code> | | <a>dhall</a> | Format Dhall files | <code>formatter</code> | <code>dhall</code> | | <a>djade</a> | A Django template formatter | <code>formatter</code> | <code>django</code>, <code>python</code> | | <a>djlint</a> | Lint &amp; Format HTML Templates | <code>formatter</code>, <code>linter</code> | <code>handlebars</code>, <code>html</code>, <code>jinja</code>, <code>mustache</code>, <code>nunjucks</code>, <code>twig</code> | | <a>docformatter</a> | Formats docstrings to follow PEP 257 | <code>formatter</code> | <code>python</code> | | <a>dockerfmt</a> | Dockerfile formatter. a modern dockfmt | <code>formatter</code> | <code>docker</code> | | <a>dockfmt</a> | Dockerfile format and parser. Like <code>gofmt</code> but for Dockerfiles | <code>formatter</code> | <code>docker</code> | | <a>docstrfmt</a> | A formatter for Sphinx flavored reStructuredText | <code>formatter</code> | <code>python</code>, <code>restructuredtext</code>, <code>sphinx</code> | | <a>doctoc</a> | Generates table of contents for markdown files | <code>formatter</code> | <code>markdown</code> | | <a>dotenv-linter</a> | Lightning-fast linter for .env files | <code>linter</code> | <code>env</code> | | <a>dprint</a> | A pluggable and configurable code formatting platform written in Rust | <code>formatter</code> | | | <a>dscanner</a> | Swiss-army knife for D source code | <code>linter</code> | <code>d</code> | | <a>duster</a> | Automatic configuration for Laravel apps to apply Tighten's standard linting &amp; code standards | <code>formatter</code>, <code>linter</code> | <code>php</code> | | <a>dx</a> | Dioxus cli | <code>formatter</code> | <code>rsx</code>, <code>rust</code> | | <a>easy-coding-standard</a> | The Easiest way to add coding standard to your PHP project | <code>formatter</code>, <code>linter</code> | <code>php</code> | | <a>efmt</a> | Erlang code formatter | <code>formatter</code> | <code>erlang</code> | | <a>elm-format</a> | elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide | <code>formatter</code> | <code>elm</code> | | <a>eradicate</a> | Removes commented-out code from Python files | <code>linter</code> | <code>python</code> | | <a>erb-formatter</a> | Format ERB files with speed and precision | <code>formatter</code> | <code>erb</code>, <code>ruby</code> | | <a>erg</a> | A statically typed language compatible with Python | <code>linter</code> | <code>erg</code> | | <a>erlfmt</a> | An automated code formatter for Erlang | <code>formatter</code> | <code>erlang</code> | | <a>eslint</a> | Find and fix problems in your JavaScript code | <code>linter</code> | <code>javascript</code>, <code>typescript</code> | | <a>fantomas</a> | FSharp source code formatter | <code>formatter</code> | <code>f#</code> | | <a>fish_indent</a> | Fish indenter and prettifier | <code>formatter</code> | <code>fish</code> | | <a>fixjson</a> | JSON Fixer for Humans using (relaxed) JSON5 | <code>formatter</code>, <code>linter</code> | <code>json5</code>, <code>json</code> | | <a>floskell</a> | Floskell is a flexible Haskell source code pretty printer | <code>formatter</code> | <code>haskell</code> | | <a>flynt</a> | A tool to automatically convert old string literal formatting to f-strings | <code>formatter</code> | <code>python</code> | | <a>fnlfmt</a> | A formatter for Fennel code | <code>formatter</code> | <code>fennel</code> | | <a>forge</a> | A Solidity formatter | <code>formatter</code> | <code>solidity</code> | | <a>fortitude</a> | A Fortran linter, written in Rust | <code>linter</code> | | | <a>fortran-linter</a> | A simple fortran syntax checker, including automatic fixing of the code | <code>formatter</code>, <code>linter</code> | <code>fortran</code> | | <a>fourmolu</a> | A formatter for Haskell source code | <code>formatter</code> | <code>haskell</code> | | <a>fprettify</a> | Auto-formatter for modern Fortran source code | <code>formatter</code> | <code>fortran</code> | | <a>futhark</a> | Code formatter for the furhark programming language | <code>formatter</code> | <code>futhark</code> | | <a>fvm</a> | Run Dart and Flutter commands through fvm | <code>formatter</code>, <code>linter</code> | <code>dart</code>, <code>flutter</code> | | <a>gci</a> | GCI, a tool that control golang package import order and make it always deterministic | <code>formatter</code> | <code>go</code> | | <a>gdformat</a> | GDScript formatter | <code>formatter</code> | <code>gdscript</code> | | <a>gdlint</a> | GDScript linter | <code>linter</code> | <code>gdscript</code> | | <a>gersemi</a> | A formatter to make your CMake code the real treasure | <code>formatter</code> | <code>cmake</code> | | <a>gleam</a> | Format Gleam source code | <code>formatter</code> | <code>gleam</code> | | <a>gluon</a> | Code formatting for the gluon programming language | <code>formatter</code> | <code>gluon</code> | | <a>gofmt</a> | Gofmt formats Go programs | <code>formatter</code> | <code>go</code> | | <a>gofumpt</a> | A stricter gofmt | <code>formatter</code> | <code>go</code> | | <a>goimports-reviser</a> | Right imports sorting &amp; code formatting tool (goimports alternative) | <code>formatter</code> | <code>go</code> | | <a>goimports</a> | goimports updates your Go import lines, adding missing ones and removing unreferenced ones | <code>formatter</code> | <code>go</code> | | <a>golangci-lint</a> | Fast linters runner for Go | <code>formatter</code>, <code>linter</code> | <code>go</code> | | <a>golines</a> | A golang formatter that fixes long lines | <code>formatter</code> | <code>go</code> | | <a>google-java-format</a> | Reformats Java source code to comply with Google Java Style | <code>formatter</code> | <code>java</code> | | <a>gospel</a> | Misspelled word linter for Go comments, string literals and embedded files | <code>spell-check</code> | <code>go</code> | | <a>grafbase</a> | The Grafbase command line interface | <code>linter</code> | <code>graphql</code> | | <a>grain</a> | Code formatter for the Grain programming language | <code>formatter</code> | <code>grain</code> | | <a>hadolint</a> | Dockerfile linter, validate inline bash, written in Haskell | <code>linter</code> | <code>dockerfile</code> | | <a>haml-lint</a> | Tool for writing clean and consistent HAML | <code>linter</code> | <code>haml</code> | | <a>hclfmt</a> | Formatter for hcl files | <code>formatter</code> | <code>hcl</code> | | <a>hfmt</a> | Format Haskell programs. Inspired by the gofmt utility | <code>formatter</code> | <code>haskell</code> | | <a>hindent</a> | Extensible Haskell pretty printer | <code>formatter</code> | <code>haskell</code> | | <a>hlint</a> | Haskell source code suggestions | <code>linter</code> | <code>haskell</code> | | <a>html-beautify</a> | A html formatter | <code>formatter</code> | <code>html</code> | | <a>htmlbeautifier</a> | A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates | <code>formatter</code> | <code>erb</code>, <code>html</code>, <code>ruby</code> | | <a>htmlhint</a> | The static code analysis tool you need for your HTML | <code>linter</code> | <code>html</code> | | <a>hurlfmt</a> | Formatter for hurl files | <code>formatter</code> | <code>hurl</code> | | <a>imba</a> | A formatter for Imba | <code>formatter</code> | <code>imba</code> | | <a>inko</a> | Code formatter for the inko programming language | <code>formatter</code> | <code>inko</code> | | <a>isort</a> | A Python utility to sort imports | <code>formatter</code> | <code>python</code> | | <a>janet-format</a> | A formatter for Janet code. | <code>formatter</code> | <code>janet</code> | | <a>joker</a> | Small Clojure interpreter, linter and formatter | <code>formatter</code>, <code>linter</code> | <code>clojure</code> | | <a>jq</a> | JSON processor | <code>formatter</code> | <code>json</code> | | <a>jqfmt</a> | like gofmt, but for jq | <code>formatter</code> | <code>jq</code> | | <a>js-beautify</a> | A JavaScript formatter | <code>formatter</code> | <code>javascript</code> | | <a>json5format</a> | JSON5 (a.k.a., JSON for Humans) formatter that preserves contextual comments | <code>formatter</code> | <code>json5</code>, <code>json</code> | | <a>jsona</a> | JSONA linter and formatter | <code>formatter</code>, <code>linter</code> | <code>jsona</code> | | <a>jsonlint</a> | A JSON parser and validator with a CLI | <code>formatter</code>, <code>linter</code> | <code>json</code> | | <a>jsonnet-lint</a> | Linter for jsonnet files | <code>linter</code> | <code>jsonnet</code> | | <a>jsonnetfmt</a> | Formatter for automatically fixing jsonnet stylistic problems | <code>formatter</code> | <code>jsonnet</code> | | <a>jsonpp</a> | A fast command line JSON pretty printer | <code>formatter</code> | <code>json</code> | | <a>juliaformatter.jl</a> | An opinionated code formatter for Julia. Plot twist - the opinion is your own | <code>formatter</code> | <code>julia</code> | | <a>just</a> | A formatter for justfiles | <code>formatter</code> | <code>just</code> | | <a>kcl</a> | KCL Format tool supports reformatting KCL files to the standard code style | <code>formatter</code> | <code>kcl</code> | | <a>kdlfmt</a> | A formatter for kdl documents | <code>formatter</code> | <code>kdl</code> | | <a>kdoc-formatter</a> | Reformats Kotlin KDoc comments, reflowing text and other cleanup | <code>formatter</code> | <code>kotlin</code> | | <a>ktfmt</a> | program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions | <code>formatter</code> | <code>kotlin</code> | | <a>ktlint</a> | An anti-bikeshedding Kotlin linter with built-in formatter | <code>linter</code> | <code>kotlin</code> | | <a>kulala-fmt</a> | An opinionated .http and .rest file linter and formatter | <code>formatter</code> | <code>http</code> | | <a>leptosfmt</a> | A formatter for the leptos view! macro | <code>formatter</code> | <code>rust</code> | | <a>liquidsoap-prettier</a> | Prettier plugin for liquidsoap script | <code>formatter</code> | <code>liquidsoap</code> | | <a>luacheck</a> | A tool for linting and static analysis of Lua code | <code>formatter</code> | <code>lua</code> | | <a>luaformatter</a> | Code formatter for Lua | <code>formatter</code> | <code>lua</code> | | <a>mado</a> | A fast Markdown linter written in Rust | <code>linter</code> | <code>markdown</code> | | <a>mago</a> | A fast linter and formatter for PHP | <code>formatter</code>, <code>linter</code> | <code>php</code> | | <a>markdownfmt</a> | Like gofmt, but for Markdown | <code>formatter</code> | <code>markdown</code> | | <a>markdownlint-cli2</a> | A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library | <code>linter</code> | <code>markdown</code> | | <a>markdownlint</a> | A Node.js style checker and lint tool for Markdown/CommonMark files | <code>linter</code> | <code>markdown</code> | | <a>markuplint</a> | An HTML linter for all markup developers | <code>linter</code> | <code>html</code> | | <a>md-padding</a> | Fix mixed spaces in Markdown: Chinese and English, numbers, links | <code>formatter</code> | <code>markdown</code> | | <a>mdformat</a> | CommonMark compliant Markdown formatter | <code>formatter</code> | <code>markdwon</code> | | <a>mdsf</a> | Run mdsf inside mdsf | <code>formatter</code> | <code>markdown</code> | | <a>mdslw</a> | Prepare your markdown for easy diff'ing! | <code>formatter</code> | <code>markdown</code> | | <a>meson</a> | Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible | <code>formatter</code> | <code>meson</code> | | <a>mise</a> | The front-end to your dev env | | | | <a>misspell</a> | Correct commonly misspelled English words in source files | <code>spell-check</code> | | | <a>mix</a> | Code formatter for Elixir | <code>formatter</code> | <code>elixir</code> | | <a>mojo</a> | Formats Mojo source files | <code>formatter</code> | <code>mojo</code> | | <a>muon</a> | An implementation of the meson build system | <code>formatter</code>, <code>linter</code> | <code>meson</code> | | <a>mypy</a> | Optional static typing for Python | <code>linter</code> | <code>python</code> | | <a>nasmfmt</a> | Formatter for NASM source files | <code>formatter</code> | <code>assembly</code> | | <a>nginxbeautifier</a> | Format and beautify nginx config files | <code>formatter</code> | <code>nginx</code> | | <a>nginxfmt</a> | nginx config file formatter/beautifier written in Python with no additional dependencies | <code>formatter</code> | <code>nginx</code> | | <a>nickel</a> | Better configuration for less | <code>formatter</code> | <code>nickel</code> | | <a>nimpretty</a> | Code formatter for the Nim programming language | <code>formatter</code> | <code>nim</code> | | <a>nixfmt</a> | The official (but not yet stable) formatter for Nix code | <code>formatter</code> | <code>nix</code> | | <a>nixpkgs-fmt</a> | Nix code formatter for nixpkgs | <code>formatter</code> | <code>nix</code> | | <a>nomad</a> | CLI for HashiCorp Nomad | <code>formatter</code> | <code>hcl</code> | | <a>nph</a> | An opinionated code formatter for Nim | <code>formatter</code> | <code>nim</code> | | <a>npm-groovy-lint</a> | Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files | <code>formatter</code>, <code>linter</code> | <code>groovy</code> | | <a>nufmt</a> | the nushell formatter | <code>formatter</code> | <code>nushell</code> | | <a>ocamlformat</a> | Auto-formatter for OCaml code | <code>formatter</code> | <code>ocaml</code> | | <a>ocp-indent</a> | Indentation tool for OCaml | <code>formatter</code> | <code>ocaml</code> | | <a>odinfmt</a> | Formatter for the Odin programming language | <code>formatter</code> | <code>odin</code> | | <a>oelint-adv</a> | Advanced oelint | <code>linter</code> | <code>bitbake</code> | | <a>opa</a> | Format Rego source files | <code>formatter</code> | <code>rego</code> | | <a>ormolu</a> | A formatter for Haskell source code | <code>formatter</code> | <code>haskell</code> | | <a>oxlint</a> | Oxlint is designed to catch erroneous or useless code without requiring any configurations by default | <code>linter</code> | <code>javascript</code>, <code>typescript</code> | | <a>packer</a> | Packer is used to format HCL2 configuration files | <code>formatter</code> | <code>hcl</code> | | <a>pasfmt</a> | Delphi code formatter | <code>formatter</code> | <code>delphi</code>, <code>pascal</code> | | <a>perflint</a> | Python Linter for performance anti patterns | <code>linter</code> | <code>python</code> | | <a>perltidy</a> | Perl::Tidy, a source code formatter for Perl | <code>formatter</code> | <code>perl</code> | | <a>pg_format</a> | A PostgreSQL SQL syntax beautifier | <code>formatter</code> | <code>sql</code> | | <a>php-cs-fixer</a> | A tool to automatically fix PHP Coding Standards issues | <code>formatter</code>, <code>linter</code> | <code>php</code> | | <a>phpcbf</a> | PHP Code Beautifier and Fixer fixes violations of a defined coding standard | <code>formatter</code> | <code>php</code> | | <a>phpinsights</a> | Instant PHP quality checks from your console | <code>linter</code> | <code>php</code> | | <a>pint</a> | Laravel Pint is an opinionated PHP code style fixer for minimalists | <code>formatter</code>, <code>linter</code> | <code>php</code> | | <a>prettier</a> | Prettier is an opinionated code formatter | <code>formatter</code> | <code>angular</code>, <code>css</code>, <code>ember</code>, <code>graphql</code>, <code>handlebars</code>, <code>html</code>, <code>javascript</code>, <code>json</code>, <code>less</code>, <code>markdown</code>, <code>scss</code>, <code>typescript</code>, <code>vue</code> | | <a>pretty-php</a> | The opinionated PHP code formatter | <code>formatter</code> | <code>php</code> | | <a>prettypst</a> | Formatter for Typst | <code>formatter</code> | <code>typst</code> | | <a>prisma</a> | Commands for interacting with the prisma ORM | <code>formatter</code> | <code>prisma</code> | | <a>proselint</a> | A linter for prose | <code>spell-check</code> | | | <a>protolint</a> | A pluggable linter and fixer to enforce Protocol Buffer style and conventions | <code>linter</code> | <code>protobuf</code> | | <a>ptop</a> | Free Pascal source formatter | <code>formatter</code> | <code>pascal</code> | | <a>pug-lint</a> | An unopinionated and configurable linter and style checker for Pug | <code>linter</code> | <code>pug</code> | | <a>puppet-lint</a> | Check that your Puppet manifests conform to the style guide | <code>linter</code> | <code>puppet</code> | | <a>purs-tidy</a> | PureScript code formatter | <code>formatter</code> | <code>purescript</code> | | <a>purty</a> | PureScript pretty-printer | <code>formatter</code> | <code>purescript</code> | | <a>pycln</a> | A formatter for finding and removing unused import statements | <code>formatter</code> | <code>python</code> | | <a>pycodestyle</a> | Simple Python style checker in one Python file | <code>linter</code> | <code>python</code> | | <a>pydoclint</a> | A Python docstring linter that checks arguments, returns, yields, and raises sections | <code>linter</code> | <code>python</code> | | <a>pydocstringformatter</a> | Automatically format your Python docstrings to conform with PEP 8 and PEP 257 | <code>formatter</code> | <code>python</code> | | <a>pydocstyle</a> | docstring style checker | <code>formatter</code> | <code>python</code> | | <a>pyflakes</a> | A simple program which checks Python source files for errors | <code>linter</code> | <code>python</code> | | <a>pyink</a> | Pyink is a Python formatter, forked from Black with a few different formatting behaviors | <code>formatter</code> | <code>python</code> | | <a>pylint</a> | Pylint is a static code analyser for Python 2 or 3 | <code>linter</code> | <code>python</code> | | <a>pyment</a> | Format and convert Python docstrings and generates patches | <code>formatter</code> | <code>python</code> | | <a>pyrefly</a> | A fast type checker for Python | <code>linter</code> | <code>python</code> | | <a>pyupgrade</a> | A tool to automatically upgrade Python syntax to newer versions | <code>linter</code> | <code>python</code> | | <a>qmlfmt</a> | Command line application that formats QML files | <code>formatter</code> | <code>qml</code> | | <a>quick-lint-js</a> | quick-lint-js finds bugs in JavaScript programs | <code>linter</code> | <code>javascript</code> | | <a>raco</a> | An extensible code formatter for Racket | <code>formatter</code> | <code>racket</code> | | <a>reek</a> | Code smell detector for Ruby | <code>linter</code> | <code>ruby</code> | | <a>refmt</a> | refmt stands by Reason Formatter and it formats Reason programs, is a parser and pretty-printer for Reason | <code>formatter</code> | <code>reason</code> | | <a>reformat-gherkin</a> | Reformat-gherkin automatically formats Gherkin files | <code>formatter</code> | <code>gherkin</code> | | <a>refurb</a> | A tool for refurbishing and modernizing Python codebases | <code>linter</code> | <code>python</code> | | <a>regal</a> | Regal is a linter and language server for Rego, bringing your policy development experience to the next level | <code>linter</code> | <code>rego</code> | | <a>reorder-python-imports</a> | Rewrites source to reorder python imports | <code>formatter</code> | <code>python</code> | | <a>rescript</a> | Formatter for ReScript | <code>formatter</code> | <code>rescript</code> | | <a>revive</a> | ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint | <code>linter</code> | <code>go</code> | | <a>roc</a> | Tools for the roc programming language | <code>formatter</code> | <code>roc</code> | | <a>rstfmt</a> | A formatter for reStructuredText | <code>formatter</code> | <code>restructuredtext</code> | | <a>rubocop</a> | A Ruby static code analyzer and formatter, based on the community Ruby style guide | <code>formatter</code>, <code>linter</code> | <code>ruby</code> | | <a>rubyfmt</a> | Ruby Autoformatter | <code>formatter</code> | <code>ruby</code> | | <a>ruff</a> | An extremely fast Python linter and code formatter, written in Rust | <code>formatter</code>, <code>linter</code> | <code>python</code> | | <a>rufo</a> | The Ruby Formatter | <code>formatter</code> | <code>ruby</code> | | <a>rune</a> | Tools for the Rune programming language | <code>formatter</code> | <code>rune</code> | | <a>runic</a> | Julia code formatter | <code>formatter</code> | <code>julia</code> | | <a>rustfmt</a> | The official code formatter for Rust | <code>formatter</code> | <code>rust</code> | | <a>rustywind</a> | CLI for organizing Tailwind CSS classes | <code>formatter</code> | <code>html</code> | | <a>salt-lint</a> | A command-line utility that checks for best practices in SaltStack | <code>linter</code> | <code>salt</code> | | <a>scalafmt</a> | Code formatter for Scala | <code>formatter</code> | <code>scala</code> | | <a>scalariform</a> | Scala source code formatter | <code>formatter</code> | <code>scala</code> | | <a>selene</a> | A blazing-fast modern Lua linter written in Rust | <code>linter</code> | <code>lua</code> | | <a>semistandard</a> | All the goodness of standardjs with semicolons sprinkled on top | <code>formatter</code>, <code>linter</code> | <code>javascript</code> | | <a>shellcheck</a> | ShellCheck, a static analysis tool for shell scripts | <code>linter</code> | <code>bash</code>, <code>shell</code> | | <a>shellharden</a> | The corrective bash syntax highlighter | <code>linter</code> | <code>bash</code>, <code>shell</code> | | <a>shfmt</a> | Shell script formatter | <code>formatter</code> | <code>shell</code> | | <a>sleek</a> | Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity | <code>formatter</code> | <code>sql</code> | | <a>slim-lint</a> | Tool for analyzing Slim templates | <code>linter</code> | <code>slim</code> | | <a>smlfmt</a> | A custom parser/auto-formatter for Standard ML | <code>formatter</code> | <code>standard-ml</code> | | <a>snakefmt</a> | The uncompromising Snakemake code formatter | <code>formatter</code> | <code>snakemake</code> | | <a>solhint</a> | Solhint is an open-source project to provide a linting utility for Solidity code | <code>linter</code> | <code>solidity</code> | | <a>sphinx-lint</a> | Check for stylistic and formal issues in .rst and .py files included in the documentation | <code>linter</code> | <code>python</code>, <code>restructredtext</code> | | <a>sql-formatter</a> | A whitespace formatter for different query languages | <code>formatter</code> | <code>sql</code> | | <a>sqlfluff</a> | A modular SQL linter and auto-formatter with support for multiple dialects and templated code | <code>formatter</code>, <code>linter</code> | <code>sql</code> | | <a>sqlfmt</a> | sqlfmt formats your dbt SQL files so you don't have to | <code>formatter</code> | <code>sql</code> | | <a>sqruff</a> | Fast SQL formatter/linter | <code>formatter</code>, <code>linter</code> | <code>sql</code> | | <a>squawk</a> | Linter for Postgres migrations &amp; SQL | <code>linter</code> | <code>postgresql</code>, <code>sql</code> | | <a>standardjs</a> | JavaScript style guide, linter, and formatter | <code>formatter</code>, <code>linter</code> | <code>javascript</code> | | <a>standardrb</a> | Ruby's bikeshed-proof linter and formatter | <code>formatter</code>, <code>linter</code> | <code>ruby</code> | | <a>statix</a> | lints and suggestions for the nix programming language | <code>linter</code> | <code>nix</code> | | <a>stylefmt</a> | stylefmt is a tool that automatically formats stylesheets | <code>formatter</code> | <code>css</code>, <code>scss</code> | | <a>stylelint</a> | A mighty CSS linter that helps you avoid errors and enforce conventions | <code>linter</code> | <code>css</code>, <code>scss</code> | | <a>stylish-haskell</a> | Haskell code prettifier | <code>formatter</code> | <code>haskell</code> | | <a>stylua</a> | An opinionated Lua code formatter | <code>formatter</code> | <code>lua</code> | | <a>superhtml</a> | HTML Language Server &amp; Templating Language Library | <code>formatter</code> | <code>html</code> | | <a>svlint</a> | SystemVerilog linter | <code>linter</code> | <code>systemverilog</code> | | <a>swift-format</a> | Formatting technology for Swift source code | <code>formatter</code> | <code>swift</code> | | <a>swiftformat</a> | A command-line tool and Xcode Extension for formatting Swift code | <code>formatter</code> | <code>swift</code> | | <a>taplo</a> | A TOML toolkit written in Rust | <code>formatter</code> | <code>toml</code> | | <a>templ</a> | Tooling for the Templ template language | <code>formatter</code> | <code>go</code>, <code>templ</code> | | <a>terraform</a> | The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style | <code>formatter</code> | <code>terraform</code> | | <a>terragrunt</a> | Recursively find hcl files and rewrite them into a canonical format | <code>formatter</code> | <code>hcl</code> | | <a>tex-fmt</a> | An extremely fast LaTeX formatter written in Rust | <code>formatter</code> | <code>latex</code> | | <a>textlint</a> | The pluggable natural language linter for text and markdown | <code>spell-check</code> | | | <a>tlint</a> | Tighten linter for Laravel conventions | <code>linter</code> | <code>php</code> | | <a>tofu</a> | The tofu fmt command is used to rewrite OpenTofu configuration files to a canonical format and style | <code>formatter</code> | <code>terraform</code>, <code>tofu</code> | | <a>tombi</a> | TOML Formatter / Linter | <code>formatter</code>, <code>linter</code> | <code>toml</code> | | <a>toml-sort</a> | A command line utility to sort and format toml files | <code>formatter</code> | <code>toml</code> | | <a>topiary</a> | Topiary aims to be a uniform formatter for simple languages, as part of the Tree-sitter ecosystem | <code>formatter</code> | | | <a>tryceratops</a> | A linter to prevent exception handling antipatterns in Python | <code>linter</code> | <code>python</code> | | <a>ts-standard</a> | Typescript style guide, linter, and formatter using StandardJS | <code>formatter</code>, <code>linter</code> | <code>typescript</code> | | <a>tsp</a> | CLI for managing TypeSpec configurations | <code>formatter</code> | <code>typespec</code> | | <a>tsqllint</a> | Configurable linting for TSQL | <code>linter</code> | <code>sql</code> | | <a>twig-cs-fixer</a> | A tool to automatically fix Twig Coding Standards issues | <code>formatter</code>, <code>linter</code> | <code>twig</code> | | <a>twigcs</a> | The missing checkstyle for twig | <code>linter</code> | <code>php</code>, <code>twig</code> | | <a>ty</a> | An extremely fast Python type checker written in Rust | <code>linter</code> | <code>python</code> | | <a>typos</a> | Source code spell checker | <code>spell-check</code> | | | <a>typstfmt</a> | Basic formatter for the Typst language | <code>formatter</code> | <code>typst</code> | | <a>typstyle</a> | Beautiful and reliable typst code formatter | <code>formatter</code> | <code>typst</code> | | <a>ufmt</a> | Safe, atomic formatting with black and usort | <code>formatter</code> | <code>python</code> | | <a>uiua</a> | A stack-based array programming language | <code>formatter</code> | <code>uiua</code> | | <a>unimport</a> | The ultimate linter and formatter for removing unused import statements in your code | <code>formatter</code> | <code>python</code> | | <a>usort</a> | Safe, minimal import sorting for Python projects | <code>formatter</code> | <code>python</code> | | <a>v</a> | Tooling for V lang | <code>formatter</code> | <code>v</code> | | <a>vacuum</a> | vacuum is the worlds fastest OpenAPI 3, OpenAPI 2 / Swagger linter and quality analysis tool | <code>linter</code> | <code>json</code>, <code>openapi</code>, <code>yaml</code> | | <a>verusfmt</a> | An Opinionated Formatter for Verus | <code>formatter</code> | <code>rust</code>, <code>verus</code> | | <a>veryl</a> | Veryl: A Modern Hardware Description Language | <code>formatter</code> | <code>veryl</code> | | <a>vhdl-style-guide</a> | Style guide enforcement for VHDL | <code>formatter</code> | <code>vhdl</code> | | <a>vint</a> | Lint Vim script | <code>linter</code> | <code>vimscript</code> | | <a>wa</a> | Formatter for the wa programming language | <code>formatter</code> | <code>wa</code> | | <a>wfindent</a> | Indents and optionally converts Fortran program sources | <code>formatter</code> | <code>fortran</code> | | <a>write-good</a> | Naive linter for English prose | <code>linter</code> | | | <a>xmlformat</a> | Format and compress XML documents | <code>formatter</code> | <code>xml</code> | | <a>xmllint</a> | XML linter | <code>linter</code> | <code>xml</code> | | <a>xo</a> | JavaScript/TypeScript linter (ESLint wrapper) with great defaults | <code>linter</code> | <code>javascript</code>, <code>typescript</code> | | <a>xq</a> | Command-line XML and HTML beautifier and content extractor | <code>formatter</code> | <code>html</code>, <code>xml</code> | | <a>yamlfix</a> | A simple opinionated yaml formatter that keeps your comments | <code>formatter</code> | <code>yaml</code> | | <a>yamlfmt</a> | An extensible command line tool or library to format yaml files | <code>formatter</code> | <code>yaml</code> | | <a>yamllint</a> | A linter for YAML files | <code>linter</code> | <code>yaml</code> | | <a>yapf</a> | A formatter for Python files | <code>formatter</code> | <code>python</code> | | <a>yew-fmt</a> | Code formatter for the Yew framework | <code>formatter</code> | <code>rust</code> | | <a>yq</a> | yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor | <code>formatter</code> | <code>yaml</code> | | <a>zig</a> | Reformat Zig source into canonical form | <code>formatter</code> | <code>zig</code> | | <a>ziggy</a> | Formats Ziggy documents and Ziggy schemas | <code>formatter</code> | <code>ziggy</code> | | <a>zprint</a> | Executables beautifully format Clojure and Clojurescript source code and s-expressions | <code>formatter</code> | <code>clojure</code>, <code>clojurescript</code> | Commands <code>mdsf</code> currently supports 349 commands. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 | Name | Command | | ---------------------------- | --------------------------------------------------------------------------------------- | | <code>actionlint</code> | <code>actionlint $PATH</code> | | <code>air:format</code> | <code>air format $PATH</code> | | <code>alejandra</code> | <code>alejandra --quiet $PATH</code> | | <code>alex</code> | <code>alex --quiet $PATH</code> | | <code>ameba</code> | <code>ameba --fix $PATH</code> | | <code>ansible-lint</code> | <code>ansible-lint $PATH</code> | | <code>asmfmt</code> | <code>asmfmt -w $PATH</code> | | <code>astyle</code> | <code>astyle --quiet $PATH</code> | | <code>atlas:fmt</code> | <code>atlas schema fmt $PATH</code> | | <code>auto-optional</code> | <code>auto-optional $PATH</code> | | <code>autocorrect</code> | <code>autocorrect --fix $PATH</code> | | <code>autoflake</code> | <code>autoflake --quiet --in-place $PATH</code> | | <code>autopep8</code> | <code>autopep8 --in-place $PATH</code> | | <code>bashate</code> | <code>bashate $PATH</code> | | <code>beancount-black</code> | <code>bean-black $PATH</code> | | <code>beautysh</code> | <code>beautysh $PATH</code> | | <code>bibtex-tidy</code> | <code>bibtex-tidy -m $PATH</code> | | <code>bicep:format</code> | <code>bicep format $PATH</code> | | <code>biome:check:unsafe</code> | <code>biome check --write --unsafe $PATH</code> | | <code>biome:check</code> | <code>biome check --write $PATH</code> | | <code>biome:format</code> | <code>biome format --write $PATH</code> | | <code>biome:lint:unsafe</code> | <code>biome lint --write --unsafe $PATH</code> | | <code>biome:lint</code> | <code>biome lint --write $PATH</code> | | <code>black</code> | <code>black --quiet $PATH</code> | | <code>blade-formatter</code> | <code>blade-formatter --write $PATH</code> | | <code>blue</code> | <code>blue --quiet $PATH</code> | | <code>bpfmt</code> | <code>bpfmt -w $PATH</code> | | <code>brittany</code> | <code>brittany --write-mode=inplace $PATH</code> | | <code>brunette</code> | <code>brunette --quiet $PATH</code> | | <code>bsfmt</code> | <code>bsfmt $PATH --write</code> | | <code>bslint</code> | <code>bslint --fix $PATH</code> | | <code>buf:format</code> | <code>buf format --write $PATH</code> | | <code>buf:lint</code> | <code>buf lint $PATH</code> | | <code>buildifier</code> | <code>buildifier $PATH</code> | | <code>cabal-fmt</code> | <code>cabal-fmt --inplace $PATH</code> | | <code>cabal-prettify</code> | <code>cabal-prettify $PATH</code> | | <code>cabal:format</code> | <code>cabal format $PATH</code> | | <code>caddy:fmt</code> | <code>caddy fmt $PATH -w</code> | | <code>caramel:fmt</code> | <code>caramel fmt $PATH</code> | | <code>cfn-lint</code> | <code>cfn-lint $PATH</code> | | <code>checkmake</code> | <code>checkmake $PATH</code> | | <code>clang-format</code> | <code>clang-format -i $PATH</code> | | <code>clang-tidy</code> | <code>clang-tidy --fix $PATH</code> | | <code>clj-kondo</code> | <code>clj-kondo --lint $PATH</code> | | <code>cljfmt:fix</code> | <code>cljfmt fix $PATH</code> | | <code>cljstyle</code> | <code>cljstyle fix $PATH</code> | | <code>cmake-format</code> | <code>cmake-format -i $PATH</code> | | <code>cmake-lint</code> | <code>cmake-lint $PATH</code> | | <code>codeql:query:format</code> | <code>codeql query format -i $PATH</code> | | <code>codespell</code> | <code>codespell $PATH --check-hidden --write-changes</code> | | <code>coffeelint</code> | <code>coffeelint -q $PATH</code> | | <code>cppcheck</code> | <code>cppcheck $PATH</code> | | <code>cpplint</code> | <code>cpplint --quiet $PATH</code> | | <code>crlfmt</code> | <code>crlfmt -w $PATH</code> | | <code>crystal:format</code> | <code>crystal tool format $PATH</code> | | <code>csharpier</code> | <code>csharpier format --write-stdout</code> | | <code>css-beautify</code> | <code>css-beautify -r --type css -f $PATH</code> | | <code>csscomb</code> | <code>csscomb -t $PATH</code> | | <code>csslint</code> | <code>csslint --quiet $PATH</code> | | <code>cue:fmt</code> | <code>cue fmt $PATH</code> | | <code>cueimports</code> | <code>cueimports</code> | | <code>curlylint</code> | <code>curlylint -q $PATH</code> | | <code>d2:fmt</code> | <code>d2 fmt $PATH</code> | | <code>dart:fix</code> | <code>dart fix --apply $PATH</code> | | <code>dart:format</code> | <code>dart format $PATH</code> | | <code>dcm:fix</code> | <code>dcm fix $PATH</code> | | <code>dcm:format</code> | <code>dcm format $PATH</code> | | <code>deadnix</code> | <code>deadnix -q --edit $PATH</code> | | <code>deno:fmt</code> | <code>deno fmt --quiet $PATH</code> | | <code>deno:lint</code> | <code>deno lint --fix $PATH</code> | | <code>dfmt</code> | <code>dfmt -i $PATH</code> | | <code>dhall</code> | <code>dhall format $PATH</code> | | <code>djade</code> | <code>djade $PATH</code> | | <code>djlint</code> | <code>djlint $PATH --reformat</code> | | <code>docformatter</code> | <code>docformatter --in-place $PATH</code> | | <code>dockerfmt</code> | <code>dockerfmt -w -n $PATH</code> | | <code>dockfmt</code> | <code>dockfmt fmt -w $PATH</code> | | <code>docstrfmt</code> | <code>docstrfmt $PATH</code> | | <code>doctoc</code> | <code>doctoc $PATH</code> | | <code>dotenv-linter:fix</code> | <code>dotenv-linter fix $PATH</code> | | <code>dprint:fmt</code> | <code>dprint fmt $PATH</code> | | <code>dscanner:fix</code> | <code>dscanner fix $PATH</code> | | <code>dscanner:lint</code> | <code>dscanner lint $PATH</code> | | <code>duster:fix</code> | <code>duster fix --quiet --no-interaction $PATH</code> | | <code>duster:lint</code> | <code>duster lint --quiet --no-interaction $PATH</code> | | <code>dx:fmt</code> | <code>dx fmt --all-code --file $PATH</code> | | <code>easy-coding-standard</code> | <code>ecs check $PATH --fix --no-interaction</code> | | <code>efmt</code> | <code>efmt -w $PATH</code> | | <code>elm-format</code> | <code>elm-format --elm-version=0.19 --yes $PATH</code> | | <code>eradicate</code> | <code>eradicate --in-place $PATH</code> | | <code>erb-formatter</code> | <code>erb-format $PATH --write</code> | | <code>erg:lint</code> | <code>erg lint $PATH</code> | | <code>erlfmt</code> | <code>erlfmt -w $PATH_STRING</code> | | <code>eslint</code> | <code>eslint --fix $PATH</code> | | <code>fantomas</code> | <code>fantomas $PATH</code> | | <code>fish_indent</code> | <code>fish_indent -w $PATH</code> | | <code>fixjson</code> | <code>fixjson -w $PATH</code> | | <code>floskell</code> | <code>floskell $PATH</code> | | <code>flynt</code> | <code>flynt $PATH</code> | | <code>fnlfmt</code> | <code>fnlfmt $PATH</code> | | <code>forge:fmt</code> | <code>forge fmt $PATH</code> | | <code>fortitude:check:fix:unsafe</code> | <code>fortitude check --quiet --no-respect-gitignore --fix --unsafe-fixes $PATH</code> | | <code>fortitude:check:fix</code> | <code>fortitude check --quiet --no-respect-gitignore --fix $PATH</code> | | <code>fortitude:check</code> | <code>fortitude check --quiet --no-respect-gitignore $PATH</code> | | <code>fortran-linter</code> | <code>fortran-linter -i $PATH</code> | | <code>fourmolu</code> | <code>fourmolu -i $PATH</code> | | <code>fprettify</code> | <code>fprettify $PATH</code> | | <code>futhark:fmt</code> | <code>futhark fmt $PATH</code> | | <code>fvm:dart:fix</code> | <code>fvm dart fix --apply $PATH</code> | | <code>fvm:dart:format</code> | <code>fvm dart format $PATH</code> | | <code>gci</code> | <code>gci write --skip-generated --skip-vendor $PATH</code> | | <code>gdformat</code> | <code>gdformat $PATH</code> | | <code>gdlint</code> | <code>gdlint $PATH</code> | | <code>gersemi</code> | <code>gersemi -i -q $PATH</code> | | <code>gleam:format</code> | <code>gleam format $PATH</code> | | <code>gluon:fmt</code> | <code>gluon fmt $PATH</code> | | <code>gofmt</code> | <code>gofmt -w $PATH</code> | | <code>gofumpt</code> | <code>gofumpt -w $PATH</code> | | <code>goimports-reviser</code> | <code>goimports-reviser -format $PATH</code> | | <code>goimports</code> | <code>goimports -w $PATH</code> | | <code>golangci-lint:fmt</code> | <code>golangci-lint fmt $PATH</code> | | <code>golangci-lint:run:fix</code> | <code>golangci-lint run --fix $PATH</code> | | <code>golangci-lint:run</code> | <code>golangci-lint run $PATH</code> | | <code>golines</code> | <code>golines -w $PATH</code> | | <code>google-java-format</code> | <code>google-java-format -i $PATH</code> | | <code>gospel</code> | <code>gospel $PATH</code> | | <code>grafbase:lint</code> | <code>grafbase lint $PATH</code> | | <code>grain:format</code> | <code>grain format $PATH -o $PATH</code> | | <code>hadolint</code> | <code>hadolint $PATH</code> | | <code>haml-lint</code> | <code>haml-lint --auto-correct $PATH</code> | | <code>hclfmt</code> | <code>hclfmt -w $PATH</code> | | <code>hfmt</code> | <code>hfmt -w $PATH</code> | | <code>hindent</code> | <code>hindent $PATH</code> | | <code>hlint</code> | <code>hlint $PATH</code> | | <code>html-beautify</code> | <code>html-beautify -r --type html -f $PATH</code> | | <code>htmlbeautifier</code> | <code>htmlbeautifier $PATH</code> | | <code>htmlhint</code> | <code>htmlhint $PATH</code> | | <code>hurlfmt</code> | <code>hurlfmt --in-place $PATH</code> | | <code>imba:fmt</code> | <code>imba fmt -f $PATH</code> | | <code>inko:fmt</code> | <code>inko fmt $PATH</code> | | <code>isort</code> | <code>isort --quiet $PATH</code> | | <code>janet-format</code> | <code>janet-format</code> | | <code>joker</code> | <code>joker --format --write $PATH</code> | | <code>jq</code> | <code>jq</code> | | <code>jqfmt</code> | <code>jqfmt</code> | | <code>js-beautify</code> | <code>js-beautify -r --type js -f $PATH</code> | | <code>json5format</code> | <code>json5format -r $PATH</code> | | <code>jsona:format</code> | <code>jsona format $PATH</code> | | <code>jsona:lint</code> | <code>jsona lint $PATH</code> | | <code>jsonlint</code> | <code>jsonlint -i $PATH</code> | | <code>jsonnet-lint</code> | <code>jsonnet-lint $PATH</code> | | <code>jsonnetfmt</code> | <code>jsonnetfmt -i $PATH</code> | | <code>jsonpp</code> | <code>jsonpp -s</code> | | <code>juliaformatter.jl</code> | <code>julia -E using JuliaFormatter;format_file(\"{$PATH_STRING}\")</code> | | <code>just</code> | <code>just --fmt --unstable --justfile $PATH</code> | | <code>kcl:fmt</code> | <code>kcl fmt $PATH</code> | | <code>kcl:lint</code> | <code>kcl lint $PATH</code> | | <code>kdlfmt:v1</code> | <code>kdlfmt format --kdl-version v1 $PATH</code> | | <code>kdlfmt:v2</code> | <code>kdlfmt format --kdl-version v2 $PATH</code> | | <code>kdlfmt</code> | <code>kdlfmt format $PATH</code> | | <code>kdoc-formatter</code> | <code>kdoc-formatter --quiet $PATH</code> | | <code>ktfmt</code> | <code>ktfmt $PATH</code> | | <code>ktlint</code> | <code>ktlint --format --log-level=error $PATH</code> | | <code>kulala-fmt:check</code> | <code>kulala-fmt check $PATH</code> | | <code>kulala-fmt:format</code> | <code>kulala-fmt format $PATH</code> | | <code>leptosfmt</code> | <code>leptosfmt $PATH</code> | | <code>liquidsoap-prettier</code> | <code>liquidsoap-prettier --write $PATH</code> | | <code>luacheck</code> | <code>luacheck $PATH</code> | | <code>luaformatter</code> | <code>lua-format -i $PATH</code> | | <code>mado:check</code> | <code>mado check $PATH</code> | | <code>mago:format</code> | <code>mago format $PATH</code> | | <code>mago:lint:fix:unsafe</code> | <code>mago lint --fix --potentially-unsafe --unsafe $PATH</code> | | <code>mago:lint:fix</code> | <code>mago lint --fix $PATH</code> | | <code>mago:lint</code> | <code>mago lint $PATH</code> | | <code>markdownfmt</code> | <code>markdownfmt -w $PATH</code> | | <code>markdownlint-cli2</code> | <code>markdownlint-cli2 --fix $PATH</code> | | <code>markdownlint</code> | <code>markdownlint --fix $PATH</code> | | <code>markuplint</code> | <code>markuplint --fix $PATH</code> | | <code>md-padding</code> | <code>md-padding -i $PATH</code> | | <code>mdformat</code> | <code>mdformat $PATH</code> | | <code>mdsf:format</code> | <code>mdsf format $PATH</code> | | <code>mdsf:verify</code> | <code>mdsf verify $PATH</code> | | <code>mdslw</code> | <code>mdslw $PATH</code> | | <code>meson:fmt</code> | <code>meson fmt -i $PATH</code> | | <code>mise:fmt</code> | <code>mise fmt --stdin</code> | | <code>misspell</code> | <code>misspell -w $PATH</code> | | <code>mix:format</code> | <code>mix format $PATH</code> | | <code>mojo:format</code> | <code>mojo format -q $PATH</code> | | <code>muon:fmt</code> | <code>muon fmt -i $PATH</code> | | <code>muon:lint</code> | <code>muon lint -i $PATH</code> | | <code>mypy</code> | <code>mypy $PATH</code> | | <code>nasmfmt</code> | <code>nasmfmt $PATH</code> | | <code>nginxbeautifier</code> | <code>nginxbeautifier $PATH</code> | | <code>nginxfmt</code> | <code>nginxfmt $PATH</code> | | <code>nickel:format</code> | <code>nickel format $PATH</code> | | <code>nimpretty</code> | <code>nimpretty $PATH</code> | | <code>nixfmt</code> | <code>nixfmt $PATH</code> | | <code>nixpkgs-fmt</code> | <code>nixpkgs-fmt $PATH</code> | | <code>nomad:fmt</code> | <code>nomad fmt $PATH</code> | | <code>nph</code> | <code>nph $PATH</code> | | <code>npm-groovy-lint</code> | <code>npm-groovy-lint --format $PATH</code> | | <code>nufmt</code> | <code>nufmt $PATH</code> | | <code>ocamlformat</code> | <code>ocamlformat --ignore-invalid-option --inplace --enable-outside-detected-project $PATH</code> | | <code>ocp-indent</code> | <code>ocp-indent --inplace $PATH</code> | | <code>odinfmt</code> | <code>odinfmt -w $PATH</code> | | <code>oelint-adv</code> | <code>oelint-adv --fix --nobackup --quiet $PATH</code> | | <code>opa:fmt</code> | <code>opa fmt $PATH -w</code> | | <code>ormolu</code> | <code>ormolu --mode inplace $PATH</code> | | <code>oxlint</code> | <code>oxlint --fix $PATH</code> | | <code>packer:fix</code> | <code>packer fix $PATH</code> | | <code>packer:fmt</code> | <code>packer fmt $PATH</code> | | <code>packer:validate</code> | <code>packer validate $PATH</code> | | <code>pasfmt</code> | <code>pasfmt $PATH</code> | | <code>perflint</code> | <code>perflint $PATH</code> | | <code>perltidy</code> | <code>perltidy -b $PATH</code> | | <code>pg_format</code> | <code>pg_format --inplace $PATH</code> | | <code>php-cs-fixer:fix</code> | <code>php-cs-fixer fix $PATH</code> | | <code>phpcbf</code> | <code>phpcbf $PATH</code> | | <code>phpinsights:fix</code> | <code>phpinsights fix $PATH --no-interaction --quiet</code> | | <code>pint</code> | <code>pint $PATH</code> | | <code>prettier</code> | <code>prettier --embedded-language-formatting off --log-level error --write $PATH</code> | | <code>pretty-php</code> | <code>pretty-php $PATH</code> | | <code>prettypst</code> | <code>prettypst $PATH</code> | | <code>prisma:format</code> | <code>prisma format --schema={$PATH_STRING}</code> | | <code>proselint</code> | <code>proselint $PATH</code> | | <code>protolint</code> | <code>protolint lint -fix $PATH</code> | | <code>ptop</code> | <code>ptop $PATH $PATH</code> | | <code>pug-lint</code> | <code>pug-lint $PATH</code> | | <code>puppet-lint</code> | <code>puppet-lint --fix $PATH</code> | | <code>purs-tidy</code> | <code>purs-tidy format-in-place $PATH</code> | | <code>purty</code> | <code>purty --write $PATH</code> | | <code>pycln</code> | <code>pycln --no-gitignore --quiet $PATH</code> | | <code>pycodestyle</code> | <code>pycodestyle $PATH</code> | | <code>pydoclint</code> | <code>pydoclint $PATH</code> | | <code>pydocstringformatter</code> | <code>pydocstringformatter -w $PATH</code> | | <code>pydocstyle</code> | <code>pydocstyle $PATH</code> | | <code>pyflakes</code> | <code>pyflakes $PATH</code> | | <code>pyink</code> | <code>pyink --quiet $PATH</code> | | <code>pylint</code> | <code>pylint --module-naming-style=any $PATH</code> | | <code>pyment</code> | <code>pyment -w $PATH</code> | | <code>pyrefly</code> | <code>pyrefly check $PATH</code> | | <code>pyupgrade</code> | <code>pyupgrade $PATH</code> | | <code>qmlfmt</code> | <code>qmlfmt -w $PATH</code> | | <code>quick-lint-js</code> | <code>quick-lint-js $PATH</code> | | <code>raco:fmt</code> | <code>raco fmt -i $PATH</code> | | <code>reek</code> | <code>reek $PATH</code> | | <code>refmt</code> | <code>refmt --in-place $PATH</code> | | <code>reformat-gherkin</code> | <code>reformat-gherkin $PATH</code> | | <code>refurb</code> | <code>refurb $PATH</code> | | <code>regal:fix</code> | <code>regal fix $PATH</code> | | <code>regal:lint</code> | <code>regal lint $PATH</code> | | <code>reorder-python-imports</code> | <code>reorder-python-imports $PATH</code> | | <code>rescript:format</code> | <code>rescript format $PATH</code> | | <code>revive</code> | <code>revive $PATH</code> | | <code>roc:format</code> | <code>roc format $PATH</code> | | <code>rstfmt</code> | <code>rstfmt $PATH</code> | | <code>rubocop</code> | <code>rubocop --fix-layout --autocorrect --format quiet $PATH</code> | | <code>rubyfmt</code> | <code>rubyfmt -i $PATH</code> | | <code>ruff:check</code> | <code>ruff check --fix --quiet $PATH</code> | | <code>ruff:format</code> | <code>ruff format --quiet $PATH</code> | | <code>rufo</code> | <code>rufo --simple-exit $PATH</code> | | <code>rune:fmt</code> | <code>rune fmt $PATH</code> | | <code>runic</code> | <code>runic --inplace $PATH</code> | | <code>rustfmt</code> | <code>rustfmt --edition 2021 --quiet $PATH</code> | | <code>rustywind</code> | <code>rustywind --write $PATH</code> | | <code>salt-lint</code> | <code>salt-lint $PATH</code> | | <code>scalafmt</code> | <code>scalafmt --quiet --mode any $PATH</code> | | <code>scalariform</code> | <code>scalariform $PATH</code> | | <code>selene</code> | <code>selene --no-summary --quiet $PATH</code> | | <code>semistandard</code> | <code>semistandard --fix --stdin</code> | | <code>shellcheck</code> | <code>shellcheck $PATH</code> | | <code>shellharden</code> | <code>shellharden --transform --replace $PATH</code> | | <code>shfmt</code> | <code>shfmt --write $PATH</code> | | <code>sleek</code> | <code>sleek $PATH</code> | | <code>slim-lint</code> | <code>slim-lint $PATH</code> | | <code>smlfmt</code> | <code>smlfmt --force $PATH</code> | | <code>snakefmt</code> | <code>snakefmt $PATH</code> | | <code>solhint</code> | <code>solhint --quiet --fix --noPrompt $PATH</code> | | <code>sphinx-lint</code> | <code>sphinx-lint $PATH</code> | | <code>sql-formatter</code> | <code>sql-formatter --fix $PATH</code> | | <code>sqlfluff:fix</code> | <code>sqlfluff fix --disable-progress-bar --nocolor --dialect ansi $PATH</code> | | <code>sqlfluff:format</code> | <code>sqlfluff format --disable-progress-bar --nocolor --dialect ansi $PATH</code> | | <code>sqlfluff:lint</code> | <code>sqlfluff lint --disable-progress-bar --nocolor --dialect ansi $PATH</code> | | <code>sqlfmt</code> | <code>sqlfmt $PATH</code> | | <code>sqruff</code> | <code>sqruff fix --force $PATH</code> | | <code>squawk</code> | <code>squawk $PATH</code> | | <code>standardjs</code> | <code>standard --fix --stdin</code> | | <code>standardrb</code> | <code>standardrb --fix $PATH</code> | | <code>statix:check</code> | <code>statix check $PATH</code> | | <code>statix:fix</code> | <code>statix fix $PATH</code> | | <code>stylefmt</code> | <code>stylefmt $PATH</code> | | <code>stylelint</code> | <code>stylelint --fix $PATH</code> | | <code>stylish-haskell</code> | <code>stylish-haskell --inplace $PATH</code> | | <code>stylua</code> | <code>stylua --verify $PATH</code> | | <code>superhtml:fmt</code> | <code>superhtml fmt $PATH</code> | | <code>svlint</code> | <code>svlint $PATH</code> | | <code>swift-format</code> | <code>swift-format --in-place $PATH</code> | | <code>swiftformat</code> | <code>swiftformat --quiet $PATH</code> | | <code>taplo</code> | <code>taplo format $PATH</code> | | <code>templ:fmt</code> | <code>templ fmt $PATH</code> | | <code>terraform:fmt</code> | <code>terraform fmt -write=true $PATH</code> | | <code>terragrunt:hclfmt</code> | <code>terragrunt hclfmt --terragrunt-hclfmt-file $PATH</code> | | <code>tex-fmt</code> | <code>tex-fmt $PATH</code> | | <code>textlint:fix</code> | <code>textlint --fix $PATH</code> | | <code>textlint</code> | <code>textlint $PATH</code> | | <code>tlint:format</code> | <code>tlint format $PATH</code> | | <code>tofu:fmt</code> | <code>tofu fmt -write=true $PATH</code> | | <code>tombi:format</code> | <code>tombi format $PATH</code> | | <code>tombi:lint</code> | <code>tombi lint $PATH</code> | | <code>toml-sort</code> | <code>toml-sort -i $PATH</code> | | <code>topiary</code> | <code>topiary format $PATH</code> | | <code>tryceratops</code> | <code>tryceratops --autofix $PATH</code> | | <code>ts-standard</code> | <code>ts-standard --fix $PATH</code> | | <code>tsp:format</code> | <code>tsp format $PATH</code> | | <code>tsqllint</code> | <code>tsqllint --fix $PATH</code> | | <code>twig-cs-fixer:lint</code> | <code>twig-cs-fixer lint $PATH --fix --no-interaction --quiet</code> | | <code>twigcs</code> | <code>twigcs $PATH</code> | | <code>ty</code> | <code>ty check $PATH</code> | | <code>typos</code> | <code>typos -w --no-ignore --hidden $PATH</code> | | <code>typstfmt</code> | <code>typstfmt $PATH</code> | | <code>typstyle</code> | <code>typstyle -i $PATH</code> | | <code>ufmt</code> | <code>ufmt format $PATH</code> | | <code>uiua:fmt</code> | <code>uiua fmt $PATH</code> | | <code>unimport</code> | <code>unimport -r $PATH</code> | | <code>usort</code> | <code>usort format $PATH</code> | | <code>v:fmt</code> | <code>v fmt -w $PATH</code> | | <code>vacuum:lint</code> | <code>vacuum lint $PATH</code> | | <code>verusfmt</code> | <code>verusfmt $PATH</code> | | <code>veryl:fmt</code> | <code>veryl fmt $PATH</code> | | <code>vhdl-style-guide</code> | <code>vsg -f $PATH --fix</code> | | <code>vint:neovim</code> | <code>vint --enable-neovim $PATH</code> | | <code>vint</code> | <code>vint $PATH</code> | | <code>wa:fmt</code> | <code>wa fmt $PATH</code> | | <code>wfindent</code> | <code>wfindent $PATH</code> | | <code>write-good</code> | <code>write-good $PATH</code> | | <code>xmlformat</code> | <code>xmlformat --overwrite $PATH</code> | | <code>xmllint</code> | <code>xmllint --format $PATH --output $PATH</code> | | <code>xo</code> | <code>xo --fix --stdin</code> | | <code>xq:html</code> | <code>xq --html</code> | | <code>xq</code> | <code>xq</code> | | <code>yamlfix</code> | <code>yamlfix $PATH</code> | | <code>yamlfmt</code> | <code>yamlfmt -quiet $PATH</code> | | <code>yamllint</code> | <code>yamllint $PATH</code> | | <code>yapf</code> | <code>yapf --in-place $PATH</code> | | <code>yew-fmt</code> | <code>yew-fmt --edition 2021 $PATH</code> | | <code>yq</code> | <code>yq --inplace $PATH</code> | | <code>zig:fmt</code> | <code>zig fmt $PATH</code> | | <code>ziggy:fmt</code> | <code>ziggy fmt $PATH</code> | | <code>zprint</code> | <code>zprint -w $PATH</code> | Shell completions Shell completions can be generated using <code>mdsf completions &lt;SHELL&gt;</code>. ``` Generate shell completion Usage: mdsf completions [OPTIONS] Arguments: [possible values: bash, elvish, fish, nushell, powershell, zsh] Options: --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help -V, --version Print version ``` Bash Add the following to your <code>.bashrc</code>. <code>bash eval "$(mdsf completions bash)"</code> Zsh Add the following to your <code>.zshrc</code>. <code>bash eval "$(mdsf completions zsh)"</code> Fish Add the following to <code>~/.config/fish/config.fish</code>. <code>fish mdsf completions fish | source</code> PowerShell Add the following to your PowerShell configuration (Can be found by running <code>$PROFILE</code>). <code>powershell Invoke-Expression (&amp;mdsf completions powershell)</code> Elvish Add the following to <code>~/.elvish/rc.elv</code>. <code>elvish eval (mdsf completions elvish)</code> Nushell Generate completions for <a>nushell</a>. <code>nushell mdsf completions nushell</code> Acknowledgement mdsf was inspired by the amazing neovim formatting plugin <a>conform.nvim</a>. Alternatives to mdsf <ul> <li><a>conform.nvim</a> using <code>injected</code> mode.</li> <li><a>mdformat</a>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/170739895?v=4
ziglist
pixqc/ziglist
2024-08-01T13:17:15Z
Discover Zig projects and packages
master
3
49
0
49
https://api.github.com/repos/pixqc/ziglist/tags
MIT
[ "zig" ]
1,358
false
2025-03-17T18:26:51Z
false
false
unknown
github
[]
<a></a> Ziglist is a web-based tool to discover Zig projects and packages. Visit <a>ziglist.org</a>. How it works: Ziglist periodically indexes GitHub for Zig-related repositories, saves it in a SQLite database, and serves it. Ziglist lives in a single JavaScript <a>file</a>. It runs on the Deno runtime. To run Ziglist locally: <ul> <li>Install Deno, refer to the <a>documentation</a></li> <li><code>git clone https://github.com/pixqc/ziglist.git</code></li> <li><code>mv .env.example .env</code> and fill it out</li> <li><code>deno task dev</code></li> </ul> Help wanted! If you found: <ul> <li>c/cpp repo built with Zig, that's not on Ziglist</li> <li>repo on Ziglist that's not Zig-related</li> <li>missing dependencies in one of the repos</li> </ul> Please open an issue or a PR, ctrl+f for <code>HELP:</code> in the <a>file</a>. Ziglist's visual design is inspired by <a>https://github.com/piotrkulpinski/openalternative</a> Check out the <a>blogpost</a>!
[]
https://avatars.githubusercontent.com/u/37773546?v=4
bamos
bagggage/bamos
2024-02-14T22:43:33Z
Open-source operating system
main
2
48
1
48
https://api.github.com/repos/bagggage/bamos/tags
MIT
[ "drivers", "embedded", "kernel", "open-source", "operating-system", "os", "zig" ]
2,775
false
2025-05-21T21:10:01Z
true
false
unknown
github
[]
<a target="_blank"></a> It is an <strong>open-source</strong> operating system project written in the Zig programming language. BamOS does not introduce new standards but strives for the <strong>best</strong> possible implementation of existing ones. Overview The main feature and goal of this project is to develop a <strong>lightweight</strong> and <strong>extremely fast</strong> operating system with a <strong>well-documented</strong>, <strong>concise</strong>, and <strong>simple</strong> codebase, as much as possible. It aims to include native support for multiple system ABIs between the kernel and user space (GNU/Linux, Windows NT, etc.) simultaneously. This should significantly improve the user experience and simplify the work for software developers. Why Zig? Despite the familiar and established languages like C/C++ or the possibly safer Rust, our choice is Zig. Zig is simple enough to be more maintainable than Rust while offering a safer and more functional alternative to C/C++. Zig allows generating high-speed and optimized machine code, and one of its main advantages is the build system, which makes the compilation process seamless and incredibly simple. To create a kernel executable, all you need is the source code, the Zig compiler, and the command <code>zig build kernel</code>. Documentation <ul> <li> The general <strong>OS</strong> documentation is available on <a>this page</a>. </li> <li> The code documentation is available on <a>this page</a>. If you want to generate the documentation locally, run the following command: </li> </ul> <code>sh zig build docs</code> A static site will be placed in the <code>docs</code> directory, which can then be launched using: <code>sh cd docs python -m http.server</code> The Zig language description and documentation for its standard library can be found on the <a>official website</a>. Contributing BamOS is still a small but <strong>growing</strong> project. We welcome any contributions and invite you to participate in the development and evolution of the project. See information on <a>contributing</a>. Building from Source The build process is quite straightforward: <ul> <li>Before you begin, ensure that the Zig compiler version <a><strong>0.14.0</strong></a> is installed on your workstation.</li> </ul> <code>sh git clone https://github.com/bagggage/bamos.git cd bamos zig build kernel --release=[small|safe|fast]</code> By default, the build result will be located in the <code>.zig-out</code> directory. To specify a different path, use the <code>--prefix=[path]</code> option during the build. Creating an Image Currently, the OS relies on the third-party <a>BOOTBOOT</a> bootloader, and the <code>bootboot/mkbootimg</code> utility is used to create the image. In the future, this stage is planned to be simplified and made more cross-platform. However, for now, to create an image, you need to: <ul> <li>Obtain precompiled <a>BOOTBOOT</a> binaries. And unzip <code>mkbootimg</code> for your host OS.</li> <li>Specify the path to the <code>bootboot-bin</code> directory by setting the <code>BOOTBOOT</code> variable in <code>env.sh</code>.</li> <li>Run <code>iso.sh</code>.</li> </ul> By default, the image will be placed in the <code>dist</code> directory. Running For quick OS testing and launch, it is recommended to use the <a>QEMU</a> emulator. On <strong>Windows</strong>, you should also add the <code>qemu</code> directory in the <code>PATH</code> environment variable beforehand. In the project's root directory, there are the <code>qemu.sh</code> and <code>debug.sh</code> scripts: <ul> <li><code>qemu.sh</code> runs a pre-built system image (by default <code>dist/bamos.iso</code>) in the emulator.</li> <li><code>debug.sh</code> compiles, creates the image, and runs the system in the emulator.</li> </ul> Details BamOS is at an early stage of development, and many things are not yet implemented. Moreover, writing the implementation and developing the operating system architecture requires an iterative approach to find the best solutions, so some details may change, but this is all for the better. Current Progress To track what has already been implemented in the project and what stage it is currently at, check out <a><strong>this page</strong></a>.
[]
https://avatars.githubusercontent.com/u/96927121?v=4
flags
joegm/flags
2024-05-15T18:33:21Z
An effortless command-line argument parser for Zig.
main
3
47
5
47
https://api.github.com/repos/joegm/flags/tags
MIT
[ "command-line-arguments-parser", "library", "zig", "zig-package" ]
131
false
2025-05-08T20:54:58Z
true
true
0.14.0-dev.2802+257054a14
github
[]
flags An effortless command-line argument parser for Zig. Features <ul> <li>Zero allocations.</li> <li>Cross platform.</li> <li>Single-function, declarative API.</li> <li>Multi-level subcommands.</li> <li>Automatic help message generation at comptime.</li> <li>Customisable terminal coloring.</li> </ul> Getting Started To import flags to your project, run the following command: <code>zig fetch --save git+https://github.com/n0s4/flags</code> Then set up the dependency in your <code>build.zig</code>: ```zig const flags_dep = b.dependency("flags", .{ .target = target, .optimize = optimize, }) <code>exe.root_module.addImport("flags", flags_dep.module("flags")); </code> ``` See the <a>examples</a> for basic usage.
[ "https://github.com/JacobCrabill/zigdown", "https://github.com/jhark/debuglog", "https://github.com/jhark/dizazm", "https://github.com/kj4tmp/gatorcat", "https://github.com/neurocyte/flow" ]
https://avatars.githubusercontent.com/u/160299836?v=4
zerl
dont-rely-on-nulls/zerl
2024-07-21T04:36:41Z
A Zig library to idiomatically communicate with other BEAM nodes
main
3
42
1
42
https://api.github.com/repos/dont-rely-on-nulls/zerl/tags
Unlicense
[ "erlang", "erlang-otp", "nix", "zerl", "zig", "zig-library", "ziglang" ]
124
false
2025-05-19T12:18:25Z
true
true
0.14.0
github
[]
404
[]
https://avatars.githubusercontent.com/u/1625198?v=4
gb-emu-zig
Ryp/gb-emu-zig
2024-05-26T19:58:31Z
Gameboy emulator written in Zig
master
0
42
2
42
https://api.github.com/repos/Ryp/gb-emu-zig/tags
MIT
[ "emulator", "gameboy", "zig" ]
226
false
2025-05-20T09:42:45Z
true
true
0.14.0
github
[ { "commit": "2bb5f57ea8b8c43eabe514f7bbd3361365ba2ff3", "name": "sdl", "tar_url": "https://github.com/castholm/SDL/archive/2bb5f57ea8b8c43eabe514f7bbd3361365ba2ff3.tar.gz", "type": "remote", "url": "https://github.com/castholm/SDL" } ]
Gameboy Emulator Here's a simple Gameboy emulator written in Zig using SDL3. It can run games like Tetris, Zelda or Kirby decently, and doesn't pretend to do much more. Most basic features are implemented, like graphics, sound and controls, but there was no effort to support any complex hardware behavior or bugs. On the other hand the codebase should be very simple to get into and hopefully very readable. Tetris | Zelda :-------------------------:|:-------------------------: | How to run This should get you going after cloning the repo: <code>bash zig build -Doptimize=ReleaseFast run -- &lt;rom_file&gt;</code> Controls | Keyboard key | Gameboy | |-----------------------|--------------------| | Esc | Exit | | WASD | DPad | | O | A | | K | B | | Enter | Start | | B | Select | Rough edges <ul> <li>ROM-only and MBC1 cartridge are supported, whereas MBC2 has limited support. Everything else is unsupported.</li> <li>It's assumed your refresh rate is 60Hz. Failing that, the gameplay speed will be wrong and the audio will get wildly out of sync.</li> <li>Sound will slowly accumulate lag over time anyway because 60Hz is not 59.94Hz.</li> </ul>
[]
https://avatars.githubusercontent.com/u/43883450?v=4
OpenMP-zig
sbancuz/OpenMP-zig
2024-02-12T09:16:53Z
An implementation of the OpenMP directives for Zig
master
0
39
0
39
https://api.github.com/repos/sbancuz/OpenMP-zig/tags
MIT
[ "openmp", "openmp-parallelization", "zig", "zig-package" ]
235
false
2025-05-15T04:50:00Z
true
true
unknown
github
[]
OpenMP-zig This wrapper implements (almost all) the OpenMP directives up-to version 3.1 and some newer stuff. All of this is (mostly, see below) without any allocation from the zig part. This is implemented using the `libomp' library of LLVM. (Gomp support is not planned) <strong>Disclaimer</strong> This project is not affiliated with LLVM in any capacity. ```zig const std = @import("std"); const omp = @import("omp"); fn main() void { omp.parallel(.{}) .run(.{}, struct { fn f() void { std.debug.print("Hello world {}!", .{omp.get_thread_num()}); } }.f); } ``` Build <code>sh zig fetch --save git+https://github.com/sbancuz/OpenMP-zig</code> <code>zig // build.zig const OpenMP_zig_dep = b.dependency("OpenMP-zig", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("omp", OpenMP_zig_dep.module("omp"));</code> Features <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> <code>#pragma omp parallel</code> <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> <code>All reductions</code> <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> <code>#pragma omp for</code> <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> <code>#pragma omp sections</code> <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> <code>#pragma omp single</code> <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> <code>#pragma omp master/masked</code> <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> <code>#pragma omp critical</code> <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> <code>#pragma omp barrier</code> <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> <code>#pragma omp task</code> <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> <code>#pragma omp atomic</code> NOT POSSIBLE TO IMPLEMENT <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> <code>#pragma omp simd</code> NOT POSSIBLE TO IMPLEMENT To see some other examples of the library check the tests folder. Extensions ```zig fn test_omp_task_error() !bool { // The ret reduction parameter tells the directive how it should reduce the return value const result = omp.parallel(.{ .ret_reduction = .plus }) .run(.{}, struct { // You can return whatever you want! fn f() !usize { const maybe = omp.single() .run(.{}, struct { // Only for tasks, you have to put the explicit error type in the promise, // otherwise it won't be able to infer the type fn f() *omp.promise(error{WompWomp}!usize) { return omp.task(.{}) .run(.{}, struct { // Same deal here fn f() error{WompWomp}!usize { return error.WompWomp; } }.f); } }.f); if (maybe) |pro| { defer pro.deinit(); return pro.get(); } return 0; } }.f) catch |err| switch (err) { error.WompWomp =&gt; std.debug.print("Caught an error :^(", .{}); }; <code>std.debug.print("No errors here!". /{}); </code> } ``` Return All of the directives can return values. To return something you may need to specify the <code>ret_reduction</code> parameter. <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 promises that are returned from the <code>task</code> directive will be heap allocated. So make sure to deinit() them! </blockquote> Errors All of the directive can return error types. <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> Returning more than one type of error from a directive it's clearly a race condition! </blockquote> Goal The goal of this library is to provide at least OpenMP 4.5 to zig and be production ready, along with the mentioned extensions.
[]
https://avatars.githubusercontent.com/u/69648959?v=4
zzmq
nine-lives-later/zzmq
2024-02-17T10:06:10Z
Zig Binding for ZeroMQ
main
6
36
8
36
https://api.github.com/repos/nine-lives-later/zzmq/tags
MPL-2.0
[ "libzmq", "zeromq", "zeromq-czmq", "zig", "ziglang" ]
63
false
2025-05-18T22:36:17Z
true
false
unknown
github
[]
Zig Binding for ZeroMQ This Zig library provides a ZeroMQ client. It is implemented based on the C API of <a>libzmq</a>. The interface is highly inspired by <a>CZMQ</a> and <a>goczmq</a>. It was originally based on the "High-level C Binding for ZeroMQ" (<a>CZMQ</a>), but later moved to using <a>libzmq</a> directly, to provide zero-copy message support. <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> The library is currently still work in progress!! Please feel free to open pull requests for features needed. </blockquote> <a></a> <a></a> Using the Library Minimal Example This repository holds various example within the <code>examples</code> folder. Please feel free to also have a look at the various unit tests in this library (esp. <a>ZSocket</a>). Running the server (also see <a>full example</a>): ```zig const zzmq = @import("zzmq"); var context = try zzmq.ZContext.init(allocator); defer context.deinit(); var socket = try zzmq.ZSocket.init(zzmq.ZSocketType.Pair, &amp;context); defer socket.deinit(); try socket.bind("tcp://127.0.0.1:*"); std.log.info("Endpoint: {s}", .{try socket.endpoint()}); // send a message var message = try zzmq.ZMessage.initUnmanaged(data, null); defer message.deinit(); try socket.send(&amp;message, .{}); ``` Running the client (also see <a>full example</a>): ```zig const zzmq = @import("zzmq"); var context = try zzmq.ZContext.init(allocator); defer context.deinit(); var socket = try zzmq.ZSocket.init(zzmq.ZSocketType.Pair, &amp;context); defer socket.deinit(); const endpoint = try std.fmt.allocPrint(allocator, "tcp://127.0.0.1:{}", .{port}); defer allocator.free(endpoint); try socket.connect(endpoint); // receive a message var message = try socket.receive(.{}); defer message.deinit(); const data = try message.data(); ``` Adding to build process Determine the specific <a>release tag</a> of the library to use in the project. <code>sh zig fetch --save=zzmq 'https://github.com/nine-lives-later/zzmq/archive/refs/tags/v0.2.2-zig0.13.tar.gz'</code> It is also required to add it to the <code>build.zig</code> file: ```zig const zzmq = b.dependency("zzmq", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("zzmq", zzmq.module("zzmq")); exe.linkSystemLibrary("zmq"); exe.linkLibC(); ``` Installing local dependencies Installing <a>libzmq</a> development library version 4.1 or higher is also required: ```sh Building on Ubuntu, PoP_OS, ZorinOS, etc. sudo apt install libzmq5-dev Running on Ubuntu, PoP_OS, ZorinOS, etc. sudo apt install libzmq5 ``` See the <a>unit test Dockerfile</a> on how to install it into an Alpine Docker image. To retrieve the version of the libzmq library actually being used, call <code>ZContext.version()</code>. Contributing Zig Version Branches There are branches for the supported Zig versions: | Branch | Zig Version | Comment | |------------|-------------|---------------------------------------------| | <code>main</code> | Zig v0.13.x | The latest unreleased version for Zig 0.13. | | <code>zig-0.12</code> | Zig v0.12.x | The latest unreleased version for Zig 0.12. | | <code>zig-0.11</code> | Zig v0.11.x | The latest unreleased version for Zig 0.11. | Please use a specific <a>release tag</a> for including the library into your project. Testing The library can be tested locally by running: <code>zig build test</code>. Contributors <ul> <li><a>Felix Kollmann</a></li> <li><a>Jacob Green</a></li> <li>Inspired by <a>CZMQ</a> and <a>goczmq</a>.</li> </ul> License Published under the <a>Mozilla Public License 2.0</a>. <ul> <li>Static linking is allowed.</li> <li>Safe for use in close-source applications.</li> <li>You do not need a commercial license.</li> </ul> Feel free to also see the <a>ZeroMQ licensing terms</a>.
[]
https://avatars.githubusercontent.com/u/206480?v=4
mqttz
karlseguin/mqttz
2024-06-06T14:24:16Z
MQTT client for Zig
master
0
36
2
36
https://api.github.com/repos/karlseguin/mqttz/tags
MIT
[ "mqtt-client", "zig", "zig-library", "zig-package" ]
182
false
2025-04-30T13:49:57Z
true
true
unknown
github
[]
MQTT Client for Zig This is a embedding-friendly MQTT client library for Zig. The library has two client: a platform-agnostic low level MQTT client where you bring your own read/write/close function and a higher level client based on Zig's stdlib. Examples These example connect to <a>test.mosquitto.org</a>, so please be respectful. The <code>example</code> folder contains examples of using both clients. The low-level client is implemented using Zig's standard library. This implementation is very basic and not as feature rich as <code>mqtt.posix.Client</code> (i.e. no timeouts) . It is only included to show how to integrate the low-level client within your own platform. To run the low-level clients: Start the subscriber via: <code>zig build example_low_level_subscriber</code>. Then start the publisher via: <code>zig build example_low_level_publisher</code>. To run the posix clients: Start the subscriber via: <code>zig build example_posix_subscriber</code>. Then start the publisher via: <code>zig build example_posix_publisher</code>. In either case, you should see 3 messages printed in your subscriber, then both programs will exit. Overview Both clients are single-threaded and follow the same paradigm. You'll call functions like <code>connect</code>, <code>subscribe</code> and <code>publish</code> to send messages to the server and call <code>readPacket</code>, as needed, to receive messages. The "as needed" part of <code>readPacket</code> is where things get interesting. MQTT is bidirectional. If you write a <code>subscribe</code> message, you'd reasonably expect to receive a <code>suback</code>, but you could also get a <code>disconnect</code> AND, if you had previously subscribed to another topic, you could get a <code>publish</code>. This is why even the higher level client doesn't run a background "read" thread nor does it expose a more linear request-&gt;response API (e.g. why the return value of <code>subscribe(...)</code> isn't a <code>Packet.Suback</code>). The message received after "subscribe" might not be "suback". If you're just publishing, the flow is straightforward (especially if you're using the default <code>at_most_once</code> QoS). Things are similarly straightforward if you're subscribing (possibly to more than 1 topic, but in a single <code>subscribe</code> message) and then receiving. This generally means that you need to call <code>readPacket</code> in a loop (until you get the expected message) and defensively handle different packet types. If you're subscribed to topics, you'll need to periodically (say, every second) call <code>readPacket</code> to check for new messages. See the examples in the <code>example</code> folder. mqtt.posix.Client <code>mqtt.posix.Client</code> is a higher level library that uses Zig's standard library and should be the preferred client to use if Zig's standard library is available. The client supports timeouts and automatic reconnects. It can optionally be configured without an allocator. ReadWriteOpts All methods are thin wrappers around the lower-level <code>mqtt.Mqtt(t)</code>. However, an additional optional parameter has been added (Zig doesn't make composing options easy, so I opted for just adding another parameter - sorry!). Where the low-level signature is <code>publish(opts: SubscribeOpts)</code> the higher-level signature is: <code>publish(rw: ReadWriteOpts, opts: SubscribeOpts)</code>. <code>ReadWriteOpts</code> allows overriding the default <code>retries</code> and <code>timeout</code>. <code>zig client.publish(.{ .retries 3, .timeout = 10_000, }, .{ .topic = "saiyan/goku/power", .message = "over 9000!", });</code> If a timeout is reached when writing a packet, <code>error.Timeout</code> will be returned. If a timeout is reached when <code>readPacket</code> is called, <code>null</code> will be returned. This allows clients to use a short timeout to periodically check for new packet. The client will automatically attempt to reconnect and continue the operation when <code>retries &gt; 0</code>. When <code>retries</code> reaches 0, the underlying error is returned. At this point, the <code>client</code> can still be used as any subsequent write/reads will automatically attempt to reconnect. init(opts: Client.Opts) !Client Initializes the client. This does not open a TCP connection to the server. Options are: <ul> <li><code>port: u16</code> - required</li> <li><code>ip: ?[]const u8 = null</code> - Either <code>ip</code> or <code>host</code> is required</li> <li><code>host: ?[]const u8 = null</code> - - Either <code>ip</code> or <code>host</code> is required</li> <li><code>connect_timeout: i32 = 10_000</code> - Time in milliseconds to try to connect</li> <li><code>default_retries: ?u16 = null</code> - When either reading/writing data from/to the server, the default number of times to automatically reconnect and retry on connection failure. Can be overridden on a per-call basis.</li> <li><code>default_timeout: ?i32 = null</code> - When either reading/writing data from/to the server, the default timeout in milliseconds, to block. Can be overridden on a per-call basis.</li> <li><code>allocator: ?Allocator = null</code> - Optional if <code>ip</code> is used instead of <code>host</code> and both <code>read_buf</code> and <code>write_buf</code> are provided.</li> <li><code>read_buf: ?[]u8 = null</code> - The buffer to read messages from the server into. If unspecified, the provided <code>allocator</code> will be used to create a buffer of <code>read_buf_size</code>. </li> <li><code>read_buf_size: u16 = 8192</code> - See <code>read_buf</code>.</li> <li><code>write_buf: ?[]u8 = null</code> - The buffer to write messages to the server into. If unspecified, the provided <code>allocator</code> will be used to create a buffer of <code>write_buf_size</code>. </li> <li><code>write_buf_size: u16 = 8192</code> - See <code>write_buf</code>.</li> </ul> When <code>host</code> is specified, <code>std.net.getAddressList</code> is used to resolve and try each possible address. This happens on each reconnection attempt. This is why an <code>allocator</code> must be provided when <code>host</code> is used. Trying to read a message from the server which is larger than <code>read_buf</code> (or <code>read_buf_size</code> will result in an <code>error.ReadBufferIsFull</code>. Similarly, trying to write a message larger than <code>write_buf</code> (or <code>write_buf_size</code>) will result in an <code>error.WriteBufferIsFull</code>. deinit(self: *Client) void Closes the socket (if it's still open) and releases the <code>read_buf</code> and <code>write_buf</code> if they are owned by the client. For a clean shutdown, you might want to call <code>disconnect</code> before calling <code>deinit</code>. lastError(self: *Client) ?mqttz.ErrorDetail The library attempts to make errors easy to manage while still providing some detail. The library typically returns a handful of higher-level errors (which makes it easier) while optionally exposing an error payload. The <code>lastErorr</code> method returns the error payload. (See the <a>errors section</a>. lastReadPacket(self: *Client) []const u8 The last read packet. Only meant to be used for debugging. Only valid until the next call to <code>readPacket</code>. connect(self: *Client, rw: ReadWriteOpts, opts: ConnectOpts) !void Sends a connect packet. publish(self: *Client, rw: ReadWriteOpts, opts: PublishOpts) !?u16 Sends a publish packet. If <code>opts.qos</code> was either <code>at_least_once</code> or <code>exactly_once</code>, then the returned value is the packet identifier, else it is null. The packet identifier is used to pair this publish with <code>puback</code>, <code>pubrec</code>, <code>pubrel</code> or <code>pubcomp</code> packets received from <code>readPacket</code>. The packet identifier is an incrementing integer. It can also be explicitly set via <code>opts.packet_identifier</code>. subscribe(self: *Client, rw: ReadWriteOpts, opts: SubscribeOpts) !u16 Sends a subscribe packet. The return value is a packet identifier used to pair this message with the corresponding suback message read via <code>readPacket</code>. The packet identifier is an incrementing integer. It can also be explicitly set via <code>opts.packet_identifier</code>. unsubscribe(self: *Client, rw: ReadWriteOpts, opts: UnsubscribeOpts) !u16 Sends a unsubscribe packet. The return value is a packet identifier used to pair this message with the corresponding unsuback message read via <code>readPacket</code>. The packet identifier is an incrementing integer. It can also be explicitly set via <code>opts.packet_identifier</code>. puback(self: *Client, rw: ReadWriteOpts, opts: PubAckOpts) !void Sends a puback packet. <code>opts.packet_identifier</code> must be set. <code>opts.reason_code</code> defaults to <code>.success</code>. pubrec(self: *Client, rw: ReadWriteOpts, opts: PubRecOpts) !void Sends a pubrec packet. <code>opts.packet_identifier</code> must be set. <code>opts.reason_code</code> defaults to <code>.success</code>. pubrel(self: *Client, rw: ReadWriteOpts, opts: PubRelOpts) !void Sends a pubrel packet. <code>opts.packet_identifier</code> must be set. <code>opts.reason_code</code> defaults to <code>.success</code>. pubcomp(self: *Client, rw: ReadWriteOpts, opts: PubCompOpts) !void Sends a pubcomb packet. <code>opts.packet_identifier</code> must be set. <code>opts.reason_code</code> defaults to <code>.success</code>. ping(self: *Client, rw: ReadWriteOpts) !void Sends a ping packet. disconnect(self: *Client, rw: ReadWriteOpts, opts: DisconnectOpts) !void Sends a disconnect packet. <code>opts.reason</code> must be set. This is a no-op if the socket is known to be disconnected (which isn't always the case). If <code>rw.retries</code> is not set, <code>0</code> will be set, overriding the default (why retry to connect just to disconnect?). readPacket(self: *Client, rw: ReadWriteOpts) !?mqttz.Packet Reads a packet from the server. mqtt.Mqtt(T) The approach of <code>mqtt.Mqtt(T)</code> is to have T provide the <code>MqttPlatform.read</code>, <code>MqttPlatform.write</code> and <code>MqttPlatform.close</code> functions. This decouples the <code>Mqtt(T)</code> library from platform details. Unlike most generic implementations, <code>Mqtt(T)</code> never references <code>T</code>. It merely calls <code>T.MqttPlatform.read()</code>, <code>T.MqttPlatform.write()</code> and <code>T.MqttPlatform.close()</code> with a per-call specific <code>anytype</code>. This provides greater flexibility and facilitates composition. Consider this partial example which wraps <code>Mqtt(T)</code> using <code>std</code>: ```zig const Client = struct { mqtt: mqtt.Mqtt(Client), socket: std.posix.socket_t, <code>// wrap mqtt.subscribe pub fn subscribe(self: *Client, opts: mqtt.SubscribeOpts) !usize { // the first parameter is an anytype and will be passed to the // read/write/close function as is return self.mqtt.subscribe(MqttPlatform.Context{ .client = self, .timeout = 5000, }, opts); } pub const MqttPlatform = struct { const Context = struct { client: *Client, timeout: i32, }; pub fn write(ctx: *Context, data: []const u8) !void { // todo implement timeout using ctx.timeout // (the real mqtt.posix.Client has timeout support) return std.posix.write(ctx.client.socket, data); } pub fn read(ctx: *Context, buf: [] u8) !?usize { // todo implement timeout using ctx.timeout // (the real mqtt.posix.Client has timeout support) return try std.posix.read(ctx.client.socket, buf); } pub fn close(ctx: *Context) void { std.posix.close(cts.socket); } }; </code> } ``` While it's common that the state you pass into the various <code>Mqtt(T)</code> methods will be of type <code>*T</code>, as we can see from the above, this is not required. The <code>read</code>, <code>write</code> and <code>close</code> functions are wrapped in the <code>MqttPlatform</code> container structure only to help avoid conflicts with any <code>read</code>, <code>write</code> and <code>close</code> function you might want on your own type. T.MqttPlatform. T must expose <code>MqttPlatform.read</code>, <code>MqttPlatform.write</code> and <code>MqttPlatform.close</code> functions. The first parameter to these functions is the same <code>anytype</code> that was passed into the <code>Mqtt(T)</code> function that triggered it. T.MqttPlatform.read(state: anytype, buf: []u8, calls: usize) !?usize Reads data into <code>buf</code> - presumably from a socket referenced directly or indirectly by <code>state</code>. Returns the number of bytes read. If <code>0</code> is returned, assumes the connection is closed. If <code>null</code> is returned, then <code>null</code> will be returned from <code>readPacket</code>. Returning <code>null</code> is how timeouts should be implemented, to indicate that there is currently no more data. Only <code>Mqtt(T).readPacket</code> can currently trigger a call to <code>read</code>. For a single call to <code>Mqtt(T).readPacket</code>, <code>read</code> might be called 0 or more times. It would be called 0 times if a previous call to <code>readPacket</code> had caused multiple packets to be read. The <code>calls</code> parameter indicates the number of times <code>read</code> has been called for a single call to <code>readPacket</code> (it can be ignored in most cases). T.MqttPlatform.write(state: anytype, data: []const u8) !void Writes <code>data</code> - presumably from a socket referenced directly or indirectly by <code>state</code>. <code>write</code> must write all of <code>data</code>. T.MqttPlatform.close(state: anytype) !void Called with <code>Mqtt(T).disconnect</code> is called. This can be called internally, via <code>disconnect</code>, by the library as required by the specification (e.g. when a <code>connack</code> response is received with indicating that a session is present, but <code>clean_start</code> was specified). Since <code>Mqtt(T)</code> is relatively stateless, it's possible for <code>close</code> to be called when your implementations' socket is already closed. Errors <code>Mqtt(T)</code> methods return errors which are meant to be easy(ish) to manage. The <code>last_error</code> field is an optional tagged union that can include additional information. The ideas is to provide a manageable number of error values without sacrificing additional details (which might traditionally be handled by having a much larger error set, which is harder to handle). For example, the only errors <code>subscribe</code> can return are: <code>error.Usage</code>, <code>error.WriteBufferIsFull</code> or any error your <code>T.write</code> method returns. If an error is returned, in most cases the optional <code>last_error</code> field will be set. Mqtt(T) As a consequence of being a foundation, <code>Mqtt(T)</code> has a simple interface. init(read_buf: []u8, write_buf: []u8) Mqtt(T) Initializes an instance. <code>read_buf</code> must remain valid for the lifetime of the returned <code>Mqtt(T)</code> value. <code>read_buf</code> must be big enough to handle any message received by the server. If you're only publishing message, than <code>read_buf</code> can be relatively small. If you're receiving message, then you'll have to size <code>read_buf</code> accordingly. <code>error.ReadBufferIsFull</code> is returned from reading functions (i.e. <code>readPacket</code>) if <code>read_buf</code> is too small to accommodate the packet. <code>write_buf</code> must remain valid for the lifetime of the returned <code>Mqtt(T)</code> value. <code>write_buf</code> must be big enough to handle any message sent to the server. If you're only only receiving messages, then <code>write_buf</code> can be relatively small. If you're sending message, then you'll have to size <code>write_buf</code> accordingly. <code>error.WriteBufferIsFull</code> is returned from writing functions (i.e. <code>connect</code>, <code>subscribe</code>, <code>publish</code>, ...) if <code>write_buf</code> is too small to accommodate the packet. MQTT is a compact protocol. To figure out the size you'll need, you can generally add up the length of your longest strings (like the name of the topic + the message) and add a few bytes of overhead. connect(state: anytype, opts: ConnectOpts) !void None of the <code>opts</code> field are required. Will call T.write(state, data) exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, any error returned from your <code>T.MqttPlatform.write</code>. subscribe(state: anytype, opts: SubscribeOpts) !usize <code>opts</code> must include at least 1 topic which must contain a filter: <code>zig mqtt.subscribe(&amp;ctx, .{ .topics = &amp;.{ .{.filter = "a/b"}, }, }</code> This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, <code>error.Usage</code>, any error returned from your <code>T.MqttPlatform.write</code>. <code>error.Usage</code> happens if no topic is provided. Returns the <code>packet_identifier</code>. The <code>packet_identifier</code> can be set explicitly via the <code>packet_identifier: ?u16 = null</code> field of the <code>SubscribeOpts</code>. Otherwise, an incrementing integer is used. The <code>packet_identifier</code> is used to pair the <code>subscribe</code> with corresponding <code>suback</code> which can be retrieved via <code>readPacket()</code>. unsubscribe(state: anytype, opts: UnsubscribeOpts) !usize <code>opts</code> must include at least 1 topic : <code>zig mqtt.unsubscribe(&amp;ctx, .{ .topics = &amp;.{"a/b"}, }</code> This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, <code>error.Usage</code> any error returned from your <code>T.MqttPlatform.write</code>. <code>error.Usage</code> happens if no topic is provided. Returns the <code>packet_identifier</code>. The <code>packet_identifier</code> can be set explicitly via the <code>packet_identifier: ?u16 = null</code> field of the <code>UnsubscribeOpts</code>. Otherwise, an incrementing integer is used. The <code>packet_identifier</code> is used to pair the <code>unsubscribe</code> with corresponding <code>unsuback</code> which can be retrieved via <code>readPacket()</code>. publish(state: anytype, opts: PublishOpts) !usize <code>opts</code> must include at a <code>topic</code> and <code>message</code>. These can be empty (an empty <code>topic</code> is common if <code>topic_alias</code> is set.) <code>zig mqtt.public(&amp;ctx, .{ .topics = "power/goku", .message = "over 9000!" }</code> This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, <code>error.Usage</code> any error returned from your <code>T.MqttPlatform.write</code>. <code>error.Usage</code> happens if the <code>retain</code> flag is set, but the server announced (via the <code>connack</code> message) that it did not support retained messages. Returns the <code>packet_identifier</code>. The <code>packet_identifier</code> can be set explicitly via the <code>packet_identifier: ?u16 = null</code> field of the <code>PublishOpts</code>. Otherwise, an incrementing integer is used. The <code>packet_identifier</code> is used to pair the <code>publish</code> with corresponding <code>pubrec</code> or <code>pubrel</code> assuming the <code>qos</code> option is set. puback(state: anytype, opts: PubAckOpts) !void <code>opts</code> must include the <code>packet_identifer</code> of the <code>publish</code> this message is in response to. This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, any error returned from your <code>T.MqttPlatform.write</code>. pubrec(state: anytype, opts: PubRecOpts) !void <code>opts</code> must include the <code>packet_identifer</code> of the <code>publish</code> this message is in response to. This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, any error returned from your <code>T.MqttPlatform.write</code>. pubrel(state: anytype, opts: PubRelOpts) !void <code>opts</code> must include the <code>packet_identifer</code> of the <code>publish</code> this message is in response to. This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, any error returned from your <code>T.MqttPlatform.write</code>. pubcomp(state: anytype, opts: PubCompOpts) !void <code>opts</code> must include the <code>packet_identifer</code> of the <code>publish</code> this message is in response to. This will call <code>T.write(state, data)</code> exactly once. Possible errors are: <code>error.WriteBufferIsFull</code>, any error returned from your <code>T.MqttPlatform.write</code>. disconnect(state: anytype. opts: DisconnectOpts) !void <code>opts</code> must include the <code>reason</code> for the disconnect. This is an enum. <code>zig * `normal` * `disconnect_with_will_message` * `unspecified` * `malformed_packet` * `protocol_error` * `implementation_specific` * `topic_name_invalid` * `receive_maximum_exceeded` * `topic_alias_invalid` * `packet_too_large` * `message_rate_too_high` * `quota_exceeded` * `administrative_action` * `payload_format_invalid`</code> This will call <code>T.write(state, data)</code> exactly once. Possible errors are: any error returned from your <code>T.MqttPlatform.write</code>. ping(state: anytype) !void This will call <code>T.write(state, data)</code> exactly once. Possible errors are: any error returned from your <code>T.MqttPlatform.write</code>. readPacket(state: anytype) !void Attempts to read a packet from the server. This may call <code>T.read(state, buf, calls)</code> 0 or more times. It will call it 0 times if there is already a packet in <code>read_buf</code> (from a previous call to <code>T.read</code> which read more than 1 packet). <code>calls</code> is the number of times (starting at 1) that <code>T.read</code> has been called in this single invocation of <code>readPacket</code>. This could be used, for example, to control a timeout (in most cases, you'll probably just ignore <code>calls</code>). Possible errors are: - <code>error.Closed</code> - <code>T.read</code> returned 0 - <code>error.ReadBufferIsFull</code> - The packet was too large to fit in <code>read_buf</code> - <code>error.Protocol</code> - A valid packet was received but, from this libraries point of view, the packet didn't make sense. For example, the packet might have had a <code>reason_code</code> which was not valid (not one of the allowed u8 values). If you're using a robust server implementation, this is likely a bug/oversight in this library - <code>error.MalformedPacket</code> - An invalid packet was received which could not be parsed. If you're using a robust server implementation, this is likely a bug/oversight in this library. Plus any error returned by your <code>T.read</code>. On success, <code>readPacket</code> returns a tagged union. This union has the following tags: <ul> <li><code>connack: mqtt.Packet.ConnAck</code></li> <li><code>suback: mqtt.Packet.SubAck</code></li> <li><code>unsuback: mqtt.Packet.UnsubAck</code></li> <li><code>publish: mqtt.Packet.Publish</code></li> <li><code>puback: mqtt.Packet.PubAck</code></li> <li><code>pubrec: mqtt.Packet.PubRec</code></li> <li><code>pubrel: mqtt.Packet.PubRel</code></li> <li><code>pubcomp: mqtt.Packet.PubComp</code></li> <li><code>disconnect: mqtt.Packet.Disconnect</code></li> <li><code>pong: void</code> - called <code>pingresp</code> in the spec, but why?</li> </ul> <code>[]const u8</code> values in the above structures are only valid until the next call to <code>readPacket</code>. See the <a>Flow</a> for more information. Packet.SubAck The <code>subscribe</code> method allows multiple topics to be specified. The corresponding <code>suback</code> contains 1 reason code per topic. If you subscribed to 3 topics, the corresponding <code>suback.results.len</code> should equal 3. However, <code>suback.results</code> is a <code>[]const u8</code>, representing the numeric reason code. Use <code>suback.result(idx) ?mqtt.QoS</code> to get a more meaningful result. When the subscription is success, you'll get a <code>mqtt.Qos</code> enum value indicating the QoS level of the subscription. Else you'll get one of these errors: <ul> <li><code>error.Protocol</code></li> <li><code>error.Unspecified</code></li> <li><code>error.ImplementationSpecific</code></li> <li><code>error.NotAuthorized</code></li> <li><code>error.TopicFilterInvalid</code></li> <li><code>error.PacketIdentifierInUse</code></li> <li><code>error.QuotaExceeded</code></li> <li><code>error.SharedSubscriptionsNotSupported</code></li> <li><code>error.SubscriptionIdentifierNotSupported</code></li> <li><code>error.WildcardSubscriptionsNotSupported</code></li> </ul> Packet.UnsubAck Like <code>subscribe</code> and <code>suback</code>, <code>unsubscribe</code> and <code>unsuback</code> also allow multiple topics to be specified. Again, <code>unsuback.results</code> is a <code>[]const u8</code> representing the underlying integer code for each unsubscribed topic. Use <code>unsuback.result(idx)</code> to get a meaningful error. On success, this returns nothing. Else you'll get an error: <ul> <li><code>error.Protocol</code></li> <li><code>error.NoSubscriptionExisted</code></li> <li><code>error.Unspecified</code></li> <li><code>error.ImplementationSpecific</code></li> <li><code>error.NotAuthorized</code></li> <li><code>error.TopicFilterInvalid</code></li> <li><code>error.PacketIdentifierInUse</code></li> </ul> User Properties All of these packets, except <code>pong</code> might have user properties. These are exposes as an iterator: <code>zig var it = suback.userPropertis(); while (it.next()) |up| { // up.key // up.value }</code> The key and value are only valid as long as the packet is valid (which is only valid until the next call to readPacket). lastReadPacket() []const u8 Returns the full raw packet from the last call to <code>readPacket</code>. Might be useful when debugging.
[]
https://avatars.githubusercontent.com/u/3759175?v=4
dipm
Hejsil/dipm
2024-06-06T19:29:02Z
An alternative to `curl | sh`
master
0
35
0
35
https://api.github.com/repos/Hejsil/dipm/tags
MIT
[ "cli", "package-manager", "zig" ]
668
false
2025-05-21T16:12:10Z
true
true
0.15.0-dev.375+8f8f37fb0
github
[]
A package manager for installing linux programs that are self contained. Packages are defined in <a><code>dipm-pkgs</code></a>. How to install <code>sh curl -L "https://github.com/Hejsil/dipm/releases/latest/download/dipm-$(uname -m)-$(uname -s)-musl" &gt; /tmp/dipm &amp;&amp; chmod +x /tmp/dipm &amp;&amp; /tmp/dipm install dipm &amp;&amp; rm /tmp/dipm</code> Why? I love Arch linux. The main reason for this is the Arch User Repository (AUR). With the AUR, most tools a developer could ever want can be installed on the system with relative ease. But life isn't always kind and sometimes you end up having to use Ubuntu. I'm sure the distro has many advantages, but the package repository is a fraction of the size. I want to use <a>zoxide</a>, <a>eza</a>, <a>fzf</a> and other modern tools, but they either don't exist in the package repo or is very out of date. Most of these tools end up creating distro independent binary releases so anyone can use them. They then guide their users to download and run install scripts like so: <code>sh curl &lt;my-cool-pkg-install-script&gt; | sh</code> But imagine a world where we had a package manager for installing these binaries. This is what <code>dipm</code> tries to be. Why not X? There are package managers that work on multiple distros like <a>homebrew</a> or <a>nix</a>. While these are great, they're quite complicated for what I want. There are also <a>eget</a> and <a>stow</a> which are much simpler. The only issue I see with these is that they are dependent on Github and cannot install binaries from elsewhere.
[]
https://avatars.githubusercontent.com/u/21952395?v=4
build.crab
akarpovskii/build.crab
2024-05-02T15:57:15Z
Build and use Rust libraries from Zig
main
0
35
4
35
https://api.github.com/repos/akarpovskii/build.crab/tags
MIT
[ "cargo", "rust", "zig", "zig-package" ]
176
false
2025-05-18T13:21:07Z
true
true
0.14.0
github
[]
build.crab Thin wrapper around Cargo which integrates it with Zig's build system. Cross-compilation is supported. Requirements Please see <code>.minimum_zig_version</code> field of the <code>build.zig.zon</code> file. Usage <code>sh zig fetch --save git+https://github.com/akarpovskii/build.crab</code> In <code>build.zig</code> (replace <code>crate</code> with the name of your crate): ```zig const build_crab = @import("build_crab"); const crate_artifacts = build_crab.addCargoBuild( b, .{ .manifest_path = b.path("path/to/Cargo.toml"), // You can pass additional arguments to Cargo .cargo_args = &amp;.{ "--release", "--quiet", }, }, .{ // Set to .Debug to see debug logs, // defaults to the same optimization level as your package. .optimize = .ReleaseSafe, }, ); module.addLibraryPath(crate_artifacts); module.linkSystemLibrary("crate", .{}); ``` See <a><code>example</code></a> for the other examples. Cross-compilation Use <code>target</code> argument to specify the cross-compilation target: <code>zig const target = b.standardTargetOptions(.{}); const build_crab = @import("build_crab"); const crate_artifacts = build_crab.addCargoBuild( b, .{ // Cargo params }, .{ .target = target, }, );</code> <code>build.crab</code> binaries will still be built for the native target, but it will try its best to convert Zig's target triple to Rust and call <code>cargo build</code> with the appropriate <code>--target</code> argument. See <a><code>rust.zig</code></a> and the tests at the bottom to know how the conversion is done. Override Rust target Use <code>rust_target</code> from <code>CargoConfig</code> to override the <code>--target</code> argument passed to <code>cargo build</code>: ```zig const target = b.standardTargetOptions(.{}); const build_crab = @import("build_crab"); const crate_artifacts = build_crab.addCargoBuild( b, .{ .rust_target = .{ // Override only some parts .override = .{ .vendor = .{ .custom = "alpine" } }, <code> // Or specify the value explicitly // .value = "x86_64-alpine-linux-musl", }, ... }, ... </code> ); ``` Windows Toolchain By default, Rust on Windows targets MSVC toolchain. This creates additional problems as you have to link against msvcrt, etc. If you want to avoid that, you can target windows-gnu. This is the default behavior of <code>build.crab</code>. Unused symbols I recommend adding the following parameters to <code>Cargo.toml</code>: <code>toml [profile.release] opt-level = "z" # Optimize for size. strip = true lto = true</code> Otherwise, you will have to link some obscure Windows libraries even if you don't use them. And it also makes the size of the rust library smaller. Duplicate symbols [obsolete since Zig 0.14.0 / build.crab 0.2.0] Both Rust and Zig provide <code>compiler_rt.lib</code> with most of the symbols having weak linking, but not <code>___chkstk</code> and <code>___chkstk_ms</code>. So if you want to link against a Rust library that needs these intrinsics, you should somehow resolve the conflict (though I'm not completely sure that it is safe to do). For this purpose, <code>build.crab</code> provides an additional artifact called <code>strip_symbols</code> that repacks <code>.a</code> archive removing <code>.o</code> files containing conflicting functions (provided by the user). ```zig const crate_lib_path = @import("build_crab").addStripSymbols(b, .{ .name = "libcrate.a", .archive = b.path("path/to/libcrate.a"), .symbols = &amp;.{ "___chkstk_ms", }, }); module.addLibraryPath(crate_lib_path.dirname()); module.linkSystemLibrary("crate", .{}); ``` If you use <code>addRustStaticlib</code>, this is already taken care of for you. See the <a><code>buid.zig</code></a> for a complete example.
[]
https://avatars.githubusercontent.com/u/56497124?v=4
gatorcat
kj4tmp/gatorcat
2024-06-24T02:49:33Z
An EtherCAT MainDevice for Zig
main
6
33
2
33
https://api.github.com/repos/kj4tmp/gatorcat/tags
MIT
[ "ethercat", "zig", "zig-package" ]
742
false
2025-05-15T04:40:19Z
true
true
0.14.0
github
[ { "commit": "0e2491d8e6d2be38dc0c2ce8e103469886e468bb", "name": "flags", "tar_url": "https://github.com/n0s4/flags/archive/0e2491d8e6d2be38dc0c2ce8e103469886e468bb.tar.gz", "type": "remote", "url": "https://github.com/n0s4/flags" }, { "commit": "fd3ea547804fdf87465a94adf200539a9a519e42",...
gatorcat <code>gatorcat</code> is an EtherCAT maindevice written in the Zig programming language. <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> <code>gatorcat</code> is <strong>alpha</strong> software. Using it today means participating in its development. You may find bugs or need features implemented before you can use <code>gatorcat</code> effectively. </blockquote> Documentation See <a>doc</a>. Status Notably Working Features <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> no config, "just works" executable <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> automatic configuration to reach OP for most subdevices, via SII and CoE <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> process data published on zenoh <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> verifcation of the network contents against an ethercat network information struct (ENI) <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> cli for scanning a network to generate ENI <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> can manipulate process data <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> CoE startup parameters <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> CLI for scanning networks and getting information about subdevices <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> multi-OS support (Linux and Windows) Notably Missing Features <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> distributed clocks <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> Ethernet Over EtherCAT (EoE), also AoE, FoE, SoE, VoE <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> user configurable processing of CoE emergency messages <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> mapping the mailbox status into the process 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> async / event loop frames <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> multi-threading friendly API <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> linux XDP <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> mac-os, embedded support <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> allocation-free API <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> cable redundancy <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> EtherCAT Network Information(ENI) XML Parsing <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> Segmented SDO transfer <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> EEPROM write access <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> Embedded friendly API / timers <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> Network diagnosis in the CLI (CRC counters etc.) TODO <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> validate individual pdo types at runtime (not just size of pdos) <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> revise error handling <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> python package: hello world <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 a custom <code>@tagName</code> that requires the parameter to be exhaustive Sponsors Please consider <a>❤️ Sponsoring</a> if you depend on this project or just want to see it succeed. Release Procedure <ol> <li>roll version in build.zig.zon</li> <li>commit</li> <li>tag commit</li> <li>push commit, push tags</li> <li>wait for CI pass</li> <li>click release in github</li> </ol>
[]
https://avatars.githubusercontent.com/u/195921428?v=4
opentelemetry-sdk
zig-o11y/opentelemetry-sdk
2024-07-31T20:33:31Z
An implementation of OpenTelemetry SDK in Zig
main
21
32
4
32
https://api.github.com/repos/zig-o11y/opentelemetry-sdk/tags
MIT
[ "observability", "opentelemetry", "zig" ]
26,757
false
2025-05-18T13:01:50Z
true
true
0.14.0
github
[ { "commit": "5ae85ea07dcc415682fc7c23497bf2a602d2d27b", "name": "protobuf", "tar_url": "https://github.com/Arwalk/zig-protobuf/archive/5ae85ea07dcc415682fc7c23497bf2a602d2d27b.tar.gz", "type": "remote", "url": "https://github.com/Arwalk/zig-protobuf" }, { "commit": "v0.9.3.tar.gz", "...
OpenTelemetry Zig <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> This project is a Work In Progress and not ready for production. In fact, it is not even ready for development as it is incomplete in its current form. </blockquote> This is an implementation of the OpenTelemetry specification for the <a>Zig</a> programming language. The version of the specification targeted here is <strong>1.35.0</strong>. Goals <ol> <li>Provide a Zig library implementing the <em>stable</em> features of an OpenTelemetry SDK:<ul> <li>Metrics</li> <li>Traces</li> <li>Logs</li> </ul> </li> <li>Provide a reference implementation of the OpenTelemetry API</li> <li>Provide examples on how to use the library in real-world use cases</li> </ol>
[]
https://avatars.githubusercontent.com/u/7783288?v=4
zenith
mtlynch/zenith
2024-02-11T21:07:46Z
An implementation of the Ethereum virtual machine in pure Zig.
master
9
32
0
32
https://api.github.com/repos/mtlynch/zenith/tags
MIT
[ "ethereum", "zig" ]
255
false
2025-03-05T09:21:18Z
true
false
unknown
github
[]
zenith <a></a> <a></a> An implementation of the Ethereum virtual machine in pure Zig. Project status <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> Execute basic EVM bytecode <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 <a>EVMC interface</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> Support all Ethereum opcodes (currently: <a>19 of 144</a> supported) <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 precompiled 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> Run <a>official Ethereum tests</a> Scope For now, this is a just-for-fun experiment to learn more about Zig and Ethereum. Run VM Run with maximum performance: <code>bash $ echo '60015f526001601ff3' | xxd -r -p | zig build run -Doptimize=ReleaseFast EVM gas used: 17 execution time: 36.685µs 0x01</code> Run in debug mode: <code>bash $ echo '60015f526001601ff3' | xxd -r -p | zig build run debug: PUSH1 0x01 debug: Stack: push 0x01 debug: Gas consumed: 3 debug: --- debug: PUSH0 debug: Stack: push 0x00 debug: Gas consumed: 5 debug: --- debug: MSTORE debug: Stack: pop 0x00 debug: Stack: pop 0x01 debug: Memory: Writing value=0x1 to memory offset=0 debug: Gas consumed: 11 debug: --- debug: PUSH1 0x01 debug: Stack: push 0x01 debug: Gas consumed: 14 debug: --- debug: PUSH1 0x1f debug: Stack: push 0x1f debug: Gas consumed: 17 debug: --- debug: RETURN debug: Stack: pop 0x1f debug: Stack: pop 0x01 debug: Memory: reading size=1 bytes from offset=31 debug: Return value: 0x01 debug: Gas consumed: 17 debug: --- EVM gas used: 17 execution time: 611.780µs 0x01</code> Run unit tests <code>bash zig build test --summary all</code>
[]
https://avatars.githubusercontent.com/u/87844133?v=4
graf
vezel-dev/graf
2024-05-17T20:16:38Z
A graph-oriented intermediate representation, optimization framework, and machine code generator.
master
25
31
2
31
https://api.github.com/repos/vezel-dev/graf/tags
0BSD
[ "c", "compiler", "interpreter", "jit", "language", "optimizer", "runtime", "toolchain", "zig" ]
385
false
2025-05-21T22:15:53Z
true
true
0.13.0
github
[ { "commit": "8a885d8f6b65c6ed44d56a9f51e0401d76e6940d", "name": "aro", "tar_url": "https://github.com/Vexu/arocc/archive/8a885d8f6b65c6ed44d56a9f51e0401d76e6940d.tar.gz", "type": "remote", "url": "https://github.com/Vexu/arocc" }, { "commit": "master", "name": "clap", "tar_url": ...
Graf <strong> A graph-oriented intermediate representation, optimization framework, and machine code generator. </strong> [![License](https://img.shields.io/github/license/vezel-dev/graf?color=brown)](LICENSE-0BSD) [![Commits](https://img.shields.io/github/commit-activity/m/vezel-dev/graf/master?label=commits&amp;color=slateblue)](https://github.com/vezel-dev/graf/commits/master) [![Build](https://img.shields.io/github/actions/workflow/status/vezel-dev/graf/build.yml?branch=master)](https://github.com/vezel-dev/graf/actions/workflows/build.yml) [![Discussions](https://img.shields.io/github/discussions/vezel-dev/graf?color=teal)](https://github.com/vezel-dev/graf/discussions) [![Discord](https://img.shields.io/badge/discord-chat-7289da?logo=discord)](https://discord.gg/wtzCfaX2Nj) [![Zulip](https://img.shields.io/badge/zulip-chat-394069?logo=zulip)](https://vezel.zulipchat.com) <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 is currently in-development vaporware. </blockquote> <strong>Graf</strong> is a graph-oriented compiler infrastructure written in Zig. Chiefly, it provides the Graph Code intermediate representation, a simple optimization framework, and a machine code generator. Graph Code is based on the <a>RVSDG</a>, a novel IR that has a number of desirable properties such as explicit data and state dependencies, inherent static-single assignment form, strong canonicalization, and whole-program representation. Optimization is primarily based on <a>e-graphs and equality saturation</a>. In addition to being a natural fit for the RVSDG, this results in a cohesive framework for discovering rewrites and losslessly adding them to the IR, thus avoiding the phase-ordering problem. For more information, please visit the <a>project home page</a>. Building You will need Zig, Pandoc, and Node.js installed. Simply run <code>zig build</code> to build artifacts. Run <code>zig build --help</code> for a list of configurable options and optional build steps. License This project is licensed under the terms found in <a><code>LICENSE-0BSD</code></a>.
[]
https://avatars.githubusercontent.com/u/910428?v=4
zoop
zhuyadong/zoop
2024-08-08T11:00:27Z
A Zig OOP solution
main
0
29
3
29
https://api.github.com/repos/zhuyadong/zoop/tags
MIT
[ "class", "interface", "oop", "zig", "zig-package" ]
82
false
2025-05-16T01:16:34Z
true
true
0.11.0
github
[]
<a>中文</a> | <a>English</a> Zoop is an OOP solution for Zig Install In the project root directory: <code>shell zig fetch "git+https://github.com/zhuyadong/zoop.git" --save=zoop</code> If you want to install a specific version: <code>shell zig fetch "git+https://github.com/zhuyadong/zoop.git#&lt;ref id&gt;" --save=zoop</code> Define the class <code>``zig // Define a class Human pub const Human = struct { // The first field of the zoop class must be aligned to</code>zoop.alignment` name: []const u8 align(zoop.alignment), age: u8 = 30, <code>// If there is no cleanup work, can skip define `deinit` pub fn deinit(self: *Human) void { self.name = ""; } pub fn getName(self: *const Human) []const u8 { return self.name; } pub fn setName(self: *Human, name: []const u8) void { self.name = name; } </code> }; ``` Creating and destroying class objects ```zig const t = std.testing; // Create a <code>Human</code> on the heap var phuman = try zoop.new(t.allocator, Human, null); // If the class field has a default value, the object field will be initialized to the default value try t.expect(phuman.age == 30); // Destroy the object and release the memory. // If the class defines <code>deinit</code>, it will be called first and then release the memory. zoop.destroy(phuman); // Create a <code>Human</code> on the stack var human = zoop.make(Human, null); // Access object fields through <code>ptr()</code> try t.expect(human.ptr().age == 30); // Clean up the object (call <code>deinit</code> if any). // If there is no work to clean up, you don't need to call <code>zoop.destroy</code> zoop.destroy(human.ptr()); // Both <code>zoop.new</code> and <code>zoop.make</code> support creation-time initialization phuman = try zoop.new(t.allocator, Human, .{.name = "HeapObj", .age = 1}); human = zoop.make(Human, .{.name = "StackObj", .age = 2}); try t.expect(phuman.age == 1); try t.expect(human.ptr().age == 2); <code>`` Note about</code>deinit<code>:</code>zoop.destroy<code>will sequentially call the</code>deinit` method of the class and all its parent classes Inheritance <code>``zig // Define</code>SuperMan<code>, inherit from</code>Human<code>, // the parent class must be the first field and the alignment is</code>zoop.alignment<code>, // The field name is arbitrary and does not have to be</code>super<code>, but it is recommended to use</code>super` pub const SuperMan = struct { super: Human align(zoop.alignment), // SuperMan can live a long time, u8 can't satisfy it, we use u16 age: u16 = 9999, <code>pub fn getAge(self: *SuperMan) u16 { return self.age; } pub fn setAge(self: *SuperMan, age: u16) void { self.age = age; } </code> }; // First create a <code>SuperMan</code> object var psuperman = try zoop.new(t.allocator, SuperMan, null); //Call parent class method psuperman.super.setName("super"); // Or call the parent class method like this. This method is suitable for situations where the // inheritance hierarchy is too deep and you don't know which parent class implements the <code>setName</code> method. // In addition, since it is called <code>upcall</code>, it means that even if <code>SuperMan</code> implements <code>setName</code>, // The following call will still call the <code>setName</code> method of the nearest parent class zoop.upcall(psuperman, .setName, .{"super"}); // You can also flexibly access all fields in the class inheritance tree. For example, // if you want to access the <code>Human.age</code> field, you can do this: var phuman_age = zoop.getField(psuperman, "age", u8); try t.expect(phuman_age.<em> == 30); // Access <code>SuperMan.age</code>, you can do this: var psuper_age = zoop.getField(psuperman, "age", u16); try t.expect(psuper_age.</em> == 9999); // Note that if two <code>age</code> are of the same type and both are called "age", // The above <code>zoop.getField</code> call will cause a compilation error to avoid bugs ``` Class type conversion ```zig // First create a Human and a SuperMan var phuman = try zoop.new(t.allocator, Human, null); var psuper = try zoop.new(t.allocator, SuperMan, null); // Subclasses can be converted to parent classes t.expect(zoop.as(psuper, Human) != null); t.expect(zoop.cast(psuper, Human).age == 30); // The parent class cannot be converted to a subclass (if <code>zoop.cast</code> is used, a compilation error will occur) t.expect(zoop.as(phuman, SuperMan) == null); // A parent class pointer to a subclass can be converted to a subclass phuman = zoop.cast(psuper, Human); try t.expect(zoop.as(phuman, SuperMan) != null); ``` Define the interface <code>``zig // Define an interface</code>IName<code>for accessing names pub const IName = struct { // The interface can only define two fields,</code>ptr<code>and</code>vptr`, // and the names and types must be the same as below ptr: <em>anyopaque, vptr: </em>anyopaque, <code>// Define the `getName` interface method pub fn getName(self: IHuman) []const u8 { return zoop.icall(self, .getName, .{}); } // Define the `setName` interface method pub fn setName(self: IHuman, name: []const u8) void { zoop.icall(self, .setName, .{name}); } // Don't worry about what `zoop.icall` is, just follow it </code> }; // Define another interface <code>IAge</code> for accessing age pub const IAge = struct { ptr: <em>anyopaque, vptr: </em>anyopaque, <code>pub fn getAge(self: IHuman) u16 { return zoop.icall(self, .getAge, .{}); } pub fn setAge(self: IHuman, age: u16) void { zoop.icall(self, .setAge, .{age}); } </code> } // Interfaces can also be inherited pub const INameAndAge struct { pub const extends = .{IName, IAge}; <code>ptr: *anyopaque, vptr: *anyopaque, </code> } // can specify exclude APIs. // Only methods defined in this interface can be specified, // and inherited methods will not be affected. pub const INameAndAge struct { pub const extends = .{IName, IAge}; // exclude “eql" method pub const excludes = .{"eql"}; <code>ptr: *anyopaque, vptr: *anyopaque, pub fn eql(self: INameAndAge, other: INameAndAge) bool { return self.ptr == other.ptr; } </code> } // Interfaces can also provide default implementations of methods, // so that classes that declare to implement interfaces can still // compile and work correctly without implementing these methods // (the interface becomes an abstract class) pub const IName = struct { ...// Same as above code <code>pub fn Default(comptime Class: type) type { return struct { pub fn getName(_: *Class) []const u8 { return "default name"; } } } </code> } ``` Implementing the interface <code>``zig // We let</code>Human<code>implement the</code>IName` interface pub const Human = struct { pub const extends = .{IName}; ...// Same as above code }; // Let <code>SuperMan</code> implement the <code>IAge</code> interface pub const SuperMan = struct { pub const extends = .{IAge}; ...//Same as above code } // The interface implemented by the parent class is automatically implemented by the class, // so <code>SuperMan</code> also implements <code>IName</code>, although it only declares that it implements <code>IAge</code>. // A subclass can repeatedly declare that it implements an interface that has already been implemented // by its parent class. This will not cause any problems and will not affect the results. // For example, the following code is equivalent to the above: pub const SuperMan = struct { pub const extends = .{IAge, IName}; ... } ``` Converting between classes and interfaces ```zig // First create a Human and a SuperMan var phuman = try zoop.new(t.allocator, Human, .{.name = "human"}); var psuper = try zoop.new(t.allocator, SuperMan, .{.super = .{.name = "super"}}); // Human implements IName, so it can be converted var iname = zoop.cast(phuman, IName); // SuperMan implements IAge, so it can be transferred var iage = zoop.cast(psuper, IAge); try t.expect(iage.getAge() == psuper.age); try t.expectEqualStrings(iname.getName(), phuman.name); // Human does not implement IAge, so the conversion will fail. // (Note that now <code>iname</code> points to <code>phuman</code>, and <code>iage</code> points to <code>psuper</code>) try t.expect(zoop.as(phuman, IAge) == null); try t.expect(zoop.as(iname, IAge) == null); // Now let iname point to psuper iname = zoop.cast(psuper, IName); // Or you can write it like this, but the performance is a little affected // (<code>cast</code> is O(1), while <code>as</code> is O(n) in the worst case n=the number of interfaces implemented by SuperMan) iname = zoop.as(psuper, IName).?; // Now iname can be converted to IAge try t.expect(zoop.as(iname, IAge) != null); try t.expectEqualStrings(iname.getName(), "super"); // Everything can be converted to zoop.IObject try t.expect(zoop.as(phuman, zoop.IObject) != null); try t.expect(zoop.as(psuper, zoop.IObject) != null); // Can also be converted back from IObject var iobj = zoop.cast(psuper, zoop.IObject); try t.expect(zoop.as(iobj, SuperMan).? == psuper); <code>`` To summarize</code>cast<code>and</code>as<code>: -</code>cast<code>is applicable - Subclass -&gt; Parent class - Sub-interface -&gt; Parent interface - Class -&gt; Interfaces implemented by the class and its parent class -</code>as<code>is applicable - All the cases where</code>cast<code>is applicable and not applicable (everything can be</code>as`) Method overriding and virtual method calls ```zig // If SuperMan overrides the getName method pub const SuperMan = struct { ...//Same as above <code>pub fn getName(_: *SuperMan) []const u8 { return "override"; } </code> } // Now IName.getName will call SuperMan.getName instead of Human.getName var psuper = try zoop.new(t.allocator, SuperMan, .{.super = .{.name = "human"}}); var iname = zoop.cast(psuper, IName); try t.expectEqualStrings(iname.getName(), "override"); // Another style of calling interface methods try t.expectEqualStrings(zoop.vcall(psuper, IName.getName, .{}), "override"); // Virtual method calls are also useful for converted classes var phuman = zoop.cast(psuper, Human); iname = zoop.cast(phuman, IName); try t.expectEqualStrings(iname.getName(), "override"); try t.expectEqualStrings(zoop.vcall(phuman, IName.getName, .{}), "override"); <code>`` Performance notes for</code>vcall<code>:</code>vcall<code>will use</code>cast<code>when possible, and</code>as` otherwise <code>zoop.IObject.formatAny</code> for print <code>zoop.IObject</code> can conveniently output the string content of the object through the <code>format(...)</code> mechanism of <code>std.fmt</code>. <code>``zig // define a class that implemented</code>zoop.IObject.formatAny` pub const SomeClass = struct { name:[]const u8 align(zoop.alignment) = "some"; <code>pub fn formatAny(self: *SomeClass, writer: std.io.AnyWriter) anyerror!void { try writer.print("SomeClass.name = {s}", .{self.name}); } </code> } // print string from <code>SomeClass.formatAny</code> const psome = try zoop.new(t.allocator, SomeClass, null); std.debug.print("{}\n", .{zoop.cast(psome, zoop.IObject)}); // output: SomeClass.name = some ```
[]
https://avatars.githubusercontent.com/u/680789?v=4
duckdb-extension-template-zig
rupurt/duckdb-extension-template-zig
2024-02-25T03:42:59Z
A Zig template for building DuckDB extensions
main
1
28
0
28
https://api.github.com/repos/rupurt/duckdb-extension-template-zig/tags
MIT
[ "c", "cpp", "duckdb", "duckdb-extension", "federated-query", "zig" ]
11
false
2025-02-01T16:01:59Z
true
true
unknown
github
[]
duckdb-extension-template-zig A Zig &amp; Nix toolkit template for building extensions against multiple versions of DuckDB using Zig, C or C++. Usage ```shell <blockquote> nix develop -c $SHELL duckdb -unsigned D LOAD 'zig-out/lib/quack.duckdb_extension'; D FROM duckdb_extensions(); ┌──────────────────┬─────────┬───────────┬──────────────┬────────────────────────────────────────────────────────────────────────────────────┬───────────────────┐ │ extension_name │ loaded │ installed │ install_path │ description │ aliases │ │ varchar │ boolean │ boolean │ varchar │ varchar │ varchar[] │ ├──────────────────┼─────────┼───────────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────┼───────────────────┤ │ arrow │ false │ false │ │ A zero-copy data integration between Apache Arrow and DuckDB │ [] │ ... │ quack │ true │ │ │ │ [] │ ... │ visualizer │ true │ │ │ Creates an HTML-based visualization of the query plan │ [] │ ├──────────────────┴─────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────────────────────────────┴───────────────────┤ │ 24 rows 6 columns │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ D FROM duckdb_extensions(); WHERE function_name ILIKE '%quack%'; ┌───────────────┬─────────────┬───────────────┬───────────────┬─────────────┬─────────────┬───┬─────────┬──────────────────┬──────────────────┬──────────┬──────────────┬─────────┐ │ database_name │ schema_name │ function_name │ function_type │ description │ return_type │ … │ varargs │ macro_definition │ has_side_effects │ internal │ function_oid │ example │ │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │ │ varchar │ varchar │ boolean │ boolean │ int64 │ varchar │ ├───────────────┼─────────────┼───────────────┼───────────────┼─────────────┼─────────────┼───┼─────────┼──────────────────┼──────────────────┼──────────┼──────────────┼─────────┤ │ system │ main │ quack │ scalar │ │ VARCHAR │ … │ │ │ false │ true │ 1473 │ │ ├───────────────┴─────────────┴───────────────┴───────────────┴─────────────┴─────────────┴───┴─────────┴──────────────────┴──────────────────┴──────────┴──────────────┴─────────┤ │ 1 rows 14 columns (12 shown) │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ D SELECT quack('howdy'); ┌────────────────┐ │ quack('howdy') │ │ varchar │ ├────────────────┤ │ Quack howdy 🐥 │ └────────────────┘ ``` </blockquote> How it Works DuckDB is a fast in-process analytical database written in C++ that can be extended by creating and loading a dynamically linked library using the <a>extension API</a>. Typically extensions are written in C++ using the officially supported <a>extension template</a>. But you're one of the cool kids and want to write your extension in Zig! Fortunately the <a>Zig build system</a> ships with a Zig, C &amp; C++ compiler. 1. Create a project directory initialized with the multi flake template The Nix environment generated by the <code>flake.nix</code> <a>template</a> provides a self contained Linux &amp; MacOS development toolchain: <ul> <li>Clang (16.0.6)</li> <li>libcxx headers (16.0.6)</li> <li>Zig <code>master</code> (0.12.0-dev.3247+26e895e3d)</li> <li>Multiple <code>duckdb</code> CLI &amp; <code>libduckdb</code> versions linked to the same versions of <code>libc</code> &amp; <code>libcxx</code> as the Zig compiler (v0.10.0, v0.9.2 &amp; main)</li> </ul> ```shell <blockquote> mkdir myextension &amp;&amp; cd myextension nix flake init -t github:rupurt/duckdb-extension-template-zig#multi nix develop -c $SHELL ``` </blockquote> 2. Implement 2 extension loader functions When a DuckDB extension is loaded via <code>LOAD 'myextension.duckdb_extension';</code> it requires <a>2 symbols</a> to be defined (<code>myextension_version</code> &amp; <code>myextension_init</code>). The value returned from <code>*_init</code> must match the version of DuckDB loading the extension. We create a <a>simple header file</a> to expose these 2 symbols in our built extension. 3. Create a C++ bridge that calls <code>DuckDB::ExtensionUtil</code> The extension utils helper plugs into DuckDB internals such as: <ul> <li>scalar functions</li> <li>table functions</li> <li>custom catalogs</li> <li>much more...</li> </ul> The example in this repository <a>registers a simple scalar function</a> called <code>quack</code> 4. Configure the Zig build system and compile the extension The Zig build system is configured in <a>build.zig</a>. <ul> <li>We'll need to add a <a>shared library</a> exposing the DuckDB extension hooks defined in <code>root.zig</code>.</li> <li>Add the <a>include</a> path for the <a>C header file</a> exposing these hooks.</li> <li>Don't forget the <a>C++ bridge</a></li> <li>By convention DuckDB extensions use the file suffix <code>.duckdb_extension</code>. Zig writes the dynamic library using the format <code>libmyextension.[so|dylib|dll]</code>. Add a custom install step to use the DuckDB naming convention for the <a>extension filename</a>.</li> </ul> Limitations Currently this template can only build extensions using versions of <code>duckdb</code> provided by the <a>duckdb-nix</a> flake. The derivation built by the flake includes header files for <code>duckdb</code> <a>third_party</a> dependencies. I have opened a <a>Github issue</a> to include those libraries in the <code>nixpkgs</code> derivation. Development This repository assumes you have Nix <a>installed</a> ```shell <blockquote> nix develop -c $SHELL nix develop .#v0-10-0 -c $SHELL nix develop .#v0-9-2 -c $SHELL nix develop .#main -c $SHELL ``` </blockquote> ```shell <blockquote> make ``` </blockquote> Run the Zig test suite ```shell <blockquote> make test ``` </blockquote> Delete artifacts from previous builds ```shell <blockquote> make clean ``` </blockquote> Build extension binary with Zig ```shell <blockquote> make build ``` </blockquote> Run <code>duckdb</code> cli allowing <code>-unsigned</code> extensions ```shell <blockquote> make run ``` </blockquote> License <code>duckdb-extension-template-zig</code> is released under the <a>MIT license</a>
[]
https://avatars.githubusercontent.com/u/11492844?v=4
fuzzig
fjebaker/fuzzig
2024-04-05T22:27:07Z
Fuzzy finder algorithms a la Smith-Waterman for Zig.
main
0
28
1
28
https://api.github.com/repos/fjebaker/fuzzig/tags
MIT
[ "alignment", "fuzzy-finder", "fuzzy-search", "fzf", "smith-waterman", "zig" ]
124
false
2025-03-23T07:03:00Z
true
true
unknown
github
[]
fuzzig Fuzzy finder algorithms in Zig based on the <a>Smith-Waterman algorithm</a>, inspired by <a>fzf</a>. For Unicode support, use the <a>unicode branch</a>. Example ```zig const std = @import("std"); const fuzzig = @import("fuzzig"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>// The default implementation needs to know the maximum haystack and needle // sizes so that it can allocate all memory contiguously. Smaller haystack // or needle strings will use subsets of the allocated memory. var searcher = try fuzzig.Ascii.init( allocator, 128, // haystack max size 32, // needle max size .{ .case_sensitive = false }, ); defer searcher.deinit(); const haystack = "Hello World"; const needle = "world"; const score = searcher.score(haystack, needle); std.debug.print("Score: {d}\n", .{score.?}); // Get a traceback of the character positions that were matched const match = searcher.scoreMatches(haystack, needle); std.debug.print( "Score with traceback: {d} {any}\n", .{ match.score.?, match.matches }, ); </code> } ``` Output <code>Score: 104 Score with traceback: 104 { 6, 7, 8, 9, 10 }</code> The traceback shows the indices of the haystack that were matched, useful for generating visual feedback. See the <a><code>AsciiOptions</code> struct</a> for a list of available options. Design The module defines an <code>Algorithm</code> generic type, which accepts the element type of the array to be fuzzy searched, the score type and values, and an algorithm implementation. The implementation must define an <code>eqlFunc</code>, a <code>scoreFunc</code> and a <code>bonusFunc</code> used to test for equality between tokens, for determining the score of two matching tokens, and for determining any in-places bonuses respectively. <ul> <li>Algorithms only have <code>score</code> and <code>scoreMatches</code> as public functions.</li> <li>If not matches are detected, the score will be <code>null</code>.</li> </ul> Usage The library was written with Zig 0.12.0-dev.3541+05b185811, but there is likely a lot of flexibility with versioning. <ul> <li>Currently supported version: Zig 0.14.0-dev.2628+5b5c60f43</li> </ul> To use in a Zig project, add it to your <code>build.zig.zon</code> <code>zig // ... .dependencies = .{ .fuzzig = .{ .url = "https://github.com/fjebaker/fuzzig/archive/main.tar.gz", .hash = "" // get with `zig fetch` }, }, // ...</code> Then add the module to your build step in <code>build.zig</code>: ```zig // ... const fuzzig = b.dependency("fuzzig", .{}).module("fuzzig"); <code>my_exe_or_lib.root_module.addImport("fuzzig", fuzzig); // ... </code> ```
[ "https://github.com/fjebaker/zorro", "https://github.com/neurocyte/flow" ]
https://avatars.githubusercontent.com/u/51087818?v=4
zig-jni
SuperIceCN/zig-jni
2024-02-18T14:10:32Z
Zig-JNI helps you to impl Java native methods in Zig.
main
0
25
2
25
https://api.github.com/repos/SuperIceCN/zig-jni/tags
MIT
[ "c", "cpp", "interop", "java", "jni", "zig", "zig-package" ]
64
false
2025-05-20T04:11:53Z
true
true
0.14.0
github
[]
Zig-JNI Zig-JNI is a thin wrapper around the Java Native Interface (JNI) for the Zig programming language. It is designed to be a simple and easy-to-use interface for implementing Java native methods in Zig. Please note that this project is <strong>still in the early stages</strong> of development, and it is <strong>not</strong> yet ready for production use. This project was initially created as a part of another project of mine which provides a write-one-run-anywhere solution for GPGPU programming using java language, and I will continue to improve it as I work on that project. Since this project is licensed under the MIT license, you are free to use it in your own projects, but please be aware that it is still a work in progress, and it may contain bugs or other issues. If you encounter any problems, please feel free to open an issue or submit a pull request. Why Zig? Zig is a modern, general-purpose programming language with a focus on safety, performance, and simplicity. It is designed to be a better C, and it is a great fit for implementing native methods in Java. The important features of Zig, especially for JNI development, are: <ul> <li><strong>First-class support for cross-compilation</strong>: Zig can compile code for any platform from any platform, and it can do so with a single command. This makes it easy to build JNI libraries for multiple platforms from a single machine.</li> <li><strong>No runtime</strong>: Zig has no runtime, and it does not require a runtime to be present on the target system. This makes it easy to build small, self-contained JNI libraries that can be easily distributed and used.</li> <li><strong>C &amp; C++ interoperability</strong>: Zig has first-class support for interoperating with C and C++ code, which makes it easy to work with the JNI API and other C libraries.</li> </ul> Platform Support | | Linux | Windows | macOS | | --- | --- | --- | --- | | x86_64 | ✅ | ✅ | ✅ | | aarch64 | ✅ | ❓ | ❓ | | armv7 | ❓ | ❌ | ❌ | <ul> <li>✅ Supported</li> <li>❓ Untested, but should work</li> <li>❌ Not supported</li> </ul> Import the library <strong>First</strong>, add Zig-JNI to your <code>build.zig.zon</code> file (Don't forget to replace <code>{VERSION}</code> with the version you want to use) : <code>zon .{ .name = "...", .version = "...", .dependencies = .{ .jni = .{ .url = "https://github.com/SuperIceCN/Zig-JNI/archive/refs/tags/{VERSION}.tar.gz", } }, }</code> <strong>Second</strong>, Run zig build in your project, and the compiler will instruct you to add a .hash = "..." field next to .url. The instruction will look like this: <code>note: expected .hash = "1220a61eebdcda95a9e51e2a4f237522d407a0404aea4225fc27b2bb1d32f27edf9c",</code> <strong>Third</strong>, use the dependency in your <code>build.zig</code> : <code>zig pub fn build(b: *std.Build) void { // depdencies const dep_JNI = b.dependency("jni", .{}).module("JNI"); // ... artifact.root_module.addImport("jni", dep_JNI); // here artifact is the return value of b.addExecutable / b.addSharedLibrary / b.addStaticLibrary // ... }</code> Example Here is a simple example of how to use Zig-JNI to implement a native method in Java: <code>com/example/SimpleAdd.java</code> : ```java package com.example; public class SimpleAdd { static { System.load("/path/to/shared_librarys.so"); } <code>private static native int add(int a, int b); public static void main(String[] args) { var a = Integer.parseInt(args[0]); var b = Integer.parseInt(args[1]); System.out.println("Answer: " + add(a, b)); } </code> } ``` <code>SimpleAdd.zig</code> : ```zig const std = @import("std"); const jni = @import("jni"); pub fn add(cEnv: *jni.cEnv, _: jni.jclass, a: jni.jint, b: jni.jint) callconv(.C) jni.jint { return a + b; } ``` <code>root.zig</code> : ```zig const jni = @import("jni"); comptime { jni.exportJNI("com.example.SimpleAdd", @import("SimpleAdd.zig")); } ```
[]
https://avatars.githubusercontent.com/u/7550632?v=4
graphon
ekzhang/graphon
2024-05-19T15:19:04Z
🌌 A very small graph database (WIP, inactive)
main
0
23
1
23
https://api.github.com/repos/ekzhang/graphon/tags
-
[ "database", "gql", "graph-database", "zig" ]
253
false
2025-05-15T09:11:39Z
true
true
0.13.0
github
[]
Graphon A very small graph database. <code>gql MATCH (db:Database {name: 'graphon'})&lt;-[:Wrote]-(p:Person) RETURN p.name</code> Can be queried with <a>GQL</a>, the ISO-standard graph query language. Getting started Graphon is a single binary that implements almost the entire GQL standard, to specification. You can query it either from Neo4j client libraries, or by making an HTTP request in any language. To start a database, just download the binary and run it. <code>sh-session $ graphon $ curl "http://127.0.0.1:7687/?query=RETURN%2055" 55</code> The recommended way to explore a running Graphon database is through the CLI. ```sh-session $ graphon-cli Connected to http://127.0.0.1:7687 <blockquote> RETURN 100 * 3 300 ``` </blockquote> Features Graphon implements the <a>GQL</a> language for graph queries, which is defined in <a>ISO/IEC 39075:2024</a>. This standard was recently published in April 2024, so there's not many resources on it yet. You can find some documentation on the <a>Google Spanner</a> website. A simple graph query looks like this: <code>gql MATCH (a:User {name: 'Eric'})-&gt;[:Likes]-&gt;(f:Food) RETURN f.name, f.calories</code> GQL is a powerful language. Here is a larger example that demonstrates a few features: <ul> <li><strong>Pattern Matching:</strong> Find a variable-length path (trail) between follower and influencer nodes, allowing for a chain of connections between one and three <code>Follows</code> relationships deep.</li> <li><strong>Complex Filtering:</strong> Uses the <code>WHERE</code> clause to filter for influencers who have created popular posts (with more than 100 likes).</li> <li><strong>Aggregation:</strong> <code>OPTIONAL MATCH</code> finds recent posts created by the influencer to enrich the output, and <code>WITH</code> implicitly aggregates them.</li> <li><strong>Structured Output:</strong> Returns distinct named results including names, the titles of popular posts, the count of recent posts, and the entire trail of connections.</li> <li><strong>Ordering and Limiting:</strong> Orders and limits the output to the top 10 results.</li> </ul> <code>gql MATCH TRAIL (follower:Person) ((nodes)-[:Follows]-&gt;()){1,3} (influencer:Person), (influencer)-[:Created]-&gt;(post:Post), (follower)-[:Likes]-&gt;(post) WHERE post.likes_count &gt; 100 OPTIONAL MATCH (influencer)-[:Created]-&gt;(otherPost:Post) WHERE otherPost.creation_date &gt; DATE '2024-01-01' WITH follower, influencer, post, nodes, COUNT(otherPost) AS recentPosts RETURN DISTINCT follower.name AS FollowerName, influencer.name AS InfluencerName, post.title AS PopularPost, recentPosts AS RecentPostCount, nodes AS FollowerTrail ORDER BY RecentPostCount DESC, InfluencerName LIMIT 10;</code> You can also insert, modify, and delete graph data. ```gql // Insert nodes and edges INSERT (a:Building {address: '285 Fulton St', city: 'New York', state: 'NY', zipcode: 10007}) INSERT (a)-[:Nearby]-(:Geography {name: 'Hudson River', type: 'water'}) INSERT (a)-[:Nearby]-(:Geography {name: 'The Battery', type: 'park'}) // Modify properties MATCH (p:Person {name: 'Eric'}) SET p.age = 23 // Delete a node and attached edges MATCH (x:Account)-[:Invoice {unpaid: true}]-&gt;(:Account {id: 627}) DETACH DELETE x ``` Graphon can be queried via HTTP (results sent in JSON format) or <a>Bolt</a> sessions. Concurrent transactions implement <a>snapshot isolation</a> to ensure consistency. The core GQL language includes graph pattern-matching queries, transactional updates, catalog changes, and list data types. These features are explicitly <em>not</em> supported right now: <ul> <li>Having multiple directories and schemas in one database</li> <li>Having multiple graphs in one database</li> <li>Typed graphs, nodes, and edges (i.e., closed type schemas)</li> <li>Named procedures</li> <li>The datetime data type and storing time zones</li> <li>Identifiers (variable names) using non-ASCII characters</li> </ul> You could consider using Graphon when you want something small and low-overhead, yet still powerful. Limitations Graphon is a very small project. It tries to be fast where possible, but the query planner is not going to be very advanced. It won't perfectly optimize every query out there. I made this database primarily out of personal interest, to experiment with algorithms, and to learn what goes into a modern database. There will be bugs. Also, the on-disk format is unstable. <strong>Do not use Graphon as a store for production data.</strong> Architecture The database itself is written in Zig and based on RocksDB as a foundational storage layer. <ol> <li><strong>Session manager:</strong> Listens for requests over HTTP and Bolt protocols, creates new sessions.</li> <li><strong>Tokenizer and parser:</strong> Convert text queries into an abstract syntax tree.</li> <li><strong>Query planner:</strong> Translate each query into an optimized, low-level query plan.</li> <li><strong>Execution engine:</strong> Safely execute query plans with specific graph algorithms in an interruptible, streaming API.</li> <li><strong>Storage and transactions:</strong> Move and fetch data from durable storage, hold transaction locks, and page files via RocksDB.</li> </ol> Query plans Query plans are constructed out of the following operations. The design here was influenced by other databases, particularly the internal representations of <a>Postgres</a> and <a>Neo4j</a>. <ul> <li><code>NodeScan</code>: Scan for nodes in a graph, optionally providing labels.</li> <li><code>EdgeScan</code>: Scan for edges in a graph, optionally providing labels.</li> <li><code>NodeById</code>: Fetch the node with an ID.</li> <li><code>EdgeById</code>: Fetch the edge with an ID.</li> <li><code>Step</code>: Traverse the graph for edges from a node.</li> <li><code>StepBetween</code>: Traverse the graph for edges between two nodes.</li> <li><code>Begin</code>: Marker node for the start of the right subtree of a repeat or join operator.</li> <li><code>Argument</code>: Marks a variable for the node or edge being repeated in a path.</li> <li><code>Repeat</code>: Repeat the sub-pattern, used for trail and path queries.</li> <li><code>ShortestPath</code>: Finds the shortest path(s) between two nodes.</li> <li><code>Join</code>: Take rows from the left subquery, execute the tree on the right subquery, and return both.</li> <li><code>SemiJoin</code>: Return rows from the left subquery where the right subquery is not null.</li> <li><code>Anti</code>: Test for the absence of a pattern, yielding a single row.</li> <li><code>Project</code>: Execute expressions or remap variable names.</li> <li><code>ProjectEndpoints</code>: Find the endpoints of an edge.</li> <li><code>EmptyResult</code>: Retrieve all results and drop them, used as the last operator in mutations.</li> <li><code>Filter</code>: Filter results by label presence or conditional expression.</li> <li><code>Limit</code>: Limit the count of result rows.</li> <li><code>Distinct</code>: Remove duplicate rows from the result.</li> <li><code>Skip</code>: Skip rows from the result.</li> <li><code>Sort</code>: Sort results by a provided key.</li> <li><code>Top</code>: Return some number of top rows by a provided key in sorted order (sort then limit).</li> <li><code>UnionAll</code>: Concatenates results from the left and right subqueries.</li> <li><code>InsertNode</code>: Insert a graph node with labels and properties.</li> <li><code>InsertEdge</code>: Insert an edge with direction, labels, and properties between two nodes.</li> <li><code>Update</code>: Set, add, or remove labels and properties from nodes and edges.</li> <li><code>Delete</code>: Delete a node or edge.</li> <li><code>Aggregate</code>: Compute aggregations, grouping by one or more columns.</li> <li><code>GroupAggregate</code>: Compute aggregations, where result table is already ordered into groups.</li> </ul> There needs to be particular attention paid to graph algorithms to implement certain kinds of path queries efficiently, especially those that traverse paths or trails. We'll add new types of backend operations as Graphon's query language increases in expressivity.
[]
https://avatars.githubusercontent.com/u/301903?v=4
ziege
photex/ziege
2024-06-04T20:28:23Z
A friendly Zig launcher and toolchain manager.
main
0
22
1
22
https://api.github.com/repos/photex/ziege/tags
Apache-2.0
[ "tools", "zig" ]
207
false
2025-02-23T05:01:21Z
true
false
unknown
github
[]
Ziege manages zig toolchains and zls releases on your system (automatically configured by a <code>.zigversion</code> in your repo root). When used as an alias (either by renaming it, or by symlink) to Zig it will seamlessly dispatch all command line arguments to the correct Zig binary for a project. Using Ziege should be totally transparent and should be the only tool you need to setup for working with Zig. <blockquote> Development is mostly happening at <a>Sourcehut</a>. I push to github frequently enough though and releases are hosted here for the moment because, sadly, github is where people expect to find things. </blockquote> This tool was inspired by <a>Bazelisk</a>. Feature Checklist Ziege is still in it's very early stagess but can hopefully be as useful for you as it is for me. Bug reports, feature requests, or any other sort of contribution are all greatly appreciated. <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> Download Zig toolchain indicated by a project <code>.zigversion</code>. <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> Works on major desktop platforms. <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> Windows <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> Linux <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> MacOS (<em>Not yet tested. Help appreciated!</em>) <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> Works on more esoteric platforms. <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> Haiku :D <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> Simple proxy for Zig. <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> Allow zig version override with launcher args (ex: <code>+version=0.12.0</code>) <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> Simple proxy for Zls. <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> Update pinned Zig version. <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> List installed Zig versions. <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 Zig toolchains. <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> Remove Zig toolchains. <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> Gracefully fail in the face of edge cases, network failures, and other problems. <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> Configure a default Zig toolchain version for when a repo doesn't specify one. <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> Allow configuration of alternate Zig and Zls indexes. <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> Allow configuration of the location of Zig toolchains. <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 symlinks in a repo (ex: <code>&lt;repo&gt;/tools/zig</code>) for folks that do not wish to use Ziege as a proxy. <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> Be your one stop shop for all your Zig tool needs! Installing Download a binary for your platform from one of the <a>releases</a> and place it somewhere in PATH. <code>sh wget https://github.com/photex/ziege/releases/download/v0.3.0/ziege-linux-x86_64 -O ziege</code> Make a symlink or a copy named <code>zig</code> and <code>zls</code>. <code>sh ln -s ziege zig ln -s ziege zls</code> And now you can use Zig as you normally would with the benefit of having toolchains automatically downloaded for you. Currently I'm testing ziege on Windows 11 and Linux (AlmaLinux 9.4) and using it to build ziege itself. I've tested zeige with some other repositories such as <a>zig-gamedev</a>, <a>sokol-zig-imgui-sample</a>, and the <a>delve-framework</a>. <blockquote> Note for cmd.exe users: For whatever reason, a symlink or copy of ziege.exe that is renamed to zig.exe or zls.exe will always get resolved as 'ziege.exe' when running the program. It only seems to affect you when you let cmd.exe resolve their location via %PATH%. If you use an absolute path to them <em>including the .exe file extension</em> then it would work. As a workaround for that (if you aren't willing to use pwsh/powershell) I have added two batch files to this repo that you can place somewhere in your %PATH% instead. </blockquote> Building It's a very straight forward <code>zig build</code> situation and at this point I'm using ziege while building ziege. :D If you build a debug version there will be some extra logging output that you wouldn't otherwise see. Modes Zig mode In this mode, ziege is a proxy for a specific zig release. This mode is activated when ziege is named 'zig' (either via a symlink or by making a copy), or if you run ziege with the <code>+zig</code> launcher arg. Ziege will try and determine the zig version to proxy by reading a file named <code>.zigversion</code> in the current working directory. If that is not found <em>ziege will use the current nightly version of zig</em>. You can override this version by using a "launcher arg": <code>sh zig +version=0.12.0 build run</code> In the event you want to always use this version you can have ziege update your .zigversion file: <code>sh zig +set-version=0.12.0 build run</code> It is also possible to set the version or override <code>.zigversion</code> with the environment variable <code>ZIG_VERSION</code>. And zeige will set that env var with running zig or zls so that any call to zig as a child process that relies on finding zig in PATH will end up using the correct version (which appears to happen for 'zig build' dependencies specified as paths in build.zig.zon). In all cases, if the resolved version isn't found then it will be downloaded first. Zls mode In this mode, ziege is a proxy for the zls associated with your specified zig version. This mode is activated when ziege is named 'zls' (either via a symlink or by making a copy), or if you run ziege with the <code>+zls</code> launcher arg. The same launcher args available to zig mode are available in zls mode by virtue of essentially being a single implementation for the proxy. Ziege mode In this mode ziege offers some basic toolchain management commands. <code>sh ziege list ziege add 0.12.0 ziege remove 0.11.0 ziege set-version 0.12.0 ziege update ziege help</code> When using <code>set-version</code> to update your .zigversion file, the specified toolchain will be downloaded if it isn't already installed. How it works When you run Ziege, it searches for a <code>.zigversion</code> file in the current working directory. If that is found the contents are read and used to locate an appropriate toolchain. In the event that no version file is present in the repo yet, Ziege will resolve the latest nightly and use that version. In addition to reading the desired version from a .zigversion file, you can use "launcher args" to set the version as well. Launcher args start with '+' and are not passed to Zig or Zls. <code>+version=X</code> will override a .zigversion file. Finally, you can use the environment variable ZIG_VERSION. The precedence for setting the zig version is: <ul> <li>Environment</li> <li>Launcher args</li> <li>.zigversion</li> </ul> If a toolchain matching the specified version isn't present on your system already, then it will be downloaded and unpacked into a standard location. Once a toolchain is located, Ziege will run the tool it's proxying and forward any command line arguments that didn't start with '+' to it. Where do we store toolchains? At the moment we create a <code>ziege</code> folder under the AppData path for your system. On Linux this is <code>$HOME/.local/share/ziege</code>, and on Windows this is <code>%USERPROFILE%\AppData\Local\ziege</code> From where do we download Zig and Zls? We cache the release indexes and use this to resolve the current nightly version or get the url for a tagged release. Because these indexes do not contain information for every nightly build, if a repo is pinned to a nightly build we have to derive the url for that toolchain. Regarding Zls <em>We only install Zls by using information in their release index. Stable versions might not line up perfectly to Zig releases as a result of the two projects being independent of each other.</em> <blockquote> Removing and adding a zig version would then also re-download zls, so once a matching tagged release was available you'd also then have it. I'm sure that some of this can be automated, but for the moment I think a light touch is best. </blockquote> Why is it called "Ziege"? Ziege is the German word for Goat, it starts with the letter 'Z', and I once overheard someone talking about Zig on the train who pronounced Zig with an accent which sounded to me like <em>tsee-guh</em>. This coincidentally is how you pronouce the German word. Ziege looks similar to the English word 'siege' and so perhaps you pronounce it <em>zeej</em>. However you like to pronounce it is fine.
[]
https://avatars.githubusercontent.com/u/143469704?v=4
synapse
Cohesible/synapse
2024-06-07T21:14:00Z
TypeScript toolchain for developing cloud-based apps
main
8
22
1
22
https://api.github.com/repos/Cohesible/synapse/tags
Apache-2.0
[ "aws", "bundler", "cloud", "devops-tools", "devtool", "nodejs", "npm", "react", "serverless", "synapse", "terraform", "typescript", "zig" ]
1,265
false
2025-02-21T08:11:57Z
false
false
unknown
github
[]
Synapse <a> </a> <a target="_blank"> </a> Synapse is a toolchain for building and deploying TypeScript applications, from CLI tools to full-stack apps. Your application's infrastructure is defined within the application itself. Features: * Multi-phase programming - run code at build time to create exactly what you need * Cloud agnostic libraries - write once, deploy anywhere, including locally * Automatic permissions solver - least privilege permissions via symbolic execution * <a>Native modules</a> - write modules using Zig (experimental) * Everything you need, built-in * TypeScript compiler and bundler * Incremental builds (distributed caching coming soon) * Extremely fast package manager * Node.js compatible JavaScript runtime * <a>A testing framework</a> * Deployment engine compatible with Terraform providers ```main.ts import { Bucket } from 'synapse:srl/storage' // <code>Bucket</code> is a storage resource, which can be deployed locally or to the cloud const bucket = new Bucket() export async function main() { const data = await bucket.get('hello', 'utf-8') console.log('hello', data) <code>if (data === undefined) { await bucket.put('hello', 'world!') console.log('Wrote to the bucket, run me again!') } </code> } ``` <code>shell synapse deploy synapse run</code> How it works One way to think about Synapse is to imagine a "metaprogram" that controls <em>what</em> code is executed and <em>where</em> it is executed. Synapse enables you to write code describing this metaprogram within traditional code. The basic idea is that your code is executed at build time to generate instructions for your metaprogram. An instruction is best thought of as an individual goal state. For example, writing <code>new Bucket()</code> describes an instruction that creates a bucket if it does not already exist. Most instructions exist as configuration for resources. The remaining instructions are purely computational. A "resource" is essentially anything that can be configured and persisted at build time. The idea of resources is deeply integrated into Synapse, meaning you can find them in many places: * Classes exported by <code>synapse:srl/*</code> modules * <a>Generated "provider"</a> classes * User-defined <a>custom resources</a> * Utility functions/classes in <code>synapse:lib</code> (most notably, <code>Bundle</code>) <code>synapse deploy</code> executes (or applies) your metaprogram, creating or updating a deployment. Deployments are the side-effects of instructions and their resulting state. Note that resources are effectively "frozen" outside of <code>synapse deploy</code>. Trying to create/update resources at runtime using Synapse APIs will fail. Installation These commands download and execute <a>a script</a> that will: * Download a release compatible with your system * Extract to <code>~/.synapse</code> * Add <code>synapse</code> to your PATH macOS/Linux <code>shell curl -fsSL https://synap.sh/install | bash</code> Windows <code>shell irm https://synap.sh/install.ps1 | iex</code> Getting Started See <a>Quick Start</a> for basic instructions. For help with specific features: * <a>Custom Resources</a> * <a>Environments</a> * <a>Packages</a> * <a>Tests</a> * <a>Providers</a> Attributions The core functionality of Synapse is built on top of several amazing projects: * <a>TypeScript</a> * <a>esbuild</a> * <a>Node.js</a> * <a>Terraform 1.5.5</a> And it wouldn't have been possible to create Synapse without them and their contributors! Each cloud target also uses their respective SDK + Terraform provider. The AWS target uses: * <a>AWS SDK for JavaScript v3</a> * <a>Terraform AWS Provider</a> A few things were also inspired by <a>Bun</a>. Most notably is the usage of Zig.
[]
https://avatars.githubusercontent.com/u/31826595?v=4
zdt
FObersteiner/zdt
2024-05-04T10:06:10Z
Timezoned Datetime in Zig
master
0
22
2
22
https://api.github.com/repos/FObersteiner/zdt/tags
MPL-2.0
[ "date", "datetime", "duration", "time", "timezones", "zig", "zig-package", "ziglang" ]
14,993
false
2025-05-13T10:35:12Z
true
true
0.14.0
github
[]
zdt Please Note... <strong>This repository is only a mirror of <a>zdt on Codeberg</a>.</strong> If you want to contribute (which is very welcome!) or raise an issue, please do so over there.
[ "https://github.com/ceyhunkerti/oracle_tocsv", "https://github.com/dasimmet/zig-git-crawler" ]
https://avatars.githubusercontent.com/u/205094268?v=4
wasmer-zig-api
zig-wasm/wasmer-zig-api
2024-05-20T14:28:29Z
Zig bindings for the Wasmer WebAssembly runtime
main
0
22
2
22
https://api.github.com/repos/zig-wasm/wasmer-zig-api/tags
MIT
[ "wasi", "wasm", "wasmer", "webassembly", "zig", "ziglang" ]
878
false
2025-04-28T13:40:59Z
true
true
0.14.0
github
[]
wasmer-zig-api Zig bindings for the <a>Wasmer</a> WebAssembly runtime. This module is based on the zigwasm/wasmer-zig fork. The old API does not work with newer versions of zig, and the main goal of this project is to continue to support the module for newer versions of zig. All WASI APIs are also implemented. All tests from the "wasmer" lib C repository are also reimplemented on zig. You can learn more about the API of this module through rich examples. The current module works with Zig 0.14.0+. Wasmer C API test examples [WIP] <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> early-exit.c <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> exports-function.c <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> exports-global.c <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> features.c <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> imports-exports.c <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> instance.c <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> memory.c <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> memory2.c <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> wasi.c Running tests and examples The <code>WASMER_DIR</code> environment variable is used to determine the presence and location of the Wasmer library. Ensure this variable is set correctly to avoid issues with library detection. <ul> <li> Run library unit tests: <code>bash zig build test</code> </li> <li> Build and run examples: <code>bash zig build run -Dexamples=true</code> </li> </ul> Using it In your zig project folder (where build.zig is located), run: <code>bash zig fetch --save "git+https://github.com/Afirium/wasmer-zig-api#v0.3.0"</code> Then, in your <code>build.zig</code>'s <code>build</code> function, add the following before <code>b.installArtifact(exe)</code>: <code>zig const wasmerZigAPI= b.dependency("wasmer_zig_api", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("wasmer", wasmerZigAPI.module("wasmer")); exe.linkLibC(); exe.addLibraryPath(.{ .cwd_relative = "/home/path_to_your_wasmer/.wasmer/lib" }); exe.linkSystemLibrary("wasmer");</code> Status | Refname | Wasmer runtime version | Zig <code>0.12.x</code> | Zig <code>0.13.x</code> | Zig <code>0.14.x</code> | Zig <code>0.15.0-dev</code> | |:----------|:-----------------------|:------------:|:------------:|:------------:|:----------------:| | <code>v0.3.0</code> | <code>v4.0.0+</code>, <code>v5.0.0+</code> | ❌ | ❌ | ✅ | ✅ |
[]
https://avatars.githubusercontent.com/u/41784264?v=4
znvim
jinzhongjia/znvim
2024-02-13T17:11:29Z
neovim remote rpc client implementation with zig
main
2
21
2
21
https://api.github.com/repos/jinzhongjia/znvim/tags
MIT
[ "neovim", "neovim-remote", "zig", "zig-package" ]
154
false
2025-05-13T11:24:47Z
true
true
0.12.0
github
[ { "commit": "refs", "name": "zig-msgpack", "tar_url": "https://github.com/zigcc/zig-msgpack/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/zigcc/zig-msgpack" } ]
znvim <em>znvim</em> is a <a>neovim remote rpc</a> client implementation with <a><code>zig</code></a>. <blockquote> This package is under developing! </blockquote> Document <a>https://jinzhongjia.github.io/znvim/</a> Features <ul> <li>Implementation of multiple remote calling methods</li> <li>Support all neovim rpc <a>channels</a></li> <li>Completely thread safe</li> <li>Asynchronous</li> </ul> Getting Started <code>0.12.0</code> / <code>0.13.0</code> / <code>master</code> <ol> <li>Add to <code>build.zig.zon</code></li> </ol> <code>sh zig fetch --save https://github.com/jinzhongjia/znvim/archive/{commit or branch}.tar.gz</code> <ol> <li>Config <code>build.zig</code></li> </ol> ```zig const znvim = b.dependency("znvim", .{ .target = target, .optimize = optimize, }); // add module exe.root_module.addImport("znvim", znvim.module("znvim")); ``` To use this lib You can find example on <code>test</code> fold! Recommend to learn about what <a>msgpack</a> is (this lib uses <a>zig-msgpack</a>) and read neovim's API <a>documentation</a>.
[]
https://avatars.githubusercontent.com/u/137767533?v=4
ZigZen
ZigIDE/ZigZen
2024-02-14T13:43:13Z
ZigZen: Zig IDE on top of the IntelliJ Platform
252.13776
0
21
1
21
https://api.github.com/repos/ZigIDE/ZigZen/tags
Apache-2.0
[ "intellij", "zig" ]
4,823,839
true
2025-05-18T04:41:06Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/78925721?v=4
crash
RGBCube/crash
2024-05-15T06:40:04Z
User-configurable login shell configured by the SHELLS environment variable.
master
0
21
0
21
https://api.github.com/repos/RGBCube/crash/tags
MIT
[ "shell", "user-configureable", "zig" ]
40
false
2025-05-07T02:09:30Z
true
true
0.14.0
github
[]
crash A user-configurable login shell wrapper. Crash is a super lightweight shim that executes the shells that are seperated by <code>:</code> in your <code>SHELLS</code> environment variable in order, halting execution if one exits sucessfully (with a 0 exit code). If you don't have anything in your <code>SHELLS</code> environment variable or all the ones that did exist failed to launch, Crash will use the fallback shell that is configured at compile time (by default, this is <code>bashInteractive</code> from nixpkgs, however you can change this by overriding the <code>fallbackShell</code> call option). Why? <ul> <li>To allow users to configure their own shells without superuser access (You can set the <code>SHELLS</code> variable to something like <code>.config/shell</code> and let users change that file).</li> <li>To be able to hotswap between shells when using SSH. This is even more useful if multiple people who use the same user account on a machine use different shells. See the "Tips &amp; Tricks" section.</li> <li>To have a fallback shell in case your primary one, which is your login shell, breaks and you don't want to get locked out (especially useful when using new unstable shells like Nushell).</li> </ul> Installation Simply add this repository to your inputs like so: <code>nix { inputs.crash.url = "github:RGBCube/crash"; }</code> And then you can set the package as your default user shell like so, in a NixOS module: ```nix { outputs = { nixpkgs, crash }: { nixosConfigurations.myhostname = nixpkgs.lib.nixosSystem { modules = [ ({ pkgs, lib, ... }: { nixpkgs.overlays = [ crash.overlays.default ]; <code> users.defaultUserShell = pkgs.crash; # Here we set our default shells. Nushell will be tried first, if that # exits with an error, fish will be launched instead. And if fish fails, the # fallback shell, which is pkgs.bashInteractive will get run. environment.sessionVariables.SHELLS = "${lib.getExe pkgs.nushell}:${lib.getExe pkgs.fish}"; # This would also work, as Crash searches $PATH: # # environment.sessionVariables.SHELLS = "nu:fish"; # # However, just setting an absolute path is pretty easy and better. }) # Uncomment to make the fallback shell of crash pkgs.dash. Will require a recompilation! # { # nixpkgs.overlays = [(final: prev: { # crash = prev.crash.override { fallbackShell = final.dash }; # })]; # } ]; }; </code> } } ``` Installation without Nix First, you have to compile the program (requires Zig 0.12.0): <code>shell zig build --release=safe -Dcpu=baseline -Dfallback_shell=/bin/&lt;yourshell&gt;</code> After that, the binary should be in <code>zig-out/bin/crash</code>. You can copy it to <code>/bin</code> like so: <code>shell cp zig-out/bin/crash /bin/</code> After that, you will need to edit PAM settings to set the <code>SHELLS</code> environment variable early on in the boot process. Consult your distros documentation on how to do this, as it may vary. Tips &amp; Tricks You can control the default shell / program that will get launched by SSH using Crash. All you need to do it make OpenSSH accept the <code>SHELLS</code> environment variable and set it when SSH'ing in. Here is a NixOS module that does that: <code>nix { services.openssh = { enable = true; settings.AcceptEnv = "SHELLS"; }; }</code> And you can utilize it by adding this to your <code>.ssh/config</code>: <code>shell Host myvps # ..snip.. SetEnv SHELLS=fish:nu:bash:dash</code> Then just SSH in like normal. This will launch you into fish, if that fails, into nu and so on... Credits <ul> <li><a>noshell</a>: This was the primary source of inspiration. I decided to create this project as noshell requires a file on disk instead of an environment variable and my <a>feature request for fallback shells got rejected</a>.</li> </ul> License ``` Copyright (c) 2024-present RGBCube Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```
[]
https://avatars.githubusercontent.com/u/15014128?v=4
zbgfx
cyberegoorg/zbgfx
2024-04-10T12:00:23Z
When zig meets bgfx.
main
1
20
3
20
https://api.github.com/repos/cyberegoorg/zbgfx/tags
WTFPL
[ "bgfx", "bgfx-graphics-library", "gamedev", "zig", "zig-package" ]
9,686
false
2025-04-11T14:41:18Z
true
true
unknown
github
[]
ZBgfx <a></a> When <a>zig</a> meets <a>bgfx</a>. Features <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> Zig api. <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> Compile as standard zig library. <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> <code>shaderc</code> as build artifact. <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> Shader compile in <code>build.zig</code> to <code>*.bin.h</code>. <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> Shader compile in <code>build.zig</code> and embed as zig module. (this is zig equivalent of <code>*.bin.h</code>) <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> Shader compile from runtime via <code>shaderc</code> as child process. <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> Binding for <a>DebugDraw API</a> <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> <code>imgui</code> render backend. Use build option <code>imgui_include</code> to enable. ex. for zgui: <code>.imgui_include = zgui.path("libs").getPath(b),</code> <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> Zig based allocator. <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> This is only zig binding. For BGFX stuff goto <a>bgfx</a>. <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> - <code>shaderc</code> need some time to compile. <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> - If you build shaders/app and see something like <code>run shaderc (shader.bin.h) stderr</code>. This is not "true" error (build success), but only in debug build shader print some stuff to stderr and zig build catch it. </blockquote> License Folders <code>libs</code>, <code>shaders</code> is copy&amp;paste from <a>bgfx</a> for more sell-contained experience and is licensed by <a>LICENSEE</a> Zig binding is licensed by <a>WTFPL</a> Zig version Minimal is <code>0.14.0</code>. But you know try your version and believe. Bgfx version <ul> <li><a>BX</a></li> <li><a>BImg</a></li> <li><a>BGFX</a></li> </ul> Getting started Copy <code>zbgfx</code> to a subdirectory of your project and then add the following to your <code>build.zig.zon</code> .dependencies: <code>zig .zbgfx = .{ .path = "path/to/zbgfx" },</code> or use <code>zig fetch --save ...</code> way. Then in your <code>build.zig</code> add: ```zig pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ ... }); <code>const zbgfx = b.dependency("zbgfx", .{}); exe.root_module.addImport("zbgfx", zbgfx.module("zbgfx")); exe.linkLibrary(zbgfx.artifact("bgfx")); // This install shaderc to install dir // For shader build in build =D check examples // b.installArtifact(zbgfx.artifact("shaderc")); </code> } ``` Usage See examples for binding usage and <a>bgfx</a> for bgfx stuff. Build options | Build option | Default | Description | |-----------------|---------|------------------------------------------------------| | <code>imgui_include</code> | <code>null</code> | Path to ImGui includes (need for imgui bgfx backend) | | <code>multithread</code> | <code>true</code> | Compile with <code>BGFX_CONFIG_MULTITHREADED</code> | | <code>with_shaderc</code> | <code>true</code> | Compile with <code>shaderc</code> | Examples Run this for build all examples: <code>sh cd examples zig build</code> <a>00-Minimal</a> Minimal setup with GLFW for window and input. <code>sh examples/zig-out/bin/00-minimal</code> | Key | Description | |-----|--------------| | <code>v</code> | Vsync on/off | | <code>d</code> | Debug on/off | <a>01-ZGui</a> Minimal setup for zgui/ImGui. <code>sh examples/zig-out/bin/01-zgui</code> | Key | Description | |-----|--------------| | <code>v</code> | Vsync on/off | | <code>d</code> | Debug on/off | <a>02-Runtime shaderc</a> Basic usage of shader compile in runtime. Try edit shaders in <code>zig-out/bin/shaders</code> and hit <code>r</code> to recompile. <code>sh examples/zig-out/bin/02-runtime-shaderc</code> | Key | Description | |-----|-----------------------------| | <code>v</code> | Vsync on/off | | <code>d</code> | Debug on/off | | <code>r</code> | Recompile shaders form file | <a>03-debugdraw</a> DebugDraw api usage example. <code>sh examples/zig-out/bin/03-debugdraw</code> | Key | Description | |-----|--------------| | <code>v</code> | Vsync on/off | | <code>d</code> | Debug on/off |
[ "https://github.com/cyberegoorg/cetech1" ]
https://avatars.githubusercontent.com/u/561689?v=4
zsmooth
adworacz/zsmooth
2024-03-06T22:05:15Z
Cross-platform, cross-architecture video smoothing functions for Vapoursynth, written in Zig
master
1
20
0
20
https://api.github.com/repos/adworacz/zsmooth/tags
MIT
[ "plugin", "vapoursynth", "video", "zig" ]
519
false
2025-05-21T23:49:53Z
true
true
0.14.0
github
[ { "commit": "6fc33f730999282cbc0852c745898d74002309a9", "name": "vapoursynth", "tar_url": "https://github.com/dnjulek/vapoursynth-zig/archive/6fc33f730999282cbc0852c745898d74002309a9.tar.gz", "type": "remote", "url": "https://github.com/dnjulek/vapoursynth-zig" } ]
Zsmooth - cross-platform, cross-architecture video smoothing functions for Vapoursynth, written in Zig <strong>Goals</strong> * Clean, easy to read code, with a standard scalar (non-SIMD) implementation for every algorithm. * Support for 8-16 integer, and 16-32 float bit depths. (See FP16 note below) * Tests for all filters, covering the scalar and vector implementations. * Support for RGB, YUV, and GRAY colorspaces (assuming an algorithm isn't designed for a specific color space). * Support Linux, Windows, and Mac. * Support x86_64 and aarch64 CPU architectures, with all architectures supported by the Zig compiler being possible in theory. * (Eventually) Vapoursynth and Avisynth support. (Whenever I get the spare time and motivation.) <strong>Note on FP16:</strong> FP16 support is a work in progress. All functions support it but some are much slower than they need to be. Future Zig versions should make this easier, see <a>this Zig issue</a> for more details. <strong>Note on AVX2:</strong> AVX2 is the assumed baseline for all pre-built x86_64 binaries. AVX2 has been out available since 2013, so there's very little hardware left that doesn't support it. If there's demand for pre-AVX2 builds, please open an issue and explain (in detail) your needs and reasoning. Implemented Features/Functions Please see this <a>pinned issue</a> for the current list, and up vote accordingly. Table of Contents <ul> <li><a>Function Documentation</a></li> <li><a>Temporal Median</a></li> <li><a>Temporal Soften</a></li> <li><a>RemoveGrain</a></li> <li><a>Repair</a></li> <li><a>VerticalCleaner</a></li> <li><a>Clense / ForwardClense / BackwardClense</a></li> <li><a>FluxSmooth(S|ST)</a></li> <li><a>DegrainMedian</a></li> <li><a>Building</a></li> <li><a>Native Builds</a></li> <li><a>Cross Compiling</a></li> <li><a>References</a></li> </ul> Function Documentation Temporal Median TemporalMedian is a temporal denoising filter. It replaces every pixel with the median of its temporal neighbourhood. This filter will introduce ghosting, so use with caution. <code>py core.zsmooth.TemporalMedian(clip clip[, int radius = 1, int[] planes = [0, 1, 2]])</code> | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | radius | int | 1 - 10 (1) | Size of the temporal window from which to calculate the median. First and last <em>radius</em> frames of a clip are not filtered. | | planes | int[] | ([0, 1, 2]) | Which planes to process. Any unfiltered planes are copied from the input clip. | Temporal Soften TemporalSoften averages radius * 2 + 1 frames. A pixel is included in the average only if the absolute difference between it and the middle frame's corresponding pixel is less than the threshold. If the <code>scenechange</code> parameter is <code>-1</code>, or greater than 0, TemporalSoften will not average frames from different scenes. Setting <code>scenechange</code>to <code>-1</code> skips the internal invocation of SCDetect from <a>Misc filters</a> and uses the standard "_SceneChangePrev" and "_SceneChangeNext" properties, which should be set by other scene detection filters prior to invoking TemporalSoften. <code>py core.zsmooth.TemporalSoften(clip clip[, int radius = 4, float[] threshold = [], int scenechange = 0, bool scalep=False])</code> | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | radius | int | 1 - 7 (4) | Size of the temporal window. This is an upper bound. At the beginning and end of the clip, only legally accessible frames are incorporated into the radius. So if radius if 4, then on the first frame, only frames 0, 1, 2, and 3 are incorporated into the result. | | threshold | float[] | 0 - 255 8-bit, 0 - 65535 16-bit, 0.0 - 1.0 float ([4,4,4] RGB, [4, 8, 8] YUV, [4] GRAY) | If the difference between the pixel in the current frame and any of its temporal neighbors is less than this threshold, it will be included in the mean. If the difference is greater, it will not be included in the mean. If set to -1, the plane is copied from the source.| | scenechange | int | -1 - 255 (-1) | Zero (0) disables scene change detection, negative one (-1) respects any existing scene change properties ("_SceneChangePrev", "_SceneChangeNext") and does not call SCDetect from Misc filters. If greater than zero, it is calculated as a percentage internally (scenechange/255) to qualify if a frame is a scenechange or not. Currently requires the SCDetect filter from the Miscellaneous filters plugin. | | scalep | bool | (False) | Parameter scaling. If set to true, all threshold values will be automatically scaled from 8-bit range (0-255) to the corresponding range of the input clip's bit depth. | RemoveGrain RemoveGrain is a spatial denoising filter. Modes 0-24 are implemented. Different modes can be specified for each plane. If there are fewer modes than planes, the last mode specified will be used for the remaining planes. <strong>Note on differences</strong>: 1. Edge pixels are properly processed using a "mirror"-based algorithm. Meaning that any pixel values that are absent at an edge are filled in by mirroring the data from the opposite side. Other implementations simply skip (copy) edge pixels verbatim. 2. This plugin operates slightly differently than RGSF, the 'single precision' floating point Vapoursynth implementation of RemoveGrain. Specifically, RGSF isn't actually 'single precision' - it's double precision. Even for operations that don't benefit from increased floating point precision. This means that RGSF is actually significantly slower than it needs to be for some/most operations. The implementation in this plugin properly uses single precision floating point for all modes. This is exactly the same approach that the Avisynth version of RgTools takes. It does mean that for some operations, the output will very sligtly differ between RGSF and this plugin, as RGSF is technically doing higher precision (but much slower) calculations. <code>py core.zsmooth.RemoveGrain(clip clip, int[] mode)</code> Parameters: | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | mode | int | 1-24 | For a description of each mode, see the docs from the original Vapoursynth documentation here: https://github.com/vapoursynth/vs-removegrain/blob/master/docs/rgvs.rst | Repair Repairs unwanted artifacts from (but not limited to) RemoveGrain. Modes 0-24 are implemented. Different modes can be specified for each plane. If there are fewer modes than planes, the last mode specified will be used for the remaining planes. <strong>Notes on differences</strong>: This implementation of Repair is different than others in 2 key ways: 1. Edge pixels are properly processed using a "mirror"-based algorithm. Meaning that any pixel values that are absent at an edge are filled in by mirroring the data from the opposite side. Other implementations simply skip (copy) edge pixels verbatim. 2. Unlike RGSF, all calculations are done in single precision floating point. See the note on <code>RemoveGrain</code> for more information. <code>py core.zsmooth.Repair(clip clip, clip repairclip, int[] mode)</code> Parameters: | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | repairclip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Reference clip, often is (but not required to be) the original unprocesed clip | | mode | int | 1-24 | For a description of each mode, see the docs from the original Vapoursynth documentation here: https://github.com/vapoursynth/vs-removegrain/blob/master/docs/rgvs.rst | VerticalCleaner VerticalCleaner is a fast vertical median filter. Different modes can be specified for each plane. If there are fewer modes than planes, the last mode specified will be used for the remaining planes. <strong>Mode 0</strong> The input plane is simply passed through. <strong>Mode 1</strong> Vertical median. <strong>Mode 2</strong> Relaxed vertical median (preserves more detail). Let b1, b2, c, t1, t2 be a vertical sequence of pixels. The center pixel c is to be modified in terms of the 4 neighbours. For simplicity let us assume that b2 &lt;= t1. Then in mode 1, c is clipped with respect to b2 and t1, i.e. c is replaced by max(b2, min(c, t1)). In mode 2 the clipping intervall is widened, i.e. mode 2 is more conservative than mode 1. If b2 &gt; b1 and t1 &gt; t2, then c is replaced by max(b2, min(c, max(t1,d1))), where d1 = min(b2 + (b2 - b1), t1 + (t1 - t2)). In other words, only if the gradient towards the center is positive on both clipping ends, then the upper clipping bound may be larger. If b2 &lt; b1 and t1 &lt; t2, then c is replaced by max(min(b2, d2), min(c, t1)), where d2 = max(b2 - (b1 - b2), t1 - (t2 - t1)). In other words, only if the gradient towards the center is negative on both clipping ends, then the lower clipping bound may be smaller. In mode 1 the top and the bottom line are always left unchanged. In mode 2 the two first and the two last lines are always left unchanged. <code>py core.zsmooth.VerticalCleaner(clip clip, int[] mode)</code> Parameters: | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | mode | int | 0-2 | Mode 0 is passthrough, Mode 1 is a vertical median, Mode 2 is a relaxed vertical median that preserves more detail | Clense / ForwardClense / BackwardClense Clense is a temporal median of three frames. (previous, current and next) ForwardClense is a modified version of Clense that works on current and next 2 frames. BackwardClense is a modified version of Clense that works on current and previous 2 frames. <code>py core.zsmooth.Clense(clip clip, [clip previous, clip next, int[] planes]) core.zsmooth.ForwardClense(clip clip,[ int[] planes]) core.zsmooth.BackwardClense(clip clip,[ int[] planes])</code> Parameters: | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | previous | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | (main clip) | Optional alternate clip from which to retrieve previous frames | | next | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | (main clip) | Optional alternate clip from which to retrieve next frames | | planes | int[] | ([0, 1, 2]) | Which planes to process. Any unfiltered planes are copied from the input clip. | FluxSmooth(S|ST) <code>py core.zsmooth.FluxSmoothT(clip clip[, float[] temporal_threshold = 7, float[] planes = [0,1,2], bool scalep=False]) core.zsmooth.FluxSmoothST(clip clip[, float[] temporal_threshold = 7, float[] spatial_threshold = 7, float[] planes = [0,1,2], bool scalep = False])</code> FluxSmoothT (<strong>T</strong>\ emporal) examines each pixel and compares it to the corresponding pixel in the previous and next frames. Smoothing occurs if both the previous frame's value and the next frame's value are greater, or if both are less than the value in the current frame. Smoothing is done by averaging the pixel from the current frame with the pixels from the previous and/or next frames, if they are within <em>temporal_threshold</em>. FluxSmoothST (<strong>S</strong>\ patio\ <strong>T</strong>\ emporal) does the same as FluxSmoothT, except the pixel's eight neighbours from the current frame are also included in the average, if they are within <em>spatial_threshold</em>. The first and last rows and the first and last columns are not processed by FluxSmoothST. | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | temporal_threshold | float[] | -1 - bit depth max ([7,7,7]) | Temporal neighbour pixels within this threshold from the current pixel are included in the average. Can be specified as an array, with values corresonding to each plane of the input clip. A negative value (such as -1) indicates that the plane should not be processed and will be copied from the input clip. | | spatial_threshold | float[] | -1 - bit depth max ([7,7,7]) | Spatial neighbour pixels within this threshold from the current pixel are included in the average. A negative value (such as -1) indicates that the plane should not be processed and will be copied from the input clip. | | planes | int[] | ([0, 1, 2]) | Which planes to process. Any unfiltered planes are copied from the input clip. | | scalep | bool | (False) | Parameter scaling. If set to true, all threshold values will be automatically scaled from 8-bit range (0-255) to the corresponding range of the input clip's bit depth. | DegrainMedian <code>py core.zsmooth.DegrainMedian(clip clip[, float[] limit, int[] mode, bool scalep])</code> Modes: | Mode | Description | | --- | --- | | 0 | Spatial-Temporal version of RemoveGrain mode 9. Essentially a line (or edge) sensitive, limited, clipping function. Clipping parameters are calculated from the minimum difference of the current pixels spatial-temporal neighbors, in a 3x3 grid. | | 1 | Spatial-Temporal and stronger version of RemoveGrain mode 8 | | 2 | Spatial-Temporal version of RemoveGrain Mode 8 | | 3 | Spatial-Temporal version of RemoveGrain Mode 7 | | 4 | Spatial-Temporal version of RemoveGrain Mode 6 | | 5 | Spatial-Temporal version of RemoveGrain Mode 5 | | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | limit | float[] | 0 - bit depth max ([7, 7, 7]) | The maximum amount that a pixel can change. A higher limit results in more smoothing. Can be specified as an array, with values corresonding to each plane of the input clip. | | mode | int[] | 0 - 5, inclusive ([1,1,1]) | The processing mode. 0 is the strongest, 5 is the weakest. Can be specified as an array, with values corresponding to each plane. | | scalep | bool | (False) | Parameter scaling. If set to true, all threshold values will be automatically scaled from 8-bit range (0-255) to the corresponding range of the input clip's bit depth. | InterQuartileMean <code>py core.zsmooth.InterQuartileMean(clip clip[, int[] radius])</code> Smartish spatial blurring filter, works well as a prefilter. Works well with <code>limit_filter</code> from <code>vs-jetpack</code> (or similar) for limiting/thresholding. Performs an <a>interquartile mean</a> of a 3x3 grid. An interquartile mean is a mean (average) where the darkest 1/4 and brightest 1/4 of pixels in the grid are thrown out, and the remaining middle values are averaged. This prevents the extremes from skewing the average. Future versions will support 5x5 (and maybe 7x7). | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | radius | int[] | 1 | The spatial radius of the filter. Currently only 1 (3x3) is supported, but future versions will include higher radii | TTempSmooth <code>py core.zsmooth.TTempSmooth(vnode clip[, int maxr=3, int[] thresh=[4, 5, 5], int[] mdiff=[2, 3, 3], int strength=2, float scthresh=12.0, bint fp=True, vnode pfclip=None, int[] planes=[0, 1, 2]])</code> TTempSmooth is a motion adaptive (it only works on stationary parts of the picture), temporal smoothing filter. It's essentially a fancy lookup table internally, but it works by computing a set of weights based on the input parameters, and then applying those weights based on the temporal differences of the input clip (or pfclip, if provided). Higher weights contribute more to the final pixel value, and lower weights contribute less. The parameters are related to each other, with <code>maxr</code> and <code>strength</code> governing the temporal distance and temporal weight, respectively. Frames closer to the center have a higher weight, and frames further from the center have a lower weight. <code>thresh</code> and <code>mdiff</code> govern the weights concerning the difference in pixel values between frames. Smaller differences are weighted higher and larger differences are weighted lower. Note that there are essentially two modes - a simple temporal weighted mode, and a temporal + difference weighted mode. The former is activated when <code>mdiff &gt;= threshold - 1</code>. This disables all difference weighting, and simply weights pixels that have a temporal difference below <code>threshold</code> based on how far they are from the center. This is the fastest mode. The latter is activated when <code>mdiff &lt; threshold - 1</code>. In this mode, temporal weights <em>and</em> difference weights are applied. So in addition to the weights applied in the previous mode, the amount that a pixel differs from the center effects how much weight is given to it. Again, smaller differences have higher weights. | Parameter | Type | Options (Default) | Description | | --- | --- | --- | --- | | clip | 8-16 bit integer, 16-32 bit float, RGB, YUV, GRAY | | Clip to process | | radius | int[] | 1 | The spatial radius of the filter. Currently only 1 (3x3) is supported, but future versions will include higher radii | | maxr | int | 1-7 (3) | This sets the maximum temporal radius. By the way it works TTempSmooth automatically varies the radius used... this sets the maximum boundary. At 1 TTempSmooth will be (at max) including pixels from 1 frame away in the average (3 frames total will be considered counting the current frame). At 7 it would be including pixels from up to 7 frames away (15 frames total will be considered). With the way it checks motion there isn't much danger in setting this high, it's basically a quality vs. speed option. Lower settings are faster while larger values tend to create a more stable image. | | thresh | int[] | ([4, 5, 5]) | (8-bit scale) Your standard thresholds for differences of pixels between frames. TTempSmooth checks 2 frame distance as well as single frame, so these can usually be set slightly higher than with most other temporal smoothers and still avoid artifacts. Valid settings are from 1 to 256. Also important is the fact that as long as <code>mdiff</code> is less than the threshold value then pixels with larger differences from the original will have less weight in the average. Thus, even with rather large thresholds pixels just under the threshold won't have much weight, helping to reduce artifacts. If a single value is specified, it will be used for all planes. If two values are given then the second value will be used for the third plane as well. | | mdiff | int[] | ([2, 3, 3]) | (8-bit scale) Any pixels with differences less than or equal to <code>mdiff</code> will be blurred at maximum. Usually, the larger the difference to the center pixel the smaller the weight in the average. <code>mdiff</code> makes TTempSmooth treat pixels that have a difference of less than or equal to <code>mdiff</code> as though they have a difference of 0. In other words, it shifts the zero difference point outwards. Set <code>mdiff</code> to a value equal to or greater than <code>thresh-1</code> to completely disable inverse pixel difference weighting. Valid settings are from 0 to 255. If a single value is specified, it will be used for all planes. If two values are given then the second value will be used for the third plane as well. | | strength | int | 1-8 (2) | TTempSmooth uses inverse distance weighting when deciding how much weight to give to each pixel value. The strength option lets you shift the drop off point away from the center to give a stronger smoothing effect and add weight to the outer pixels. It does for the spatial weights what <code>mdiff</code> does for the difference weights. | scthresh | float | -1.0 - 0 - 100.0 (12.0) | The standard scenechange threshold as a percentage of maximum possible change of the luma plane. A good range of values is between 8 and 15. Set <code>scthresh</code> to 0.0 to disable scenechange detection. Set <code>scthresh</code> to -1 to disable calls to <code>misc.SCDetect</code> internally and just use existing <code>_SceneChangePrev/Next</code> properties (useful for when said properties have already been set prior to calling this function). | fp | bool | True | Setting <code>fp=True</code> will add any weight not given to the outer pixels back onto the center pixel when computing the final value. Setting <code>fp=False</code> will just do a normal weighted average. <code>fp=True</code> is much better for reducing artifacts in motion areas and usually produces overall better results. | pfclip | same format clip as <code>clip</code> | (none) | This allows you to specify a separate clip for TTempSmooth to use when calculating pixel differences. This applies to checking the motion thresholds, calculating inverse difference weights, and detecting scenechanges. Basically, the <code>pfclip</code> will be used to determine the weights in the average but the weights will be applied to the original input clip's pixel values. | planes | int[] | ([0, 1, 2]) | Which planes to process. Any unfiltered planes are copied from the input clip. | Example of the impact of <code>strength</code> on the temporal weights, with the center frame being in the middle of each line: <ul> <li>1 = 0.13 0.14 0.16 0.20 0.25 0.33 0.50 1.00 0.50 0.33 0.25 0.20 0.16 0.14 0.13</li> <li>2 = 0.14 0.16 0.20 0.25 0.33 0.50 1.00 1.00 1.00 0.50 0.33 0.25 0.20 0.16 0.14</li> <li>3 = 0.16 0.20 0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25 0.20 0.16</li> <li>4 = 0.20 0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25 0.20</li> <li>5 = 0.25 0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33 0.25</li> <li>6 = 0.33 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50 0.33</li> <li>7 = 0.50 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.50</li> <li>8 = 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00</li> </ul> The values shown are for <code>maxr=7</code>, when using smaller radius values the weights outside of the range are simply dropped. Thus, setting <code>strength</code> to a value of <code>maxr+1</code> or higher will give you equal spatial weighting of all pixels in the kernel. Building All build artifacts are placed under <code>zig-out/lib</code>. Native builds To build for the operating system and architecture of the current machine: <code>sh zig build -Doptimize=ReleaseFast</code> Cross-compiling Zig has excellent cross-compilation support, letting us create Windows, Mac, or Linux compatible libraries from any of those same operating systems and architectures. To generate Windows compatible DLLs, with AVX2 support: <code>sh zig build -Doptimize=ReleaseFast -Dtarget=x86_64-windows -Dcpu=x86_64_v3</code> To generate Windows compatible DLLs with AVX512 support: ```sh zig build -Doptimize=ReleaseFast -Dtarget=x86_64-windows -Dcpu=x86_64_v4 or the following for specific targeting of AMD Zen4 CPUs zig build -Doptimize=ReleaseFast -Dtarget=x86_64-windows -Dcpu=znver4 ``` See https://en.wikipedia.org/wiki/AVX-512#CPUs_with_AVX-512 for a better breakdown on which CPUs support AVX512 features. To generate Mac (x86_64) compatible libraries: <code>sh zig build -Doptimize=ReleaseFast -Dtarget=x86_64-macos</code> To generate Mac (aarch64) ARM compatible libraries: <code>sh zig build -Doptimize=ReleaseFast -Dtarget=aarch64-macos</code> To generate Mac (aarch64) ARM compatible libraries for a specific CPU (like M1, M2, etc): <code>sh zig build -Doptimize=ReleaseFast -Dtarget=aarch64-macos -Dcpu=apple_m1</code> Use <code>zig targets</code> to see an exhaustive list of all architectures, CPUs, and operating systems that Zig supports. References The following open source software provided great inspiration and guidance, and this plugin wouldn't exist without the hard work of their authors. <ul> <li>Avisynth RemoveGrain: https://github.com/pinterf/RgTools</li> <li>Vapoursynth RemoveGrain: https://github.com/vapoursynth/vs-removegrain</li> <li>Vapoursynth TemporalSoften: https://github.com/dubhater/vapoursynth-temporalsoften2</li> <li>Vapoursynth TemporalMedian: https://github.com/dubhater/vapoursynth-temporalmedian</li> <li>Neo Temporal Median: https://github.com/HomeOfAviSynthPlusEvolution/neo_TMedian</li> <li>Vapoursynth FluxSmooth: https://github.com/dubhater/vapoursynth-fluxsmooth/</li> <li>Dogway's <code>ex_median</code> functions: https://github.com/Dogway/Avisynth-Scripts/blob/c6a837107afbf2aeffecea182d021862e9c2fc36/ExTools.avsi#L2456</li> </ul>
[]
https://avatars.githubusercontent.com/u/12820359?v=4
astroz
ATTron/astroz
2024-06-25T00:35:54Z
Astrodynamics and Spacecraft Toolkit Written in Zig! Features orbit prop, celestial precession, CCSDS parsing, RF parsing, fits image parsing, and more!
main
0
20
1
20
https://api.github.com/repos/ATTron/astroz/tags
GPL-3.0
[ "astro", "astronomy", "astrophysics", "ccsds", "celestial-bodies", "fits-files", "fits-image", "orbital-simulation", "radio-frequency", "rf", "space", "spacecraft", "tle", "toolkit", "vita", "zig", "zig-library", "zig-package" ]
107,268
false
2025-04-17T13:10:36Z
true
true
0.14.0-dev.3445+6c3cbb0c8
github
[ { "commit": "29ff47f9e011065460d1d049cdc18784d733e23b", "name": "zigimg", "tar_url": "https://github.com/zigimg/zigimg/archive/29ff47f9e011065460d1d049cdc18784d733e23b.tar.gz", "type": "remote", "url": "https://github.com/zigimg/zigimg" } ]
ASTROZ <a></a> <a></a> <a></a> Astronomical and Spacecraft Toolkit Written in Zig for Zig! Features / Plans Spacecraft <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> CCSDS Packets <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> CCSDS Stream Parser <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> VITA49 Packets <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> Vita49 Stream Parser <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> TLE Support <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> Orbital Propagation <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> RK4 <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> Orbital Maneuvers <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> Impulse Maneuvers <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> Phase Maneuvers <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> Plane Change Maneuvers <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> Orientation Determination Astronomical <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> Astronomical References <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> J2000 and JD <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> Celestial Bodies <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> Mass <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> Radius <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> Orbital Details <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> Astronomical Coordinates <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> Equatorial Coordinate System <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> World Coordinate System <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> Astronomical Computation <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> Precession <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> Celestial Bodies <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> Orbital Mechanics <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> Interplanetary Maneuvers <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> FITS File Parsing - BROKEN DUE TO ZIGIMG DEPENDENCY BREAKING ON MAIN <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> Image Generation <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> Multi Image Parsing/Generation <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> Table Parsing Feature not listed ? To request a feature, please create an issue for this project and I will try my best to be responsive. Usage <ul> <li>Add <code>astroz</code> as a dependency in your <code>build.zig.zon</code>.</li> </ul> <code>sh zig fetch --save https://github.com/ATTron/astroz/archive/&lt;git_tag_or_commit_hash&gt;.tar.gz</code> <ul> <li>Use <code>astroz</code> as a module in your <code>build.zig</code>.</li> </ul> <code>zig const astroz_dep = b.dependency("astroz", .{ .target = target, .optimize = optimize, }); const astroz_mod = astroz_dep.module("astroz"); exe.root_module.addImport("astroz", astroz_mod);</code> Examples <ul> <li> <a>Parse TLE</a> </li> <li> <a>Orbit Prop for Next 3 Days</a> </li> </ul> <ul> <li> <a>Orbit Prop for Next 3 Days with Impulse Maneuvers</a> </li> </ul> <ul> <li> <a>Orbit Plane Change</a> </li> <li> <a>Orbit Phase Change</a> </li> <li> <a>Orbit Orientation Determination</a> </li> <li> <a>Parse Vita49</a> </li> <li> <a>Parse Vita49 with Callback</a> </li> <li> <a>Parse CCSDS from File</a> </li> <li> <a>Parse CCSDS from File with File Sync</a> </li> <li> <a>Create CCSDS Packet</a> </li> <li> <a>Create CCSDS Packet with Config</a> </li> </ul> <strong>NOTE THIS IS CURRENTLY BROKEN DUE TO ZIGIMG DEPENDENCY BREAKING ON THE MAIN BRANCH</strong> <ul> <li> <a>Generate Image from FITS File</a> </li> </ul> <ul> <li> <a>Precess star to July 30, 2005</a> </li> <li> <a>Calculate WCS values from a TLE</a> </li> </ul>
[]
https://avatars.githubusercontent.com/u/84684231?v=4
zaft
LVala/zaft
2024-05-28T20:26:31Z
The Raft Consensus Algorithm in Zig
main
0
19
2
19
https://api.github.com/repos/LVala/zaft/tags
MIT
[ "consensus", "distributed-systems", "raft", "raft-consensus-algorithm", "zig" ]
72
false
2025-04-02T13:22:36Z
true
true
0.12.1
github
[]
# `zaft` <a></a> <a></a> <a></a> ### The Raft Consensus Algorithm in Zig This repository houses `zaft` - [Raft Consensus Algorithm](https://raft.github.io/) library implemented in Zig. It provides the building blocks for creating distributed systems requiring consensus among replicated state machines, like databases. Installation This package can be installed using the Zig package manager. In <code>build.zig.zon</code> add <code>zaft</code> to the dependency list: <code>zig // in build.zig.zon .{ .name = "my-project", .version = "0.0.0", .dependencies = .{ .zaft = .{ .url = "https://github.com/LVala/zaft/archive/&lt;git-ref-here&gt;.tar.gz", .hash = "12208070233b17de6be05e32af096a6760682b48598323234824def41789e993432c" }, }, }</code> The output of <code>zig build</code> will provide you with a valid hash, use it to replace the one above. Add the <code>zaft</code> module in <code>build.zig</code>: <code>zig // in build.zig const zaft = b.dependency("zaft", .{ .target = target, .optimize = optimize }); exe.root_module.addImport("zaft", zaft.module("zaft"));</code> Now you should be able to import <code>zaft</code> in your <code>exe</code>s root source file: <code>zig const zaft = @import("zaft");</code> Usage This section will show you how to integrate <code>zaft</code> with your program step-by-step. If you prefer to take a look at a fully working example, check out the <a>kv_store</a> - in-memory, replicated key-value store based on <code>zaft</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> This tutorial assumes some familiarity with the Raft Consensus Algorithm. If not, I highly advise you to at least skim through the <a>Raft paper</a>. Don't worry, it's a short and very well-written paper! </blockquote> Firstly, initialize the <code>Raft</code> struct: ```zig // we'll get to UserData and Entry in a second const Raft = @import("zaft").Raft(UserData, Entry); const raft = Raft.init(config, initial_state, callbacks, allocator); defer raft.deinit(); ``` <code>Raft.init</code> takes four arguments: <ul> <li><code>config</code> - configuration of this particular Raft node:</li> </ul> <code>zig const config = Raft.Config{ .id = 3, // id of this Raft node .server_no = 5, // total number of Raft nodes, there should be nodes with ids from 0 up to server_no-1 // there's other options with some sane defaults, check out this struct's definition to learn // what else can be configured };</code> <ul> <li><code>callbacks</code> - <code>Raft</code> will call this function to perform various actions:</li> </ul> ```zig // makeRPC is used to send Raft messages to other nodes // this function should be non-blocking (not wait for the response) fn makeRPC(ud: *UserData, id: u32, rpc: Raft.RPC) !void { const address = ud.node_addresse[id]; // it's your responsibility to serialize the message, consider using e.g. std.json const msg: []u8 = serialize(rpc); try ud.client.send(address, msg); } // Entry can be whatever you want // in this callback the entry should be applied to the state machine // applying an entry must be deterministic! This means that, after applying the // same entries in the same order, the state machine must end up in the same state every time fn applyEntry(ud: *UserData, entry: Entry) !void { // let's assume that is some kind of key-value store switch(entry) { .add =&gt; |add| try ud.store.add(add.key, add.value), .remove =&gt; |remove| try ud.store.remove(remove.key), } } // these two functions have to append/pop entry to/from the log fn logAppend(ud: *UserData, log_entry: Raft.LogEntry) !void { try ud.database.appendEntry(log_entry); } fn logPop(ud: *UserData) !Raft.LogEntry { const log_entry = try ud.database.popEntry(); return log_entry; } // these functions are responsible for persisting values, that can be overridden on every save fn persistCurrentTerm(ud: *UserData, current_term: u32) !void { try ud.database.persistCurrentTerm(current_term); } fn persistVotedFor(ud: *UserData, voted_for: ?u32) !void { try ud.database.persistVotedFor(voted_for); } ``` <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> Notice that all of the callbacks can return an error (mostly for the sake of convenience). Error returned from <code>makeRPC</code> will be ignored, the RPC will be simply retried after an appropriate timeout. Errors returned from other functions, as of now, will result in a panic. </blockquote> ```zig // pointer to user_data will be passed as a first argument to all of the callbacks // you can place whatever you want in the UserData const user_data = UserData { // these are some imaginary utilities // necessary to make Raft work database: Database, http_client: HttpClient, node_addresses: []std.net.Address, store: Store, }; const callbacks = Raft.Callbacks { .user_data = &amp;user_data, .makeRPC = makeRPC, .applyEntry = applyEntry, .logAppend = logAppend, .logPop = logPop, .persistCurrentTerm = persisCurrentTerm, .persistVotedFor = persistVotedFor, }; ``` <ul> <li><code>initial_state</code> - the persisted state of this Raft node. On each reboot, you need to read the persisted Raft state (<code>current_term</code>, <code>voted_for</code>, and <code>log</code>, previously saved by the callbacks) and use it as the <code>InitialState</code>:</li> </ul> <code>zig const initial_state = Raft.InitialState { //let's assume we saved the state to a persistent database of some kind .voted_for = user_data.database.readVotedFor(), .current_term = user_data.database.readCurrentTerm(), .log = user_data.database.readLog(), };</code> Lastly, an <code>std.mem.Allocator</code> will be used to provide memory for the Raft log. The <code>Raft</code> struct needs to be periodically ticked to trigger timeouts and other necessary actions. You can use a separate thread to do that, or built your program based on an event loop like <a>libexev</a> with its <code>xev.Timer</code>. <code>zig const tick_after = raft.tick(); // tick_after is the number of milliseconds after which raft should be ticked again</code> For instance, <a>kv_store</a> uses a separate thread exclusively to tick the <code>Raft</code> struct. <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 <code>Raft</code> struct is <em>not</em> thread-safe. Use appropriate synchronization means to make sure it is not accessed simultaneously by many threads (e.g. a simple <code>std.Thread.Mutex</code> will do). </blockquote> Next, messages from other Raft nodes need to be fed to the local <code>Raft</code> struct by calling: <code>zig // you will need to receive and deserialize the messages from other peers const msg: Raft.RPC = try recv_msg(); raft.handleRPC(msg);</code> Lastly, entries can be appended to <code>Raft</code>s log by calling: <code>zig const entry = Entry { ... }; const idx = try raft.appendEntry(entry);</code> It will return an index of the new entry. According to the Raft algorithm, your program should block on client requests until the entry has been applied. You can use <code>std.Thread.Condition</code> and call its <code>notify</code> function in the <code>applyEntry</code> callback to notify the program that the entry was applied. You can check whether the entry was applied by using <code>raft.checkIfApplied(idx)</code>. Take a look at how <a>kv_store</a> does this. <code>appendEntry</code> function will return an error if the node is not a leader. In such a case, you should redirect the client request to the leader node. You can check which node is the leader by using <code>raft.getCurrentLeader()</code>. You can also check if the node is a leader proactively by calling <code>raft.checkifLeader()</code>. Next steps The library is fine to be used already, but there's plenty of room for improvements and new features, like: <ul> <li>Creating a simulator to test and find problems in the implementation.</li> <li>Add auto-generated API documentation based on <code>zig build -femit-docs</code>.</li> <li>Implementing <em>Cluster membership changes</em>.</li> <li>Implementing <em>Log compaction</em>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/4424467?v=4
zensor
ethanthoma/zensor
2024-07-08T06:59:30Z
Zig tensor library
main
1
17
0
17
https://api.github.com/repos/ethanthoma/zensor/tags
MIT
[ "machine-learning", "tensor", "zig", "zig-package" ]
196
false
2025-03-19T20:14:02Z
true
true
0.14.0
github
[]
Zensor, a zig tensor library A zig tensor library. Correctness first, speed second. This library promises compile-time type and shape checking. <strong>Very WIP</strong> Example Usage: ```zig const std = @import("std"); const T = u32; const Tensor = @import("zensor").Tensor(T); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); <code>var compiler = zensor.Compiler.init(allocator); defer compiler.deinit(); const filename = "./examples/numpy.npy"; const a = try zensor.Tensor(.Int64, .{3}).from_numpy(&amp;compiler, filename); const b = try zensor.Tensor(.Int64, .{3}).full(&amp;compiler, 4); const c = try a.mul(b); const d = try c.sum(0); std.debug.print("{}\n", .{d}); </code> } ``` Results in: <code>❯ zig build run Tensor( type: dtypes.Int64, shape: [1], length: 1, data: [56, ] )</code> Install Fetch the library: <code>bash zig fetch --save git+https://github.com/ethanthoma/zensor.git#main</code> Add to your <code>build.zig</code>: <code>zig const zensor = b.dependency("zensor", .{ .target = target, .optimize = optimize, }).module("zensor"); exe.root_module.addImport("zensor", zensor);</code> Examples Examples can be found in <code>./examples</code>. You can run these via: <code>bash zig build NAME_OF_EXAMPLE</code> Assuming you have cloned the source. Tests If you want to run the tests after cloning the source. Simply run: <code>bash zig build test</code> Design This library conversts all your tensor operations into an AST: <code>0 Store RuntimeBuffer(ptr=@140052063859008, dtype=dtypes.Int64, shape={ 3 }) 1 ┗━Mul 2 ┣━Load RuntimeBuffer(ptr=@140052063858688, dtype=dtypes.Int64, shape={ 3 }) 3 ┗━Const 4</code> When you want to execute your operations, it first gets split into schedules: <code>Schedule{ status: NotRun topological sort: [4]ast.Nodes{Load, Const, Mul, Store}, global buffers: [(0, true), (1, false)], dependencies count: 0, AST: 0 Store RuntimeBuffer(ptr=@140052063859008, dtype=dtypes.Int64, shape={ 3 }) 1 ┗━Mul 2 ┣━Load RuntimeBuffer(ptr=@140052063858688, dtype=dtypes.Int64, shape={ 3 }) 3 ┗━Const 4 }</code> And then IR code: <code>step op name type input arg 0 DEFINE_GLOBAL Pointer [] (0, true) 1 DEFINE_GLOBAL Pointer [] (1, false) 2 CONST Int [] 0 3 CONST Int [] 3 4 DEFINE_ACC Int [5] 0 5 LOOP Int [2, 3] None 6 LOAD Int [1, 5] None 7 ALU Int [4, 6] ALU.Add 8 UPDATE Int [4, 7] None 9 ENDLOOP [5] None 10 CONST Int [] 0 11 STORE [0, 10, 4] None</code> And finally, executed: <code>PC: 0 PC: 1 PC: 2 CONST: 0 PC: 3 CONST: 3 PC: 4 ACC: 0 PC: 5 LOOP: from 0 to 3 PC: 6 LOAD: 4 from buffer 1 at 0 PC: 7 ALU: Add(0, 4) = 4e0 PC: 8 UPDATE: value stored in step 4 to 4e0 PC: 6 LOAD: 16 from buffer 1 at 1 PC: 7 ALU: Add(4e0, 16) = 2e1 PC: 8 UPDATE: value stored in step 4 to 2e1 PC: 6 LOAD: 36 from buffer 1 at 2 PC: 7 ALU: Add(2e1, 36) = 5.6e1 PC: 8 UPDATE: value stored in step 4 to 5.6e1 PC: 9 PC: 10 CONST: 0 PC: 11 STORE: 5.6e1 into 0 at 0</code>
[]
https://avatars.githubusercontent.com/u/89275?v=4
play.zig
dgv/play.zig
2024-03-26T18:28:56Z
Zig Playground webeditor with snippets sharing support and ziglings
main
1
17
0
17
https://api.github.com/repos/dgv/play.zig/tags
MIT
[ "learning", "learning-by-doing", "snippet", "webeditor", "zig", "ziglings" ]
293
false
2025-04-26T06:55:35Z
true
true
0.14.0
github
[ { "commit": "master", "name": "s3db", "tar_url": "https://github.com/dgv/s3db.zig/archive/master.tar.gz", "type": "remote", "url": "https://github.com/dgv/s3db.zig" }, { "commit": "master", "name": "httpz", "tar_url": "https://github.com/karlseguin/http.zig/archive/master.tar.gz"...
play.zig <a></a> <a></a> <a></a> <a></a> play.zig is just another Zig playground, actually an adaptation wrapping Zig for compilation and format code from my old <a>go-vim</a> (Go Playground)... Following considerations when you use it: <ul> <li>Running at last Zig stable version.</li> <li>5s timeout by default.</li> <li>if firejail is installed networking is sandboxed.</li> <li>code snippets for sharing are stored using sqlite.</li> </ul> Motivation During my learning I miss some place to run <a>ziglings</a> or share code quickly, so here we go. Another playgrounds implementations: <ul> <li><a>playground from zigtools</a>: nice, but weird highlighting, no fmt.</li> <li><a>zig-play</a>: slow, no share option.</li> </ul> Related: <ul> <li><a>zigbin.io</a>: another purpose but nice, run zig trunk version by default, can run and share local files there via curl, no fmt.</li> <li><a>zig.run</a>: nice, written in zig but offline, confused layout, no share option. give me the idea to add ziggy ;)</li> </ul> Run locally with docker <code>bash docker run --rm -p 8080:8080 dgvargas/play-zig</code> Run locally from the source <code>bash git clone https://github.com/dgv/play.zig; cd play.zig zig build run</code> Env vars <code>ADDR Binding Address (default: 0.0.0.0) PORT port binding number (defult: 8080) AWS_ENDPOINT_URL_S3 endpoint of s3 to persist sqlite database (default: "") AWS_BUCKET_NAME_S3 bucket name of s3 to persist sqlite database (default: "play-zig")</code> <em>Note: regarding s3 persistence credentials variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION and include project dir on LD_LIBRARY_PATH) must be set to work properly.</em>
[]
https://avatars.githubusercontent.com/u/36502791?v=4
zcrun
1nwf/zcrun
2024-02-25T18:33:37Z
linux container runtime built with zig
main
0
16
2
16
https://api.github.com/repos/1nwf/zcrun/tags
MIT
[ "container-runtime", "containers", "docker", "linux", "zig" ]
64
false
2025-02-28T04:25:36Z
true
true
unknown
github
[]
zcrun a simple linux container runtime built with zig Features <ul> <li>namespaces:</li> <li>isolate user, network, pid, mount, ipc, and uts namespace</li> <li>cgroups:</li> <li>support cgroups v2</li> <li>limit memory, cpu, or pids (# of procs).</li> <li>internet access inside containers using SNAT</li> </ul> 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> make sure that ip forwarding is enabled to be able to access the internet inside containers. run <code>sysctl net.ipv4.ip_forward</code> to check if it is enabled. if not, run <code>sudo sysctl -w net.ipv4.ip_forward=1</code> to enable it. [!Important] zcrun must be run as root </blockquote> ```sh $ mkdir rootfs export container rootfs dir using docker $ docker export $(docker create busybox) | tar -C rootfs -xvf - run the container using zcrun zcrun run [-mem] [-cpu] [-pids] $ zcrun run busybox rootfs sh ``` Dependencies: <ul> <li>The <code>iptables</code> command.</li> <li>Zig. This branch was tested using version <code>0.12.0-dev.3191+9cf28d1e9</code>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/71455761?v=4
ziglang-caches
Jeevananthan-23/ziglang-caches
2024-03-05T11:10:44Z
In-memory cache implementation with commonly used LRU, W-LFU and S3-FIFO as the eviction policy
master
3
14
0
14
https://api.github.com/repos/Jeevananthan-23/ziglang-caches/tags
MIT
[ "cache", "lfu-cache", "lru-cache", "s3fifo", "sieve", "zig", "zig-package", "ziglang" ]
50
false
2025-04-27T01:37:00Z
true
true
0.12.0-dev.2334+aef1da163
github
[]
ziglang-caches This is a modern cache implementation, inspired by the following papers, provides high efficiency. <ul> <li>SIEVE | <a>SIEVE is Simpler than LRU: an Efficient Turn-Key Eviction Algorithm for Web Caches (NSDI'24)</a></li> <li>S3-FIFO | <a>FIFO queues are all you need for cache eviction (SOSP'23)</a></li> <li>W-TinyLFU | <a>TinyLFU: A Highly Efficient Cache Admission Policy</a></li> </ul> This offers state-of-the-art efficiency and scalability compared to other LRU-based cache algorithms. Basic usage <blockquote> [!LRU_Cache] Least recents used cache eviction policy for cache your data in-memory for fast access. </blockquote> ```zig const std = @import("std"); const lru = @import("lru"); const cache = lru.LruCache(.locking, u8, []const u8); pub fn main() !void { <code>// Create a cache backed by DRAM var lrucache = try cache.init(std.heap.page_allocator, 4); defer lrucache.deinit(); // Add an object to the cache try lrucache.insert(1, "one"); try lrucache.insert(2, "two"); try lrucache.insert(3, "three"); try lrucache.insert(4, "four"); // Most recently used cache std.debug.print("mru: {s} \n", .{lrucache.mru().?.value}); // least recently used cache std.debug.print("lru: {s} \n", .{lrucache.lru().?.value}); // remove from cache _ = lrucache.remove(1); // Check if an object is in the cache O/P: false std.debug.print("key: 1 exists: {} \n", .{lrucache.contains(1)}); </code> } ``` :rocket: Usage <ol> <li> Add <code>ziglang-caches</code> as a dependency in your <code>build.zig.zon</code>. <code>build.zig.zon</code> example <code>zig .{ .name = "&lt;name_of_your_package&gt;", .version = "&lt;version_of_your_package&gt;", .dependencies = .{ .caches = .{ .url = "https://github.com/jeevananthan-23/ziglang-caches/archive/&lt;git_tag_or_commit_hash&gt;.tar.gz", .hash = "&lt;package_hash&gt;", }, }, }</code> Set <code>&lt;package_hash&gt;</code> to <code>12200000000000000000000000000000000000000000000000000000000000000000</code>, and Zig will provide the correct found value in an error message. </li> <li> Add <code>lrucache</code> as a module in your <code>build.zig</code>. <code>build.zig</code> example <code>zig const lrucache = b.dependency("caches", .{}); exe.addModule("lrucache", lrucache.module("lrucache"));</code> </li> </ol>
[]
https://avatars.githubusercontent.com/u/1562827?v=4
json-schema-gen
travisstaloch/json-schema-gen
2024-07-03T08:38:40Z
Input arbitrary json. Output zig code which can parse the json.
main
2
14
3
14
https://api.github.com/repos/travisstaloch/json-schema-gen/tags
MIT
[ "json", "wasm", "zig" ]
58
false
2025-03-23T23:00:31Z
true
true
0.14.0
github
[]
json-schema-gen Input arbitrary json. Output zig code which can parse the json. Web https://travisstaloch.github.io/ Motivation When you need to parse arbitrary json in zig, you usually pass <code>std.json.Value</code> to one of the parse() methods. This is convenient but is generally slower and allocates more memory than passing a concrete type. Also, <code>std.json.Value</code> can be a little akward at times. Here is how it looks to access data from the <a>github api</a> with std.json.Value: <code>zig const url = parsed.value.object.get("items").? .array.items[0].object.get("commits_url").?.string;</code> with generated schema: <code>zig const url = parsed.value.items[0].commits_url;</code> Generate a zig schema clone or download this project and run the following, replacing <code>examples/1.json</code> with the path to your json file. ```console $ zig build json -- examples/1.json &gt; /my/project/src/json-schema.zig parsing .../json-schema-gen/examples/1.json schema file .../json-schema-gen/.zig-cache/o/1bcb06dde0b5dc7c91c6fe363f6d75fd/stdout success! printing schema to stdout $ cat /my/project/src/json-schema.zig pub const Root = []const struct { a: struct { b: []const struct { key: ?[]const u8 = null, }, }, }; ``` Running with --verbose shows how the build system uses <code>json-to-zig-schema.zig</code> to generate a zig schema file in the cache. The schema file is then used by <a>src/main.zig</a> to parse the input <code>examples/1.json</code> file. The json path and generated schema paths are shown along with a 'success!' message or an error trace if parsing fails. ```console $ zig build json --verbose -- examples/1.json json-schema-gen/.zig-cache/o/ebdbc614762cd389f778330b79addccd/json-to-zig-schema examples/1.json ... omitted .../json-schema-gen/.zig-cache/o/0ef81ace90ad368f1e00b92e39512af1/parse-json-with-gen-schema examples/1.json parsing .../json-schema-gen/examples/1.json schema file .../json-schema-gen/.zig-cache/o/1bcb06dde0b5dc7c91c6fe363f6d75fd/stdout success! printing schema to stdout ... omitted ``` The <a>zig script</a> has a couple options ```console $ zig build gen -- -h USAGE: $ json-to-zig-schema &lt;?options&gt; options: --debug-json - add a jsonParse() method to each object which prints field names. --dump-schema - print schema json instead of generating zig code. --input-schema - treat input as schema json file and skip build phase. --include-test - add a test skeleton to ouptut. ``` Generate a zig schema from a json schema <ol> <li>generate json schema (optional) <code>console $ zig build $ zig-out/bin/json-to-zig-schema examples/1.json --dump-schema &gt; /tmp/example-1-schema.json</code></li> <li>specify it as input with the <code>--input-schema</code> flag <code>console $ zig-out/bin/json-to-zig-schema /tmp/example-1-schema.json --input-schema pub const Root = []const struct { a: struct { b: []const struct { key: ?[]const u8 = null, }, }, };</code></li> </ol> Using generated schema <a>src/main.zig</a> and <a>src/tests.zig</a> both show how to pass the generated schema file to a std.json.parse() method. If you want to do the same, you can <ol> <li>run <code>zig build json /path/to/my.json</code> and either redirect stdout to a file or pipe to your editor and save it next to your zig project. lets call it <code>json-schema.zig</code></li> <li>redirect to file: <code>zig build json -- examples/1.json &gt; /my/project/src/json-schema.zig</code></li> <li>pipe to editor: <code>zig build json -- examples/1.json | nvim -</code></li> <li>add this line a zig file where you want to use it: <code>const generated = @import("json-schema.zig");</code></li> <li>parse your json.</li> </ol> Troubleshooting parse errors If your json file won't parse, you can use the --debug-json option to generate zig code which prints field names as they are parsed. ```console $ zig build json -- examples/1.json --debug-json ... omitted a b key success! ... omitted ``` Hopefully that narrows your search for the problem json field and helps decide what edits to make to <code>json-schema.zig</code>. Or if you find a way to improve the <a>schema gen script</a> to fix your parse error, patches are welcome. Please add a reproduction of your parse error to examples/ and a test case to <a>src/tests.zig</a>. You'll need to add entries for your file to <code>example_mods</code> and <code>example_fmts</code>.
[]
https://avatars.githubusercontent.com/u/113083639?v=4
zstbi
zig-gamedev/zstbi
2024-08-07T22:58:40Z
Zig bindings and build package for stb_image, stb_image_resize and stb_image_write
main
2
14
8
14
https://api.github.com/repos/zig-gamedev/zstbi/tags
MIT
[ "bindings", "gamedev", "stb-image", "zig" ]
132
false
2025-05-13T11:40:41Z
true
true
0.13.0-dev.351+64ef45eb0
github
[]
<a>zstbi</a> Zig bindings and build package for stb_image, stb_image_resize and stb_image_write from <a>Sean Barrett's stb single-file C libraries</a> Features <ul> <li>Supports Zig memory allocators</li> <li>Supports decoding most popular formats</li> <li>Supports HDR images</li> <li>Supports 8-bits and 16-bits per channel</li> <li>Supports image resizing</li> <li>Supports image writing (.png, .jpg)</li> </ul> Getting started Add <code>zstbi</code> to your <code>build.zig.zon</code> .dependencies with: <code>zig fetch --save git+https://github.com/zig-gamedev/zstbi</code> and in your <code>build.zig</code> add: ```zig pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ ... }); <code>const zstbi = b.dependency("zstbi", .{}); exe.root_module.addImport("zstbi", zstbi.module("root")); </code> } <code>`` Now in your code you may import and use</code>zstbi`. Init the lib. <code>zstbi.init()</code> is cheap and you may call it whenever you need to change memory allocator. Must be called from the main thread. ```zig const zstbi = @import("zstbi"); zstbi.init(allocator); defer zstbi.deinit(); <code></code>zig pub const Image = struct { data: []u8, width: u32, height: u32, num_components: u32, bytes_per_component: u32, bytes_per_row: u32, is_hdr: bool, ... <code></code>zig pub fn loadFromFile(pathname: [:0]const u8, forced_num_components: u32) !Image pub fn loadFromMemory(data: []const u8, forced_num_components: u32) !Image pub fn createEmpty(width: u32, height: u32, num_components: u32, args: struct { bytes_per_component: u32 = 0, bytes_per_row: u32 = 0, }) !Image pub fn info(pathname: [:0]const u8) struct { is_supported: bool, width: u32, height: u32, num_components: u32, } pub fn resize(image: *const Image, new_width: u32, new_height: u32) Image pub fn writeToFile( image: *const Image, filename: [:0]const u8, image_format: ImageWriteFormat, ) ImageWriteError!void pub fn writeToFn( image: <em>const Image, write_fn: </em>const fn (ctx: ?<em>anyopaque, data: ?</em>anyopaque, size: c_int) callconv(.C) void, context: ?*anyopaque, image_format: ImageWriteFormat, ) ImageWriteError!void <code></code>zig var image = try zstbi.Image.loadFromFile("data/image.png", forced_num_components); defer image.deinit(); const new_resized_image = image.resize(1024, 1024); <code>Misc functions:</code>zig pub fn isHdr(filename: [:0]const u8) bool pub fn is16bit(filename: [:0]const u8) bool pub fn setFlipVerticallyOnLoad(should_flip: bool) void ```
[ "https://github.com/Avokadoen/zig_vulkan", "https://github.com/flyfish30/zig-basic", "https://github.com/foxnne/aftersun", "https://github.com/foxnne/pixi", "https://github.com/yusdacra/levent", "https://github.com/zewenn/TAGe4", "https://github.com/zig-gamedev/zig-gamedev" ]
https://avatars.githubusercontent.com/u/60631511?v=4
dishwasher
edqx/dishwasher
2024-06-09T23:50:43Z
A non-spec-compliant, but probably pretty fast, XML parser for Zig.
master
0
13
0
13
https://api.github.com/repos/edqx/dishwasher/tags
MIT
[ "household-appliance", "xml", "zig", "zig-package" ]
344
false
2025-05-14T18:30:14Z
true
true
unknown
github
[]
Dishwasher A fairly fast XML parser for <a>Zig</a>. Note that this parser isn't strictly spec-compliant, however it will probably work with most well-formed xml documents. Features <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> Pretty speedy <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> Reader API-friendly <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> Can populate structs <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> Can populate dynamic values <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> Compile-time parsing <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> Diagnostics for malformed documents <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> Stringification (coming soon) Benchmarks Here are the results from the given benchmarks on my pc (i9-14900kf) in different optimisation modes, when parsing the <a>OpenGL XML Spec document</a> fully. | Mode | Min | Max | Avg | |------|-----|-----|-----| | <code>Debug</code> | <code>100ms</code> | <code>280ms</code> | <code>131ms</code> | | <code>ReleaseSafe</code> | <code>13ms</code> | <code>25ms</code> | <code>15ms</code> | | <code>ReleaseSmall</code> | <code>18ms</code> | <code>50ms</code> | <code>30ms</code> | | <code>ReleaseFast</code> | <code>7ms</code> | <code>27ms</code> | <code>13ms</code> | <em>All times are averaged over 100 runs, rounded to the nearest 2sf.</em> Usage Dishwasher has 4 APIs, 3 of which will be most useful. <ul> <li><a>Parsing API</a> - for parsing an entire XML document at runtime.</li> <li><a>Populate API</a> - for mapping an XML document to a given struct.</li> <li><a>Comptime Parsing and Populate API</a> - for parsing an entire XML document at compile time.</li> <li><a>Scanner API</a> - for iterating through XML symbols from a slice or reader.</li> </ul> Parsing API Dishwasher lets you parse an XML document from either an entire slice or a reader into a tree-like structure that represents all nodes. All of the parse methods create an arena which is returned back to you so that you can deinitialise it when you no longer need the data. Parse from a slice ```zig const owned_tree = dishwasher.parse.fromSlice(allocator, xml_text); defer owned_tree.deinit(); // all strings and lists will be free'd std.debug.assert(owned_tree.tree.children[0] == .elem); ``` Parse from a reader ```zig const owned_tree = dishwasher.parse.fromReader(allocator, file.reader()); defer owned_tree.deinit(); std.debug.assert(owned_tree.tree.children[0] == .elem); ``` Diagnostics You can also get basic information about invalid documents using the parse diagnostics struct, and passing it into either <code>parse.fromSliceDiagnostics</code> or <code>parse.fromReaderDiagnostics</code>. ```zig var diagnostics = dishwasher.parse.Diagnostics.init(allocator); defer diagnostics.deinit(); const parsed = try dishwasher.parse.fromReaderDiagnostics(allocator, file.reader(), &amp;diagnostics); defer parsed.deinit(); for (diagnostics.defects.items) |defect| { std.debug.print("{} from {}..{}", .{ defect.kind, defect.range.start, defect.range.end }); } ``` Tree API The returned tree has the following signature: ```zig const Tree = struct { pub const Node = union(enum) { pub const Elem = struct { pub const Attr = struct { name: []const u8, value: ?[]const u8, }; <code> tag_name: []const u8, attributes: []const Attr, tree: ?Tree, // Get an attribute given its name. pub fn attributeByName(self: Elem, needle: []const u8) ?Attr; pub fn attr(self: Elem, needle: []const u8) ?Attr; // Get the value of an attribute given its name. Note that if the // attribute has no value, e.g., &lt;button disabled&gt; this will // still return null. Use attr or attributeByName in those // cases. pub fn attributeValueByName(self: Elem, needle: []const u8) ?[]const u8; pub fn attrValue(self: Elem, needle: []const u8) ?[]const u8; }; pub const Text = struct { contents: []const u8, // Return the text without any whitespace at the beginning or end. pub fn trimmed(self: Text) []const u8; } pub const Comment = struct { contents: []const u8, }; elem: Elem, text: text, comment: Comment, }; children: []const Node, // Find an element child by its tag name pub fn elementByTagName(self: Tree, needle: []const u8) ?Node.Elem; pub fn elem(self: Tree, needle: []const u8) ?Node.Elem; // Allocate a slice for all of the element children of a given tag name // To free the returned slice, you can just call allocator.free(elements) // where 'elements' is the returned slice. pub fn elementsByTagNameAlloc(self: Tree, allocator: std.mem.Allocator, needle: []const u8) ![]Node.Elem; pub fn elemsAlloc(self: Tree, allocator: std.mem.Allocator, needle: []const u8) ![]Node.Elem; // Get an element by the value of one of its attributes pub fn elementByAttributeValue(self: Tree, needle_name: []const u8, needle_value: []const u8) ?Node.Elem; pub fn elemByAttr(self: Tree, needle_name: []const u8, needle_value: []const u8) ?Node.Elem; // Return the inner text (not including the elements) of the tree. Note that the // result will be entirely unformatted. pub fn concatTextAlloc(self: Tree, allocator: std.mem.Allocator) ![]const u8; // Return the inner text (not including the elements) of the tree but without // any whitespace at the start or end. pub fn concatTextTrimmedAlloc(self: Tree, allocator: std.mem.Allocator) ![]const u8; </code> } ``` Populate API Often, it's useful to be able to populate a given struct with values from an XML document. That is, 'reading' the document into the struct. Dishwasher comes with a shaping API so you can dictate how the document should be read into the struct. Simply declare an <code>xml_shape</code> on the struct: ```zig const Job = struct { title: []const u8, start_date: []const u8, end_date: []const u8, } const Person = struct { pub const xml_shape = .{ .name = .content_trimmed, .age = .{ .attribute, "age" }, .jobs = .{ .elements, "job", .{ .start_date = .{ .attribute, "start_date" }, .end_date = .{ .attribute, "end_date" }, .title = .content_trimmed, .fired = .attribute_exists, } }, .location = .{ .one_of, .{ .element, "house", .content }, .{ .element, "work", .content }, .none, }, .apprentice = .{ .maybe, .{ .element, "apprentice", Person } }, .children = .{ .elements, "child", Person }, }; <code>name: []const u8, age: []const u8, jobs: []struct { start_date: []const u8, end_date: []const u8, title: []const u8, fired: bool, }, location: union(enum) { house: []const u8, work: []const u8, none: void, }, apprentice: ?*Person, children: []Person, </code> }; pub const Register = struct { pub const xml_shape = .{ .people = .{ .elements, "person", Person }, }; <code>people: []Person, </code> }; const register = try diswasher.Populate(Register).initFromSlice(allocator, xml_text); defer register.deinit(); // register.value: Register ``` Alternatively, you can populate an existing struct: <code>zig var register: Register = undefined; const arena = try dishwasher.Populate(Register).fromSlice(allocator, xml_text, &amp;register); defer arena.deinit();</code> If you want to own all of your values yourself, use: ```zig const owned_tree = dishwasher.parse.fromReader(allocator, file.reader()); defer owned_tree.deinit(); const register = try dishwasher.Populate(Register).initFromTreeOwned(allocator, owned_tree.tree); // free 'register' values yourself.. ``` Dynamic values If some field accepts any sort of XML document shape, you can instruct it to accept a <code>parse.Tree</code>: ```zig const Register = struct { pub const xml_shape = .{ .people = .{ .elements, "person", dishwasher.parse.Tree }, }; people: []dishwasher.parse.Tree, }; ``` <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> Note that the tree is not duplicated for you, so if you use the <code>initFromTreeOwned</code> method, the values in the tree will still belong to the arena that was initialised for the tree. </blockquote> Free struct If you use the <code>initFromTreeOwned</code> population method, you can free all of the values in an arena-friendly way with: <code>zig dishwasher.Populate(Register).deinit(allocator, register);</code> Comptime Parsing and Populate API It could be useful to parse an XML document at compile time, for example for some inline code generation. While comptime doesn't have allocators, there's a custom API for this: <code>zig const tree = dishwasher.parse.fromSliceComptime(xml_text);</code> Check out the <a>Tree API</a> to know what to do with the returned value. Comptime Populate API If you want to populate a struct at compile time, you can use the <code>*Comptime</code> methods on the <code>Populate</code> struct: <code>zig const register = dishwasher.Populate(Register).initFromSliceComptime(xml_text);</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> Remember that for the target struct, all pointers need to be <code>*const T</code> or <code>[]const T</code>. </blockquote> Scanner API If you want low-level access to the iterator for lexing an XML document, you can use the Scanner API, which accepts a slice buffer: <code>zig var xmlScanner = Scanner.fromSlice(xml_text); while (try xmlScanner.next()) |token| { std.debug.print("token kind: ", .{ token.kind }); }</code> If you have a reader and no access to the entire slice, the Reader API can connect any reader to the Scanner API so you can lex from a reader: <code>zig var xmlReader = Scanner.staticBufferReader(file.reader()); while (try xmlScanner.next()) |token| { std.debug.print("token kind: ", .{ token.kind }); }</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> If you're given an error about running out of buffer space, try increase the reader buffer size with <code>zig const buffer_size = 4096; const XmlFileReader = zigScanner.StaticBufferReader(@TypeOf(file.reader()), buffer_size); const xmlReader = XmlFileReader.init(file.reader());</code> </blockquote> Comptime Scanner The scanner works during compile time without any modification. License All dishwasher code is under the MIT license.
[ "https://github.com/Zig-Sec/kdbx" ]
https://avatars.githubusercontent.com/u/124872?v=4
zig-aes-gem
jedisct1/zig-aes-gem
2024-07-13T23:19:08Z
AES-GEM (AES Galois Extended Mode) implementation.
main
0
13
1
13
https://api.github.com/repos/jedisct1/zig-aes-gem/tags
MIT
[ "aes", "aes-gem", "gem", "zig", "zig-package" ]
4
false
2025-03-07T05:42:44Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/109542784?v=4
aws-sdk-zig
by-nir/aws-sdk-zig
2024-02-26T22:48:38Z
🟧 AWS SDK for the Zig programming language
main
0
13
0
13
https://api.github.com/repos/by-nir/aws-sdk-zig/tags
MIT
[ "aws", "aws-sdk", "cloud", "sdk", "zig", "zig-package" ]
1,354
false
2025-02-24T18:03:42Z
true
true
0.14.0
github
[ { "commit": null, "name": "smithy", "tar_url": null, "type": "relative", "url": "smithy" }, { "commit": null, "name": "aws", "tar_url": null, "type": "relative", "url": "aws" }, { "commit": "1b147145c53dab1e7910c6de81a3749e6e71457b", "name": "aws-models", ...
AWS SDK for Zig <a></a> <strong>The <em>AWS SDK for Zig</em> provides an interface for <em>Amazon Web Services (AWS)</em>.</strong> <blockquote> <span class="bg-red-100 text-red-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300">CAUTION</span> This project is in early development, DO NOT USE IT IN PRODUCTION! Support for the remaining services and features will be added as the project matures and stabilize. <strong>Breaking changes are imminent!</strong> </blockquote> <em>Pure Zig implementation,</em> from code generation to runtime SDKs. Building upon the language’s strong foundation, this project provides a <strong>performant</strong> and fully functioning SDKs, while <strong>minimizing dependencies</strong> and increased <strong>platform portability</strong>. <blockquote> [!TIP] Use the <a>AWS Lambda Runtime for Zig</a> to deploy Lambda functions written in Zig. </blockquote> Supported Features Authentication | Status | Method | Runs locally | |:------:|:-------|:------------:| | | <a>IAM Identity Center authentication</a> | ✓ | | | <a>IAM Roles Anywhere</a> | ✓ | | | <a>Assume a role</a> | ✓ | | ✓ | <a>AWS access keys</a> | ✓ | | | <a>IAM roles for EC2 instances</a> | | Settings | Status | Feature | Notes | |:------:|:--------|:------| | | <a>Application ID</a> | | | | <a>Amazon EC2 instance metadata</a> | | | | <a>Amazon S3 access points</a> | | | | <a>Amazon S3 Multi-Region Access Points</a> | | | ✓ | <a>AWS Region</a> | | | | <a>AWS STS Regionalized endpoints</a> | | | ✓ | <a>Dual-stack and FIPS endpoints</a> | | | | <a>Endpoint discovery</a> | | | | <a>General configuration</a> | | | | <a>IMDS client</a> | | | | <a>Retry behavior</a> | | | | <a>Request compression</a> | | | | <a>Service-specific endpoints</a> | | | | <a>Smart configuration defaults</a> | | Contributing <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> At this point, the project serves as environment for developing other experimental sub-projects. This initiative is in an exploratory phase and is <strong>not yet ready for contributions</strong>. </blockquote> | 📁 | Description | |:----------------------------------|:----------------------------------------------------------------| | <a>sdk</a> | AWS SDKs for Zig<em>Auto-generated, do not modify manually!</em> | | <a>aws/runtime</a> | SDK runtime shared by all the services | | <a>aws/codegen</a> | AWS-specific source generation pipeline | | <a>smithy/runtime</a> | <a>Smithy 2.0</a> client runtime | | <a>smithy/codegen</a> | <a>Smithy 2.0</a> source generation pipeline | CLI Commands <ul> <li><code>zig build --build-file build.codegen.zig</code> Generate the AWS SDKs source code.<ul> <li>Optionally specify one or more <code>-Dfilter=sdk_codename</code> to select specific services.</li> </ul> </li> <li><code>zig build test:&lt;service&gt;</code> Run generated SDK service’s unit tests.</li> </ul> License The author and contributors are not responsible for any issues or damages caused by the use of this software, part of it, or its derivatives. See <a>LICENSE</a> for the complete terms of use. <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> <em>AWS SDK for Zig</em> is not an official <em>Amazon Web Services</em> software, nor is it affiliated with <em>Amazon Web Services, Inc</em>. </blockquote> The SDKs code is generated based on a dataset of <em>Smithy models</em> created by <em>Amazon Web Services</em>. The models are extracted from the official <a>AWS SDK for Rust</a> and <a>licensed</a> as declared by Amazon Web Services, Inc. at the source repository. This codebase, including the generated code, are covered by a <a>standalone license</a>. References Smithy <ul> <li><a>Smithy Spec</a></li> <li><a>Smithy Reference Implementation</a></li> <li><a>Smithy Rust</a></li> </ul> AWS SDKs <ul> <li><a>AWS SDKs and Tools Reference Guide</a></li> <li><a>AWS Common Runtime (CRT) libraries</a></li> <li><a>AWS SDK for C++</a></li> <li><a>AWS SDK for Rust</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/9478529?v=4
cross-compiling-rust-c-wasm-zig
scristobal/cross-compiling-rust-c-wasm-zig
2024-02-17T16:39:09Z
Cross compiling Rust + C codebase to Web Assembly (web and WASI) using Zig
main
0
13
0
13
https://api.github.com/repos/scristobal/cross-compiling-rust-c-wasm-zig/tags
-
[ "c", "crosscompile", "rust", "wasi", "wasm", "webassembly", "zig" ]
71
false
2025-05-03T10:55:05Z
false
false
unknown
github
[]
Crosscompile a Rust project with C dependencies into Web Assembly (WASM and WASI) using Zig Easy way using <a>rust-bindgen</a> and <a>cargo-zigbuild</a> CLI tools. Generate Rust bindings for the C code We just need the C/C++ header files wit the definitions and <a>rust-bindgen</a> will generate the Rust FFI bindings. <code>bash bindgen some-c-code/gcd.h -o src/bindings.rs # generate Rust FFI bindings for gcd.h</code> Quick WASI try out Using <a>zigbuild</a> we can cross compile to WASI <code>bash rustup target add wasm32-wasip1 # make sure wasm32-wasi target is installed cargo zigbuild --target=wasm32-wasip1 --release # cross compile to WASI, release flag is optional</code> <blockquote> [!warning] Previously the target <code>wasm32-wasip1</code> was <code>wasm32-wasi</code> but it is now being deprecated, still you might want to use it even if you <a>get some warnings</a>. </blockquote> we can try it with <a>wasm3</a> engine <code>bash wasm3 target/wasm32-wasip1/release/rust-ffi-playground.wasm # try it out, requires wasm3</code> or <a>wasmi</a> <code>bash wasmi_cli target/wasm32-wasip1/release/rust-ffi-playground.wasm # run it with wasmi runtime</code> Cross compile for web (WASM) Generate code for WASM with <a>zigbuild</a>, and then use <a>wasm-bindgen</a> to generate the js/ts bindings to the WASM code. <code>bash cargo zigbuild --target=wasm32-unknown-unknown --release # cross compile to WASM, release flag is optional wasm-bindgen target/wasm32-unknown-unknown/release/rust-ffi-playground.wasm --out-dir ./dist --target web # generate JS and TS FFI bindings into WASM code</code> To try it, manually include the script tag to load and initialize the wasm module ```html import init from "./bin/rust-ffi-playground.js"; init().then(() =&gt; console.log("WASM Loaded")); ``` or use a WASM plugin like <a><code>vite-plugin-wasm</code></a> or use <a>Trunk</a> Note: As in this <a>github issue</a> it can be compiled to <code>wasm32-unknown-emscripten</code>. Same <a>example</a> but using <code>wasm-pack</code>, hence <code>wasm-bindgen</code> instead Going further Not a trivial project, eg. building a native library, link to a system library... Replace CLI commands with a simple <code>Makefile</code> or (even better) a <code>builder.rs</code> file, eg. use <code>cargo_zigbuild</code> and <code>bindgen</code> directly in <code>build.rs</code> by replacing <code>cc</code> with <code>zigbuild</code> ```rust use cargo_zigbuild::Zig::Cc; use std::{env, error::Error}; fn main() -&gt; Result&lt;(), Box&gt; { cc::Build::new().file("some-c-code/def.c").compile("def"); <code>let out_dir = env::var("OUT_DIR").unwrap(); let cc = Cc { args: vec![ format!("some-c-code/def.c"), "-c".to_string(), "-o".to_string(), format!("{}/def.o", out_dir), ], }; cc.execute().expect("Failed to compile def.c"); let ar = cargo_zigbuild::Zig::Ar { args: vec![ "crus".to_string(), format!("{}/libdef.a", out_dir), format!("{}/def.o", out_dir), ], }; ar.execute().expect("Failed to create def.a"); println!("cargo:rustc-link-search=native={}", out_dir); println!("cargo:rustc-link-lib=static=def"); println!("cargo:rerun-if-changed=some-c-code"); println!("cargo:rerun-if-changed=build.rs"); Ok(()) </code> } ``` References <ul> <li><a>The <code>cc-rs</code> project</a></li> <li><a>Official cargo reference</a></li> <li><a>zig.guide's Cross-compilation</a></li> <li><a><code>zig cc</code>: a Powerful Drop-In Replacement for GCC/Clang</a></li> <li><a>Bindgen tutorial</a></li> <li><a>The embedded Rust book</a></li> <li><a>Shrinking <code>.wasm</code> code size</a></li> </ul> Issues wasm-bindgen targets <code>wasm32-unknown-unknown</code> and <code>wasi-unknown</code> do not (fully) support C-ABI, only older targets like <code>wasm32-unknown-emscripten</code>. See <a>comment</a>, <a>comment</a> and <a>documentation PR</a> There is an experimental flag <code>--Z wasm_c_abi=spec</code> that <a>circumvents this limitation</a> Other tools <ul> <li><a>c2rust</a> - C to Rust translator produces <code>unsafe</code> Rust code from C99-compilant C code. It does not support cross compilation, but maybe it can with the help of Zig.</li> </ul> From their website: <blockquote> C source code is parsed and typechecked using clang before being translated by our tool. </blockquote> would it be possible to use it with Zig as a drop-in replacement for clang? From their README: <blockquote> I translated code on platform X, but it didn't work correctly on platform Y. We run the C preprocessor before translation to Rust. This specializes the code to the host platform. For this reason, we do not support cross compiling translated code at the moment. What platforms can C2Rust be run on? The translator and refactoring tool support both macOS and Linux. Other features, such as cross checking the functionality between C and Rust code, are currently limited to Linux hosts. </blockquote> Utils <ul> <li><a>https://wasm-feature-detect.surma.technology/</a> <a>source</a></li> </ul> Remarks <blockquote> In general, a <code>lib&lt;name&gt;.so</code> or <code>lib&lt;name&gt;.a</code> should be referenced in the build file by <code>&lt;name&gt;</code>. </blockquote>
[]
https://avatars.githubusercontent.com/u/14044749?v=4
raylib-zig-bindings
L-Briand/raylib-zig-bindings
2024-05-24T11:09:22Z
One to one translation of raylib.h, rlgl.h, rcamera.h and raygui.h files in zig. Build tools to compile raylib from source with simple zon dependency.
master
1
13
2
13
https://api.github.com/repos/L-Briand/raylib-zig-bindings/tags
Zlib
[ "raygui", "raylib", "raylib-binding", "zig" ]
96
false
2025-01-01T19:22:12Z
true
true
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/8823448?v=4
init
lawrence-laz/init
2024-06-26T19:46:29Z
A command line tool for initializing files and directories
main
1
12
0
12
https://api.github.com/repos/lawrence-laz/init/tags
GPL-3.0
[ "cli", "command-line", "command-line-tool", "zig" ]
43
false
2025-01-12T00:07:30Z
true
true
0.13.0
github
[ { "commit": "c0193e9247335a6c1688b946325060289405de2a", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/c0193e9247335a6c1688b946325060289405de2a.tar.gz", "type": "remote", "url": "https://github.com/Hejsil/zig-clap" } ]
<code>html .__ .__ __ |__| ____ |__|/ |_ | |/ \| \ __\ | | | \ || | |__|___| /__||__| \/</code> Create custom project templates with ease. 📦 Install <ol> <li>Build from source: <code>sh git clone --depth 1 https://github.com/lawrence-laz/init &amp;&amp; cd init &amp;&amp; zig build --release=safe</code></li> <li>Add an alias to your shell config: <code>sh alias init="/path/to/init/zig-out/bin/init -c '/path/to/init/config/'"</code></li> </ol> 🔨 Create a template <ol> <li>Create a directory for your new template: <code>sh mkdir -p config/templates/your-template-name</code></li> <li>Create template sub-directory structure and files, for example: <code>config/templates/your-template-name |- src/ | |- main.zig |- build.zig |- build.zig.zon</code></li> </ol> 🎉 Use <code>sh mkdir my-project &amp;&amp; cd my-project init your-template-name</code> Parameters Templates can have parameters, which are surrounded by three underscores (ex. <code>___name___</code>) in file contents, file and directory names. Then they can be used by calling <code>init</code> with <code>-p name=value</code> For example running: <code>sh init your-template-name -p name=my-project -p "description=My very own project."</code> Would replace: - from <code>./your-template-name/dir-___name___/</code> to <code>./dir-my-project/</code> - from <code>./your-template-name/___name___.txt</code> to <code>./my-project.txt</code> - and contents of <code>some-file.txt</code> from <code>This project name is ___name___</code> to <code>This project name is my-project</code>
[]
https://avatars.githubusercontent.com/u/55673467?v=4
build.nvim
cyuria/build.nvim
2024-04-20T09:09:07Z
A neovim plugin written in lua to automatically detect your current workspace's build system and set makeprg accordingly
main
3
12
1
12
https://api.github.com/repos/cyuria/build.nvim/tags
MIT
[ "build-tools", "cargo", "cmake", "makefile", "mesonbuild", "neovim-plugin", "setuptools", "zig" ]
35
false
2025-02-03T06:55:18Z
false
false
unknown
github
[]
build.nvim A neovim plugin written in lua which automatically detects the build system of your current project and sets <code>makeprg</code> accordingly. Requirements <ul> <li>neovim &gt;= 0.8</li> </ul> Features Automatically detects your build system based on the first build file found, currently supports: - CMake (<code>CMakeLists.txt</code>) - Make (<code>Makefile</code>) - Meson (<code>meson.build</code>) - Zig (<code>build.zig</code>) - Cargo (<code>Cargo.toml</code>) - Setuptools (<code>setup.py</code>) Automatically detects project root based on the presence of a file - Git, mercurial, svn and a few other version control systems - A <code>package.json</code> file - Failing all else, <em>build.nvim</em> searches recursively downwards for known build system files Highly customisable, with sensible defaults - You can configure almost everything. Installation Install as you would any other plugin. vim-plug ```vim " Vimscript Plug "cyuria/build.nvim" lua &lt;&lt; EOF require('build').setup { -- put your configuration here -- or don't, see the config section for -- available options and defaults } EOF ``` lazy <code>lua { "cyuria/build.nvim", opts = {} }</code> packer <code>lua -- lua use { "cyuria/build.nvim", config = function() require('build').setup { -- put your configuration here -- or don't, see the config section for -- available options and defaults } end }</code> Usage For detailed info, see <code>:help build.nvim</code>. To use <em>build.nvim</em>, just run <code>:make</code> as you would with any Makefile based build system. Even if you aren't in the project root directory, <em>build.nvim</em> should automatically find the project root and add extra arguments for you. I.e. instead of running <code>make</code> <em>build.nvim</em> will run <code>make -C /PATH/TO/YOUR/PROJECT/ROOT</code> when in a makefile based build system. A Note for Some Build Systems Some build systems, i.e. meson and cargo, will need an extra argument, such as <code>:make compile</code> with meson or <code>:make build</code> with cargo. This allows you more control, like running <code>:make test</code> or <code>:make check</code> instead. Configuration <em>build.nvim</em> comes with the following options and defaults. ```lua require('build').setup({ -- Set the makeprg variable during the setup call set_makeprg_immediately = true, <code>-- A list of autocommand events upon which to update/set the makeprg -- varaible update_on_event = { "DirChanged", }, -- A list of files used for detecting the project root. If any one of these -- files or directories is detected, that directory is selected as the root -- directory. If none of the files are found, recursively descend the -- directory tree until one of them is found root_files = { ".git", "package.json", "_darcs", ".hg", ".bzr", ".svn", }, -- A list of directories to search for which will be set as the build -- directory for the project build_dirs = { "build", "builddir", "bin" }, -- Custom build system indicators and programs. Can also be used to -- overwrite existing indicators and/or programs extra_indicators = {}, extra_programs = {}, -- The path of the JSON file used to store individually set build -- directories on a case by case basis using the project root directory build_dirs_file = vim.fn.stdpath('data') .. '/build.nvim/build_directories.json', </code> }) ``` Contributing Please feel free to submit any PRs or issues, especially if they add support for more build systems. It would be great if we could support every build system under the sun. Some currently unsupported systems which would be nice to support are - build2 - Maven or Gradle or something java I don't know - Bazel - Better support for the different variations of Make (i.e. GNU make vs BSD make vs NMake etc) - Ninja Another cool feature I've been thinking about but been too lazy to implement is adding a default make command for meson/cargo etc, so that you can run <code>:make</code> and it will default to <code>:make build</code> or whatever equivalent. If you want to open a PR for this that would be incredible.
[]
https://avatars.githubusercontent.com/u/119983202?v=4
fastlanez
spiraldb/fastlanez
2024-02-26T15:25:02Z
A Zig implementation of the paper Decoding >100 Billion Integers per Second with Scalar Code.
develop
2
12
0
12
https://api.github.com/repos/spiraldb/fastlanez/tags
Apache-2.0
[ "compression", "simd", "zig" ]
100
false
2024-09-19T16:38:45Z
true
true
0.11.0
github
[ { "commit": "refs", "name": "zig-cycleclock", "tar_url": "https://github.com/fulcrum-so/zig-cycleclock/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/fulcrum-so/zig-cycleclock" } ]
<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 repository is deprecated, please see our Rust implementation: https://github.com/spiraldb/fastlanes </blockquote> FastLanez A Zig implementation of the paper <a>Decoding &gt;100 Billion Integers per Second with Scalar Code</a>. Huge thanks to <a><strong>Azim Afroozeh</strong></a> and <a><strong>Peter Boncz</strong></a> for sharing this incredible work. Supported Codecs: * <strong>Bit-Packing</strong> - packing T bit integers into 0 &lt;= W &lt; T bit integers. * <strong>Delta</strong> - taking the difference between adjacent values. * <strong>Fused Frame-of-Reference</strong> - a fused kernel that subtracts a reference value before applying bit-packing. Requires Zig trunk &gt;= 0.12.0-dev.2541 Benchmarks can be run with <code>zig build bench -Doptimize=ReleaseSafe</code> What is FastLanes? FastLanes describes a practical approach to developing SIMD-based lightweight compression codecs. With a clever transposed layout of data it enables efficient compression and decompression among CPUs with varying width SIMD registers, even for codecs with data dependencies such as Delta and RLE. FastLanes operates over vectors of 1024 elements, 1024-bits at a time. It is up to the caller to decide how to handle padding. A typical FastLanes codec might look something like this: <ul> <li>Take an <code>FL.Vector</code> of 1024 elements of width <code>T</code>.</li> <li>Transpose the vector with <code>FL.transpose</code>.</li> <li>Apply a light-weight codec, such as <code>Delta</code>.</li> <li>Bit-pack into integers of width <code>W</code>.</li> <li>Return the <code>W * MM1024</code> words.</li> </ul> Strictly speaking, the transpose is only required for codecs with data dependencies, i.e. where the output value of the next element depends on the previous element. However, if all FastLanes compressed vectors are ordered the same way, it's possible to more efficiently perform comparisons between these vectors without un-transposing the data. Unified Transposed Layout The transposed layout works like this: * Take a 1024 element vector. * Split into 8 blocks of 128 elements. * Transpose the 128 elements from 8x16 to 16x8. * Reorder the blocks according to <code>0, 4, 2, 6, 1, 5, 3, 7</code> <blockquote> Figure 6d in the paper is very helpful for visualizing this! </blockquote> With this order it is possible to make adjacent cells appear in adjacent SIMD words, regardless of how wide the CPU's SIMD register is. For example, a vector of u32s will be rearranged and then iterated such that adjacent words look like this: ``` 2xu32 64-bit SIMD { 0, 64 } { 1, 65 } { 2, 66 } ... 4xu32 128-bit SIMD { 0, 64, 128, 192 } { 1, 65, 129, 193 } { 2, 66, 130, 194 } ... 16xu32 512-bit SIMD { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 } { 1, 65, 129, 193, 257, 321, 385, 449, 513, 577, 641, 705, 769, 833, 897, 961 } { 2, 66, 130, 194, 258, 322, 386, 450, 514, 578, 642, 706, 770, 834, 898, 962 } ... ``` Note that for a codec like Delta, instead of taking the delta from a single starting element, we must start with a 1024-bits worth of base values. So 32 * u32s. Design of FastLanez FastLanez leverages Zig's SIMD abstraction to create a virtual 1024-bit word: <code>@Vector(1024 / @bitSizeOf(T), T)</code>. This allows us to implement codecs that are astonishingly close to the psuedo-code presented by the paper. Here is Listing 2 (unpacking 3-bit integers into 8-bit integers) ported to FastLanez with line-breaks adjusted to match the original: ```zig comptime var mask: [W + 1]E = undefined; inline for (0..W + 1) |i| { mask[i] = (1 &lt;&lt; i) - 1; } var r0: FL.MM1024 = undefined; var r1: FL.MM1024 = undefined; r0 = FL.load(in, 0); r1 = FL.and_rshift(r0, 0, mask[3]); FL.store(out, 0, r1); r1 = FL.and_rshift(r0, 3, mask[3]); FL.store(out, 1, r1); r1 = FL.and_rshift(r0, 6, mask[2]); r0 = FL.load(in, 1); FL.store(out, 2, FL.or_(r1, FL.and_lshift(r0, 2, mask[1]))); r1 = FL.and_rshift(r0, 1, mask[3]); FL.store(out, 3, r1); r1 = FL.and_rshift(r0, 4, mask[3]); FL.store(out, 4, r1); r1 = FL.and_rshift(r0, 7, mask[1]); r0 = FL.load(in, 2); FL.store(out, 5, FL.or_(r1, FL.and_lshift(r0, 1, mask[2]))); r1 = FL.and_rshift(r0, 2, mask[3]); FL.store(out, 6, r1); r1 = FL.and_rshift(r0, 5, mask[3]); FL.store(out, 7, r1); ``` Zig's comptime feature allows us to wrap up this logic and generate <strong>all</strong> kernels at compile-time without any runtime performance overhead: ```zig const FL = FastLanez(u8); pub fn unpack(comptime W: comptime_int, in: <em>const FL.PackedBytes(W), out: </em>FL.Vector) void { comptime var unpacker = FL.bitunpacker(W); var tmp: FL.MM1024 = undefined; inline for (0..FL.T) |i| { const next, tmp = unpacker.unpack(in, tmp); FL.store(out, i, next); } } ``` Loop Ordering There is a key difference to the implementation of this library vs FastLanes: loop ordering. <ul> <li>FastLanes: SIMD word, tile, row.</li> <li>FastLanez: tile, row, SIMD word. Where the SIMD word loop is internal to the Zig <code>@Vector</code>.</li> </ul> We can see the difference more clearly with some psuedo-code: <code>zig const a, const b = FL.load(input, 0), FL.load(input, 1); FL.store(output, 0, FL.add(a, b));</code> Unoptimized FastLanes assembly would look something like this: <code>asm LDR ADD STR LDR ADD STR ...</code> Whereas unoptimized FastLanez assembly would look like this: <code>asm LDR LDR ... ADD ADD ... STR STR ...</code> Given there is a limited number of SIMD registers in a CPU, one would expect the FastLanes code to perform better. In fact, our benchmarking suggests that option 2 has a slight edge. Although I don't suspect this will hold true for more complex compression kernels and may become an issue in the future requiring us to invert the loop ordering of this library. Another possible advantage to the FastLanes loop ordering is that we can avoid unrolling the outer SIMD word loop, resulting in potentially much smaller code size for minimal impact on performance. C Library Running <code>zig build lib</code> will generate a static C library in <code>zig-out/lib</code> and a header file in <code>zig-out/include</code>. The header file requires <code>zig.h</code> which is located in the <code>lib_dir</code> output by running <code>zig env</code>. This process should improve as https://github.com/ziglang/zig/issues/13528 is resolved. Installing Zig Running <code>./zigup</code> will download and install the zig version specified in the <code>.zig-version</code> file. We recommend adding <code>$HOME/.zig/zig-latest</code> to your <code>PATH</code>. Python Library TODO: this library will be made available as a Python library using <a>Ziggy Pydust</a>. Benchmarks Benchmarks can be run with <code>zig build bench -Doptimize=ReleaseSafe</code> As with all benchmarks, take the results with a pinch of salt. <blockquote> I found the performance of benchmarks varies greatly depending on whether the inputs and outputs are stack allocated or heap allocated. I was surprised to find that often heap allocation was significantly faster than stack allocation. If anyone happens to know why, please do let me know! </blockquote>
[]
https://avatars.githubusercontent.com/u/22726048?v=4
relay
zfl9/relay
2024-05-12T14:20:49Z
高性能、低资源开销的 relay/proxy 工具
master
0
12
1
12
https://api.github.com/repos/zfl9/relay/tags
AGPL-3.0
[ "iptables", "linux", "nftables", "proxy", "relay", "socks4", "socks5", "ss-tproxy", "transparent-proxy", "trojan", "trojan-gfw", "trojan-go", "zig" ]
97
false
2025-02-12T10:13:43Z
true
false
unknown
github
[]
relay 高性能 relay(中继/转发)工具,类似 socat,但专注于 proxy 领域,通过组合不同的 in、out 协议,可实现: <ul> <li>ipt2socks:<code>in:tproxy</code> + <code>out:socks4/5</code></li> <li>tls-client:<code>in:tproxy</code> + <code>out:tlsproxy</code></li> <li>tls-server:<code>in:tlsproxy</code> + <code>out:raw</code></li> <li>trojan-tproxy:<code>in:tproxy</code> + <code>out:trojan</code></li> <li>trojan-client:<code>in:socks5</code> + <code>out:trojan</code></li> <li>trojan-server:<code>in:trojan</code> + <code>out:raw</code></li> </ul> <blockquote> 积极开发中,优先实现 ipt2socks,并支持 socks4 传出,然后是 tlsproxy 协议、trojan-tproxy 客户端。 </blockquote> 设计目标 <ul> <li>Linux only</li> <li>高性能,尽可能零拷贝,减少系统调用</li> <li>低资源开销,即便是低端路由器也能流畅运行</li> <li>支持条件编译,避免对不需要的协议支付相关成本</li> </ul>
[]
https://avatars.githubusercontent.com/u/87844133?v=4
libffi
vezel-dev/libffi
2024-06-20T05:16:35Z
A friendly libffi fork with a Zig build script and bindings. Migrated to Codeberg.
master
3
12
0
12
https://api.github.com/repos/vezel-dev/libffi/tags
NOASSERTION
[ "bindings", "build", "c", "ffi", "interop", "zig" ]
8,345
true
2025-05-22T02:56:52Z
true
true
unknown
github
[]
Vezel libffi Fork <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> <a>This repository has moved to Codeberg.</a> Please update your <code>build.zig.zon</code> as necessary. The GitHub repository has been archived and will not see further development. </blockquote> This is a friendly fork of <a>libffi</a>. The notable changes made in this fork are the additions of a <a>Zig</a> build script, making it easy to integrate libffi into Zig projects using the Zig package manager, and a set of idiomatic Zig bindings for libffi's main API. Additionally, to reduce the package download size, we have removed a large number of files that are unnecessary when using libffi in a Zig project. Importantly, <strong>all library source code is identical to upstream</strong>, so in terms of API/ABI compatibility, using this fork is no different from linking to a system libffi package. Usage The minimum Zig version supported by this project can be found in the <code>minimum_zig_version</code> field of the <a><code>build.zig.zon</code></a> file. We generally try to track the latest release of Zig. But do note that the <code>master</code> branch may sometimes contain code that only works with a <code>master</code> build of Zig. Please note that the <code>master</code> branch is rebased on top of upstream periodically. <strong>You should use a release tag rather than <code>master</code>.</strong> For example: ```bash zig fetch --save=libffi https://github.com/vezel-dev/libffi/archive/vX.Y.Z-B.tar.gz Or, to use Git: zig fetch --save=libffi git+https://github.com/vezel-dev/libffi.git#vX.Y.Z-B ``` (You can find the latest version on the <a>releases page</a>.) Consume the library in your <code>build.zig</code>: ```zig const libffi = b.dependency("libffi", .{ .target = target, .optimize = optimize, }); exe.root_module.addImport("ffi", libffi.module("ffi")); if (b.systemIntegrationOption("ffi", .{})) { exe.root_module.linkSystemLibrary("ffi", .{}); } else { exe.root_module.linkLibrary(libffi.artifact("ffi")); } ``` You can now use the Zig bindings in your code. See <a><code>example.zig</code></a> for basic usage. License This project is licensed under the terms found in <a><code>LICENSE</code></a>; this file is unchanged from upstream.
[ "https://github.com/allyourcodebase/wayland" ]
https://avatars.githubusercontent.com/u/43353831?v=4
graphs-complexity
storopoli/graphs-complexity
2024-07-25T13:30:22Z
Graph Theory and Computational Complexity
main
0
12
1
12
https://api.github.com/repos/storopoli/graphs-complexity/tags
CC0-1.0
[ "algorithms", "c", "complexity", "typst", "zig" ]
1,687
false
2025-03-29T22:36:36Z
false
false
unknown
github
[]
Graph Theory and Computational Complexity <a></a> <a></a> <a></a> <a></a> <a></a> <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> For the Portuguese version, check out the <a>README-pt.md</a>. Para a versão em português, confira o <a>README-pt.md</a>. </blockquote> Contents <ol> <li>Why study Graph Theory and Computational Complexity?;</li> <li>Graphs, Paths, and Cycles;</li> <li>Trees;</li> <li>Computational Complexity;</li> <li>P, NP-Complete, and NP-Hard Problems.</li> <li>Algorithm Analysis;</li> <li>Search and Sorting Algorithms;</li> <li>Recursion;</li> <li>Divide and Conquer;</li> <li>Dynamic Programming; and</li> <li>Greedy Algorithms.</li> </ol> Code Examples The primary programming language used for examples is C. Also there are <a>Zig</a> examples. Check them at <code>code/c/</code> and <code>code/zig/</code> directories, respectively. Dependencies <ul> <li>C/C++ Compiler;</li> <li>(Optional) <a>Zig</a> compiler; and</li> <li><a><code>typst</code></a> for the slides.</li> </ul> The slides are generated using <a>Typst</a> with GitHub Actions and can be found in the <a><code>latest version</code></a>. License This content is licensed under a <a>Creative Commons Public Domain CC0 1.0 License</a>. <a></a>
[]
https://avatars.githubusercontent.com/u/51416554?v=4
zflame
hendriknielaender/zflame
2024-02-13T17:20:00Z
🔥 Flamegraph Profiling
main
15
11
0
11
https://api.github.com/repos/hendriknielaender/zflame/tags
MIT
[ "flamegraph", "performance", "zig" ]
466
false
2025-04-20T05:14:29Z
true
true
0.14.0
github
[]
zflame - Flamegraph Profiling Tool in Zig <a></a> <a></a> zflame is a cutting-edge flamegraph profiling tool designed for the Zig programming language, aimed at simplifying performance analysis and optimization. By leveraging Zig's low-level capabilities, <code>zflame</code> provides detailed, interactive flamegraphs that help developers identify and address performance bottlenecks in their applications.
[]
https://avatars.githubusercontent.com/u/2242?v=4
zig-duckdb-ext
softprops/zig-duckdb-ext
2024-04-28T05:00:09Z
🐥 a duckdb extension library for zig
main
1
11
0
11
https://api.github.com/repos/softprops/zig-duckdb-ext/tags
MIT
[ "duckdb", "duckdb-extension", "zig", "zigdex-lib" ]
90
false
2025-04-15T02:33:55Z
true
true
unknown
github
[]
duckdb ext 🐥 a <a>DuckDB</a> extension library for zig duck backpack by Vectors Market from <a target="_blank">Noun Project</a> (CC BY 3.0) --- The zig analog to the [c++ extension template](https://github.com/duckdb/extension-template) \- softprops 2024
[]
https://avatars.githubusercontent.com/u/5008987?v=4
zig-fractions
Chriscbr/zig-fractions
2024-07-06T06:39:45Z
Simplify, convert, and do math with fractions in Zig
main
0
11
0
11
https://api.github.com/repos/Chriscbr/zig-fractions/tags
MIT
[ "fractions", "zig", "zig-library", "zig-package" ]
22
false
2025-05-19T16:24:54Z
true
true
unknown
github
[]
zig-fractions A Zig library for performing math with fractions, where each fraction is represented by a pair of integers. Compatible with Zig 0.13 stable. Supported APIs: <ul> <li>convertion from floats, or numerator/denominator pairs (<code>fromFloat()</code>, <code>init()</code>)</li> <li>convertion to floats and integers (<code>to(T)</code>)</li> <li>formatting (<code>toString()</code>, <code>toStringAlloc()</code>, <code>format()</code>)</li> <li>negation, absolute value (<code>negate()</code>, <code>abs()</code>)</li> <li>addition, subtraction, multiplication, division (<code>add()</code>, <code>sub()</code>, <code>mul()</code>, <code>div()</code>)</li> <li>comparison (<code>eql()</code>, <code>eqlAbs()</code>, <code>eqlZero()</code>, <code>order()</code>, <code>orderAbs()</code>)</li> <li>simplifying (<code>simplify()</code>)</li> </ul> Installation First, run the following: <code>zig fetch --save git+https://github.com/Chriscbr/zig-fractions</code> Then add the following to build.zig: <code>zig const zig_fractions = b.dependency("zig-fractions", .{}); exe.root_module.addImport("zig-fractions", zig_fractions.module("zig-fractions"));</code> Then you can use the library in your Zig project: ```zig const Fraction = @import("zig-fractions").Fraction; var f1 = try Fraction.fromFloat(@as(f32, 2.5)); const f2 = try Fraction.init(1, 5, false); try f1.mul(&amp;f2); // 2.5 * 1/5 = 1/2 std.debug.print("{}\n", .{f1}); // "1/2" ``` Contributing Pull requests are welcome.
[]
https://avatars.githubusercontent.com/u/2242?v=4
zig-graphql
softprops/zig-graphql
2024-03-27T17:38:46Z
a basic GraphQL client for zig
main
0
11
2
11
https://api.github.com/repos/softprops/zig-graphql/tags
MIT
[ "gql", "graphql", "zig" ]
41
false
2025-01-20T23:27:32Z
true
true
0.13.0
github
[]
zig graphql A very basic GraphQL HTTP client for zig <a></a> <a></a> examples ```zig const std = @import("std"); const graphql = @import("graphql"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>const authz = if (std.posix.getenv("GH_TOKEN")) |pat| blk: { var buf: [400]u8 = undefined; break :blk try std.fmt.bufPrint( &amp;buf, "bearer {s}", .{pat}, ); } else { std.log.info("Required GH_TOKEN env var containing a GitHub API token - https://github.com/settings/tokens", .{}); return; }; // 👇 constructing a client var github = try graphql.Client.init( allocator, .{ .endpoint = .{ .url = "https://api.github.com/graphql" }, .authorization = authz, }, ); defer github.deinit(); // 👇 sending a request const result = github.send( .{ .query = \\query test { \\ search(first: 100, type: REPOSITORY, query: "topic:zig") { \\ repositoryCount \\ } \\} , }, // 👇 struct representing returned data, this maybe be an adhoc or named struct // you want this to line up with the shape of your query struct { search: struct { repositoryCount: usize, }, }, ); // 👇 handle success and error if (result) |resp| { defer resp.deinit(); switch (resp.value.result()) { .data =&gt; |data| std.debug.print( "zig repo count {any}\n", .{data.search.repositoryCount}, ), .errors =&gt; |errors| { for (errors) |err| { std.debug.print("Error: {s}", .{err.message}); if (err.path) |p| { const path = try std.mem.join(allocator, "/", p); defer allocator.free(path); std.debug.print(" @ {s}", .{path}); } } }, } } else |err| { std.log.err( "Request failed with {any}", .{err}, ); } </code> } ``` 📼 installing Create a new exec project with <code>zig init-exe</code>. Copy the echo handler example above into <code>src/main.zig</code> Create a <code>build.zig.zon</code> file to declare a dependency <blockquote> .zon short for "zig object notation" files are essentially zig structs. <code>build.zig.zon</code> is zigs native package manager convention for where to declare dependencies </blockquote> Starting in zig <code>0.12.0</code>, you can use <code>sh zig fetch --save https://github.com/softprops/zig-graphql/archive/refs/tags/v0.2.2.tar.gz</code> to manually add it as follows <code>zig .{ .name = "my-app", .version = "0.1.0", .dependencies = .{ // 👇 declare dep properties .graphql = .{ // 👇 uri to download .url = "https://github.com/softprops/zig-graphql/archive/refs/tags/v0.2.2.tar.gz", // 👇 hash verification .hash = "{current-hash-here}", }, }, .paths = .{""}, }</code> <blockquote> the hash below may vary. you can also depend any tag with <code>https://github.com/softprops/zig-graphql/archive/refs/tags/v{version}.tar.gz</code> or current main with <code>https://github.com/softprops/zig-graphql/archive/refs/heads/main/main.tar.gz</code>. to resolve a hash omit it and let zig tell you the expected value. </blockquote> Add the following in your <code>build.zig</code> file ```diff const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); <code>const optimize = b.standardOptimizeOption(.{}); </code> <ul> <li>// 👇 de-reference graphql dep from build.zig.zon</li> <li>const graphql = b.dependency("graphql", .{</li> <li>.target = target,</li> <li>.optimize = optimize,</li> <li>}).module("graphql"); var exe = b.addExecutable(.{ .name = "your-exe", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, });</li> <li>// 👇 add the graphql module to executable</li> <li> exe.root_module.addImport("graphql", graphql); b.installArtifact(exe); } ``` </li> </ul> 🥹 for budding ziglings Does this look interesting but you're new to zig and feel left out? No problem, zig is young so most us of our new are as well. Here are some resources to help get you up to speed on zig <ul> <li><a>the official zig website</a></li> <li><a>zig's one-page language documentation</a></li> <li><a>Learning Zig</a></li> <li><a>ziglings exercises</a></li> </ul> - softprops 2024
[]
https://avatars.githubusercontent.com/u/25432120?v=4
progress
BrookJeynes/progress
2024-08-08T14:08:38Z
A simple thread safe progress bar and spinner library
main
0
10
2
10
https://api.github.com/repos/BrookJeynes/progress/tags
MIT
[ "cli", "zig", "zig-package" ]
32
false
2025-04-23T13:05:18Z
true
true
0.14.0
github
[]
progress A simple thread safe progress bar and spinner library. <ul> <li><a>Installation</a></li> <li><a>Example</a></li> <li><a>Contributing</a></li> </ul> Installation <ol> <li>Fetch the package. <code>zig fetch --save git+https://github.com/BrookJeynes/progress</code></li> <li>Add to your <code>build.zig</code>. <code>zig const progress = b.dependency("progress", .{}).module("progress"); exe.root_module.addImport("progress", progress);</code></li> </ol> Example ```zig const std = @import("std"); const ProgressBar = @import("progress").Bar; const ProgressSpinner = @import("progress").Spinner; pub fn bar() !void { const stdout = std.io.getStdOut().writer(); var pb = ProgressBar.init(10, stdout.any(), .{}); <code>while (!pb.isFinished()) { pb.add(1); try pb.render(); std.time.sleep(std.time.ns_per_ms * 150); } </code> } pub fn spinner() !void { const stdout = std.io.getStdOut().writer(); var ps = ProgressSpinner.init(stdout.any(), .{ .symbols = ProgressSpinner.PredefinedSymbols.default, }); <code>var iterations: usize = 0; while (!ps.isFinished()) { iterations += 1; try ps.render(); if (iterations == 20) try ps.finish(); std.time.sleep(std.time.ns_per_ms * 150); } </code> } ``` You can find more examples in the <code>examples/</code> folder. For more information, see the source code or documentation (<code>zig build docs</code>). Contributing Contributions, issues, and feature requests are always welcome! This project is using the latest stable release of Zig (0.14.0).
[]
https://avatars.githubusercontent.com/u/50487716?v=4
frametap
srijan-paul/frametap
2024-03-28T21:07:26Z
Cross platform screen capture library
main
0
10
1
10
https://api.github.com/repos/srijan-paul/frametap/tags
MIT
[ "gif", "screen-capture", "screenshot", "zig" ]
45,645
false
2025-04-22T13:07:27Z
true
true
unknown
github
[ { "commit": "0a89cc09da6804ae448241a673ce85a282216074.tar.gz", "name": "zig-objc", "tar_url": "https://github.com/mitchellh/zig-objc/archive/0a89cc09da6804ae448241a673ce85a282216074.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/mitchellh/zig-objc" }, { "commit": "refs", ...
Frametap <blockquote> frametap is <em>very</em> early in development. Definitely do not use it just yet. </blockquote> A cross platform screen capture library for MacOS, Windows, and Linux. Frametap can: - Deliver live frame information from your screen. - Capture GIFs. - Export frames as PNGs. Why? I wanted a screen capture app that lets me control the compression, quantization, dithering, etc. Surprisingly, there's nothing that can do all that on all three major OSes (well, except for FFMPEG – but that's a command line tool). Hopefully, once the library is mature, I'll be able to use it to build such an app. While I'm still figuring thngs out, you can try <a>LICECap</a> — it's pretty solid! Goals <ul> <li>Cross platform</li> <li><strong>MacOS</strong>: ScreenCaptureKit and CoreGraphics (AVFoundation at some point).</li> <li><strong>Windows</strong>: Win32 API.</li> <li><strong>Linux</strong>: Figure something out with Wayland / dbus.</li> <li>Fast. Drop as few frames as possible.</li> <li>Control over parameters such as FPS, Quantization algorithm, dithering, etc.</li> </ul>
[]
https://avatars.githubusercontent.com/u/231785?v=4
obelizmo
mnemnion/obelizmo
2024-08-05T15:32:16Z
Markup and print strings to the terminal
trunk
1
10
0
10
https://api.github.com/repos/mnemnion/obelizmo/tags
MIT
[ "ansi", "terminal", "vt100", "xterm", "zig", "zig-package" ]
134
false
2025-05-15T12:42:47Z
true
true
0.14.0
github
[ { "commit": "refs", "name": "ohsnap", "tar_url": "https://github.com/mnemnion/ohsnap/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/mnemnion/ohsnap" }, { "commit": "refs", "name": "mvzr", "tar_url": "https://github.com/mnemnion/mvzr/archive/refs.tar.gz", "...
Obeli⚡️mo: A String Marking Library This library provides a flexible system for marking up text, a practice referred to in ancient days as <a>Obelism</a>. A relic of this use is the <a>obelus</a>, which you know is an oddball word, since in English, it means <code>÷</code> or <code>†</code>, depending. The goal of <code>obelizmo</code> is to provide a performant and output-agnostic way to mark up a string, keeping the metadata and the text separate. A claim like "output-agnostic" always has its limits: <code>obelizmo</code> in its present state is a capable obelist of ANSI escape sequences and HTML, and the mechanism provided is, perhaps, general enough to accomodate other formats as well. Status This library is entirely usable at present for its main focus, which is terminal printing. I'm reasonably happy with the structure of the marked strings, and the collection of methods for marking them is acceptably featureful. Printing with ANSI/SGR is fully implemented, with proper handling of nested regions and a color builder. Printing in HTML is... possible, and might be good enough for your purposes. I have a long-term goal to come up with a really nice solution there, but it wasn't the primary application of interest. Install Using the Zig build system: <code>sh zig fetch --save https://www.github.com/mnemnion/obelizmo/archive/refs/tags/v0.1.0.tar.gz</code> The package offers two modules, <code>obezlimo</code> itself and <a>colors</a>. Obelizmo works in two stages: marking strings, and printing them. Marking Strings To use the library, define an <code>enum</code> of all the categories of markup you intend to use. A simple example: <code>zig const Colors = enum(u32) { blue, red, yellow, green, teal, // However many you would like };</code> This enum can be non-exhaustive, and it is valid to assign any number you like to the enums (although using the default order is optimal). The enum may be smaller or larger than <code>u32</code>, but smaller will not save space because of alignment, and larger will bloat the size of marks. The enum is provided to <code>obelizmo.MarkedString(Enum_T)</code>, which returns a <code>MarkedString</code> specialized to that enum. This is initialized with the string, and an allocator, like so: ```zig const ColorMarker = obelizmo.MarkedString(Colors); const a_string_marker = ColorMarker.init(allocator, a_string); defer a_string_marker.deinit(); // Or you can reserve capacity for some number of marks. const another_string_marker = try ColorMarker.initCapacity(allocator, a_string, 8); defer another_string_marker.deinit(); ``` Now you're ready to provide some marks. Marking up a MarkedString A collection of member functions for marking up strings is provided. Some of these have return values, which you're free to ignore. Invalid inputs will return errors, as will failure to allocate. Marks may be provided in any order. They're stored on a <a>priority queue</a>, which has predicable and good algorithmic complexity for this purpose. Usage note: be aware that marks can overlap each other, and this may give undesired results, depending on how you choose to print the marked string. No attempt is made to correct for this condition, or compensate for it. Among other reasons, this is because there are real uses for which overlapping marks are correct. The terminal printer handles this with aplomb, but if you wish to produce valid HTML, you'll need the marks to properly nest. Also worth knowing: if you mark a single region repeatedly, the lower-valued enum will print first on entry, and last on exit. Direct Marking The simplest option is to specify either slice bounds, or an offset and length, to mark. ```zig try string_marker.markSlice(.red, a, b) catch |e| { switch(err) { error.OutOfMemory =&gt; |err| return err, error.InvalidRegion =&gt; @panic(".markSlice provided with invalid data"), } }; try string_marker.markFrom(.blue, a, 7); // Same error set as markSlice ``` Find and Mark Another way to mark the string is using the find functions, which work like their equivalents in <a>std.mem</a>. These return the starting index if a mark was applied, or <code>null</code> otherwise, and can only fail to allocate. ```zig const first_err: usize = try string_marker.findAndMark(.red, "ERROR:").?; _ = try string_marker.findAndMarkPos(.red, "ERROR:", first_err + 7); _ = try string_marker.findAndMarkLast(.yellow, "line"); ``` Match and Mark The last way to apply marks is by using an <a>mvzr Regex</a>, or several. These functions are actually type-generic, so anything which precisely matches the interface and field names used in <code>mvzr</code> would suffice. But so far as I'm aware, that list only includes <code>mvzr</code> at the present time. The main reason for this is that <code>mvzr</code> statically allocates Regexen, so the structs themselves are comptime-generic by size. <code>zig const number_regex = mvzr.Regex.compile("\\d+").?; const index: ?usize = try string_marker.matchAndMark(.teal, number_regex); if (index) |i| { _ = try string_marker.matchAndMarkPos(.yellow, number_regex, index.? + 10); } const fizz_regex = mvzr.Regex.compile("([Ff]izz([Bb]uzz)?)|[Bbuzz])").?; const did_match: bool = try string_marker.matchAndMarkAll(.teal, fizz_regex); if (!did_match) { std.debug.print("definitely not fizzbuzz\n", .{}); }</code> That's it for marking methods. If you have some complex structure, like an abstract or concrete syntax tree, you should find it easy to mark up the string using the direct methods, since one of <code>[start, end]</code> or <code>[offset, length]</code> is generally used to store the span in those structures. As a reminder, the order of marking doesn't matter, any order will result in the same printed value and will take more-or-less as long to build as any other. So any convenient approach to iterating such a tree will suit the purpose. Removing Marks A mark may be removed with <code>string_marker.removeMark(.kind)</code>. This removes the first mark of its kind which it encounters, which may not be the first mark in the order of the string. Anticipated use cases are removing one unique mark of a given kind, or all unique marks of a kind, which may be accomplished by calling the function until it returns <code>null</code>. ```zig const removed_mark: ?Mark = string_marker.removeMark(.yellow); while (string_marker.removeMark(.red)) |_| {} ``` Since <code>obelizmo</code> uses a heap to store marks, the <code>while</code> loop above is roughly as efficient as it can be at removing all such marks. While it's possible to remove the first or last mark of a kind as ordered on the string, with a linear search, this is not currently included as it's unlikely to prove useful. Printing Once your <code>MarkedString</code> is marked, you'll probably want to print it to something, or potentially several somethings. <code>obelizmo</code> provides for a couple of approaches to this. The simpler printer uses <code>marked_string.writeAsTree(writer, markups)</code>, where the second parameter is a <code>MarkupStringArray</code>. This is an <a>EnumArray</a> where the value type is <code>[2][]const u8</code>, for the beginning and end of the region marked with a given enum. Suitably loaded with the right tags, and given that the <code>MarkedString</code> has the right shape, this can produce acceptable HTML. HTML body text needs to be escaped, for which you can use <code>HTMLEncodedWriter</code>, wrapping the underlying Writer of your choice. Printing A MarkedString to the Terminal This use case was the real motivation for this project, and the fully-supported one, so we'll focus there. The marks are just marks: a struct holding the provided enum, as well as the boundaries of the text region in <code>[offset, length]</code> form. To print to the terminal, you'll need to create <code>Color</code>s, and a <code>MarkupColorArray</code>, this is another <code>EnumArray</code> where the value is <code>Color</code>. Next, create an <code>XtermLinePrinter</code> specialized to the Writer for the terminal. Initialize with <code>init</code> and call <code>next</code>: ```zig const xprint = XtermPrinter.init(&amp;marked_string, markup_array, writer); defer xprint.deinit(); while (try xprint.next()) |more| { // <code>more</code> is true until the final line // Newlines are not printed, for terminal raw-mode reasons, // So this is where you place the cursor where you want it. // When complete, next() will return null. } <code>`` Foreground, background, and underline colors, are kept on separate stacks, and will restart automatically at the end of any given marked region. You can keep the</code>xprint<code>around for later, and provide a fresh</code>MarkedString<code>with</code>xprint.newText(&amp;marked_string)`. It is also possible to drop some amount of the marked text. The <code>XtermLinePrinter</code> will properly track styles, so that, for instance, if printing picks up in the middle of a red italic foreground section, without printing the beginning, that text will be italic and red. This may be done with <code>try x_print.seek(n)</code>, where <code>n</code> is greater than the currently printed text (this number is <code>x_print.cursor</code>) and less than the length of the marked string. Alternately, text up to the next newline can be dropped with <code>x_print.drop</code>, or any number of lines with <code>x_print.dropN</code>. It is not required that the indicated number of lines still exist to be printed, however, <code>xprint.next</code> must be called at least one more time to guarantee that any applied <code>Color</code> styles are properly ended. And what is a <code>Color</code>, you might fairly ask? The <code>colors</code> module Obelizmo includes a standalone module, "colors", which primarily features <code>Color</code>, a union which allows the full proliferation of SGR-compatible text attributes to be created and wielded in an <code>obelizmo</code>-friendly manner. The preferred way to use this module is via the included builder functions, as documented in the container doc comment at <code>src/color_marks</code>. Though provided for independent use, on the premise that this might be useful, the <code>colors</code> module is fully <code>usingnamespace</code>-included in the <code>obelizmo</code> module, such that any declaration in <code>colors</code> may be used directly. Fin That's Obeli⚡️mo. Mark a string, print it.
[]
https://avatars.githubusercontent.com/u/231785?v=4
runeset
mnemnion/runeset
2024-05-27T17:25:59Z
Fast UTF-8 codepoint sets for Zig.
trunk
0
10
0
10
https://api.github.com/repos/mnemnion/runeset/tags
MIT
[ "parsing", "sets", "utf-8", "zig", "zig-package" ]
48,630
false
2025-03-17T16:57:42Z
true
true
0.13.0
github
[ { "commit": "refs", "name": "ztap", "tar_url": "https://github.com/mnemnion/ztap/archive/refs.tar.gz", "type": "remote", "url": "https://github.com/mnemnion/ztap" } ]
Runeset: Sets of UTF-8 Characters This library offers a compact data structure for "generalized"[^1] UTF-8 encoded codepoints. The design is based on an <a>implicit data structure</a>[^2], which uses <code>@popCount</code> and bit masking to check membership quickly, with minimal branching, and without having to decode the UTF-8 into another format (for instance, a codepoint). This design is original, in the sense that I invented it. There may be prior art, it's remarkably difficult to search for "UTF-8 character sets" and find papers on set data structures, so I can't say with high confidence that it's truly novel; in a sense, it's an obvious extension of the widespread practice of using a pair of <code>u64</code> bitmasks to detect a set of ASCII values. What I can say is: it's effective. The <code>RuneSet</code> struct is just a slice of <code>u64</code>, offering a few variations on set membership tests, depending on how confident you are that the string it's testing is valid UTF-8, and what you would like the test to do in the event that it isn't. Also supported are the fundamental set operations: equality, subset, union, intersection, and difference. All of the three combining forms produce a new <code>RuneSet</code>, and must be given an <code>Allocator</code>. The <code>RuneSet</code> is immutable by design, and as such, doesn't support adding or removing codepoints to an already-created set. This would be possible to implement in principle, but I don't happen to have a use for mutable adds and removes, and therefore didn't write them. You can create a <code>RuneSet</code> containing a single character, and via union or difference, either add or subtract that character, if you would like: this would create a new <code>RuneSet</code> with just that character added or removed. The data structure is very fast. The test suite, with extensions, contains 5MB of sample data, with a 20MB extra collection, and performs a multitude of operations on that data, on the order of a dozen per string. In ReleaseFast mode, the main suite of 5MB concludes in roughly a second on an M1. With the annex, including fuzzing the creation function 2^24 times, a complete run is over in six seconds, give or take a few milli. About 2/3rds of that is the fuzzing. While I have yet to set up definitive benchmarks, it's clear that membership testing using <code>RuneSet</code> has a throughput over 100 MB/sec on modern machines, potentially substantially higher than this. I'll update this with better numbers when I get around to benchmarking it; the focus has been on implementing the library, and assuring good test coverage. For real character sets, it is also quite sparing of memory. The CJK Ideographs block of Unicode, consisting of 22,992 codepoints, is represented as a <code>RuneSet</code> in 338 words. Dense ranges such as that block can of course be tested by decoding the tested sequence into a codepoint and checking if it's in that range, but the combination of generality, compactness, and speed, offered by the <code>RuneSet</code>, is unique. Speaking of test coverage, the library has 100% line coverage, which you may verify by running <code>zig build cov</code>, provided you have <a>kcov</a> installed. To run the extended suite, including the fuzzer, use <code>zig build -Dtest-more test</code>. This will take an appreciable amount of time in the default debug-mode builds, as it will trigger the 244 assertions which gird the library. Roadmap I intend to add some ability to write out the data structure, whether as binary data, Zig source code, or potentially both. As an allocating data structure, it isn't currently possible to generate a RuneSet at comptime, and many applications of them will use character sets known in advance, which may as well be built into the <code>.rodata</code> of programs, rather than constructed at runtime from strings. I also plan to wrap all of the major functionality in C-compatible data structures and functions, for use wherever the C ABI is spoken. Other than that, I consider the library fully implemented and feature-complete. Odds are good, however, that more open-source code, which makes use of the RuneSet as a foundation, will be forthcoming. [^1]: Generalized, here, has a similar meaning to its use in <a>WTF-8</a>, except that <code>RuneSet</code> can also encode so-called "overlong" encodings, as well as surrogates (paired vs. unpaired is a meaningless distinction for a codepoint set). This falls out of the design: it's capable of encoding those sequences, and I saw no reason to impose a performance burden in order to prevent it. On the contrary, should you want to represent the set of all overlong encodings, perhaps to detect them and raise an error, a <code>RuneSet</code> is a fine way to do it. A set which does not contain overlong encodings or surrogates will never match against them, so this seeming laxity comes with no disadvantages. The five- and six-byte sequences from Pike and Thompson's original FSS UTF-8 of 1993 are not supported. As such, what would constitute lead bytes for those sequences are rejected as invalid. It would be possible to extend the <code>RuneSet</code> data structure to include these, if there were ever any point in so doing. [^2]: That the <code>RuneSet</code> is 'implicit' doesn't make it the smallest possible encoding for every subset of UTF-8. For example, the CJK Unified Ideographs block could be represented as two numbers, and for some crafted inputs, such as one in 64 characters throughout the Unicode range, a bitmask of one bit per character would be smaller as well. It means that the structure is implicit to the data, without indirection, and that in full generality it isn't possible to represent UTF-8 sequences more compactly, compared to the information theoretic lower-bound. Our overhead is limited to one word, used to store one of the offsets as an important optimization.
[]
https://avatars.githubusercontent.com/u/32790578?v=4
zigClipboard
Aryvyo/zigClipboard
2024-07-10T20:09:21Z
A small clipboard tracker for X11 in zig
main
0
9
0
9
https://api.github.com/repos/Aryvyo/zigClipboard/tags
MIT
[ "clipboard", "clipboard-history", "clipboard-tracker", "linux", "x11", "zig" ]
99
false
2025-03-30T10:35:56Z
true
true
unknown
github
[ { "commit": null, "name": "zgui", "tar_url": null, "type": "relative", "url": "libs/zgui" }, { "commit": null, "name": "zglfw", "tar_url": null, "type": "relative", "url": "libs/zglfw" }, { "commit": null, "name": "zopengl", "tar_url": null, "type": "r...
Zig Clipboard Tracker My first project in zig, acts as a drop-in tracker for the X11 Selection server (clipboard). This does not take ownership of the selection except when you copy from it, I don't aim to disrupt the usual flow of the server Usage its as easy as downloading and <code>./zigClipManager</code> Installation A built file should be available in the releases, however if you instead wish to build it yourself: Using zig 0.13.0 Download <code>zgui</code>, <code>zglfw</code> and <code>system-sdk</code> from <a>zig-gamdev/libs</a> and place them in a folder named <code>libs</code> in the root directory of this project You will also need libx11-dev, please make sure you change the include path in <code>build.zig</code>. Once you have all that, you should be able to run <code>zig build run</code> <strong><em>PLEASE REMEMBER TO DOWNLOAD ALL REQUIRED LIBRARIES BEFORE DMING ME</em></strong> Feel free to contact me on <a>X</a> if you are encountering issues Contributions I will try to ship all required features myself, but I will only really work on this as long as I require it. If you wish to contribute, simply fork the repo, make any changes and make a pull request :) Look below for a place to start ^-^ TO-DO <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 image support <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 support for hiding window <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 icon (no one do this)
[]
https://avatars.githubusercontent.com/u/2242?v=4
zig-retry
softprops/zig-retry
2024-08-04T05:19:37Z
♻️ Retry faillible zig functions
main
2
9
1
9
https://api.github.com/repos/softprops/zig-retry/tags
MIT
[ "retry", "retry-library", "zig", "zig-library", "zig-package" ]
18
false
2025-03-04T18:50:51Z
true
true
unknown
github
[]
♻️ zig retry A retry library for fault tolerant zig applications <a></a> <a></a> A goal of any operation should be a successful outcome. This package gives operations a better chance at achieving that. 📼 installing Create a new exec project with <code>zig init</code>. Copy an example from the examples directory into your into <code>src/main.zig</code> Create a <code>build.zig.zon</code> file to declare a dependency <blockquote> .zon short for "zig object notation" files are essentially zig structs. <code>build.zig.zon</code> is zigs native package manager convention for where to declare dependencies </blockquote> Starting in zig 0.12.0, you can use and should prefer <code>sh zig fetch --save https://github.com/softprops/zig-retry/archive/refs/tags/v0.1.0.tar.gz</code> otherwise, to manually add it, do so as follows <code>diff .{ .name = "my-app", .version = "0.1.0", .dependencies = .{ + // 👇 declare dep properties + .jwt = .{ + // 👇 uri to download + .url = "https://github.com/softprops/zig-retry/archive/refs/tags/v0.1.0.tar.gz", + // 👇 hash verification + .hash = "...", + }, }, }</code> <blockquote> the hash below may vary. you can also depend any tag with <code>https://github.com/softprops/zig-retry/archive/refs/tags/v{version}.tar.gz</code> or current main with <code>https://github.com/softprops/zig-retry/archive/refs/heads/main/main.tar.gz</code>. to resolve a hash omit it and let zig tell you the expected value. </blockquote> Add the following in your <code>build.zig</code> file ```diff const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); <code>const optimize = b.standardOptimizeOption(.{}); // 👇 de-reference dep from build.zig.zon </code> <ul> <li>const retry = b.dependency("retry", .{</li> <li>.target = target,</li> <li>.optimize = optimize,</li> <li>}).module("retry"); var exe = b.addExecutable(.{ .name = "your-exe", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); // 👇 add the module to executable</li> <li> exe.root_mode.addImport("retry", retry); b.installArtifact(exe); } ``` </li> </ul> examples See examples directory 🥹 for budding ziglings Does this look interesting but you're new to zig and feel left out? No problem, zig is young so most us of our new are as well. Here are some resources to help get you up to speed on zig <ul> <li><a>the official zig website</a></li> <li><a>zig's one-page language documentation</a></li> <li><a>ziglearn</a></li> <li><a>ziglings exercises</a></li> </ul> - softprops 2024
[]
https://avatars.githubusercontent.com/u/417833?v=4
cowsay
shaozi/cowsay
2024-07-09T05:14:50Z
🐮 🐮 🐮 A simple library generates an ascii cow says a message. 🐮 🐮 🐮
main
1
9
1
9
https://api.github.com/repos/shaozi/cowsay/tags
-
[ "beginner", "fun", "zig" ]
36
false
2025-04-16T18:15:46Z
true
true
unknown
github
[ { "commit": "v0.13.2.tar.gz", "name": "zg", "tar_url": "https://codeberg.org/dude_the_builder/zg/archive/v0.13.2.tar.gz.tar.gz", "type": "remote", "url": "https://codeberg.org/dude_the_builder/zg" } ]
Cowsay This is a simple zig library that mimic the ascii art <a><strong>cowsay</strong></a> . What's New [x] Support UTF-8 Install <ol> <li>Use the <code>zig fetch</code> command to fetch and save the library:</li> <li>Fetch the latest: <code>zig fetch --save git+https://github.com/shaozi/cowsay</code></li> <li>or, fetch a specific version: <code>zig fetch --save https://github.com/shaozi/cowsay/archive/refs/tags/v3.0.0.tar.gz</code></li> <li> Add the module to you own <code>build.zig</code> file: </li> <li> Add these lines right before the line <code>b.installArtifact(exe);</code>: <code>zig const Cowsay = b.dependency("Cowsay", .{}); exe.root_module.addImport("Cowsay", Cowsay.module("Cowsay"));</code> </li> <li> Import it in your zig file: </li> </ol> <code>zig const Cowsay = @import("Cowsay");</code> Usage Basic usage ```zig const stdout = std.io.getStdOut().writer(); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { const deinit_status = gpa.deinit(); //fail test; can't try in defer as defer is executed after we return if (deinit_status == .leak) @panic("TEST FAIL"); } var cow = Cowsay.init(gpa.allocator, stdout.any()); defer cow.deinit(); try cow.say("Hello {s}", .{"world!"}); ``` Output: <code>text +--------------+ | Hello world! | +--------------+ \ ^__^ \(oo)\_______ (__)\ )\/\ ||----w | || ||</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> Cowsay takes type <code>std.io.AnyWriter</code>. Therefore, you must use the <code>.any()</code> to convert a writer before pass it in. This allows you to use an ArrayList(u8) to let cowsay write output to a string. </blockquote> Eyes <code>zig cow.eyes = [_]u8{ '$', '$' };</code> Output: <code>text +--------------+ | Hello world! | +--------------+ \ ^__^ \($$)\_______ (__)\ )\/\ ||----w | || ||</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> The first two <code>o</code> in the file are eyes. </blockquote> Load an ASCII cow file <code>zig try cow.useCowFile("cat");</code> Output <code>text +-------------+ | Hello meow! | +-------------+ \ /\___/\ \(= ^.^ =) (") (")__/</code> and use the default cow: <code>zig cow.useDefaultCow();</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> <ul> <li>Cow file is simple text file of the ascii image, without the <code>\</code> bubble pointer.</li> <li>Max length of the file is 1000 bytes.</li> </ul> </blockquote> Cow think <code>zig try cow.think("Hmm... Hello ... world ...", .{});</code> Output <code>text +----------------------------+ | Hmm... Hello ... world ... | +----------------------------+ o ^__^ o (oo)\_______ (__)\ )\/\ ||----w | || ||</code> Write to an <code>ArrayList</code>, out as a string <code>zig var buffer = std.ArrayList(u8).init(std.heap.page_allocator); defer buffer.deinit(); const w = buffer.writer().any(); var cow = Cowsay.init(allocator, w); defer cow.deinit(); try cow.say("Hello world!", .{}); try stdout.print("{s}", buffer.items);</code>
[]
https://avatars.githubusercontent.com/u/480330?v=4
zig-budoux
Cloudef/zig-budoux
2024-02-25T17:27:45Z
Budoux for Zig and C
master
0
9
0
9
https://api.github.com/repos/Cloudef/zig-budoux/tags
MIT
[ "c", "chinese", "dependency-free", "internationalization", "japanese", "machine-learning", "natural-language-processing", "no-std", "text", "thai", "typography", "word", "word-wrapping", "zig" ]
36
false
2025-03-12T02:28:51Z
true
true
unknown
github
[ { "commit": "master", "name": "budoux", "tar_url": "https://github.com/google/budoux/archive/master.tar.gz", "type": "remote", "url": "https://github.com/google/budoux" } ]
zig-budoux <a>Budoux</a> for Zig (and C) <a></a> Project is tested on zig version 0.15.0-dev.27+17b40b1d6 Example Zig <code>zig const budoux = @import("zig-budoux"); var model = try budoux.init(allocator, .ja); defer model.deinit(allocator); var iter = model.iterator("今日は天気です。"); try std.testing.expectEqualSlices(u8, "今日は", iter.next().?); try std.testing.expectEqualSlices(u8, "天気です。", iter.next().?);</code> C ```c include BudouxModel model = budoux_init(budoux_model_ja); BudouxChunkIterator iter = budoux_iterator_init(model, "今日は天気です。"); BudouxChunk chunk; chunk = budoux_iterator_next(&amp;iter); // 今日は chunk = budoux_iterator_next(&amp;iter); // 天気です。 budoux_deinit(model); ``` <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> zig-budoux does not allocate any strings, thus it won't add any html markup or zero width spaces. However with <code>model.iterator</code> it is simple to construct strings for your needs. To parse html you need to bring your own html parser. </blockquote> Depend <code>build.zig.zon</code> <code>zig .zig_budoux = .{ .url = "https://github.com/Cloudef/zig-budoux/archive/{COMMIT}.tar.gz", .hash = "{HASH}", },</code> <code>build.zig</code> <code>zig const zig_budoux = b.dependency("zig_budoux", .{}).module("zig-budoux"); exe.root_module.addImport("zig-budoux", zig_budoux);</code>
[]
https://avatars.githubusercontent.com/u/30725570?v=4
bench-ws
andrehrferreira/bench-ws
2024-08-06T09:34:21Z
Websocket performance testing in different languages
main
0
9
8
9
https://api.github.com/repos/andrehrferreira/bench-ws/tags
-
[ "bun", "cpp", "csharp", "dart", "deno", "elixir", "erlang", "go", "java", "node", "php", "python", "ruby", "rust", "swoole", "uwebsocket", "websocket", "zig" ]
192,522
false
2025-04-23T10:11:05Z
false
false
unknown
github
[]
Benchmark Websocket The result so far is an Intel Core i9 10980XE desktop, 256GB DDR RAM, individual Docker configuration for each server, 2024-08-14 | (index) | Server | Avg Messages/sec | % Difference | |:-------:|:------------------:|:----------------:|:------------:| | 0 | Rust | 1,438,459.2 | 247.87% | | 1 | Java | 1,136,289.2 | 174.79% | | 2 | C# | 876,244.4 | 111.91% | | 3 | C++ (Crow + TBB) | 484,825.4 | 17.25% | | 4 | PHP / Swoole | 473,327 | 14.47% | | 5 | Erlang / Elixir | 348,513.2 | -15.72% | | 6 | Go (Gorilla) | 253,044.8 | -38.81% | | 7 | Bun | 230,723.2 | -44.20% | | 8 | uWebsocket.js | 225,335.6 | -45.51% | | 9 | Go (Fasthttp) | 191,886 | -53.60% | | 10 | Node | 124,721.6 | -69.84% | | 11 | Ruby | 3,557.8 | -99.14% | | 12 | Python3 | 1,177 | -99.72% | // Need revision | 13 | Dart | 980 | -99.76% | // Need revision The result so far is an Intel Core i9 10980XE desktop, 256GB DDR RAM, individual Docker configuration for each server | (index) | Server | Avg Messages/sec | % Difference | |---------|------------------|------------------|--------------| | 0 | Rust | 1,232,041.4 | 541.60% | | 1 | Java | 1,175,892 | 516.41% | | 2 | C# | 1,132,847.8 | 496.48% | | 3 | C++ (Crow + TBB) | 504,620.8 | 157.50% | | 4 | PHP / Swoole | 485,236.6 | 149.58% | | 5 | Erlang / Elixir | 296,681.2 | 66.95% | | 6 | Bun | 266,875.2 | 53.20% | | 7 | Go | 263,391.2 | 51.51% | | 8 | Python3 | 191,937 | 16.15% | | 9 | Node | 154,831.2 | -4.33% | | 10 | uWebsocket.js | 100,140.4 | -33.47% | | 11 | Dart | 6,936.8 | -95.12% | | 12 | Ruby | 3,456.4 | -97.51% | The result so far is an Intel Core i9 10980XE desktop, 256GB of DDR RAM, using WSL and manual configuration. | | Server | Avg Messages/sec | % Difference | |----|------------------|------------------|--------------| | 0 | Rust | 990,420.4 | 315.79% | | 1 | C# | 871,702.6 | 265.95% | | 2 | Erlang / Elixir | 654,033.6 | 156.37% | | 3 | C++ (Crow + TBB) | 518,418.2 | 90.88% | | 4 | Java | 146,882.6 | -57.73% | | 5 | Bun | 88,682.2 | -76.19% | | 6 | Go | 87,612.8 | -76.53% | | 7 | uWebsocket.js | 82,604.8 | -78.24% | | 8 | PHP / Swoole | 80,273.8 | -79.00% | | 9 | Python3 | 72,891.0 | -81.36% | | 10 | Node | 63,003.6 | -84.76% | | 11 | * Deno | 61,819.0 | -85.18% | <ul> <li> Deno has been removed from testing due to memory leek and poor performance issues </li> <li> Soon implementations in Zig </li> </ul> Run in Node <code>bash $ node server-node.js</code> Run in uWebsocket.js <code>bash $ node server-uws.js</code> Run in Deno <code>bash $ deno run -A server-deno.mjs</code> Run in Bun <code>bash $ bun server-bun.js</code> Run in C# Build <code>bash $ cd server-csharp $ dotnet build</code> Run <code>bash $ dotnet run</code> Run in Erlang / Elixir Depedences <code>bash $ mix deps.get</code> Build <code>bash $ cd server_elixir $ mix deps.compile</code> Run <code>bash $ mix run --no-halt</code> Run in Phyton 3 Depedences <code>bash $ pip install gevent $ pip install gevent-websocket</code> Run <code>bash $ cd server-python $ python server-python.py</code> Run in Rust Build <code>bash $ cd server-rust $ cargo build --release</code> Run <code>bash $ ./target/release/server-rust</code> Run in Java Build <code>bash $ cd server-java $ mvn compile</code> Run <code>bash $ java -jar server-java/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar</code> Run in Go Build <code>bash $ cd server-go $ go build</code> Run <code>bash $ ./server</code> Run in C++ (Crow + TBB) Dependeces <code>bash $ vcpkg install</code> Run <code>bash $ server-cpp/x64/Release/server-cpp.exe</code> Run in PHP / Swoole Run <code>bash $ php ./server-swoole/server.php</code> Client To start the test it will be necessary to start all the servers, each one is configured on a port <code>bash $ bun ./client.js</code> The test script will perform local tests and send and broadcast messages and will store the total number of messages received per second. It will also generate a comparison between all tested servers, summarizing the average number of messages per second and the comparative performance to other servers.
[]
https://avatars.githubusercontent.com/u/7820420?v=4
zig-basic
flyfish30/zig-basic
2024-04-04T05:27:16Z
These project are used to collect some basic example of Zig program, it is only for myself.
main
1
9
0
9
https://api.github.com/repos/flyfish30/zig-basic/tags
GPL-3.0
[ "functional-programming", "simd", "zig" ]
516
false
2025-05-10T11:30:15Z
true
true
unknown
github
[ { "commit": null, "name": "zstbi", "tar_url": null, "type": "relative", "url": "libs/zstbi" } ]
zig-basic These project are used to collect some basic example of Zig program, it is only for myself. zig version The supported zig version is 0.13. Build and Run Run bellow command to build and run this project. <code>zig build run</code> Features vqsort This is a vectorized and performance-portable Quicksort that supports some SIMD instruction sets, including AVX for X86_64, Neon for ARM aarch64, wasm32. image processing This is an example of image processing in Zig language, which uses zstbi to encode and decode image formats, load and store image files. category theory supporting Add some types and functions for support category theory and functional programing in Zig. All types and functions are provided in functor_alg.zig file. <strong>Note</strong>: This feature has been separated into a standalone project and is no longer developed or updated. Please go to new project <a>zig-cats</a>. The list of supported concept of category theory is show in bellow: <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> Functor <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> Natural Transformation <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> Applicative Functor <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> Monad <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> Compose Functor <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> Compose Applicative <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> Product Functor <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> Product Applicative <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> Coproduct Functor <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> Coproduct Applicative
[]
https://avatars.githubusercontent.com/u/1552770?v=4
flow-syntax
neurocyte/flow-syntax
2024-03-06T18:29:57Z
Syntax highlighting module used by flow and zat
master
0
9
8
9
https://api.github.com/repos/neurocyte/flow-syntax/tags
MIT
[ "tree-sitter", "zig", "zig-package" ]
97
false
2025-04-19T10:44:51Z
true
true
0.14.0-dev.3451+d8d2aa9af
github
[ { "commit": "master", "name": "tree_sitter", "tar_url": "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz/archive/master.tar.gz", "type": "remote", "url": "https://github.com/neurocyte/tree-sitter/releases/download/master-86...
flow-syntax Syntax highlighting module used by <a>flow</a>, <a>zat</a> and <a>zine</a>
[]
https://avatars.githubusercontent.com/u/119983202?v=4
zimd
spiraldb/zimd
2024-03-01T08:59:50Z
Additional cross-platform SIMD support for Zig
develop
0
8
0
8
https://api.github.com/repos/spiraldb/zimd/tags
Apache-2.0
[ "simd", "zig" ]
7
false
2025-04-13T07:26:35Z
true
true
0.11.0
github
[]
ZIMD Additional cross-platform SIMD support for Zig. Based loosely on <a>Google Highway</a> Why? Zig has builtin support for SIMD operations using <code>@Vector</code>. However this only supports a few basic operations. This library aims to fill in some of the blanks. Operators <a>TableLookupBytesOr0</a> Architectures: Scalar, X86_SSE3, Arm_Neon Similar to Zig's <code>@shuffle</code> operator, except doesn't require the shuffle mask to be comptime known.
[]
https://avatars.githubusercontent.com/u/65700195?v=4
zigverm
AMythicDev/zigverm
2024-05-05T13:35:33Z
Version manager for the Zig Programming Language
main
4
8
0
8
https://api.github.com/repos/AMythicDev/zigverm/tags
Apache-2.0
[ "version-manager", "zig" ]
155
false
2025-03-16T17:51:03Z
true
true
0.11.0
github
[ { "commit": "b1f8fe858943cb14eb333c7424bb23ae002ee7a1", "name": "zip", "tar_url": "https://github.com/AMythicDev/zip.zig/archive/b1f8fe858943cb14eb333c7424bb23ae002ee7a1.tar.gz", "type": "remote", "url": "https://github.com/AMythicDev/zip.zig" } ]
zigverm zigverm is a version manager for the <a>Zig</a> programming Language. It lets you install Zig and further manage your installation. Platform Support Legend: 🎉 - Binary releases + automatic installer available 💪 - binary releases available ❌ - No binary releases. Maybe supported later. Requires <a>compiling</a> - - Not applicable | OS/Arch | x86_64 | x86 | aarch64 | armv7a | riscv64 | | ------- | ------ | --- | ------- | ------ | ------- | | Windows | 💪 | 💪 | ❌ | - | - | | Linux | 🎉 | 🎉 | 🎉 | ❌ | ❌ | | MacOS | 🎉 | - | 🎉 | - | - | Installation For Linux and MacOS (x86_64/aarch64) You can use this automated install script which will install zigverm along with the latest version of Zig <code>sh curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/AMythicDev/zigverm/main/scripts/install.sh | bash</code> By default it will create <code>$HOME/.zigverm</code> directory as the root folder for zigverm. You can customize this by setting this by setting the <code>ZIGVERM_ROOT_DIR</code> to the directory where you want to install zigverm. Make sire you add the <code>ZIGVERM_ROOT_DIR</code> in your shell config otherwise zigverm would not be able to locate the installation folder. The script will also put the installation directory's <code>bin</code> folder to your <code>$PATH</code> variable. For this it will append a line to your <code>$HOME/.profile</code> and your shell's rc file. The file for each shell supported is listed below: <ul> <li>Bash: <code>$HOME/.bashrc</code></li> <li>Zsh: <code>$HOME/.zshrc</code></li> <li>Fish: <code>$XDG_CONFIG_HOME/fish/config.fish</code>, if not set then uses <code>$HOME/.config/fish/config.fish</code></li> </ul> For Windows <ul> <li>Create the following folder structure in <code>C:\Users\[YOU-USERNAME]\.zigverm</code>:</li> </ul> <code>. ├── bin ├── downloads └── installs</code> <ul> <li>Download the latest release for Windows from GitHub and extract it.</li> <li>Copy <code>zigverm.exe</code> and <code>zig.exe</code> to the <code>bin/</code> folder.</li> <li>Add the <code>bin</code> directory to your <code>PATH</code> enviroment variable</li> </ul> Compiling Requirements: <ul> <li>Zig &gt;= 0.12.0. See <a>this</a> for Zig v0.14.</li> <li>libc on non-Windows systems. Can be provided by Zig itself, if available for the platform.</li> <li><code>git</code>, if you want to compile the latest commit or you want to develop <code>zigverm</code>.</li> </ul> Now to compile: <ul> <li>Clone the repo or download a source archive depending on if you want to compile the latest <code>main</code> branck or a release.</li> <li>Extract the archive and change into the extracted directory.</li> <li>Run the following command</li> </ul> <code>zig build --release=safe</code> <ul> <li>If you are devloping <code>zigverm</code>, you can omit the <code>--release=safe</code> flag.</li> <li>You will have <code>zigverm</code> and <code>zig</code> in <code>zig-out/bin/</code> directory</li> <li>Lastly follow the same steps <a>for windows</a></li> </ul> Note for Zig &gt;= v0.14 There have been some API changes in Zig v0.14 (not released yet) which makes zigverm fail to compile on these versions of Zig. All the changes required to fix this is issue is being tracked in <a>this</a> PR. It will be merged into main once this version of Zig comes out. Features <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> Install versions (master, stable, x.y x.y.z) <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> Continue download if previously interrupted <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> Remove versions <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> List down installed versions <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> Update zigverm itself <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> Manage default and per-directory version overrides <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> Open the language reference and standard library docs (even when offline). <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> Tries to maintain strong compatiblity with the wider zig ecosystem (<code>zls</code>, <code>zig.vim</code>) Docs Read the <a>quick guide</a> License <code>zigverm</code> is licensed under the Apache License 2.0. See the <a>LICENSE</a> file.
[]
https://avatars.githubusercontent.com/u/146390816?v=4
AFLplusplus
allyourcodebase/AFLplusplus
2024-07-20T19:15:04Z
Zig build for AFL++
main
0
8
5
8
https://api.github.com/repos/allyourcodebase/AFLplusplus/tags
MIT
[ "afl", "afl-fuzz", "afl-fuzzer", "aflplusplus", "fuzzer", "fuzzing", "zig", "zig-lang", "zig-package", "ziglang" ]
35
false
2025-03-18T14:25:31Z
true
true
0.14.0
github
[ { "commit": "v4.21c.tar.gz", "name": "AFLplusplus", "tar_url": "https://github.com/AFLplusplus/AFLplusplus/archive/v4.21c.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/AFLplusplus/AFLplusplus" } ]
AFLplusplus <a></a> <a></a> Zig build for <a>AFLplusplus</a>. :arrow_down: Dependencies Requires a build of LLVM. You can either get one from your favorite package manager, or <a>build it yourself</a>. :rocket: Usage <code>sh git clone https://github.com/allyourcodebase/AFLplusplus.git cd AFLplusplus/ zig build</code> :100: Easy Source Fuzzing with AFL++ For help fuzzing your executables, see <a>kristoff-it/zig-afl-kit</a>.
[ "https://github.com/allyourcodebase/AFLplusplus" ]
https://avatars.githubusercontent.com/u/1776476?v=4
Zig-Torrent
ookami125/Zig-Torrent
2024-04-14T17:05:14Z
A torrent client written in pure zig
main
0
8
1
8
https://api.github.com/repos/ookami125/Zig-Torrent/tags
GPL-3.0
[ "torrent", "torrent-client", "zig" ]
488
false
2025-04-06T21:51:44Z
true
false
unknown
github
[]
<a name="readme-top"></a> <a></a> <a></a> <a></a> <a></a> <a></a> <a> </a> Zig Torrent Client An multi-file torrent client using an event and coroutine system <a><strong>Explore the docs »</strong></a> <a>View Demo</a> · <a>Report Bug</a> · <a>Request Feature</a> Table of Contents <ol> <li> <a>About The Project</a> </li> <li> <a>Getting Started</a> <ul> <li><a>Prerequisites</a></li> <li><a>Installation</a></li> </ul> </li> <li><a>Roadmap</a></li> <li><a>Contributing</a></li> <li><a>License</a></li> <li><a>Contact</a></li> </ol> About The Project The main goal of this project is to remove a lot of small projects I've made like an RSS file downloaded and an media sorter. This client's goal is to remove those while holding to some other standards. <ul> <li>All torrent files should work</li> <li>Allow moving of media without breaking the connection</li> <li>Automate pulling of new content based on plugins</li> <li>Http client so client is headless by default but works on any device</li> </ul> Use the <code>GETTING_STARTED.md</code> to get started. (<a>back to top</a>) Getting Started All that should be needed is a <code>sh zig build -Doptimize=ReleaseFast run</code> If that doesn't work Prerequisites <ul> <li>Currently only supports linux</li> <li>zig version <code>sh $ zig version 0.12.0-dev.2058+04ac028a2</code></li> </ul> Installation <em>Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.</em> <ol> <li>Clone the repo <code>sh git clone https://github.com/ookami125/Zig-Torrent.git</code></li> <li>Build with zig <code>sh zig build -Doptimize=ReleaseFast</code></li> </ol> (<a>back to top</a>) 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> Add Changelog <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 DHT and other ways of getting torrent info <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 multiple ways of changing a torrent (move files, delete, sparce download) See the <a>open issues</a> for a full list of proposed features (and known issues). (<a>back to top</a>) Contributing Any contributions you make are <strong>greatly appreciated</strong>, but under my full discretion as how and when the change gets in. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". <ol> <li>Fork the Project</li> <li>Create your Feature Branch (<code>git checkout -b feature/AmazingFeature</code>)</li> <li>Commit your Changes (<code>git commit -m 'Add some AmazingFeature'</code>)</li> <li>Push to the Branch (<code>git push origin feature/AmazingFeature</code>)</li> <li>Open a Pull Request</li> </ol> (<a>back to top</a>) License Distributed under the GNU GPLv3 License. See <code>LICENSE.txt</code> for more information. (<a>back to top</a>) Contact Tyler Peterson - TylerLGPeterson@gmail.com Project Link: <a>https://github.com/ookami125/Zig-Torrent</a> (<a>back to top</a>)
[]
https://avatars.githubusercontent.com/u/1160419?v=4
zio
TheWaWaR/zio
2024-07-26T10:39:25Z
Zig io from tigerbeetle/src/io
master
0
8
0
8
https://api.github.com/repos/TheWaWaR/zio/tags
-
[ "non-bloking-io", "tigerbettle", "zig" ]
43
false
2024-08-29T00:02:44Z
true
true
unknown
github
[]
Zio A cross-platform event loop library extract from <a>tigerbeetle</a> code base. Supported platform: * Linux (io_uring) * Darwin (kqueue) * Windows (IOCP) Examples See: <code>src/io/test.zig</code> Import Guide <code>shell zig fetch --save https://github.com/TheWaWaR/zio/archive/&lt;commit-id&gt;.tar.gz</code> In <code>build.zig</code> <code>zig const zio = b.dependency("zio", .{ .target = target, .optimize = optimize }); exe.root_module.addImport("zio", zio.module("zio"));</code> LICENSE Apache 2.0
[]
https://avatars.githubusercontent.com/u/35711760?v=4
qoi-enc-zig
gianni-rosato/qoi-enc-zig
2024-02-25T01:46:10Z
QOI lossless image encoder written in Zig.
main
0
7
0
7
https://api.github.com/repos/gianni-rosato/qoi-enc-zig/tags
BSD-3-Clause
[ "codec", "encoding", "qoi", "zig", "ziglang" ]
4,250
false
2025-03-16T05:43:16Z
true
true
0.14.0
github
[]
QOI Image Encoder in Zig This Zig program encodes a subset of Portable Arbitrary Map (PAM) images into the Quite OK Image Format (QOI). It is a freestanding implementation, existing entirely in one file. The QOI format is a simple, lossless image format designed for fast encoding and decoding. Program Details I wrote this mostly as a learning exercise, and I was heavily inspired by the <a>Simplified QOI Codec Library</a>, a one header file library for encoding and decoding QOI files written in C. Benchmarks These are some rudimentary, unscientific benchmarks performed on a Linux system running a Core i7-13700k with the <a><code>poop</code></a> benchmarking utility. The <code>qoi-zig</code> binary was built in ReleaseFast mode, and we're using FFmpeg n6.1.1 from the Arch repos. <ol> <li>This first benchmark was run on a <code>big2.pam</code> image that I haven't included in the <code>examples</code> directory because it is rather large at 59.8 MB for a massive 5468x3644 image. I'll link a lossless JPEG-XL encode <a>here</a> if you'd like to take a look for yourself.</li> </ol> <code>bash 13700k :: ~ » poop -d 25000 'ffmpeg -y -i big2.pam -frames:v 1 big2.qoi' 'qoi-zig big2.pam big2.qoi 0' Benchmark 1 (104 runs): ffmpeg -y -i big2.pam -frames:v 1 big2.qoi measurement mean ± σ min … max outliers delta wall_time 242ms ± 8.53ms 229ms … 277ms 2 ( 2%) 0% peak_rss 244MB ± 261KB 243MB … 245MB 7 ( 7%) 0% cpu_cycles 945M ± 10.2M 877M … 961M 9 ( 9%) 0% instructions 2.11G ± 17.2M 1.96G … 2.12G 13 (13%) 0% cache_references 5.66M ± 432K 3.88M … 5.98M 23 (22%) 0% cache_misses 3.42M ± 320K 2.04M … 3.66M 13 (13%) 0% branch_misses 15.7M ± 136K 14.5M … 15.8M 13 (13%) 0% Benchmark 2 (128 runs): qoi-zig big2.pam big2.qoi 0 measurement mean ± σ min … max outliers delta wall_time 196ms ± 3.80ms 185ms … 211ms 6 ( 5%) ⚡- 18.7% ± 0.7% peak_rss 119MB ± 654KB 118MB … 121MB 0 ( 0%) ⚡- 51.0% ± 0.1% cpu_cycles 756M ± 3.83M 741M … 772M 8 ( 6%) ⚡- 20.0% ± 0.2% instructions 1.82G ± 3.34M 1.79G … 1.82G 11 ( 9%) ⚡- 13.7% ± 0.1% cache_references 6.07M ± 109K 5.23M … 6.15M 12 ( 9%) 💩+ 7.1% ± 1.4% cache_misses 2.22M ± 68.3K 2.07M … 2.57M 6 ( 5%) ⚡- 35.2% ± 1.7% branch_misses 15.2M ± 48.5K 14.9M … 15.4M 6 ( 5%) ⚡- 3.3% ± 0.2%</code> <ol> <li>This benchmark was performed on the <code>qoi_logo.pam</code> image included in this repo's <code>examples</code> directory.</li> </ol> <code>bash 13700k :: ~ » poop 'ffmpeg -y -i qoi_logo.pam -frames:v 1 qoi_logo.qoi' 'qoi-zig qoi_logo.pam qoi_logo.qoi 0' Benchmark 1 (178 runs): ffmpeg -y -i qoi_logo.pam -frames:v 1 qoi_logo.qoi measurement mean ± σ min … max outliers delta wall_time 28.1ms ± 3.17ms 25.5ms … 42.5ms 17 (10%) 0% peak_rss 54.3MB ± 311KB 53.5MB … 55.0MB 0 ( 0%) 0% cpu_cycles 91.0M ± 2.03M 72.5M … 93.6M 11 ( 6%) 0% instructions 159M ± 3.45M 124M … 161M 21 (12%) 0% cache_references 675K ± 27.4K 534K … 765K 9 ( 5%) 0% cache_misses 226K ± 16.7K 133K … 254K 4 ( 2%) 0% branch_misses 647K ± 15.3K 506K … 675K 19 (11%) 0% Benchmark 2 (3107 runs): qoi-zig qoi_logo.pam qoi_logo.qoi 0 measurement mean ± σ min … max outliers delta wall_time 1.55ms ± 537us 227us … 11.6ms 262 ( 8%) ⚡- 94.5% ± 0.5% peak_rss 844KB ± 28.3KB 635KB … 848KB 87 ( 3%) ⚡- 98.4% ± 0.0% cpu_cycles 66.1K ± 59.7K 0 … 186K 0 ( 0%) ⚡- 99.9% ± 0.1% instructions 142K ± 137K 0 … 281K 0 ( 0%) ⚡- 99.9% ± 0.1% cache_references 447 ± 296 0 … 1.58K 23 ( 1%) ⚡- 99.9% ± 0.1% cache_misses 2.69 ± 4.68 0 … 93 197 ( 6%) ⚡-100.0% ± 0.3% branch_misses 666 ± 624 0 … 1.70K 0 ( 0%) ⚡- 99.9% ± 0.1%</code> FFmpeg is pretty fast, but it is evident there is more going on under the hood there. Even so, we'll take what we can get! Building In order to build this program, you will need to have the latest version of the Zig programming language (at least version <code>0.14.0</code>) installed on your system as well as <code>git</code>. You can find instructions for installing Zig on the <a>official website</a>. Once that is set up, follow the steps below for building the <code>qoi-zig</code> binary: <code>bash git clone https://github.com/gianni-rosato/qoi-enc-zig # Clone the repo cd qoi-enc-zig # Enter the directory zig build -Doptimize=ReleaseFast # Build the program</code> <em>Note: A previous version of this program encoded RGB source images, and had a smaller codebase. If you'd like to build that verion, simply run <code>git reset --hard 36317c52896d8642ae10c3c18774991f4f68bf22</code> in the cloned directory before running <code>zig build</code>. The old README.md will also be present in the reset directory if you would like to see the old usage instructions.</em> Usage The program is run from the command line with the following arguments: <code>bash qoi-zig -h Freestanding QOI Encoder in Zig Example usage: qoi-zig [input.pam] [output] [colorspace] [color_depth] [dither] Colorspace: 0: sRGB w/ Linear Alpha 1: Linear RGB Color Depth: 0: Same as Source *: Palletize Dithering: 0: None 1: Sierra Lite</code> <ul> <li><code>input.pam</code>: The input PAM image file to encode.</li> <li><code>output</code>: The output QOI image file to create.</li> <li><code>colorspace</code>: The colorspace of the image. Use <code>0</code> for sRGB with linear alpha and <code>1</code> for linear RGB.</li> <li><code>color_depth</code>: The color depth of the image. Use <code>0</code> for the same as the source image (lossless), and any other number to lossily palletize the image to that specified color depth.</li> <li><code>dither</code>: The dithering algorithm to use. Use <code>0</code> for no dithering and <code>1</code> for Sierra Lite dithering.</li> </ul> If the input file is too small for the specified image dimensions &amp; channels, an error message is printed. Creating PAM Files If you're just interested in testing this program, you can use the PAM files in the <code>examples/</code> directory. If you want to create your own PAM files, you can use <a>FFmpeg</a> like so: Create an 8-bit RGB PAM file from an input image: <code>bash ffmpeg -i [input] -pix_fmt rgb24 -c pam -update 1 -f image2 output_rgb.pam</code> Create an 8-bit RGBA PAM file from an input image: <code>bash ffmpeg -i [input] -pix_fmt rgba -c pam -update 1 -f image2 output_rgba.pam</code> Note: This program's encoder will only encode 8-bit PAM files with 3 or 4 color channels. It will not encode 16-bit PAM files or PAM files with more than 4 color channels. Examples There are some compatible PAM examples provided in the <code>examples/</code> directory. You can use these to test the program and see how it works. Encode <code>plants.pam</code> in sRGB with linear alpha: <code>bash qoi-zig plants.pam plants.qoi 0</code> Encode <code>photograph.pam</code> in linear RGB (even though this image is meant to be encoded in sRGB w/ linear alpha): <code>bash qoi-zig photograph.pam photograph.qoi 1</code> These commands will create QOI image files from the inputs shown. The original and compressed file sizes are printed upon successful encoding. This program does not perform any error checking on the input file. It is assumed that the file is a compatible PAM file. Incorrect inputs can lead to unexpected results or program crashes; always ensure that your input data is correct before running the program. Dependencies This program requires the Zig programming language, at least version <code>0.14.0</code>. It also uses the standard library provided with Zig. No other dependencies are required. License This program is released under the BSD 3-Clause License. You are free to use, modify, and distribute the program under the terms of this license. Acknowledgments Thank you to the authors of the Simplified QOI Codec Library, and Cancername for their expert consulting on the Zig programming language! Much appreciated! <ul> <li><a>QOI Specification</a></li> <li><a>QOI Site</a></li> <li><a>Zig</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/34311583?v=4
vzit
ttytm/vzit
2024-05-17T15:50:37Z
Zig formatter that utilizes `zig fmt` while allowing for tab indentation and diff viewing.
main
1
7
1
7
https://api.github.com/repos/ttytm/vzit/tags
MIT
[ "cli-app", "code-formatter", "diff", "formatter", "tabs", "zig", "zig-fmt" ]
34
false
2024-11-17T17:20:52Z
false
false
unknown
github
[]
VZiT <a></a> <a></a> Uses <code>zig fmt</code> to format Zig code while allowing for tab indentation and diff viewing. Quick Start <ul> <li><a>Installation</a></li> <li><a>Editor Setup</a></li> <li><a>Neovim</a></li> <li><a>VS Code / Codium</a></li> </ul> Feature Overview <ul> <li>Use tabs with <code>zig fmt</code> under the hood (no need to miss out on the amazing work that goes into it).</li> <li>View diffs with your preferred tool.</li> </ul> https://github-production-user-asset-6210df.s3.amazonaws.com/34311583/337395033-be5d0270-713f-495a-9f91-15665841eb64.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240606%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20240606T184324Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=2df83e6313c9b80dfaab603825d552c4858a2876cbb7331afea85da1547f8097&amp;X-Amz-SignedHeaders=host&amp;actor_id=34311583&amp;key_id=0&amp;repo_id=802144933 Usage ``` Usage: vzit [flags] [commands] Formatter and diff viewer utilizing zig fmt. By default, formatted output is written to stdout. Flags: -w --write Modifies non-conforming files in-place. -l --list Prints paths of non-conforming files. Exits with an error if any are found. -d --diff Prints differences of non-conforming files. Exits with an error if any are found. - The 'VZIT_DIFF_CMD' environment variable allows setting a custom diff command. -i --indentation Sets the indentation used [possible values: 'tabs', 'smart', ''(spaces)]. - tabs: used by default. - smart: based on the initial indentations in a file. - : number of spaces. -h --help Prints help information. -v --version Prints version information. Commands: update Updates vizit to the latest version. help Prints help information. version Prints version information. ``` Disclaimer Maintaining quality throughout development will be paramount. However, it is still an early release. Until a stable 1.0 release is available, minor versions (<code>0.&lt;minor&gt;.*</code>) may contain breaking changes. This is a spare time project. Please take it easy if there are delays in replying.
[]
https://avatars.githubusercontent.com/u/102893782?v=4
mcbot
nmalthouse/mcbot
2024-03-15T21:37:32Z
Minecraft bot for 1.21.3. Written in zig
master
0
7
0
7
https://api.github.com/repos/nmalthouse/mcbot/tags
GPL-3.0
[ "bot", "minecraft", "zig", "ziglang" ]
1,539
false
2025-01-20T11:21:17Z
true
true
unknown
github
[ { "commit": null, "name": "ratgraph", "tar_url": null, "type": "relative", "url": "ratgraph" } ]
A Minecraft Bot written in zig Linux only because epoll() is used. <a>Lua API documentation</a> Running: <code> # Install zig version 0.13.0 # make sure you have the following libraries installed system-wide: # libepoxy # sdl2 # freetype # # Setup a 1.21.3 Minecraft server and ensure the following is set in server.properties: # online-mode=false git clone https://github.com/nmalthouse/mcbot.git cd mcbot git submodule update --init --recursive zig build run </code> The file bot_config.lua sets port, ip, and bots that will be added. Current features: <ul> <li>Code generation for the Minecraft protocol.</li> <li>Dimensions</li> <li>Pathfinding, (includes: ladders, gaps)</li> <li>Debug rendering</li> <li>Block breaking</li> <li>Basic inventory interaction</li> <li>Crafting</li> <li>Multiple bots</li> <li>Lua scripting</li> </ul> A picture of the debug renderer. Depends on <ul> <li><a>zig-nbt</a></li> <li>Everything listed under ratgraph's dependencies</li> </ul> Architecture overview: <code> fn main reads bot_config.lua Establishes connections with Minecraft server for all bots specified. Spawn a thread per bot, see function luaBotScript Sets up epoll() to monitor all the tcp file descriptors. Respond to epoll events, parsing Minecraft packets and updating our version of the Minecraft state. This thread sends some packets back to the server, (keepalive, respawn, confirm teleport request). Optionally spawn the draw() thread. fn draw() Renders a basic view of the Minecraft world. Can show entities, inventory, pathfinding nodes. launch with zig build run -- draw </code>
[]
https://avatars.githubusercontent.com/u/2242?v=4
zig-iter
softprops/zig-iter
2024-06-24T14:38:36Z
iterators for zig
main
1
7
1
7
https://api.github.com/repos/softprops/zig-iter/tags
MIT
[ "iterator", "zig", "zig-library", "zig-package" ]
45
false
2024-12-08T22:39:32Z
true
true
0.13.0
github
[]
zig iter iterators (for zig) <a></a> <a></a> what's next()? If you are coming to zig from any variety of other languages (we welcome you) you might be asking the questions like: how can I transform this zig collection?, how can I filter out elements?, and other perfectly valid questions based on what you might be used to from where you are coming from. The answer in zig is "it depends", but you'll likely be using a for loop and allocating a copy of the collection you have on hand. Let's use a very simple example: doubling the value of an array of elems that you may do something later with. I'll just print it out for simplicity, but you'll likely be doing something more useful. <code>zig const elems = [_]i32{ 1, 2, 3 }; // 👇 conjure an allocator for the list below var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); // 👇 allocate a new list to hold the data of the transformation, DONT FORGET TO DEALLOCATE IT var buf = try std.ArrayList(i32).initCapacity(allocator, elems.len); defer buf.deinit(); for (elems) |elem| { buf.appendAssumeCapacity(elem * 2); } // 👇 capture a ref to the slice of data you want, DONT FORGET TO DEALLOCATE IT const doubled = try buf.toOwnedSlice(); defer allocator.free(doubled); // 👇 do something with it for (doubled) |elem| { std.debug.print("{d}", .{elem}); }</code> The simple example above quickly becomes much more complicated as additional transformations and filtering is required. If you are coming to zig from another language you are probably used to expressing this with something like <code>elems.map(...)</code> With this library you can <em>almost</em> have that too. Below is an equivalent program but sans required additional allocations and zig's required memory deallocation. <code>zig var elems = [_]i32 { 1, 2, 3 }; // 👇 create an interator and apply a transformation var doubled = iter.from(elems) .then().map(i32, struct { fn func(n: i32) i32 { return n * 2; } }.func); // 👇 do something with it while (doubled.next()) |elem| { std.debug.print("{d}", .{elem}); }</code> I say <em>almost</em> because <ul> <li>zig does not support closures, but it does support functions as arguments so we can emulate these to a certain degree with struct fn references</li> <li>some <a>changes to <code>usingnamespace</code></a> facilitate the need for an itermediatory method, we use <code>then()</code>, to access and chain iterator methods. If zig brings that back in a different form this library's <code>then()</code> will no longer been nessessary.</li> </ul> The following functions create iterators <ul> <li><code>from(zigType)</code> - create an iterator for a native zig type, we're expanding the list of types supported</li> <li><code>fromFn(returnType, init, func)</code> - create an iterator from a generator func</li> <li><code>once(value)</code> - create an iterator that only repeats once</li> <li><code>repeat(value)</code> - create an iterator that repeats a given value indefinitely</li> </ul> The following methods are available when calling <code>then()</code> on iterator types <ul> <li><code>chain(other)</code> - extends one iterator with another</li> <li><code>cycle()</code> - repeats an iterator indefinitely</li> <li><code>filter(func)</code> - filters an iterator by testing a <code>func</code> predicate</li> <li><code>fold(returnType, init, func)</code> - reduces an iterator down to a single value</li> <li><code>map(returnType, func)</code> - transforms an iterator by applying <code>func</code></li> <li><code>skip(n)</code> - skip the first <code>n</code> elems of an iterator</li> <li><code>take(n)</code> - take only the first <code>n</code> elems of an iterator</li> <li><code>zip(iter)</code> - create an iterator yielding a tuple of iterator values</li> </ul> likely more to come Note, nothing is allocated behind the scenes. If you do need to take the results and store the result in an allocatoed type simply do what you would do with any iterator: feed it values of <code>next()</code> ```zig var elems = [_]i32 { 1, 2, 3 }; var doubled = iter.from(elems) .then().map(i32, struct { fn func(n: i32) i32 { return n * 2; } }.func); // now go ahead feed the result into a list // 👇 conjure an allocator for the list below var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); // 👇 allocate a new list to hold the data of the transformation, DONT FORGET TO DEALLOCATE IT var buf = try std.ArrayList(i32).initCapacity(allocator, elems.len); defer buf.deinit(); while (doubled.next()) |elem| { buf.appendAssumeCapacity(elem * 2); } // 👇 capture a ref to the slice of data you want, DONT FORGET TO DEALLOCATE IT const copied = try buf.toOwnedSlice(); defer allocator.free(copied); ``` examples For more examples see the <code>examples</code> directory 📼 installing Create a new exec project with <code>zig init</code>. Copy an example from the examples directory into your into <code>src/main.zig</code> Create a <code>build.zig.zon</code> file to declare a dependency <blockquote> .zon short for "zig object notation" files are essentially zig structs. <code>build.zig.zon</code> is zigs native package manager convention for where to declare dependencies </blockquote> Starting in zig 0.12.0, you can use and should prefer <code>sh zig fetch --save https://github.com/softprops/zig-iter/archive/refs/tags/v0.1.0.tar.gz</code> otherwise, to manually add it, do so as follows <code>diff .{ .name = "my-app", .version = "0.1.0", .dependencies = .{ + // 👇 declare dep properties + .iter = .{ + // 👇 uri to download + .url = "https://github.com/softprops/zig-iter/archive/refs/tags/v0.1.0.tar.gz", + // 👇 hash verification + .hash = "...", + }, }, }</code> <blockquote> the hash below may vary. you can also depend any tag with <code>https://github.com/softprops/zig-iter/archive/refs/tags/v{version}.tar.gz</code> or current main with <code>https://github.com/softprops/zig-iter/archive/refs/heads/main/main.tar.gz</code>. to resolve a hash omit it and let zig tell you the expected value. </blockquote> Add the following in your <code>build.zig</code> file ```diff const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); <code>const optimize = b.standardOptimizeOption(.{}); // 👇 de-reference dep from build.zig.zon` </code> <ul> <li>const iter = b.dependency("iter", .{</li> <li>.target = target,</li> <li>.optimize = optimize,</li> <li>}).module("iter"); var exe = b.addExecutable(.{ .name = "your-exe", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); // 👇 add the module to executable</li> <li> exe.root_mode.addImport("iter", iter); b.installArtifact(exe); } ``` </li> </ul> 🥹 for budding ziglings Does this look interesting but you're new to zig and feel left out? No problem, zig is young so most us of our new are as well. Here are some resources to help get you up to speed on zig <ul> <li><a>the official zig website</a></li> <li><a>zig's one-page language documentation</a></li> <li><a>ziglearn</a></li> <li><a>ziglings exercises</a></li> </ul> - softprops 2024
[]
https://avatars.githubusercontent.com/u/41646249?v=4
ScriptHookVZig
nitanmarcel/ScriptHookVZig
2024-06-11T21:18:50Z
Write GTA V mods using Zig
devel
0
7
0
7
https://api.github.com/repos/nitanmarcel/ScriptHookVZig/tags
MIT
[ "gta5", "gtamodding", "scripthookv", "zig" ]
7,118
false
2025-03-24T07:04:16Z
true
true
unknown
github
[]
ScriptHookVZig Develop GTA V mods with the help of Zig <ul> <li><a>ScriptHookVZig</a></li> <li><a>Requirements</a></li> <li><a>Usage</a><ul> <li><a>Adding to build.zig.zon</a></li> <li><a>Adding to build.zig</a></li> <li><a>Your first script</a></li> </ul> </li> <li><a>Documentation</a></li> <li><a>Thanks</a></li> <li><a>LICENSE</a></li> </ul> Requirements <ul> <li>Zig 0.12.0=&gt;</li> <li><a>ScriptHookV v1.0.3179.0</a> and it's <a>requirements</a></li> </ul> Usage Adding to build.zig.zon <code>zig zig fetch git+https://github.com/nitanmarcel/ScriptHookVZig#{LastCommitHash} -- save</code> Adding to build.zig ```zig // Shared/Dynamic library is required const lib = b.addSharedLibrary(.{ .name = "{name}", .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); <code>// Add ScriptHookVZig as a dependency const shvz_dep = b.dependency("shvz", .{}); // Import is as a module lib.root_module.addImport("shvz", shvz_dep.module("shvz")); // Save the dll b.installArtifact(lib); // Copy bin/{name}.dll (zig-0.13.0 and above) / lib/{name}.dll (zig-0.12.0) to the GTA root folder where ScriptHookV.dll is located and rename the library extension to .asi: {name}.dll -&gt; {name}.asi </code> ``` Your first script ```zig // import the module const shvz = @import("shvz"); // Create the script main function pub export fn scriptMain() void {} pub const DLL_PROCESS_ATTACH: std.os.windows.DWORD = 1; pub const DLL_THREAD_ATTACH: std.os.windows.DWORD = 2; pub const DLL_THREAD_DETACH: std.os.windows.DWORD = 3; pub const DLL_PROCESS_DETACH: std.os.windows.DWORD = 4; /// Main entry point. Will be loaded by ScriptHookV.dll pub fn DllMain(hInstance: std.os.windows.HINSTANCE, reason: std.os.windows.DWORD, lpReserved: std.os.windows.LPVOID) std.os.windows.BOOL { _ = lpReserved; <code>switch (reason) { DLL_PROCESS_ATTACH =&gt; { // shvz.init() REQUIRED // It handles opening the ScriptHookV.dll library and read symbols from it shvz.init() catch |e| { }; // register the script's entry point shvz.main.scriptRegister(hInstance, scriptMain); }, DLL_PROCESS_DETACH =&gt; { // Unregister the script's entry point // Call this before shvz.deInit() to ensure taht we didn't unloaded ScriptHookV.dll library. shvz.main.scriptUnregister(scriptMain); // call shvz.deInit() REQUIRED // Will close the loaded ScriptHookV.dll library freeing memory shvz.deinit(); }, else =&gt; {}, } return std.os.windows.TRUE; </code> } ``` Documentation <ul> <li>You can find a set of examples (C) and a readme in the <a>ScriptHookV SDK</a> archive and help on <a>gtaforums</a>.</li> <li>Natives are documented on <a>Github Pages</a></li> <li>The example project in here only showcases the setup for this respective zig library.</li> </ul> Thanks <ul> <li><a>Alexander Blade - Script Hook V</a>.</li> <li>Discord Zig - For guiding me with some things.</li> <li><a>c2z</a> - Helped in the translation of over 6000 native methods from ScriptHookV sdk.</li> <li><a>alloc8or</a> - Most of the native methods are pulled from his <a>gta5-nativedb-data repo</a></li> </ul> LICENSE <ul> <li>MIT</li> </ul>
[]
https://avatars.githubusercontent.com/u/6756180?v=4
zig-mos-bootstrap
kassane/zig-mos-bootstrap
2024-05-01T20:01:15Z
zig with llvm-mos backend
main
4
7
1
7
https://api.github.com/repos/kassane/zig-mos-bootstrap/tags
-
[ "6502", "6502-compiler", "llvm", "llvm-mos", "mos6502", "zig" ]
244,674
false
2025-03-29T03:08:00Z
false
false
unknown
github
[]
Zig LLVM-MOS Bootstrap This project is a fork of <a>zig-bootstrap</a>, originally created by <a>Andrew Kelley</a>, the creator of <a>Zig programming language</a>. The aim of this fork, <strong>zig-mos-bootstrap</strong>, is to switch the <em>LLVM upstream</em> dependency over to <em>LLVM-mos</em> in order to add support for a new target based on <strong>mos6502 architecture</strong>. Project Objective The primary goal of this project is to minimize system dependencies while achieving a fully functional Zig compiler for various targets. Acknowledgements This project owes its existence to the invaluable contributions of several individuals and communities: <ul> <li><strong>Andrew Kelley:</strong> The original creator of zig-bootstrap, which serves as the foundation for this project.</li> <li><strong>Zig Developers:</strong> For helping to maintain the Zig.</li> <li><strong>LLVM-MOS Developers:</strong> For their work on llvm-mos, enabling support for the mos6502 architecture.</li> </ul> Version Information This repository copies sources from upstream. Patches listed below. Use git to find and inspect the patch diffs. <ul> <li>LLVM-MOS (LLVM 20.0.0)</li> <li>zlib 1.3.1</li> <li>zstd 1.5.2</li> <li>zig 0.14.0-dev</li> </ul> For other versions, check the git tags of this repository. Patches <ul> <li>all: Deleted unused files.</li> <li>LLVM: Support .lib extension for static zstd.</li> <li>LLVM: Portable handling of .def linker flag</li> <li>Clang: Disable building of libclang-cpp.so.</li> <li>LLD: Added additional include directory to Zig's libunwind.</li> <li>LLD: Respect <code>LLD_BUILD_TOOLS=OFF</code></li> <li>zlib: Delete the ability to build a shared library.</li> </ul> Host System Dependencies <ul> <li>C++ compiler capable of building LLVM, Clang, and LLD from source (GCC 5.1+ or Clang)</li> <li>CMake 3.19 or later</li> <li>make, ninja, or any other build system supported by CMake</li> <li>POSIX system (bash, mkdir, cd)</li> <li>Python 3</li> </ul> Build Instructions <code>./build &lt;arch&gt;-&lt;os&gt;-&lt;abi&gt; &lt;mcpu&gt;</code> All parameters are required: <ul> <li><code>&lt;arch&gt;-&lt;os&gt;-&lt;abi&gt;</code>: Replace with one of the Supported Triples below, or use <code>native</code> for the <code>&lt;arch&gt;</code> value (e.g. <code>native-linux-gnu</code>) to use the native architecture.</li> <li><code>&lt;mcpu&gt;</code>: Replace with a <code>-mcpu</code> parameter of Zig. <code>baseline</code> is recommended and means it will target a generic CPU for the target. <code>native</code> means it will target the native CPU. See the Zig documentation for more details.</li> </ul> Please be aware of the following two CMake environment variables that can significantly affect how long it takes to build: <ul> <li><code>CMAKE_GENERATOR</code> can be used to select a different generator instead of the default. For example, <code>CMAKE_GENERATOR=Ninja</code>.</li> <li><code>CMAKE_BUILD_PARALLEL_LEVEL</code> can be used to introduce parallelism to build systems (such as make) which do not default to parallel builds. This option is irrelevant when using Ninja.</li> </ul> When it succeeds, output can be found in <code>out/zig-&lt;triple&gt;-&lt;cpu&gt;/</code>. Windows Build Instructions Bootstrapping on Windows with MSVC is also possible via <code>build.bat</code>, which takes the same arguments as <code>build</code> above. This script requires that the "C++ CMake tools for Windows" component be installed via the Visual Studio installer. The script must be run within the <code>Developer Command Prompt for VS 2019</code> shell: <code>build.bat &lt;arch&gt;-&lt;os&gt;-&lt;abi&gt; &lt;mcpu&gt;</code> To build for x86 Windows, run the script within the <code>x86 Native Tools Command Prompt for VS 2019</code>. Supported Triples If you try a "not tested" one and find a problem please file an issue, and a pull request linking to the issue in the table. If you try a "not tested" one and find that it works, please file a pull request changing the status to "OK". If you try an "OK" one and it does not work, please check if there is an existing issue, and if not, file an issue. Note: Generally, for Linux targets, we prefer the musl libc builds over the glibc builds here, because musl builds end up producing a static binary, which is more portable across Linux distributions. | triple | support status | |----------------------------|----------------| | <code>aarch64_be-linux-gnu</code> | <a>#90</a> | | <code>aarch64_be-linux-musl</code> | <a>#92</a> | | <code>aarch64_be-windows-gnu</code> | <a>#94</a> | | <code>aarch64-linux-gnu</code> | OK | | <code>aarch64-linux-musl</code> | OK | | <code>aarch64-windows-gnu</code> | OK | | <code>aarch64-macos-none</code> | OK | | <code>armeb-linux-gnueabi</code> | <a>#96</a> | | <code>armeb-linux-gnueabihf</code> | <a>#97</a> | | <code>armeb-linux-musleabi</code> | <a>#98</a> | | <code>armeb-linux-musleabihf</code> | <a>#99</a> | | <code>armeb-windows-gnu</code> | <a>#100</a> | | <code>arm-linux-gnueabi</code> | <a>#101</a> | | <code>arm-linux-gnueabihf</code> | <a>#102</a> | | <code>arm-linux-musleabi</code> | <a>#103</a> | | <code>arm-linux-musleabihf</code> | OK | | <code>arm-windows-gnu</code> | <a>#105</a> | | <code>i386-linux-gnu</code> | not tested | | <code>i386-linux-musl</code> | OK | | <code>i386-windows-gnu</code> | OK | | <code>mips64el-linux-gnuabi64</code> | <a>#106</a> | | <code>mips64el-linux-gnuabin32</code> | <a>#107</a> | | <code>mips64el-linux-musl</code> | <a>#3</a> | | <code>mips64-linux-gnuabi64</code> | <a>#108</a> | | <code>mips64-linux-gnuabin32</code> | <a>#109</a> | | <code>mips64-linux-musl</code> | <a>#110</a> | | <code>mipsel-linux-gnu</code> | <a>#111</a> | | <code>mipsel-linux-musl</code> | <a>#12</a> | | <code>mips-linux-gnu</code> | <a>#112</a> | | <code>mips-linux-musl</code> | not tested | | <code>powerpc64le-linux-gnu</code> | <a>#24</a> | | <code>powerpc64le-linux-musl</code> | OK | | <code>powerpc64-linux-gnu</code> | <a>#113</a> | | <code>powerpc64-linux-musl</code> | OK | | <code>powerpc-linux-gnu</code> | <a>#114</a> | | <code>powerpc-linux-musl</code> | OK | | <code>riscv64-linux-gnu</code> | <a>#115</a> | | <code>riscv64-linux-musl</code> | OK | | <code>s390x-linux-gnu</code> | <a>#116</a> | | <code>s390x-linux-musl</code> | <a>#52</a> | | <code>sparc-linux-gnu</code> | <a>#117</a> | | <code>sparcv9-linux-gnu</code> | <a>ziglang/zig#4931</a> | | <code>x86_64-freebsd-gnu</code> | <a>#45</a> | | <code>x86_64-linux-gnu</code> | OK | | <code>x86_64-linux-gnux32</code> | <a>#20</a> | | <code>x86_64-linux-musl</code> | OK | | <code>x86_64-windows-gnu</code> | OK | | <code>x86_64-macos-none</code> | OK | | <code>loongarch64-linux-musl</code> | <a>#164</a> | | <code>loongarch64-linux-gnu</code> | <a>#166</a> | Other Notable Targets Known to Work <ul> <li><code>arm-linux-musleabi</code> with mcpu value of <code>generic+v6kz</code>. This produces a build of Zig that runs on the RPi 1 and RPi Zero.</li> <li>If you want to produce a build for this CPU exactly, use <code>arm1176jzf_s</code>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/6833300?v=4
zcellterm
Siphonay/zcellterm
2024-03-14T23:24:51Z
Zig CLI implementation of the Wolfram Elementary Cellular Automaton
main
0
7
0
7
https://api.github.com/repos/Siphonay/zcellterm/tags
CC0-1.0
[ "cellular-automata", "cellular-automaton", "cli", "cli-toy", "cli-toys", "elementary-cellular-automata", "elementary-cellular-automaton", "toy", "zig", "ziglang" ]
40
false
2024-08-03T04:02:27Z
true
true
unknown
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" } ]
zcellterm CLI toy, Zig implementation of the Wolfram Elementary Cellular Automaton, with various customization features Inspired by the <a>Coding Train</a> video on the subject. Demo Features <ul> <li>Call any of the 256 rules of the Elementary Cellular Automaton</li> <li>Automatic terminal size detection, manual size setting, infinite mode</li> <li>Pre-computation of a specified number of generations before display</li> <li>Per-line display delay</li> <li>Start with only one active cell in the middle of the automaton, or specify a custom or random starting condition</li> </ul> Supported platforms for automatic terminal size detection Tested <ul> <li>Linux</li> <li>macOS</li> <li>Windows</li> <li>FreeBSD</li> <li>OpenBSD</li> <li>NetBSD</li> </ul> Untested, <a>works in theory</a> if you can build for those platforms (might be non-trivial) <ul> <li>Haiku</li> <li>Solaris</li> </ul> Know how to implement size detection for a platform not listed here? Feel free to contribute! Build <code>zig build</code> Release 1.0.2 tested with zig 0.13.0 and zig-clap 0.9.0 releases. Feel free to use optimization flags. Thanks I’m using the <a>zig-clap</a> library to parse arguments. Thank you <a>@AliceDiNunno</a> for testing out macOS compatibility, as well as all the nice people on the <a>Zig Programming Language Discord server</a> who gave me their help and feedback. I was able to improve the terminal size detection for Windows by taking example on <a>softprops’ implementation</a>.
[]