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/6793008?v=4 | mandelbrot | ndrean/mandelbrot | 2024-11-03T09:49:02Z | Mandelbrot set and orbits with Zig, Zigler and Elixir Nx in a Livebook | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/ndrean/mandelbrot/tags | MIT | [
"elixir",
"livebook",
"mandelbrot-set",
"mandelbrot-viewer",
"nx",
"zig",
"zigler"
] | 48,243 | false | 2024-12-10T08:08:20Z | true | true | unknown | github | [
{
"commit": "5b5d718159c6ec223a54c9bb960690576e5df9c2.tar.gz",
"name": "zigimg",
"tar_url": "https://github.com/zigimg/zigimg/archive/5b5d718159c6ec223a54c9bb960690576e5df9c2.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/zigimg/zigimg"
}
] | Orbits and Mandelbrot set explorer with Numerical Elixir and Zig
Introduction
Source:
<ul>
<li><a>Mandelbrot set</a></li>
<li><a>Plotting algorithm</a></li>
</ul>
This repo is about visualising the orbits of points in the 2D-plane under the map <code>z -> z*z + c</code> known as Julia or Mandelbrot sets.
We are looking whether the iterates stay bounded are not. When we associate a colour that reflects this stability, this gives rise to Mandelbrot images.
These images are therefor a colourful representation of where the sequence is stable and how fast does these sequences diverge.
This repo contains:
- a pur <code>Zig</code> computation
- two <code>Livebook</code> to explore the orbits of points and to zoom into the Mandelbrot set.
The two Livebooks are:
- one proposing a pur <code>Elixir</code> orbit explorer. You click and it displays the orbit of any point.
- the other proposing a Mandelbrot set explorer with a clickable image to zoom in (and out):
- we have a pur <code>Elixir</code> implementation using Numerical Elixir with <code>EXLA</code> backend of the Mandelbrot set.
- we have an enhanced version where the heavy computations are made with running embedded <code>Zig</code> code thanks to the library <code>Zigler</code>.
The <code>Zig</code> code is compiled to <code>WebAssembly</code> to demonstrate quickly how this renders:
<a>https://ndrean.github.io/zig-assembly-test/</a>
Orbit explorer
Given a complex number <code>c</code> and the polynomial <code>p_c(x)=x^2+c</code>, we compute the sequence of iterates:
<code>p(0)=c
p(p(0))=p(c)=c^2+2
p(p(c)) = c^4+2c^3+c^2+c
...</code>
The set of this sequence is the <em>orbit</em> of the number <code>c</code> under the map <code>p</code>.
For example, for <code>c=1</code>, we have the orbit <code>O_1 = { 0, 1, 2, 5, 26,...}</code> but for <code>c=-1</code>, we have a cyclic orbit, <code>O_{-1} = {−1, 0, −1, 0,...}</code>.
The code below computes "orbits". You select a point and a little animation displays the orbit.
<a></a>
Mandelbrot set explorer
The algorithm
Given an image of size W x H in pixels,
- loop over 1..H rows, <code>i</code>, and over 1..W columns, <code>j</code>
- compute the coordinate <code>c</code> in the 2D-plane projection corresponding to the pixel <code>(i,j)</code>
- compute the "escape" iterations <code>n</code>,
- compute the RGB colours for this <code>n</code>,
- append to your final array.
A Livebook
<a></a>
You can explore the fractal by clicking into the 2D-plane.
This happens thanks to <code>KinoJS.Live</code>.
We have a pur <code>Elixir</code> version that uses <code>Nx</code> with the <code>EXLA</code> backend, and another one that uses embedded <code>Zig</code> code for the heavy computations. The later is 3-4 magnitude faster mostly because we are running compiled Zig code versus interpreted Elixir code in a Livebook running uncompiled on a BEAM.
Details of the mandelbrot set
[Needs latex]
In fact, this set is contained in a disk
$ D_2$ of radius 2. This does not mean that
$ 0_c$ is bounded whenever
$|c|\leq 2$ as seen above. Merely
$0_c$ is certainly unbounded - the sequence of
$z_n$ is divergent whenever
$|c| > 2$.
We have a more precise criteria: whenever the absolute value $<code>|z_n|</code>$ is greater that 2, then the absolute values of the following iterates grow to infinity.
The <strong>Mandelbrot set</strong> $M$ is the set of numbers $c$ such that its sequence $O_c$ remains bounded (in absolute value). This means that $<code>| z_n (c) | < 2</code>$ for any $<code>n</code>$.
When the sequence $<code>O_c</code>$ is <em>unbounded</em>, we associate to $c$ the first integer $N_c$ such that $<code>|z_N (c)| > 2</code>$.
Since we have to stop the computations at one point, we set a limit $m$ to the number of iteration. Whenever we have $<code>|z_{n}|\leq 2</code>$ when $n=m$, then point $<code>c</code>$ is declared <em>"mandelbrot stable"</em>.
When the sequence $O_c$ remains bounded, we associate to $<code>c</code>$ a value $<code>max</code>$.
So to each $<code>c</code>$ in the plane, we can associate an integer $n$, whether <code>null</code> or a value between 1 and $m$.
Furthermore, we decide to associate each integer $<code>n</code>$ a certain RGB colour.
With this map:
<code>math
c \mapsto n(c) \Leftrightarrow \mathrm{colour} = f\big(R(n),G(n),B(n)\big)</code>
we are able to plot something.
By convention it is <strong>black</strong> when the orbit $O_c$ remains bounded.
When you represente the full Mandelbrot set, you can take advantage of the symmetry; indeed, if $c$ is bounded, so is its conjugate.
Math details:
Firstly consider some $<code>|c| \leq 2</code>$ and suppose that for some $<code>N</code>$, we have $<code>|z_N|= 2+a</code>$ with $<code>a > 0</code>$. Then:
<code>math
|z_{N+1}| = |z_N^2+c|\geq |z_N|^2 -|c| > 2+2a = |z_N|+a</code>
so $<code>|z_{N+k}| \geq |z_N| +ka \to \infty</code>$ as $<code>k\to \infty</code>$.
Lastly, consider $|c| > 2$. Then for every $n$, we have $|z_n| > |c|$. So:
<code>math
|z_{n+1}| \geq |z_n|^2 -|c| \geq |z_n|^2-|z_n| = |z_n|(|z_n|-1) \geq |z_n|(|c|-1) > |z_n|</code>
so the term grows to infinity and "escapes".
The <em>mandelbrot set</em> $M$ is <strong>compact</strong>, as <em>closed</em> and bounded (contained in the disk of radius 2).
It is also surprisingly <em>connected</em>.
<blockquote>
Fix an integer $n\geq 1$ and consider the set $M_n$ of complex numbers $c$ such that there absolute value at the rank $n$ is less than 2. In other words, $ M_n={c\in\mathbb{C}, \, |z_n(c)|\leq 2} $. Then the complex numbers Mandelbrot-stable are precisely the numbers in all these $ M_n$, thus $M = \bigcap_n M_n$.
We conclude by remarking that each $M_n$ is closed as a preimage of the closed set $ [0,2]$ by a continous function, and since $M$ is an intersection of closed sets (not necesserally countable), it is closed.
</blockquote> | [] |
https://avatars.githubusercontent.com/u/194645670?v=4 | imgui | InteractiveBin/imgui | 2025-01-16T15:16:11Z | Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/InteractiveBin/imgui/tags | MIT | [
"zig",
"zig-package"
] | 57,370 | true | 2025-01-20T08:44:54Z | true | true | unknown | github | [] | 404 | [
"https://github.com/JamWils/zig-graphics-experiments",
"https://github.com/ashpil/moonshine",
"https://github.com/fjebaker/zig-sokol-imgui-wasm",
"https://github.com/kassane/sokol-d",
"https://github.com/zoeesilcock/gamedev-playground"
] |
https://avatars.githubusercontent.com/u/93522910?v=4 | zig-dockerfile | 42LM/zig-dockerfile | 2025-01-20T23:12:47Z | Zig ⚡️- Dockerfile examples (mainly for use in a Docker container github action 🐳) | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/42LM/zig-dockerfile/tags | MIT | [
"container-actions",
"dockerfile",
"dockerfile-examples",
"github-actions",
"zig",
"ziglang"
] | 8 | false | 2025-05-12T08:58:32Z | false | false | unknown | github | [] | zig-dockerfile
This repo provides docker image examples that contain zig.
These docker images can be used for the purpose of creating a <a>Docker container github action</a> or testing.
If you just want to use zig for building a github action and want to waive javascript completely this image might be for <strong>YOU</strong> 🫵!
<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 <code>Dockerfile</code> in the <a>main/default</a> branch lets
you build a regular version on <code>linux x86_64</code>.
For more options check out different branches:
Build a regular version with setting the <code>OS</code> and <code>ARCH</code>?
- Check out the <a>default_os_arch</a> branch.
Build master/dev on <code>linux x85_64</code>?
- Check out the <a>dev</a> branch.
Build master/dev version with setting the <code>OS</code> and <code>ARCH</code>?
- Check out the <a>dev_os_arch</a> branch.
</blockquote>
Usage
Build image
<code>sh
docker build -t zig0.13.0 . --build-arg ZIGVER=0.13.0</code>
Run image
<code>sh
docker run -it zig0.13.0 sh</code>
<code>sh
docker run --name zigdocker zig0.13.0</code>
Notes
This docker image fills a tiny niche and only exists for testing purposes and github actions.
<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>
<blockquote>
<a><strong>Zig makes Docker irrelevant.</strong></a> You probably do not need a Docker image to
build your Zig application, ...
Andrew Kelley
</blockquote>
</blockquote> | [] |
https://avatars.githubusercontent.com/u/70208852?v=4 | hot-shot | a4arpon/hot-shot | 2024-10-27T03:26:44Z | Welcome to Hot Shot, a meta-framework built on top of Hono, inspired by the best features of AdonisJS and NestJS. Hot Shot provides a structured and efficient way to build scalable web applications that can run on multiple JavaScript runtimes, including Node.js, Deno, and Bun. | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/a4arpon/hot-shot/tags | - | [
"adonisjs",
"bun",
"bundler",
"bytecode",
"hono",
"honojs",
"http-server",
"javascript",
"linux-app",
"nestjs",
"nodejs",
"nodejs-api",
"nodejs-server",
"nodemailer",
"typescript",
"zig"
] | 130 | false | 2025-01-04T13:22:32Z | false | false | unknown | github | [] | Hot Shot
Hottest framework on planet earth for building scalable web applications server.
<strong>If you're on other planets you can use it too. Just use Bun only for now.</strong>
If You Want To Ship Fast, You Have To Build Faster.
<strong>But this framework is more faster than your crush rejects your proposal.</strong>
Welcome to <strong>Hot Shot</strong>, a meta-framework built on top of
<a>Hono</a>, inspired by the best features of AdonisJS and
NestJS. Hot Shot provides a structured and efficient way to build scalable web
applications that can run on multiple JavaScript runtimes, including Node.js,
Deno, and Bun.
Introduction
Hot Shot leverages the simplicity and performance of Hono while offering a
higher-level abstraction for organizing your application's components. By
combining concepts from AdonisJS and NestJS, Hot Shot promotes a clean
architecture using classes for controllers, routes, and middleware, making your
codebase modular and maintainable.
Key Features
<ul>
<li><strong>Modular Routing</strong>: Organize routes into classes for better structure and
readability.</li>
<li><strong>Middleware Support</strong>: Easily integrate middleware for authentication,
validation, and more.</li>
<li><strong>Controller-Based Design</strong>: Encapsulate request handling logic within
controllers.</li>
<li><strong>Inspired by AdonisJS and NestJS</strong>: Familiar patterns for developers coming
from these frameworks.</li>
<li><strong>Multi-Runtime Support</strong>: Run your applications seamlessly on Node.js, Deno,
and Bun.</li>
</ul>
Getting Started
Copy Starter Kit (Recommended)
Copy the <a>starter kit</a> to your project directory and start coding.
<code>bash
git clone https://github.com/a4arpon/hot-shot-kit.git && cd hot-shot-kit && rm -rf .git && code .</code>
I am too lazy to write the documentation for this. So, I recommend you to copy the starter kit to your project directory
and start coding. I don't know know what this documentation contains. This is 99% ChatGPT generated. If you face any
problem, please open an issue on GitHub or Hey directly message me on LinkedIn Or Twitter.
<ul>
<li><a>LinkedIn</a></li>
<li><a>Twitter</a></li>
<li><a>Facebook</a></li>
</ul>
Installation
Install Hot Shot via npm:
```bash
NPM Installation
npx jsr add @a4arpon/hotshot
Bun Installation
bunx jsr add @a4arpon/hotshot
Deno Installation
deno add jsr:@a4arpon/hotshot
```
Creating Routes
Hot Shot encourages organizing your routes into classes, each representing a
module or feature of your application.
Example: Creating a User Routes Class
```typescript
export class UserRoutes {
public readonly routes: Hono;
private readonly userController: UserController;
<code>constructor() {
this.userController = new UserController();
this.routes = router({
basePath: "users",
routes: [
{
path: "/register",
method: "POST",
controller: this.userController.register,
},
{
path: "/login",
method: "POST",
controller: this.userController.login,
},
{
path: "/profile",
method: "GET",
controller: this.userController.getProfile,
middlewares: [AuthGuard],
},
],
});
}
</code>
}
```
<ul>
<li><strong><code>basePath</code></strong>: Sets the base URL for all routes in the class.</li>
<li><strong><code>routes</code></strong>: An array of route definitions with methods, paths, controllers,
and optional middleware.</li>
</ul>
Creating Controllers
Controllers contain the business logic for handling requests and generating
responses.
Example: Creating a User Controller
```typescript
export class UserController {
async register(ctx: Context): Promise {
const data = await ctx.req.json();
// Logic to register a user
return response("User registered successfully", {userId: 1});
}
<code>async login(ctx: Context): Promise<ApiResponse> {
const data = await ctx.req.json();
// Logic to authenticate a user
return response("User logged in successfully", {token: "jwt-token"});
}
async getProfile(ctx: Context): Promise<ApiResponse> {
// Logic to retrieve user profile
return response("User profile retrieved", {name: "John Doe"});
}
</code>
}
```
<ul>
<li><strong>Controller Methods</strong>: Asynchronous functions that handle specific endpoints.</li>
</ul>
Implementing Middleware
Middleware functions perform actions before or after route handlers, such as
authentication or input validation.
Example: Creating an Authentication Guard
```typescript
export const AuthGuard = async (ctx: Context, next: () => Promise) => {
try {
const authHeader = ctx.req.header("Authorization");
const token = authHeader?.split(" ")[1];
<code> if (!token) {
ctx.status(401);
return ctx.json(response("Unauthorized access", null, {}, false));
}
// Verify token (implementation depends on your auth strategy)
const user = verifyToken(token);
if (!user) {
ctx.status(401);
return ctx.json(response("Invalid token", null, {}, false));
}
ctx.user = user;
await next();
} catch (error) {
ctx.status(500);
return ctx.json(response("Server error", null, {}, false));
}
</code>
};
```
<ul>
<li><strong>Middleware Functions</strong>: Take <code>ctx</code> and <code>next</code> as arguments and can modify
the context or control the flow.</li>
</ul>
Combining Routes
Use <code>routerFactory</code> to combine multiple route classes into a single application
route.
Example: Combining Multiple Route Classes
<code>typescript
export const applicationRoutes = routerFactory([
UserRoutes,
ProductRoutes,
OrderRoutes,
]);</code>
Utilities and Helpers
Response Helper
Use the <code>response</code> function to create consistent API responses.
Example: Using the Response Helper
<code>typescript
return response("Operation successful", {data: "Sample data"});</code>
Middleware Exception Response
Use <code>middleWareExceptionResponse</code> to handle exceptions in middleware.
Example: Handling Middleware Exceptions
<code>typescript
export const ExampleMiddleware = async (
ctx: Context,
next: () => Promise<void>,
) => {
try {
// Middleware logic
await next();
} catch (error) {
return middleWareExceptionResponse(ctx, error);
}
};</code>
Full Usage Example
Let's build a simple blog module with posts and comments.
Step 1: Create Controllers
```typescript
export class PostsController {
async createPost(ctx: Context): Promise {
const data = await ctx.req.json();
// Logic to create a post
return response("Post created", {postId: 1});
}
<code>async getPost(ctx: Context): Promise<ApiResponse> {
const {postId} = ctx.req.param();
// Logic to get a post
return response("Post retrieved", {postId, title: "Sample Post"});
}
</code>
}
export class CommentsController {
async addComment(ctx: Context): Promise {
const data = await ctx.req.json();
// Logic to add a comment
return response("Comment added", {commentId: 1});
}
}
```
Step 2: Define Route Classes
```typescript
export class PostsRoutes {
public readonly routes: Hono;
private readonly postsController: PostsController;
<code>constructor() {
this.postsController = new PostsController();
this.routes = router({
basePath: "posts",
routes: [
{
path: "/",
method: "POST",
controller: this.postsController.createPost,
middlewares: [AuthGuard],
},
{
path: "/:postId",
method: "GET",
controller: this.postsController.getPost,
},
],
});
}
</code>
}
export class CommentsRoutes {
public readonly routes: Hono;
private readonly commentsController: CommentsController;
<code>constructor() {
this.commentsController = new CommentsController();
this.routes = router({
basePath: "comments",
routes: [
{
path: "/",
method: "POST",
controller: this.commentsController.addComment,
middlewares: [AuthGuard],
},
],
});
}
</code>
}
```
Step 3: Combine Routes into Application Routes
<code>typescript
export const applicationRoutes = routerFactory([
UserRoutes,
PostsRoutes,
CommentsRoutes,
]);</code>
Step 4: Initialize the Application
```typescript
const app = new Hono();
app.route("/", applicationRoutes);
app.listen(3000, () => {
console.log("Blog application is running on http://localhost:3000");
});
```
Best Practices
<ul>
<li><strong>Organize by Feature</strong>: Group related controllers and routes together.</li>
<li><strong>Use Middleware Wisely</strong>: Apply middleware at the route or controller level
as needed.</li>
<li><strong>Handle Errors Gracefully</strong>: Use <code>safeAsync</code> and consistent error responses.</li>
<li><strong>Keep Controllers Focused</strong>: Controllers should handle request logic, not
business logic.</li>
</ul>
Conclusion
Hot Shot provides a robust structure for building scalable and maintainable web
applications. By following familiar patterns and offering utilities to simplify
common tasks, it helps you focus on writing clean and efficient code.
Explore the framework and start building your next application with Hot Shot!
Feel free to dive deeper into each section and adapt the examples to fit your
application's specific needs.
Developer Information
Mr Wayne
<strong>Github</strong> : <a>a4arpon</a>
<strong>Twitter</strong> : <a>@a4arpon</a>
<strong>LinkedIn</strong> : <a>@a4arpon</a>
<strong>Instagram</strong> : <a>@a4arpon</a>
<strong>Facebook</strong> : <a>@a4arpon</a> | [] |
https://avatars.githubusercontent.com/u/147310126?v=4 | NGLYD-IFJ24-Compiler | fifixsandy/NGLYD-IFJ24-Compiler | 2024-09-23T19:02:31Z | Compiler of a subset of Zig (IFJ24) | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/fifixsandy/NGLYD-IFJ24-Compiler/tags | GPL-3.0 | [
"brno-university-of-technology",
"compiler",
"compilers",
"ifj",
"ifj24",
"zig"
] | 1,373 | false | 2025-02-11T18:37:30Z | false | false | unknown | github | [] | NGLYD IFJ24 Compiler
Description
In this repository you can find implementation of a compiler for a subset of Zig programming language - IFJ24.
It has been developed by team NGLYD as a semestral project for <a>IFJ (Formal languages and compilers)</a> course on Brno University of Technology, Faculty of information technologies.
Compiler consists of following parts:
<ul>
<li>lexical analyser based on <em>finite automaton</em></li>
<li><em>LL1 recursive</em> top-down syntactic analyser</li>
<li>syntactic analyser of expressions based on <em>precedence table</em></li>
<li>generator of <em>abstract syntactic tree</em></li>
<li>symbol table implemented as <em>AVS-tree</em></li>
<li>generator of intermediate code "IFJcode24"</li>
</ul>
Lexical, syntactic and semantic checks are perfomed during tokenizing and parsing.
For more detailed description, refer to documentation.pdf in /doc.
Environment
Linux
Build
| Target | Description | Command Example |
|--------|--------------------------------------------------------------|-----------------|
| <code>dev</code> | Compiles source files into objects and links them. | <code>make dev</code> |
| <code>test</code> | Runs the test script using the compiled binary and interpreter.| <code>make test</code> |
| <code>pack</code> | Creates a zip package of source code and documentation. | <code>make pack</code> |
| <code>doc</code> | Compiles the LaTeX documentation into a PDF. | <code>make doc</code> |
| <code>run</code> | Runs the compiled executable with input/output redirection. | <code>make run</code> |
Usage
Make sure you have downloaded an interpreter for <em>IFJcode24</em> from <a>this link</a> and have it in root directory.
Use <code>make run</code> with input file <em>in.ifj</em> or execute the compiler with source file in IFJ24 with redirection to standard input.
Compiler prints <em>IFJcode24</em> to standard output. Redirect it to the interpreter or another file.
Test outputs and percentages
| Module | Score | Passed/Total | Incorrect Return Codes | Incorrect Outputs |
|---------------------------------------------|--------|-------------|------------------------|-------------------|
| Lexical Analysis (error detection) | 91 % | 192/210 | 8 % | - |
| Syntax Analysis (error detection) | 97 % | 261/267 | 2 % | - |
| Semantic Analysis (error detection) | 98 % | 394/402 | 1 % | - |
| Code Interpretation (basic) | 96 % | 346/360 | 2 % | 1 % |
| Code Interpretation (expressions, built-ins)| 100 % | 170/170 | 0 % | 0 % |
| Code Interpretation (complex) | 86 % | 363/421 | 13 % | 0 % |
| Function Expressions (FUNEXP) | 100 % | 150/150 | 0 % | 0 % |
| <strong>Total (excluding extensions)</strong> | <strong>94 %</strong>| <strong>1726/1830</strong>| <strong>-</strong> | <strong>-</strong> |
Authors
NGLYD
<ul>
<li><a>xfignam00 Matúš Fignár</a></li>
<li><a>xmalegt00 Tibor Malega</a></li>
<li><a>xnovakf00 Filip Novák</a></li>
<li><a>xskovaj00 Ján Skovajsa</a></li>
</ul>
License
This program is licensed under the GNU General Public License v3.0 | [] |
https://avatars.githubusercontent.com/u/609180?v=4 | advent-of-zig | demiazz/advent-of-zig | 2024-11-11T15:07:58Z | Advent of Code on Zig lang and WASM | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/demiazz/advent-of-zig/tags | - | [
"advent-of-code",
"wasm",
"zig",
"ziglang"
] | 108 | false | 2025-01-14T18:01:15Z | true | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/194645670?v=4 | bgfx | InteractiveBin/bgfx | 2025-01-16T04:59:31Z | Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library. | master | 0 | 1 | 0 | 1 | https://api.github.com/repos/InteractiveBin/bgfx/tags | BSD-2-Clause | [
"zig",
"zig-package"
] | 276,217 | true | 2025-01-20T08:51:43Z | true | true | unknown | github | [
{
"commit": "23d892161557c20d085a84bd51f59759ebcb2c89",
"name": "bx",
"tar_url": "https://github.com/InteractiveBin/bx/archive/23d892161557c20d085a84bd51f59759ebcb2c89.tar.gz",
"type": "remote",
"url": "https://github.com/InteractiveBin/bx"
},
{
"commit": "9e05c85a5a2a684f964dd3a4ba9d852... |
<a>bgfx</a> - Cross-platform rendering library
<a>What is it?</a> -
<a>Building</a> -
<a>Getting Involved</a> -
<a>Examples</a> -
<a>API Reference</a> -
<a>Tools</a> -
<a>Who is using it?</a> -
<a>License</a>
<a></a>
<a></a>
<a></a>
<ul>
<li><a>GitHub Discussions</a></li>
<li><a>Discord Chat</a></li>
<li><a>GitHub Actions</a></li>
</ul>
<a>What is it?</a>
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style
rendering library.
Supported rendering backends:
<ul>
<li>Direct3D 11</li>
<li>Direct3D 12</li>
<li>GNM (only for licensed PS4 developers, search DevNet forums for source)</li>
<li>Metal</li>
<li>OpenGL 2.1</li>
<li>OpenGL 3.1+</li>
<li>OpenGL ES 2</li>
<li>OpenGL ES 3.1</li>
<li>Vulkan</li>
<li>WebGL 1.0</li>
<li>WebGL 2.0</li>
</ul>
Supported platforms:
<ul>
<li>Android (14+)</li>
<li>iOS/iPadOS/tvOS (16.0+)</li>
<li>Linux</li>
<li>macOS (13.0+)</li>
<li>PlayStation 4</li>
<li>RaspberryPi</li>
<li>UWP (Universal Windows, Xbox One)</li>
<li>Wasm/Emscripten</li>
<li>Windows (7+)</li>
</ul>
Supported compilers:
<ul>
<li>Clang 11 and above</li>
<li>GCC 11 and above</li>
<li>VS2019 and above</li>
<li>Apple clang 12 and above</li>
</ul>
Languages:
<ul>
<li><a>C/C++ API documentation</a></li>
<li><a>Beef API bindings</a></li>
<li><a>C# language API bindings #1</a></li>
<li><a>D language API bindings</a></li>
<li><a>Go language API bindings</a></li>
<li><a>Haskell language API bindings</a></li>
<li><a>Lightweight Java Game Library 3 bindings</a></li>
<li><a>Lua language API bindings</a></li>
<li><a>Nim language API bindings</a></li>
<li><a>Pascal language API bindings</a></li>
<li><a>Python language API bindings #1</a></li>
<li><a>Python language API bindings #2</a></li>
<li><a>Rust language API bindings (new)</a></li>
<li><a>Swift language API bindings</a></li>
<li><a>Zig language API bindings</a></li>
</ul>
Who is using it? <a>#madewithbgfx</a>
AirMech
https://www.carbongames.com/airmech-strike - AirMech is a free-to-play
futuristic action real-time strategy video game developed and published by
Carbon Games.
cmftStudio
https://github.com/dariomanesku/cmftStudio - cmftStudio - Cubemap filtering
tool.
Crown
https://github.com/dbartolini/crown - Crown is a general purpose data-driven
game engine, written from scratch with a minimalistic and data-oriented design
philosophy in mind.
Offroad Legends 2
http://www.dogbytegames.com/ - Dogbyte Games is an indie mobile developer studio
focusing on racing games.
Torque6
https://github.com/andr3wmac/Torque6 - Torque 6 is an MIT licensed 3D engine
loosely based on Torque2D. Being neither Torque2D or Torque3D it is the 6th
derivative of the original Torque Engine.
<a target="_blank"></a>
Kepler Orbits
https://github.com/podgorskiy/KeplerOrbits - KeplerOrbits - Tool that calculates
positions of celestial bodies using their orbital elements.
CETech
https://github.com/cyberegoorg/cetech - CETech is a data-driven game engine and
toolbox inspired by Bitsquid/Stingray engine.
ioquake3
https://github.com/jpcy/ioq3-renderer-bgfx - A renderer for ioquake3 written in
C++ and using bgfx to support multiple rendering APIs.
DLS
http://makingartstudios.itch.io/dls - DLS, the digital logic simulator game.
<a target="_blank"></a>
http://dls.makingartstudios.com/sandbox/ - DLS: The Sandbox.
MAME
https://github.com/mamedev/mame - MAME - Multiple Arcade Machine Emulator.
Blackshift
https://blackshift.itch.io/blackshift - Blackshift is a grid-based, space-themed
action puzzle game which isn't afraid of complexity - think Chip's Challenge on
crack.
<a target="_blank"></a>
Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
https://eheitzresearch.wordpress.com/415-2/ - Real-Time Polygonal-Light Shading
with Linearly Transformed Cosines, Eric Heitz, Jonathan Dupuy, Stephen Hill and
David Neubelt, ACM SIGGRAPH 2016.
<a target="_blank"></a>
Dead Venture
http://www.dogbytegames.com/dead_venture.html - Dead Venture is a new Drive 'N
Gun game where you help a handful of survivals reach the safe haven: a military
base on a far island.
<a target="_blank"></a>
REGoth
https://github.com/degenerated1123/REGoth - REGoth is an open-source
reimplementation of the zEngine, used by the game "Gothic" and "Gothic II".
<a target="_blank"></a>
Ethereal Engine
https://github.com/volcoma/EtherealEngine - EtherealEngine is a C++ game engine
and WYSIWYG editor.
Go Rally
http://gorallygame.com/ - Go Rally is top-down rally game with a career mode,
multiplayer time challenges, and a track creator.
<a target="_blank"></a>
vg-renderer
https://github.com/jdryg/vg-renderer#vg-renderer - vg-renderer is a vector
graphics renderer for bgfx, based on ideas from both NanoVG and ImDrawList (Dear
ImGUI).
Zombie Safari
http://www.dogbytegames.com/zombie_safari.html - Do what you please in this
open-world offroad driving game: explore massive landscapes, complete
challenges, smash zombies, find secret locations, unlock and upgrade cars and
weapons, it's up to you!
<a target="_blank"></a>
Smith and Winston
http://www.smithandwinston.com/ - Smith and Winston is an exploration twin stick
shooter for PC, PS4 & XBoxOne arriving in late 2018. Smith and Winston features
a massively destructible voxel world, rapid twin stick combat, physics puzzles
and Metroid-style discovery.
<a target="_blank"></a>
Football Manager 2018
http://www.footballmanager.com/ - Football Manager 2018 is a 2017 football
management simulation video game developed by Sports Interactive and published
by Sega.
<a target="_blank"></a>
WonderWorlds
http://wonderworlds.me/ - WonderWorlds is a place to play thousands of
user-created levels and stories, make your own using the extensive in-game tools
and share them with whomever you want.
<a target="_blank"></a>
two-io / mud
https://hugoam.github.io/two-io/ - An all-purpose c++ app prototyping library,
focused towards live graphical apps and games.
Talking Tom Pool
https://outfit7.com/apps/talking-tom-pool/ - A "sling and match" puzzle game for
mobile devices.
<a target="_blank"></a>
GPlayEngine
https://github.com/fredakilla/GPlayEngine#gplayengine - GPlayEngine is a C++
cross-platform game engine for creating 2D/3D games based on the GamePlay 3D
engine v3.0.
Off The Road
http://www.dogbytegames.com/off_the_road.html - A sandbox off-road driving
simulator.
<a target="_blank"></a>
Coal Burnout
https://beardsvibe.com/ - A multiplayer PVP rhythm game.
My Talking Tom 2
https://outfit7.com/apps/my-talking-tom-2/ - Many mini games for mobile devices.
<a target="_blank"></a>
NeoAxis Engine
https://www.neoaxis.com/ - Versatile 3D project development environment.
xatlas
https://github.com/jpcy/xatlas#xatlas - Mesh parameterization library.
Heroes of Hammerwatch
https://store.steampowered.com/app/677120/Heroes_of_Hammerwatch/ - Heroes of
Hammerwatch is a rogue-lite action-adventure game set in the same universe as
Hammerwatch. Encounter endless hordes of enemies, traps, puzzles, secrets and
lots of loot, as you battle your way through procedurally generated levels to
reach the top of the Forsaken Spire.
<a target="_blank"></a>
Babylon Native
https://github.com/BabylonJS/BabylonNative#babylon-native - Build cross-platform
native applications with the power of the Babylon.js JavaScript framework.
Nira
https://nira.app/ - Instantly load and view assets on any device. All you need
is a web browser.
SIGGRAPH 2019: Project Nira: Instant Interactive Real-Time Access to
Multi-Gigabyte Sized 3D Assets on Any Device:
https://s2019.siggraph.org/presentation/?sess=sess104&id=real_130#038;id=real_130
<a target="_blank"></a>
openblack
https://github.com/openblack/openblack#openblack - An open-source
reimplementation of the game Black & White (2001).
Cluster
https://github.com/pezcode/Cluster#cluster - Implementation of Clustered Shading
and Physically Based Rendering with the bgfx rendering library.
NIMBY Rails
https://store.steampowered.com/app/1134710/NIMBY_Rails/ - NIMBY Rails is a
management and design sandbox game for railways you build in the real world.
Minecraft
https://www.minecraft.net/zh-hant/attribution/
FFNx
https://github.com/julianxhokaxhiu/FFNx#ffnx - Next generation driver for Final
Fantasy VII and Final Fantasy VIII (with native Steam 2013 release support!)
Shadow Gangs
https://www.microsoft.com/en-gb/p/shadow-gangs/9n6hkcr65qdq - Shadow Gangs is an
arcade style ninja action game.
Growtopia
https://growtopiagame.com/ - Growtopia is a free-to-play sandbox MMO game with
almost endless possibilities for world creation, customization and having fun
with your friends. Enjoy thousands of items, challenges and events.
Galaxy Trucker
https://galaxytrucker.com/ - Digital implementation of tabletop spaceship
building in real-time or turn-based mode, then surviving space adventures, with
AI opponents, multiplayer, achievements and solo campaign.
Through the Ages
https://throughtheages.com/ - The card tabletop deep strategy game in your
devices. Lead your civilization from pyramids to space flights. Challenges,
achievements, skilled AIs and online multiplayer.
Codenames
https://codenamesgame.com/ - One of the best party games. Two rival spymasters
know the secret identities of 25 agents. Their teammates know the agents only by
their codenames. Simple to explain, easy to understand, challenging gameplay.
PeakFinder
https://www.peakfinder.org/ - PeakFinder shows the names of all mountains and
peaks with a 360° panorama display. More than 850'000 peaks - from Mount Everest
to the little hill around the corner.
Ember Sword
https://embersword.com - Ember Sword is a free to play MMORPG running directly
in your browser and is being developed and published by Bright Star Studios.
Off The Road Unleashed
https://www.nintendo.com/games/detail/off-the-road-unleashed-switch/ - Off The
Road Unleashed is a sandbox driving game for the Nintendo Switch. If you see a
vehicle you bet you can hop into it! Pilot big rigs, helicopters, boats,
airplanes or even trains. Sand dunes, frozen plains, mountains to climb and
conquer.
<a target="_blank"></a>
Guild Wars 2
https://www.guildwars2.com/ - Guild Wars 2 is an online role-playing game with
fast-paced action combat, a rich and detailed universe of stories, awe-inspiring
landscapes to explore, two challenging player vs. player modes—and no
subscription fees!
Griftlands
https://klei.com/games/griftlands - Griftlands is a roguelike deck-building game
with role-playing story elements in a science fiction setting, developed and
published by Klei Entertainment.
<a target="_blank"></a>
HARFANG 3D
https://www.harfang3d.com - HARFANG® 3D is a <strong>BGFX-powered</strong> 3D visualization
framework for C++, Python, Go, and Lua. It comes with a 3D editor, HARFANG
Studio.
Marine Melodies / Resistance
https://www.pouet.net/prod.php?which=91906 - Demoscene musicdisk released at
Evoke 2022 demoparty.
https://github.com/astrofra/demo-marine-melodies
<a target="_blank"></a>
Activeworlds
https://www.activeworlds.com/ - Activeworlds is an online VR platform with rich
multimedia and presentation features. Create your own worlds or build in free
community worlds, hold your own event / meeting or join inworld events!
Equilibrium Engine
https://github.com/clibequilibrium/EquilibriumEngine - Equilibrium Engine is a
data-oriented and multi-threaded C11 Game Engine with libraries & shaders
hot-reloading.
Pinhole Universe
https://festina-lente-productions.com/pinhole-universe/ - Explore a generated
world where you can zoom in on anything, forever.
Unavowed (Nintendo Switch version only)
https://www.nintendo.com/us/store/products/unavowed-switch/ - A demon has possessed you
and used your body to tear a swath of bloodshed through New York. You are now free, but
life as you knew it is over. Your only path forward is joining the Unavowed - an ancient
society dedicated to stopping evil. No matter what the cost.
The Excavation of Hob's Barrow (Nintendo Switch version only)
https://www.nintendo.com/us/store/products/the-excavation-of-hobs-barrow-switch/ - A folk
horror narrative-driven adventure. Explore the isolated moors of rural Victorian England
as you uncover the mysteries of Hob's Barrow. The answers lie in the soil...
Primordia (Nintendo Switch version only)
https://www.nintendo.com/us/store/products/primordia-switch/ - Life has ceased. Man is
but a myth. And now, even the machines have begun to fail. Lead Horatio Nullbuilt and his
sarcastic sidekick Crispin on a journey through the crumbling world of Primordia, facing
malfunctioning robots, ancient secrets, and an implacable, power-hungry foe.
ProtoTwin
https://prototwin.com - Online industrial simulation software for manufacturing and material handling.
WARCANA
WARCANA is a fantasy inspired base defence, RTS game with a deck-building mechanic.
Face hundreds of thousands of unrelenting monsters in a battle royale between 30 other
mighty magicians. Build your deck. Prepare your defences. Summon your armies.
Survive the onslaught.
<a target="_blank"></a>
DiskBoard
https://www.diskboard.com - DiskBoard is the ultimate tool that can help you measure
the performance and monitor the health of your hardware. All of your devices are
presented in a clean and easy to understand view. The tests offer extensive
customization options, allowing you to simulate various workloads. The intuitive
visuals provide clear insights, benchmark comparisons, and performance guidelines.
Join a community of tech enthusiasts, compare your device's prowess, and witness
your hardware shine!
Ant
https://github.com/ejoy/ant - Ant is an open-source game engine focused on mobile platforms. It is implemented
based on Lua, with excellent performance and easy customization.
<a>Red Frontier Game using Ant Game Engine</a>
Crypt of the NecroDancer
https://braceyourselfgames.com/crypt-of-the-necrodancer/ - Crypt of the NecroDancer
is an award-winning hardcore roguelike rhythm game. Move to the music and deliver
beatdowns to the beat! The game uses bgfx on Windows, macOS, Linux, Nintendo
Switch and PlayStation 4.
Tomb4Plus
https://www.github.com/SaracenOne/Tomb4Plus - Tomb4Plus is an open source
reimplementation of the Tomb Raider: The Last Revelation engine. It is an
enhanced fork of the original <a>Tomb4</a>
reimplementation project which focuses on supporting the Level Editor runtime
and aims for full compatibility with the unofficial binary-patched scripting
extensions used by many custom levels. Tomb4Plus also replaces the original
legacy Direct3D renderer with bgfx.
Braid, Anniversary Edition
https://play.google.com/store/apps/details?id=com.netflix.NGP.BraidAnniversaryEdition -
bgfx is used only in Android version of the game.
<a target="_blank"></a>
Rotwood
https://store.steampowered.com/app/2015270/Rotwood/ - Rotwood is an upcoming
beat'em up, rogouelike video game developed and published by Klei Entertainment.
<a target="_blank"></a>
Cubzh
https://app.cu.bzh/ - Cubzh is a User Generated Social Universe, an online
platform where all items, avatars, games, and experiences are made by users
from the community.
Source: https://github.com/cubzh/cubzh
World Of Goo 2
https://store.epicgames.com/en-US/p/world-of-goo-2 - Build bridges,
grow towers, terraform terrain, and fuel flying machines in
the stunning followup to the multi-award winning World of Goo.
<a target="_blank"></a>
<a>License (BSD 2-clause)</a>
<a target="_blank">
</a>
<code>Copyright 2010-2025 Branimir Karadzic
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
</code> | [
"https://github.com/jerome-trc/viletech-2022"
] |
https://avatars.githubusercontent.com/u/130330524?v=4 | otimorm | takuma-shishido/otimorm | 2024-10-30T22:50:34Z | library for PostgreSQL ORM written in zig 🔥 | develop | 0 | 1 | 0 | 1 | https://api.github.com/repos/takuma-shishido/otimorm/tags | - | [
"database",
"orm",
"postgresql",
"zig",
"zig-package"
] | 38 | false | 2024-11-04T17:35:35Z | true | true | unknown | github | [
{
"commit": "master",
"name": "pg",
"tar_url": "https://github.com/karlseguin/pg.zig/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/karlseguin/pg.zig"
}
] | otimorm
<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>
<strong>This project is still under development and there are bugs</strong>
If you find a bug, please open an issue. I will fix it as soon as possible.
</blockquote>
<code>otimorm</code> is an easy-to-use ORM for PostgreSQL that works with the latest version of Zig.
tested with <code>0.14.0-dev</code>
Code Example
see <a>this</a>.
TODO
<ul>
<li>Support for more complex queries</li>
</ul>
Credit
This project was inspired by <a>zig-orm</a> | [] |
https://avatars.githubusercontent.com/u/61627919?v=4 | aoc_zig_templ | nuIIpointerexception/aoc_zig_templ | 2024-12-08T07:00:57Z | A easy to use template for building solutions for advent of code! 🎄✨ | main | 0 | 1 | 0 | 1 | https://api.github.com/repos/nuIIpointerexception/aoc_zig_templ/tags | MIT | [
"advent-of-code",
"aoc",
"zig",
"ziglang"
] | 11 | false | 2024-12-10T16:59:59Z | true | true | unknown | github | [] | aoc_zig
This is my template repository for the <a>Advent of Code</a> challenges in <a>Zig</a>.
It includes a neat build system for fetching inputs, submitting solutions, and managing AoC code.
Features
<ul>
<li>Automatic input data fetching</li>
<li>Submit your result with a command!</li>
<li>Tests and benchmarking!</li>
<li>Supports every year and every day!</li>
</ul>
Usage
To fetch the input data for solutions, you need to provide a <code>TOKEN</code> file in the root directory of the repository. This file should contain a single line with your <a>advent of code</a> cookie.
Build & Run:
<code>bash
zig build <day> -Dyear=<year></code>
<code>bash
zig build 1</code>
If no year is provided, the current year will be used.
If no day is provided, the current day will be used.
Test:
<code>bash
zig build test:<day> -Dyear=<year</code>
example for day 1 (automatic year detection):
<code>bash
zig build test:1</code>
Submit:
<code>bash
zig build submit:<day> -Dyear=<year</code>
example:
<code>bash
zig build submit:1</code>
Hard reset / clean project:
<code>bash
zig build clean</code>
NOTE: For your own safety you will have to add -Dconfirm=true to confirm this action!
Contributing
Contributions are welcome!
If you have a solution to an existing solution,
feel free to submit a PR.
License
This project is licensed under the MIT License - see the <a>LICENSE</a> file for details | [] |
https://avatars.githubusercontent.com/u/68423550?v=4 | aoc2024 | TimStricker/aoc2024 | 2024-12-03T06:58:16Z | Advent of Code 2024 in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/TimStricker/aoc2024/tags | MIT | [
"advent-of-code",
"advent-of-code-2024",
"advent-of-code-in-zig",
"advent-of-code-zig",
"aoc",
"aoc-2024",
"aoc2024",
"zig",
"ziglang"
] | 62 | false | 2024-12-15T17:50:47Z | false | false | unknown | github | [] | Advent of Code 2024
My attempt to solve AoC 2024 in <a>Zig</a>. I am not
yet super familiar with the language, so don't expect the most beautiful,
idiomatic Zig code. This is really just me trying to learn.
Supported Zig version
I'm using the nightly version of Zig to solve these tasks. At the time of
writing, this is <code>0.14.0-dev.2465+70de2f3a7</code>. Note that Zig is still in active
development and new versions might have braking changes, so it is not guaranteed
that the code works with any other version.
How to run
You can find the solution for each day in the <code>dayXY</code> directories. They are all
self-contained and can simply be executed using <code>zig run</code>.
As an example, here you can see how to run the solution to day 1:
<code>$ zig run day01/main.zig
Total distance: 2742123
Similarity score: 21328497
Task took 8 ms to complete.</code>
<strong>Note:</strong> At the moment, the applications assume they are being called from the
repository root. If you call them from anywhere else, they won't be able to find
the input for the day. I might fix this in the future.
Basically all of the solutions contain some tests with the sample input, you
can run these using <code>zig test <dayXY>/main.zig</code>. | [] |
https://avatars.githubusercontent.com/u/1063891?v=4 | ziglings-exercises | oldratlee/ziglings-exercises | 2024-10-29T03:47:16Z | my exercises of https://codeberg.org/ziglings/exercises | my-fix | 0 | 0 | 0 | 0 | https://api.github.com/repos/oldratlee/ziglings-exercises/tags | MIT | [
"exercises",
"learning-by-doing",
"zig",
"ziglang",
"ziglings",
"ziglings-exercises"
] | 1,372 | false | 2024-11-04T15:52:46Z | true | false | unknown | github | [] | Ziglings
Welcome to Ziglings! This project contains a series of tiny
broken programs (and one nasty surprise). By fixing them, you'll
learn how to read and write <a>Zig</a> code.
Those broken programs need your help! (You'll also save the
planet from evil aliens and help some friendly elephants stick
together, which is very sweet of you.)
This project was directly inspired by the brilliant and fun
<a>rustlings</a>
project for the <a>Rust</a> language.
Indirect inspiration comes from <a>Ruby Koans</a>
and the Little LISPer/Little Schemer series of books.
Ziglings was initiated by <a>Dave Gauer</a>.
Intended Audience
This will probably be difficult if you've <em>never</em> programmed
before. But no specific programming experience is required. And
in particular, you are <em>not</em> expected to have any prior
experience with "systems programming" or a "systems" level
language such as C.
Each exercise is self-contained and self-explained. However,
you're encouraged to also check out these Zig language resources
for more detail:
<ul>
<li>https://ziglang.org/learn/</li>
<li>https://ziglearn.org/</li>
<li>https://ziglang.org/documentation/master/</li>
<li><a>Zig in Depth! (video series)</a></li>
</ul>
Also, the <a>Zig community</a>
is incredibly friendly and helpful!
Getting Started
Install a <a>development build</a> of
the Zig compiler. (See the "master" section of the downloads
page.)
Verify the installation and build number of <code>zig</code> like so:
<code>$ zig version
0.14.0-dev.xxxx+xxxxxxxxx</code>
Clone this repository with Git:
<code>$ git clone https://ziglings.org
$ cd ziglings.org</code>
Then run <code>zig build</code> and follow the instructions to begin!
<code>$ zig build</code>
Note: The output of Ziglings is the unaltered output from the Zig
compiler. Part of the purpose of Ziglings is to acclimate you to
reading these.
A Note About Versions
<strong>Hint:</strong> To check out Ziglings for a stable release of Zig, you can use
the appropriate tag.
The Zig language is under very active development. In order to be
current, Ziglings tracks <strong>development</strong> builds of the Zig
compiler rather than versioned <strong>release</strong> builds. The last
stable release was <code>0.13.0</code>, but Ziglings needs a dev build with
pre-release version "0.14.0" and a build number at least as high
as that shown in the example version check above.
It is likely that you'll download a build which is <em>greater</em> than
the minimum.
Once you have a build of the Zig compiler that works with
Ziglings, they'll continue to work together. But keep in mind
that if you update one, you may need to also update the other.
Version Changes
Version-0.14.0-dev.1573
* <em>2024-09-16</em> zig 0.14.0-dev.1573 - introduction of labeled switch, see <a>#21257</a>
* <em>2024-09-02</em> zig 0.14.0-dev.1409 - several changes in std.builtin, see <a>#21225</a>
* <em>2024-08-04</em> zig 0.14.0-dev.1224 - several changes in build system, see <a>#21115</a>
* <em>2024-08-04</em> zig 0.14.0-dev.839 - several changes in build system, see <a>#20580</a>, <a>#20600</a>
* <em>2024-06-17</em> zig 0.14.0-dev.42 - changes in <code>std.mem.split and tokenize</code> - see <a>#15579</a>
* <em>2024-05-29</em> zig 0.13.0-dev.339 - rework std.Progress - see <a>#20059</a>
* <em>2024-03-21</em> zig 0.12.0-dev.3518 - change to @fieldParentPtr - see <a>#19470</a>
* <em>2024-03-21</em> zig 0.12.0-dev.3397 - rename std.os to std.posix - see <a>#5019</a>
* <em>2024-03-14</em> zig 0.12.0-dev.3302 - changes in <code>std.fmt</code> - floating-point formatting implementation - see <a>#19229</a>
* <em>2024-02-05</em> zig 0.12.0-dev.2618 - changes in <code>build system</code> - from <code>Step.zig_exe</code> to <code>Step.graph.zig_exe</code> - see <a>#18778</a>
* <em>2024-01-05</em> zig 0.12.0-dev.2043 - rename of <code>std.Build.FileSource</code> to <code>std.Build.LazyPath</code> - see <a>#16353</a>
* <em>2023-10-24</em> zig 0.12.0-dev.1243 - changes in <code>std.ChildProcess</code>: renamed exec to run - see <a>#5853</a>
* <em>2023-06-26</em> zig 0.11.0-dev.4246 - changes in compile step (now it can be null)
* <em>2023-06-26</em> zig 0.11.0-dev.3853 - removal of destination type from all cast builtins
* <em>2023-06-20</em> zig 0.11.0-dev.3747 - <code>@enumToInt</code> is now <code>@intFromEnum</code> and <code>@intToFloat</code> is now <code>@floatFromInt</code>
* <em>2023-05-25</em> zig 0.11.0-dev.3295 - <code>std.debug.TTY</code> is now <code>std.io.tty</code>
* <em>2023-04-30</em> zig 0.11.0-dev.2704 - use of the new <code>std.Build.ExecutableOptions.link_libc</code> field
* <em>2023-04-12</em> zig 0.11.0-dev.2560 - changes in <code>std.Build</code> - remove run() and install()
* <em>2023-04-07</em> zig 0.11.0-dev.2401 - fixes of the new build system - see <a>#212</a>
* <em>2023-02-21</em> zig 0.11.0-dev.2157 - changes in <code>build system</code> - new: parallel processing of the build steps
* <em>2023-02-21</em> zig 0.11.0-dev.1711 - changes in <code>for loops</code> - new: Multi-Object For-Loops + Struct-of-Arrays
* <em>2023-02-12</em> zig 0.11.0-dev.1638 - changes in <code>std.Build</code> cache_root now returns a directory struct
* <em>2023-02-04</em> zig 0.11.0-dev.1568 - changes in <code>std.Build</code> (combine <code>std.build</code> and <code>std.build.Builder</code> into <code>std.Build</code>)
* <em>2023-01-14</em> zig 0.11.0-dev.1302 - changes in <code>@addWithOverflow</code> (now returns a tuple) and <code>@typeInfo</code>; temporary disabled async functionality
* <em>2022-09-09</em> zig 0.10.0-dev.3978 - change in <code>NativeTargetInfo.detect</code> in build
* <em>2022-09-06</em> zig 0.10.0-dev.3880 - Ex 074 correctly fails again: comptime array len
* <em>2022-08-29</em> zig 0.10.0-dev.3685 - <code>@typeName()</code> output change, stage1 req. for async
* <em>2022-07-31</em> zig 0.10.0-dev.3385 - std lib string <code>fmt()</code> option changes
* <em>2022-03-19</em> zig 0.10.0-dev.1427 - method for getting sentinel of type changed
* <em>2021-12-20</em> zig 0.9.0-dev.2025 - <code>c_void</code> is now <code>anyopaque</code>
* <em>2021-06-14</em> zig 0.9.0-dev.137 - std.build.Id <code>.Custom</code> is now <code>.custom</code>
* <em>2021-04-21</em> zig 0.8.0-dev.1983 - std.fmt.format() <code>any</code> format string required
* <em>2021-02-12</em> zig 0.8.0-dev.1065 - std.fmt.format() <code>s</code> (string) format string required
Advanced Usage
It can be handy to check just a single exercise:
<code>zig build -Dn=19</code>
Or run all exercises, starting from a specific one:
<code>zig build -Ds=27</code>
Or let Ziglings pick an exercise for you:
<code>zig build -Drandom</code>
You can also run without checking for correctness:
<code>zig build -Dn=19 test</code>
Or skip the build system entirely and interact directly with the
compiler if you're into that sort of thing:
<code>zig run exercises/001_hello.zig</code>
Calling all wizards: To prepare an executable for debugging,
install it to zig-cache/bin with:
<code>zig build -Dn=19 install</code>
To get a list of all possible options, run:
```
zig build -Dn=19 -l
install Install 019_functions2.zig to prefix path
uninstall Uninstall 019_functions2.zig from prefix path
test Run 019_functions2.zig without checking output
...
```
What's Covered
The primary goal for Ziglings is to cover the core Zig language.
It would be nice to cover the Standard Library as well, but this
is currently challenging because the stdlib is evolving even
faster than the core language (and that's saying something!).
Not only would stdlib coverage change very rapidly, some
exercises might even cease to be relevant entirely.
Having said that, there are some stdlib features that are
probably here to stay or are so important to understand that they
are worth the extra effort to keep current.
Conspicuously absent from Ziglings are a lot of string
manipulation exercises. This is because Zig itself largely avoids
dealing with strings. Hopefully there will be an obvious way to
address this in the future. The Ziglings crew loves strings!
Zig Core Language
<ul>
<li>[x] Hello world (main needs to be public)</li>
<li>[x] Importing standard library</li>
<li>[x] Assignment</li>
<li>[x] Arrays</li>
<li>[x] Strings</li>
<li>[x] If</li>
<li>[x] While</li>
<li>[x] For</li>
<li>[x] Functions</li>
<li>[x] Errors (error/try/catch/if-else-err)</li>
<li>[x] Defer (and errdefer)</li>
<li>[x] Switch</li>
<li>[x] Unreachable</li>
<li>[x] Enums</li>
<li>[x] Structs</li>
<li>[x] Pointers</li>
<li>[x] Optionals</li>
<li>[x] Struct methods</li>
<li>[x] Slices</li>
<li>[x] Many-item pointers</li>
<li>[x] Unions</li>
<li>[x] Numeric types (integers, floats)</li>
<li>[x] Labelled blocks and loops</li>
<li>[x] Loops as expressions</li>
<li>[x] Builtins</li>
<li>[x] Inline loops</li>
<li>[x] Comptime</li>
<li>[x] Sentinel termination</li>
<li>[x] Quoted identifiers @""</li>
<li>[x] Anonymous structs/tuples/lists</li>
<li>[ ] Async <--- ironically awaiting upstream Zig updates</li>
<li>[X] Interfaces</li>
<li>[X] Bit manipulation</li>
<li>[X] Working with C</li>
<li>[X] Threading</li>
<li>[x] Labeled switch</li>
</ul>
Zig Standard Library
<ul>
<li>[X] String formatting</li>
<li>[X] Testing</li>
<li>[X] Tokenization</li>
<li>[X] File handling</li>
</ul>
Contributing
Contributions are very welcome! I'm writing this to teach myself
and to create the learning resource I wished for. There will be
tons of room for improvement:
<ul>
<li>Wording of explanations</li>
<li>Idiomatic usage of Zig</li>
<li>Additional exercises</li>
</ul>
Please see <a>CONTRIBUTING</a>
in this repo for the full details. | [] |
https://avatars.githubusercontent.com/u/69948027?v=4 | Zprob | AXiX-official/Zprob | 2024-09-04T13:35:27Z | A simple console progress bar for Zig(no dependencies required). | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/AXiX-official/Zprob/tags | MIT | [
"zig",
"ziglang"
] | 3 | false | 2024-09-04T13:39:57Z | true | true | 0.13.0 | github | [] | Zprob
A simple console progress bar for Zig(no dependencies required).
Only tested on zig 0.13.0.
Usage
only need import <code>Zprob.zig</code>(in <code>src</code> folder) and use <code>Zprob</code> struct.
run <code>zig build run</code> to see <code>example.zig</code>'s output.
<code>example.zig</code>:
```zig
const std = @import("std");
const Zprob = @import("Zprob.zig");
pub fn main() !void {
// Get a new Zprob instance.
// The capacity is set to 100.
// The output file is set to the standard output.
var zprob = Zprob{ .capacity = 100, .out = &std.io.getStdOut() };
<code>// Reset(initialize) the progress bar.
// Must be called just before the loop.
zprob.Reset();
for (0..100) |i| {
_ = i;
// Because write to the standard output may fail, we use `try`.
// Can't use `defer` here because return value is not `void`.
try zprob.Update(1, "test");
}
// Reuse the Zprob instance.
zprob.Resize(1000);
var b: u32 = 0;
while (b < 1000) : (b += 1) {
var buffer: [10]u8 = undefined;
const curr_number_str = std.fmt.bufPrint(buffer[0..], "{}", .{b}) catch unreachable;
// Update the progress bar with description.
try zprob.Update(1, curr_number_str);
std.time.sleep(10_000_000);
}
zprob.Reset();
b = 0;
while (b < 1000) : (try zprob.Update(1, "")) {
b += 1;
std.time.sleep(10_000_000);
}
</code>
}
``` | [] |
https://avatars.githubusercontent.com/u/22549550?v=4 | zmodb | EloToJaa/zmodb | 2024-08-13T15:49:23Z | Zig modbus library based on libmodbus | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/EloToJaa/zmodb/tags | - | [
"c",
"libmodbus",
"modbus",
"zig"
] | 23 | false | 2024-09-28T11:20:46Z | true | true | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/179981696?v=4 | zig-redismodule | ziglana/zig-redismodule | 2024-08-31T03:43:23Z | zig 0.13 ⚡️blazigly fast⚡️ redis module 2024 | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/ziglana/zig-redismodule/tags | - | [
"blazigly",
"keydb",
"keydb-module",
"redis",
"redis-module",
"zig"
] | 77 | true | 2024-10-25T06:39:47Z | true | true | unknown | github | [] | zig-redismodule
zig 0.13 redis module 2024
<code>zig build-lib -dynamic src/main.zig</code>
add libmain.dylib in redis.conf or keydb.conf
<code>redis-cli</code>
<code>127.0.0.1:6379> mymodule.hello</code>
<code>Hello, world!</code> | [] |
https://avatars.githubusercontent.com/u/187213054?v=4 | base | refilelabs/base | 2024-11-05T12:45:48Z | Base repository holding all shared components, logic etc. | main | 0 | 0 | 1 | 0 | https://api.github.com/repos/refilelabs/base/tags | - | [
"convert",
"nuxt",
"rust",
"wasm",
"webassembly",
"zig"
] | 153 | false | 2025-02-19T18:53:24Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/152508846?v=4 | windowpain | haha-systems/windowpain | 2025-01-01T02:27:59Z | Windowpain is a random-access tool for reading genetic sequences from huge FASTA sequence files in milliseconds. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/haha-systems/windowpain/tags | MIT | [
"dna",
"fasta",
"mmap",
"rna",
"zig"
] | 26 | false | 2025-01-01T18:35:42Z | true | true | unknown | github | [] | windowpain
Windowpain is a random-access tool for reading genetic sequences from huge FASTA sequence files in milliseconds.
Overview
Windowpain provides lightning-fast random access to FASTA sequence files by using memory mapping and efficient indexing. It allows you to read specific windows of sequence data without loading the entire file into memory.
Features
<ul>
<li>Memory-mapped file access for optimal performance</li>
<li>JSON-based indexing of sequence positions</li>
<li>Random access to sequence windows</li>
<li>Handles newlines in FASTA files transparently</li>
<li>Zero-copy reading of sequence data</li>
</ul>
Installation
<code>bash
git clone https://github.com/haha-systems/windowpain.git
cd windowpain
zig build --release=fast</code>
Usage
<code>bash
./windowpain index <fasta_filename> <index.json>
./windowpain read <fasta_filename> <index.json> <sequence_index> [window_size] [window_start] [--raw]</code>
Examples
Indexing a FASTA file and reading a sequence window
<code>bash
./windowpain index test.fasta test.json
./windowpain read test.fasta test.json 0 10</code>
This will first index the <code>test.fasta</code> file and then read the first 10 characters of the first sequence in <code>test.fasta</code> and print it to the console.
Using raw output to pass to another tool through <code>stdin</code>
<code>bash
./windowpain read test.fasta test.json 0 10 --raw | <other_tool></code>
This will read the first 10 characters of the first sequence in <code>test.fasta</code> and pass it to <code>other_tool</code>. The <code>other_tool</code> can be any tool that accepts raw sequence data on <code>stdin</code>.
<blockquote>
If you want to iterate over a sequence, just pass the <code>position += window_size</code> to the <code>read</code> command's <code>window_start</code> argument.
</blockquote>
Notes
<ul>
<li>Windowpain uses memory mapping to read sequence data, so it may not be suitable for small files.</li>
<li>The index file is created by the <code>index</code> command and should be used with the <code>read</code> command.</li>
<li>The <code>read</code> command can optionally output the raw sequence data without formatting to <code>stdout</code>.</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/57322933?v=4 | zglfw | griush/zglfw | 2025-01-03T15:25:10Z | Zig GLFW bindings | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/griush/zglfw/tags | MIT | [
"zig"
] | 108 | false | 2025-01-06T15:01:34Z | false | true | 0.14.0-dev | github | [] | zglfw
Zig GLFW bindings
Usage
Run <code>zig fetch --save git+https://github.com/griush/zglfw</code>.
Add in <code>build.zig</code>:
```zig
// module links libc
const zglfw = b.dependency("zglfw", .{});
module.addAnonymousImport("glfw", .{
.root_source_file = zglfw.path("glfw3.zig"),
.target = target,
.optimize = optimize,
});
if (builtin.os.tag == .windows) {
module.addLibraryPath(zglfw.path("bin/windows-mingw64/"));
module.linkSystemLibrary("Gdi32");
}
module.linkSystemLibrary("glfw3");
``` | [
"https://github.com/Aryvyo/zigClipboard",
"https://github.com/Avokadoen/zig_vulkan",
"https://github.com/Name-hw/JanRenderer",
"https://github.com/Senryoku/Deecy",
"https://github.com/azillion/gravitas",
"https://github.com/braheezy/zonk",
"https://github.com/cyberegoorg/cetech1",
"https://github.com/... |
https://avatars.githubusercontent.com/u/76602421?v=4 | scoutnet | theodore-brucker/scoutnet | 2025-01-19T15:02:19Z | Distributed Honeynet infrastructure components to build threat intel | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/theodore-brucker/scoutnet/tags | - | [
"azure",
"cloud",
"cybersecurity",
"honeypot",
"threat-intelligence",
"zig"
] | 8 | false | 2025-01-22T21:59:58Z | false | false | unknown | github | [] | Scoutnet Deployment Guide
System Overview
The distributed Honeynet consists of two components:
1. Central C2 Server (c2.zig): Collects and processes intrusion attempt reports
2. Scout Nodes (scout.zig): Lightweight sensors that monitor for connection attempts
Prerequisites
<ul>
<li>Azure Subscription with Contributor access</li>
<li>Azure CLI installed and configured</li>
<li>Zig compiler (version 0.13.0 or later)</li>
<li>Linux build environment</li>
</ul>
C2 Server Deployment
Infrastructure Setup
```bash
Create resource group
az group create --name rg-honeynet-prod --location eastus2
Create dedicated VNET
az network vnet create \
--name vnet-honeynet \
--resource-group rg-honeynet-prod \
--address-prefix 10.0.0.0/16 \
--subnet-name snet-c2 \
--subnet-prefix 10.0.1.0/24
Create NSG for C2 server
az network nsg create \
--name nsg-c2 \
--resource-group rg-honeynet-prod
Allow inbound traffic only from scout subnets
az network nsg rule create \
--name allow-scouts \
--nsg-name nsg-c2 \
--priority 100 \
--resource-group rg-honeynet-prod \
--access Allow \
--destination-port-ranges 8080 \
--direction Inbound \
--protocol Tcp
```
C2 Server VM Deployment
```bash
Create C2 server VM
az vm create \
--resource-group rg-honeynet-prod \
--name vm-c2-prod \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--vnet-name vnet-honeynet \
--subnet snet-c2 \
--nsg nsg-c2
Configure VM
az vm run-command invoke \
--resource-group rg-honeynet-prod \
--name vm-c2-prod \
--command-id RunShellScript \
--scripts "apt-get update && apt-get install -y build-essential"
```
Application Deployment
```bash
Install Zig 0.13.0
sudo apt update && \
sudo apt install -y curl xz-utils build-essential && \
curl -O https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz && \
tar xf zig-linux-x86_64-0.13.0.tar.xz && \
sudo mv zig-linux-x86_64-0.13.0 /usr/local/zig && \
sudo ln -s /usr/local/zig/zig /usr/local/bin/zig && \
zig version
Compile C2 server
zig build-exe c2.zig -O ReleaseSafe
Create systemd service
sudo vi /etc/systemd/system/c2-server.service
```
Paste this into the service file
```
[Unit]
Description=C2 Server Service
After=network.target
[Service]
Type=simple
User=azureuser
ExecStart=/home/azureuser/c2
WorkingDirectory=/home/azureuser
Restart=always
RestartSec=5
StandardOutput=append:/var/log/c2-server.log
StandardError=append:/var/log/c2-server.log
[Install]
WantedBy=multi-user.target
<code></code>
Create log file with proper permissions
sudo touch /var/log/c2-server.log
sudo chown azureuser:azureuser /var/log/c2-server.log
Start service
systemctl daemon-reload
systemctl enable c2-server.service
systemctl start c2-server.service
```
Scout Node Deployment
Infrastructure Setup
```bash
Create scout subnet
az network vnet subnet create \
--name snet-scouts \
--resource-group rg-honeynet-prod \
--vnet-name vnet-honeynet \
--address-prefix 10.0.2.0/24
Create NSG for scouts
az network nsg create \
--name nsg-scouts \
--resource-group rg-honeynet-prod
Allow monitored ports
az network nsg rule create \
--name allow-honeypot-ports \
--nsg-name nsg-scouts \
--priority 100 \
--resource-group rg-honeynet-prod \
--access Allow \
--destination-port-ranges 22 23 3389 \
--direction Inbound \
--protocol Tcp
```
Scout VM Deployment
```bash
Create scout VM (repeat for each scout)
az vm create \
--resource-group rg-honeynet-prod \
--name vm-scout-001 \
--image Ubuntu2204 \
--size Standard_B1s \
--admin-username azureuser \
--generate-ssh-keys \
--vnet-name vnet-honeynet \
--subnet snet-scouts \
--nsg nsg-scouts
```
Application Deployment
```bash
Install Zig 0.13.0
sudo apt update && \
sudo apt install -y curl xz-utils build-essential && \
curl -O https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz && \
tar xf zig-linux-x86_64-0.13.0.tar.xz && \
sudo mv zig-linux-x86_64-0.13.0 /usr/local/zig && \
sudo ln -s /usr/local/zig/zig /usr/local/bin/zig && \
zig version
Compile scout
zig build-exe scout.zig -O ReleaseSafe
Create systemd service
sudo vi /etc/systemd/system/scout.service
<code>Paste this into the service file</code>
[Unit]
Description=Scout Service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/home/azureuser/scout
WorkingDirectory=/home/azureuser
Restart=always
RestartSec=5
StandardOutput=append:/var/log/scout.log
StandardError=append:/var/log/scout.log
[Install]
WantedBy=multi-user.target
<code></code>
Create log file with proper permissions
sudo touch /var/log/scout.log
sudo chown root:root /var/log/scout.log
Start service
systemctl daemon-reload
systemctl enable honeynet-scout
systemctl start honeynet-scout
```
Monitor
```
Monitor C2 server reports
tail -f /home/azureuser/c2_reports.log
Monitor scout reports
tail -f /home/azureuser/scout_reports.log
```
Maintenance
<ul>
<li>Regularly update Ubuntu packages</li>
<li>Monitor VM metrics and logs</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/76602421?v=4 | zig-azure-keyvault-client | theodore-brucker/zig-azure-keyvault-client | 2025-01-14T04:18:16Z | Azure KeyVault client written in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/theodore-brucker/zig-azure-keyvault-client/tags | MIT | [
"azure",
"microsoft",
"o365",
"security",
"security-tools",
"system-programming",
"zig"
] | 37,298 | false | 2025-01-18T05:53:24Z | true | true | unknown | github | [] | Zig Azure KeyVault Client
A lightweight, secure Azure Key Vault client written in Zig. This project provides a simple interface for interacting with Azure Key Vault, implementing secure token handling and key vault operations. The demo here uses an empty sandbox Azure tenant spun up for the testing of this tool.
Features
<ul>
<li>Secure OAuth2 token handling with memory safety</li>
<li>Key Vault operations:</li>
<li>List all secrets</li>
<li>Get specific secret values</li>
<li>Set secret values</li>
<li>Memory-safe implementation with proper cleanup</li>
<li>Optional React-based UI demo included</li>
</ul>
Prerequisites
<ul>
<li>Zig 0.13.0</li>
<li>Azure subscription</li>
<li>Azure Key Vault instance</li>
<li>Application registered in Azure Active Directory with the following:</li>
<li>Client ID</li>
<li>Client Secret</li>
<li>Tenant ID</li>
<li>Key Vault access permissions</li>
</ul>
Installation
<ol>
<li>
Clone the repository:
<code>bash
git clone https://github.com/yourusername/zig-azure-keyvault.git
cd zig-azure-keyvault</code>
</li>
<li>
Build the project:
<code>bash
zig build</code>
</li>
</ol>
Configuration
Create a configuration with your Azure credentials:
<code>zig
const client_id = "your-client-id";
const client_secret = "your-client-secret";
const tenant_id = "your-tenant-id";
const vault_name = "your-vault-name";
const api_version = "7.3";</code>
Usage
Basic Example
```zig
const std = @import("std");
const azure_auth = @import("azure_auth.zig");
const keyvault = @import("azure_keyvault.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit() == .ok);
const allocator = gpa.allocator();
<code>// Get OAuth token
var token = try azure_auth.getOAuthToken(allocator, client_id, client_secret, tenant_id);
defer token.deinit();
// List secrets
const secret_list = try keyvault.list_secrets(allocator, token.secure_token, vault_name, api_version);
defer secret_list.deinit(allocator);
// Get a specific secret
const secret = try keyvault.get_secret(allocator, token.secure_token, vault_name, "my-secret", api_version);
defer secret.deinit(allocator);
</code>
}
```
API Reference
<code>azure_auth.getOAuthToken</code>
Securely obtains an OAuth token from Azure Active Directory.
<code>keyvault.list_secrets</code>
Lists all secrets in the specified vault.
<code>keyvault.get_secret</code>
Retrieves a specific secret by name.
<code>keyvault.set_secret</code>
Sets a secret value in the vault.
Error Handling
The library uses Zig's error union type system to handle various error conditions:
<code>zig
pub const KeyVaultError = error{
RequestFailed,
InvalidResponse,
SecretNotFound,
AuthenticationFailed,
InvalidRequest,
};</code>
Error handling example:
<code>zig
const secret = keyvault.get_secret(allocator, token.secure_token, vault_name, "missing-secret", api_version) catch |err| {
switch (err) {
KeyVaultError.SecretNotFound => {
// Handle missing secret
},
KeyVaultError.AuthenticationFailed => {
// Handle authentication failure
},
else => {
// Handle other errors
},
}
};</code>
Security Considerations
<ol>
<li><strong>Token Security</strong></li>
<li>Tokens are stored in secure memory buffers</li>
<li>Memory is zeroed before deallocation</li>
<li>
Timing-safe comparisons are used for token verification
</li>
<li>
<strong>Memory Safety</strong>
</li>
<li>All allocations are tracked and properly freed</li>
<li>Sensitive data is explicitly cleared from memory</li>
<li>
No global state or static buffers are used
</li>
<li>
<strong>Best Practices</strong>
</li>
<li>Use environment variables or secure configuration management for credentials</li>
<li>Implement proper error handling for all operations</li>
<li>Regularly rotate client secrets</li>
<li>
Use the principle of least privilege when assigning Key Vault access permissions
</li>
<li>
<strong>Known Limitations</strong>
</li>
<li>Buffer sizes are fixed for HTTP responses (8192 bytes)</li>
<li>No automatic token refresh implementation</li>
<li>Single-threaded operation only</li>
</ol>
Demo UI
A React-based demo UI is included in the <code>ui</code> directory. This is for demonstration purposes only and should not be used in production without proper security review and implementation.
License
MIT License - See LICENSE file for details.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Disclaimer
This is a proof of concept implementation. While care has been taken to implement security best practices, it has not undergone a security audit and should be reviewed thoroughly before use in production environments. | [] |
https://avatars.githubusercontent.com/u/5161200?v=4 | rayman | viddrobnic/rayman | 2024-12-21T18:42:01Z | Rogue like web game with custom raycasting engine. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/viddrobnic/rayman/tags | MIT | [
"wasm",
"zig"
] | 227 | false | 2025-02-25T13:27:10Z | true | true | unknown | github | [] | RayMan
Simple rogue-like web game using a custom raycasting engine.
Building and Running
<ol>
<li>Build the <code>wasm</code> and move it to correct place:
<code>sh
zig build
cp zig-out/bin/rayman.wasm dist/</code></li>
<li>Run a local server with:
<code>sh
cd dist
python3 -m http.server</code></li>
<li>Open the game at <code>localhost:8000</code></li>
</ol>
License
The project is licensed under the <a>MIT License</a>. | [] |
https://avatars.githubusercontent.com/u/735975?v=4 | zig-linux-cookbook | godsarmy/zig-linux-cookbook | 2025-01-19T19:11:08Z | Cookbook examples for zig to call linux system call | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/godsarmy/zig-linux-cookbook/tags | MIT | [
"cookbook",
"linux",
"zig"
] | 67 | false | 2025-04-02T05:09:21Z | true | true | 0.14.0 | github | [] | Zig Linux System Programming Cookbook
Overview
This repository is a collection of practical examples and recipes of
<a>std.os.linux</a> for
developing applications and system tools using the <a>Zig</a>
programming language on Linux.
It's designed to be a helpful resource for Zig developers of all levels who
want to learn by example and quickly find solutions to port code of C system
calls into <a>Zig</a>.
Examples
| File | Related Call |
| ------------------------------------------ | ------------ |
| <a>capget.zig</a> | <a>capget</a> |
| <a>clock_gettime.zig</a> | <a>clock_gettime</a> |
| <a>clone_thread.zig</a> | <a>clone</a> <a>gettid</a> |
| <a>dup2.zig</a> | <a>dup2</a> |
| <a>execve.zig</a> | <a>execve</a> |
| <a>fork_waitpid.zig</a> | <a>fork</a> <a>waitpid</a> |
| <a>getcwd.zig</a> | <a>getcwd</a> <a>chdir</a> |
| <a>getdents64</a> | <a>getdents64</a> |
| <a>getgroups.zig</a> | <a>getgroups</a> |
| <a>getrandom.zig</a> | <a>getrandom</a> |
| <a>ioctl.zig</a> | <a>ioctl</a> |
| <a>kill.zig</a> | <a>kill</a> |
| <a>lstat.zig</a> | <a>lstat</a> |
| <a>mmap.zig</a> | <a>mmap</a> <a>munmap</a> |
| <a>open_errno.zig</a> | <a>open</a> |
| <a>pipe.zig</a> | <a>pipe</a> <a>read</a> <a>write</a> |
| <a>ptrace.zig</a> | <a>ptrace</a> |
| <a>symlink.zig</a> | <a>symlink</a> <a>readlink</a> |
| <a>unshare.zig</a> | <a>getuid</a> <a>unshare</a> |
| <a>uname.zig</a> | <a>uname</a> |
Usage
<ul>
<li>
Install <a>zig >= 0.14</a>
</li>
<li>
Build Only.
<code>sh
zig build</code>
You will have binaries in <code>zig-out/bin</code>.
</li>
<li>
Build & Run all
<code>sh
zig build run-all</code>
</li>
</ul>
Other awesome zig learning materials
<ul>
<li><a>zig-cookbook</a></li>
<li><a>awesome-zig</a></li>
<li><a>zig-learning</a></li>
<li><a>zig-book</a></li>
<li><a>zig-guide</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/147350704?v=4 | zig-examples | baranasoftware/zig-examples | 2024-09-28T23:51:53Z | A collection of Zig examples. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/baranasoftware/zig-examples/tags | - | [
"zig",
"ziglang"
] | 40 | false | 2025-02-16T22:32:52Z | false | false | unknown | github | [] | A collections of Zig examples
<ul>
<li><a>Unicode Support</a></li>
<li><a>Random Numbers</a></li>
<li><a>Using Pacakges</a></li>
<li><a>Basic Types</a></li>
<li><a>For, While Loops</a></li>
<li><a>Strings, Vector, Struct, Unions, Arrays, Slices</a></li>
<li><a>Command line arguments</a></li>
<li><a>CPU endian</a></li>
<li><a>Thread example</a></li>
<li><a>Single thread TCP server</a></li>
<li><a>Using single copy TCP server</a></li>
<li><a>Improved single threaded TCP server</a></li>
<li><a>Single thread TCP server(Vectored I/O)</a></li>
<li><a>Multi-threaded server</a></li>
<li><a>Multi-threaded - thread pool</a></li>
<li><a>Non-Blocking I/O</a></li>
<li><a>Non-Blocking I/O - Poll</a></li>
<li><a>Non-Blocking I/O - Pollv2</a></li>
<li><a>Non-Blocking I/O - Pollv3</a></li>
<li><a>Non-Blocking I/O - epoll</a></li>
<li><a>Non-blocking I/O - kqueue</a></li>
<li><a>Task scheduler</a></li>
<li><a>Task scheduler - with a priority queue</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/96076981?v=4 | ZigBlobs | JohanRimez/ZigBlobs | 2024-08-21T10:38:49Z | Graphic demonstration featuring ZIG & SDL2 | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/JohanRimez/ZigBlobs/tags | MIT | [
"sdl2",
"zig"
] | 12 | false | 2024-09-18T11:33:13Z | true | true | 0.13.0 | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/73901165?v=4 | docker-tags-zig | kawana77b/docker-tags-zig | 2025-01-20T21:48:42Z | CLI tool to search Docker Hub image tags by zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/kawana77b/docker-tags-zig/tags | MIT | [
"docker",
"zig"
] | 107 | false | 2025-02-08T18:44:28Z | true | true | unknown | github | [
{
"commit": "c8cd1144aa800f87db3c4bee3d1f0fa0e8c96feb.zip",
"name": "chroma",
"tar_url": "https://github.com/adia-dev/chroma-zig/archive/c8cd1144aa800f87db3c4bee3d1f0fa0e8c96feb.zip.tar.gz",
"type": "remote",
"url": "https://github.com/adia-dev/chroma-zig"
},
{
"commit": "refs",
"nam... | docker-tags-zig
Search <a>dockerhub</a> tags. I made it using Zig.
```
Usage: docker-tags [options] ...
Description: Search for image tags from DockerHub
<code>-h, --help
Display this help and exit.
-v, --version
Output version information and exit.
-i, --with-image
Connect and display image names and tags.
-b, --browse
Open the URL in the browser.
-l, --limit <count>
Limit the number of tags to display. (default: 30)
-d, --detail
Displays detailed information in table.
<IMAGE>...
</code>
```
usage
<code>bash
docker-tags node
docker-tags tensorflow/tensorflow -i # Image name and tag in combination, such as python:latest
docker-tags python -l 100 # Set the number of searches. default 30.
docker-tags python -b # Display the DockerHub page in your browser (Linux must be able to use xdg-open)</code>
Basically, it appears as follows:
<code>$ docker-tags node
lts-jod
lts-bullseye
lts-bookworm
lts
latest
...</code>
detail view
Use the <code>-d</code> option to display the table and see more detailed information.
<code>$ docker-tags node -d
image tag architectures full_size last_pushed image_tag
node lts-jod amd64 / arm / arm64 / ppc64le / s390x 386.46 MB 2025-01-14 16:39:46 node:lts-jod
node lts-bullseye amd64 / arm / arm64 360.58 MB 2025-01-15 01:40:30 node:lts-bullseye
node lts-bookworm amd64 / arm / arm64 / ppc64le / s390x 386.46 MB 2025-01-14 16:39:46 node:lts-bookworm
node lts amd64 / arm / arm64 / ppc64le / s390x 386.46 MB 2025-01-15 01:40:16 node:lts
node latest amd64 / arm / arm64 / ppc64le / s390x 387.87 MB 2025-01-14 16:40:32 node:latest
node jod-bullseye amd64 / arm / arm64 360.58 MB 2025-01-15 01:40:30 node:jod-bullseye
node jod-bookworm amd64 / arm / arm64 / ppc64le / s390x 386.46 MB 2025-01-14 19:40:16 node:jod-bookworm
node jod amd64 / arm / arm64 / ppc64le / s390x 386.46 MB 2025-01-14 16:39:46 node:jod
node iron-bullseye amd64 / arm / arm64 353.44 MB 2025-01-15 01:39:41 node:iron-bullseye
node iron-bookworm amd64 / arm / arm64 / ppc64le / s390x 379.32 MB 2025-01-14 19:39:22 node:iron-bookworm
node iron amd64 / arm / arm64 / ppc64le / s390x 379.32 MB 2025-01-14 19:39:22 node:iron
node hydrogen-bullseye amd64 / arm / arm64 351.03 MB 2025-01-15 01:38:49 node:hydrogen-bullseye
...</code>
with Docker CLI
It can be used as a docker cli plugin (v0.1.2~). That is, this tool can also be used as a subcommand of <code>docker</code>.
For example:
<code>bash
docker tags ubuntu -d</code>
To use it as a plugin, place the <code>docker-tags</code> binary in the following location:
<ul>
<li><code>~/.docker/cli-plugins</code></li>
</ul>
env
<ul>
<li>It is built for Windows, Linux x86_64, and MacOS aarch64.</li>
<li>The author has only tested Windows and Linux builds.</li>
<li>I have not done any code signing or anything else to the tool. Note that files in the release may be detected by virus scanning. I assume no liability whatsoever for the release files.</li>
<li>Only publicly API accessible images are supported</li>
<li>API endpoints use v2</li>
<li>zig 0.13.0</li>
</ul>
why did you create this?
With Zig, this is due to the motivation to make it cross-platform and small binary.
I created it by hand and am satisfied with its size of approximately 1000 KB, which is much smaller for my personal tool.
There are <a>several better similar tools</a>.
credits
The following third-party libraries are used:
<ul>
<li><a>zig-clap</a> by Hejsil (MIT)</li>
<li><a>zul</a> by karlseguin (MIT)</li>
<li><a>chroma-zig</a> by adia-dev (MIT)</li>
<li><a>prettytable-zig</a> by dying-will-bullet (MIT)</li>
</ul>
NOTE
I hope that by making it open source, it will be useful to someone for something!
Zig is difficult for me as a beginner, but fun! 👍 | [] |
https://avatars.githubusercontent.com/u/46865726?v=4 | zigbeam | Gandalf-Le-Dev/zigbeam | 2024-09-12T14:14:01Z | A std.log compliant colored logging library for Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Gandalf-Le-Dev/zigbeam/tags | MIT | [
"colored-logging",
"log",
"logging",
"structured-logging",
"zig"
] | 48 | false | 2024-10-31T14:43:43Z | true | true | unknown | github | [] | Zigbeam
Structured Logging library for the Zig language
How to use
<ol>
<li>You can fetch Zigbeam with this command</li>
</ol>
<code>cmd
zig fetch --save=zigbeam git+https://github.com/Gandalf-Le-Dev/zigbeam/#HEAD</code>
It will fetch the master version. If you wish to fetch a specific version, replace <code>#HEAD</code> with the commit hash.
<ol>
<li>Then in your build.zig you must add:</li>
</ol>
<code>zig
const zigbeam_dep = b.dependency("zigbeam", .{});
const zigbeam_mod = zigbeam_dep.module("zigbeam");
exe.root_module.addImport("zigbeam", zigbeam_mod);</code>
<ol>
<li>You can now use Zigbeam in your project. Here is an example:</li>
</ol>
```zig
const std = @import("std");
const zigbeam = @import("zigbeam");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
<code>var log = try zigbeam.Logger.init(allocator);
defer log.deinit();
try log.info("Zigbeam is working!");
</code>
}
``` | [] |
https://avatars.githubusercontent.com/u/161890530?v=4 | bittorrent-client | soheil-01/bittorrent-client | 2024-09-16T10:43:27Z | Simple BitTorrent Client | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/soheil-01/bittorrent-client/tags | - | [
"bittorrent",
"bittorrent-client",
"zig"
] | 16 | false | 2024-11-13T11:57:26Z | true | true | unknown | github | [
{
"commit": "9a94c4803a52e54c26b198096d63fb5bde752da2",
"name": "zig-cli",
"tar_url": "https://github.com/sam701/zig-cli/archive/9a94c4803a52e54c26b198096d63fb5bde752da2.tar.gz",
"type": "remote",
"url": "https://github.com/sam701/zig-cli"
}
] | 404 | [] |
https://avatars.githubusercontent.com/u/16033061?v=4 | advent-of-code-2024 | Flygrounder/advent-of-code-2024 | 2024-12-01T14:23:25Z | My Advent of Code 2024 solutions using Zig programming language | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Flygrounder/advent-of-code-2024/tags | MIT | [
"advent-of-code",
"advent-of-code-2024",
"advent-of-code-2024-zig",
"problem-solving",
"zig"
] | 62 | false | 2024-12-26T07:45:41Z | true | true | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/1569633?v=4 | riscv-zigos | jimnicholls/riscv-zigos | 2025-01-06T09:48:50Z | RISC-V ZigOS is intended to be a toy operating system written in Zig targeting the RISC-V architecture. The operating system is inspired by the classic Amiga OS, although there will be no attempt to be in any way compatible with Amiga OS. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/jimnicholls/riscv-zigos/tags | MIT | [
"operating-system",
"os",
"risc-v",
"riscv",
"zig",
"ziglang"
] | 4 | false | 2025-01-06T10:41:54Z | false | false | unknown | github | [] | RISC-V ZigOS
RISC-V ZigOS is intended to be a toy operating system written in Zig targeting the RISC-V architecture.
The operating system is inspired by the classic Amiga OS, although there will be no attempt to be in any way compatible with Amiga OS.
Affiliation, or lack thereof
This project is in no way affiliated with <a>RISC-V International</a> or <a>Zig</a>.
Copyright and license
Copyright (c) 2025 Jim Nicholls
The source code, released binaries, and other artefacts of this project are distributed under the terms of <a>the MIT license</a>.
Your use of this software is entirely at your own risk.
<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>
There is a significant possibility of irreparable loss.
</blockquote> | [] |
https://avatars.githubusercontent.com/u/61843100?v=4 | DSA | WestDragonIroh/DSA | 2024-11-30T16:50:56Z | Data Structure and algorithms in different languages | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/WestDragonIroh/DSA/tags | - | [
"c",
"dsa",
"zig"
] | 48 | false | 2025-05-03T15:35:58Z | false | false | unknown | github | [] | Data Structures And Algorithms
Following concepts are covered in this repo.
Problem statments and solutions are from <a>Strivers A2Z DSA Course/Sheet</a> and <a>Jenny's DSA Series</a> | [] |
https://avatars.githubusercontent.com/u/137279923?v=4 | atak | ken-morel/atak | 2024-12-25T09:59:35Z | Atak zig toolkit | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/ken-morel/atak/tags | GPL-3.0 | [
"atak",
"components",
"efus",
"language",
"toolkit",
"zig"
] | 31,683 | false | 2025-05-13T09:40:22Z | false | false | unknown | github | [] | Nothing here sorry. | [] |
https://avatars.githubusercontent.com/u/32078353?v=4 | ytplayer | xyaman/ytplayer | 2024-12-12T07:28:00Z | Simple cli music player that fetches from youtube using yt-dlp. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/xyaman/ytplayer/tags | MIT | [
"tui",
"youtube",
"zig"
] | 16 | false | 2024-12-16T10:46:27Z | true | true | unknown | github | [
{
"commit": "5beb53da11a9fcd01cb5f30f0375c845f0acc4be",
"name": "portaudio",
"tar_url": "https://github.com/allyourcodebase/portaudio/archive/5beb53da11a9fcd01cb5f30f0375c845f0acc4be.tar.gz",
"type": "remote",
"url": "https://github.com/allyourcodebase/portaudio"
},
{
"commit": "560c8dd7... | ytplayer
Youtube audio player TUI.
Features
<ul>
<li>Search</li>
<li>Play/Pause</li>
</ul>
Usage/Build
```bash
build
zig build --release=safe
run
zig-out/bin/ytplayer
```
Dependencies
<ul>
<li><a>yt-dlp</a> (runtime)</li>
<li><a>ffmpeg</a> (runtime)</li>
<li><a>portaudio</a>(build, handled by zig)</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/15135669?v=4 | lkml-parser | alhankeser/lkml-parser | 2024-08-09T06:00:18Z | A faster LookML parser | main | 1 | 0 | 0 | 0 | https://api.github.com/repos/alhankeser/lkml-parser/tags | MIT | [
"looker",
"lookml",
"zig",
"ziglang"
] | 69 | false | 2024-09-14T07:34:23Z | false | false | unknown | github | [] | An adequately-built, fast LookML parser
Created without knowledge of parsers or the language its written in, this parser has only one goal: be faster than lkml.
<a>Read More</a>
Usage
Assuming you have Zig installed, build the zig executable:
<code>bash
zig build-exe main.zig -O ReleaseFast</code>
Use it inside of Python:
```python
import json
import subprocess
view_as_json = subprocess.check_output(["./main", "customer.view.lkml"]).decode('utf-8')
view_as_dict = json.loads(view_as_json)
```
What's missing today
<ul>
<li>Testing</li>
<li>Edge case handling</li>
<li>Parametrization</li>
<li>Advanced features</li>
<li>Ability to handle files other than view files</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/5805468?v=4 | s2s | Madeorsk/s2s | 2024-12-30T22:51:35Z | A zig binary serialization format. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Madeorsk/s2s/tags | MIT | [
"binary-data",
"serialization",
"serialization-library",
"zig",
"zig-package"
] | 3,808 | true | 2024-12-31T16:58:52Z | true | true | unknown | github | [] | struct to stream | stream to struct
A Zig binary serialization format and library.
Features
<ul>
<li>Convert (nearly) any Zig runtime datatype to binary data and back.</li>
<li>Computes a stream signature that prevents deserialization of invalid data.</li>
<li>No support for graph like structures. Everything is considered to be tree data.</li>
</ul>
<strong>Unsupported types</strong>:
<ul>
<li>All <code>comptime</code> only types</li>
<li>Unbound pointers (c pointers, pointer to many)</li>
<li><code>volatile</code> pointers</li>
<li>Untagged or <code>external</code> unions</li>
<li>Opaque types</li>
<li>Function pointers</li>
<li>Frames</li>
</ul>
Madeorsk's fork
This is a fork from <a><code>ziglibs/s2s</code></a> which provides more features for real-world usage.
<ul>
<li>Usable with zig's dependency manager.</li>
<li>Support <code>[]u8</code> with sentinels.</li>
<li>Support hash maps.</li>
</ul>
API
The library itself provides only some APIs, as most of the serialization process is not configurable.
<code>``zig
/// Serializes the given</code>value: T<code>into the</code>stream<code>.
/// -</code>stream<code>is a instance of</code>std.io.Writer<code>/// -</code>T<code>is the type to serialize
/// -</code>value` is the instance to serialize.
fn serialize(stream: anytype, comptime T: type, value: T) StreamError!void;
/// Deserializes a value of type <code>T</code> from the <code>stream</code>.
/// - <code>stream</code> is a instance of <code>std.io.Reader</code>
/// - <code>T</code> is the type to deserialize
fn deserialize(stream: anytype, comptime T: type) (StreamError || error{UnexpectedData,EndOfStream})!T;
/// Deserializes a value of type <code>T</code> from the <code>stream</code>.
/// - <code>stream</code> is a instance of <code>std.io.Reader</code>
/// - <code>T</code> is the type to deserialize
/// - <code>allocator</code> is an allocator require to allocate slices and pointers.
/// Result must be freed by using <code>free()</code>.
fn deserializeAlloc(stream: anytype, comptime T: type, allocator: std.mem.Allocator) (StreamError || error{ UnexpectedData, OutOfMemory,EndOfStream })!T;
/// Releases all memory allocated by <code>deserializeAlloc</code>.
/// - <code>allocator</code> is the allocator passed to <code>deserializeAlloc</code>.
/// - <code>T</code> is the type that was passed to <code>deserializeAlloc</code>.
/// - <code>value</code> is the value that was returned by <code>deserializeAlloc</code>.
fn free(allocator: std.mem.Allocator, comptime T: type, value: T) void;
```
Usage and Development
Adding the library
The current latest version is 0.3.0 for zig 0.13.0.
<code>sh-session
[user@host s2s]$ zig fetch --save git+https://github.com/madeorsk/s2s#v0.3.0</code>
In <code>build.zig</code>.
<code>zig
// Add s2s dependency.
const s2s = b.dependency("s2s", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("s2s", s2s.module("s2s"));</code>
Project Status
Most of the serialization/deserialization is implemented for the <em>trivial</em> case.
Pointers/slices with non-standard alignment aren't properly supported yet. | [
"https://github.com/bernardassan/recblock",
"https://github.com/ziglibs/antiphony"
] |
https://avatars.githubusercontent.com/u/15092561?v=4 | tetris-zig | kurapov-peter/tetris-zig | 2025-02-01T16:46:51Z | Tetris in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/kurapov-peter/tetris-zig/tags | MIT | [
"tetris",
"zig"
] | 365 | false | 2025-02-18T17:31:36Z | true | true | unknown | github | [] | tetris-zig
A tetris in ziglang co-authored with copilot :smirk:.
This should work on any platform. Building requires (e.g., linux):
<code>bash
sudo apt-get install libsdl2-dev libsdl2-ttf-dev</code>
then your regular
<code>bash
zig bulid</code> | [] |
https://avatars.githubusercontent.com/u/60233333?v=4 | zig_api | rajrupdasofficial/zig_api | 2024-12-20T00:08:27Z | zig based rest api and websocket logics and programming | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/rajrupdasofficial/zig_api/tags | BSD-3-Clause | [
"zig",
"ziglang"
] | 8 | false | 2025-04-11T16:42:49Z | true | true | unknown | github | [
{
"commit": "master",
"name": "pg",
"tar_url": "https://github.com/karlseguin/pg.zig/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/karlseguin/pg.zig"
}
] | Websocket and REST api using zig
Zig based backend for saving user information and some other complex zig based logics | [] |
https://avatars.githubusercontent.com/u/99418006?v=4 | rover-lang | martazvch/rover-lang | 2024-10-31T17:20:48Z | Simple, feature rich and highly embeddable language | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/martazvch/rover-lang/tags | - | [
"embedded",
"language",
"zig"
] | 1,513 | false | 2025-05-21T20:09:20Z | true | true | 0.14.0 | github | [
{
"commit": "refs",
"name": "clap",
"tar_url": "https://github.com/Hejsil/zig-clap/archive/refs.tar.gz",
"type": "remote",
"url": "https://github.com/Hejsil/zig-clap"
}
] | Rover
Simple and higly embeddable language written in Zig.
| [] |
https://avatars.githubusercontent.com/u/115993332?v=4 | OpenChat | vhyran/OpenChat | 2024-12-10T15:46:04Z | ChatApp is a simple and intuitive chat application that allows users to communicate in real-time. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/vhyran/OpenChat/tags | NOASSERTION | [
"toml",
"websocket",
"zap",
"zig"
] | 192 | false | 2024-12-16T08:00:21Z | false | false | unknown | github | [] | OpenChat
ChatApp is a simple and intuitive chat application that allows users to communicate in real-time.
<blockquote>
<strong>Note:</strong> UI improvements are coming soon.
</blockquote>
Tech Stack
The initial version of OpenChat was built using the following technologies:
<ul>
<li><strong>Python</strong>: For frontend development and real-time communication.</li>
<li><strong>Bun (TypeScript) + Hono</strong>: For backend services and logic.</li>
</ul>
The new version of OpenChat has been upgraded with the following technologies:
<ul>
<li><strong>Zig</strong>: For improved performance and system-level programming.</li>
</ul>
Old Code Base
The old code base can be found in the <code>log</code> folder for reference and historical purposes.
Check Log and Implementation of Zig
For detailed information on the log and the implementation of Zig in the new version of OpenChat, please refer to the <code>TODO.md</code> file located in the root directory of the project. | [] |
https://avatars.githubusercontent.com/u/43007994?v=4 | zr | yusa-imit/zr | 2024-10-26T16:08:15Z | Multi (Mono)repo Task Running Solution written in Zig | main | 4 | 0 | 0 | 0 | https://api.github.com/repos/yusa-imit/zr/tags | - | [
"zig"
] | 352 | false | 2024-10-27T05:24:01Z | true | true | unknown | github | [] | powershell
<code>Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/yusa-imit/zr/main/install.ps1'))</code>
bash curl/wget
<code>curl -fsSL https://raw.githubusercontent.com/yusa-imit/zr/main/install.sh | sudo bash
wget -qO- https://raw.githubusercontent.com/yusa-imit/zr/main/install.sh | sudo bash</code> | [] |
https://avatars.githubusercontent.com/u/11700503?v=4 | zig-lox | braheezy/zig-lox | 2024-10-21T04:52:36Z | Bytecode VM for Lox | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/braheezy/zig-lox/tags | - | [
"lox",
"zig"
] | 104 | false | 2024-11-18T02:43:14Z | true | false | unknown | github | [] | zig-lox
A Zig implementation of a bytecode VM for the educational Lox programming language as taught in the book <a>Crafting Interpreters</a>.
The first half of the book covers a purely interpreted approach to implementing Lox. I did that in Go <a>here</a>.
```console
<blockquote>
echo 'print 1 + 1;' | zig-lox --eval
2
```
</blockquote>
Usage
You need Zig. The <code>.devcontainer</code> can be used to easily provide that.
Helpful commands:
```bash
Build an executable: zig-out/bin/zig-lox
zig build --summary all
Run all tests
zig build test --summary all
Run a file
zig-out/bin/zig-lox test.lox
Or run the repl
zig-out/bin/zig-lox
Or eval an expression over stdin
echo '1 + 1' | zig-out/bin/zig-lox --eval
``` | [] |
https://avatars.githubusercontent.com/u/21205469?v=4 | zapdos | stringflow/zapdos | 2024-09-11T21:29:23Z | null | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/stringflow/zapdos/tags | - | [
"zig"
] | 4 | false | 2024-09-11T21:30:10Z | true | true | unknown | github | [] | zapdos
A minimal screenshot utility for X11. zapdos was written to replace <a>maim</a> in my workflow.
Features:
- Exports PNG screenshots to stdout to then be piped elsewhere (file or clipboard)
- Supports multiple kinds of selections: active window, custom region
Dependencies
Compile-time:
- zig v0.13.0
- libc
- xorg
Runtime:
- ffmpeg
Cloning and Compiling
Clone the repository
<code>$ git clone https://github.com/stringflow/zapdos</code>
Change the directory to zapdos
<code>$ cd zapdos</code>
Compile
<code>$ zig build</code>
Install the binary to PATH
<code>$ cp zig-out/bin/zapdos ~/bin</code> | [] |
https://avatars.githubusercontent.com/u/11492844?v=4 | zorro | fjebaker/zorro | 2024-09-22T15:10:36Z | A CLI for interacting with Zotero. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/fjebaker/zorro/tags | GPL-3.0 | [
"cli",
"search",
"zig",
"zotero"
] | 873 | false | 2024-09-24T23:28:00Z | true | true | unknown | github | [
{
"commit": "master.tar.gz",
"name": "sqlite",
"tar_url": "https://github.com/vrischmann/zig-sqlite/archive/master.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/vrischmann/zig-sqlite"
},
{
"commit": "main.tar.gz",
"name": "fuzzig",
"tar_url": "https://github.com/fj... | zorro
<i>Your clunky CLI for zeroing in on search results in Zotero</i>
Zorro is a command line tool for more expressively and interactively searching through the Zotero library.
Installation
Grab a binary from the <a>releases</a> for your OS.
Building from source
Using the Zig master version, clone and <code>cd</code> and then:
<code>bash
zig build --release=safe</code>
The binary will then be in <code>./zig-out/bin/zorro</code>.
To build statically (for distribution), specify the target with <code>musl</code> to avoid linking the system LibC:
<code>bash
zig build --release=safe -Dtarget=x86_64-linux-musl</code>
Features and planned features
The order below is arbitary:
<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> A small interactive TUI for selecting and viewing the search results
<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> Search author, scoring the author position (first author scores higher than second, etc.)
<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> Search year including ranges (before, after, inbetween)
<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> Fuzzy searching in titles
<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> Fuzzy searching in abstracts
<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> Zotero interaction: open or select items from the CLI directly in Zotero
<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> Sort based on tags / visualise tags. I use a <code>read</code> and <code>todo</code> tag to track what I've read and what I need to look at, and I want visual feedback for those.
<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> Search in and export highlights and notes.
<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> Open current browser with search engine of choice. My plan here to to take advantage of the search features that e.g. NASA's ADS library have, so that if I don't have something in Zotero, I can easily go find it using the same search query.
Usage
```
$ zorro help
Commands:
find
[-a/--author name] Author (last) name.
[-y/--year YYYY] Publication year. Optionally may use <code>before:YYYY</code>,
<code>after:YYYY</code>, or <code>YYYY-YYYY</code> (range) to filter publication years.
help
``` | [] |
https://avatars.githubusercontent.com/u/808099?v=4 | AoC2024 | Maverik/AoC2024 | 2024-12-07T07:00:46Z | Advent of Code 2024 Solutions | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Maverik/AoC2024/tags | NOASSERTION | [
"aoc-2024",
"aoc-2024-in-csharp",
"aoc-2024-in-zig",
"csharp",
"dotnet",
"linqpad",
"zig"
] | 73 | false | 2024-12-24T02:59:14Z | false | false | unknown | github | [] |
<a></a>
🚀 Advent of Code 2024 Solutions by Maverik
This repo contains my take on solutions for <a>Advent of Code - 2024</a> solutions in C# using <a>LINQPad 8</a> and <a>Zig</a>.
💡 Good to know
Given the different natures of Zig and C#, the solutions take different approaches to solution that is closer to the intended language design.
<a>C# solutions</a> are generally more geared towards LINQ based pipelines where applicable while <a>Zig solutions</a> are more performance oriented offering compiler the chance to vectorize more readily with few abstractions getting in the way.
This is my first time writing Zig so the code is a learning journey (and a very pleasant one at that!). 😊
🎈 Fun while solving challenges
https://github.com/user-attachments/assets/d764a7c0-f59a-4f60-a860-883d80a58e29
⚖️ License & Attribution
<a>This work</a> by <a>Maverik</a> is licensed under <a target="_blank">CC BY-NC-SA 4.0 </a>
Please familiarize yourself with your <strong>rights</strong> and <strong>obligations</strong> under this license grant by clicking the relevant link above. | [] |
https://avatars.githubusercontent.com/u/26406?v=4 | hello-zig | seletz/hello-zig | 2024-12-23T14:13:46Z | Some experiments in ZIG | develop | 0 | 0 | 0 | 0 | https://api.github.com/repos/seletz/hello-zig/tags | MIT | [
"zig",
"ziglang"
] | 22 | false | 2024-12-23T18:22:52Z | true | true | unknown | github | [
{
"commit": "9d113214f7750f8ab68b465b2605ce308e995fb4",
"name": "sokol",
"tar_url": "https://github.com/floooh/sokol-zig/archive/9d113214f7750f8ab68b465b2605ce308e995fb4.tar.gz",
"type": "remote",
"url": "https://github.com/floooh/sokol-zig"
}
] | hello-zig
<a></a>
Some experiments in <a>zig</a>. The main goal here is to get some graphics going and generally play around a bit.
TODO
<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> Get a <code>hello world</code> going
<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> Get syntax highlighting and debugging to work
<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> Get a basic triangle on the screen
<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> Get a animated triangle mesh going. Wireframes only.
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Build for other systems than macos
<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> Try to get a dynamic library built in zig, and use <code>dlopen()</code> to live-reload functions
Decisions made
<ul>
<li>Zig people seem to use VSCode. Well, ok then.</li>
<li>I tried raylib-zig but could not get it to compile. Switched to <a>sokol</a> and <a>sokol-zig</a> bindings.</li>
</ul>
Dependencies
VSCode
<blockquote>
[!Note]
I use <code>vscodium</code> and I'm a complete NOOB wrt VSCode.
</blockquote>
I use these extensions:
<ul>
<li><a>Zig Language</a>, which installs <code>zig</code> and <code>zls</code> (zig language server)</li>
<li>The debugger task uses <a>CodeLLDB</a></li>
<li><a>Shader language support</a></li>
<li><a>GLSL Lint</a> <em>could not get this running</em></li>
</ul>
sokol
<ul>
<li>put <code>sokol-shdc</code> from <a>sokol-tools</a> somewhere in your path. I used the binaries from <a>sokol-tools-bin</a> and linked it to <code>~/.local/bin</code></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/148186549?v=4 | zig-revolution | KennethChilds/zig-revolution | 2025-02-05T06:07:49Z | Celestial body revolution in Zig using Raylib | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/KennethChilds/zig-revolution/tags | MIT | [
"physics-simulation",
"raylib-zig",
"zig"
] | 106,920 | false | 2025-03-31T20:24:32Z | true | true | 0.14.0 | github | [
{
"commit": "master",
"name": "raylib_zig",
"tar_url": "https://github.com/Not-Nik/raylib-zig/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/Not-Nik/raylib-zig"
}
] | Orbital Revolution Simulation in Zig
Project Summary
This Zig project implements a basic orbital revolution simulation with <a>raylib-zig bindings</a>
Orbital Revolution
The simulation models objects moving in circular orbits, a fundamental concept in celestial mechanics. Key aspects of the implementation include:
Representation
An orbital revolution is represented by:
- Position (x, y coordinates)
- Angular velocity (rate of rotation)
- Radius of orbit
- Current angle
Usage
To run the project, use the following command:
<code>sh
git clone https://github.com/KennethChilds/zig-revolution.git
cd zig-revolution
zig build run</code>
Play around with values and watch what happens! | [] |
https://avatars.githubusercontent.com/u/57362253?v=4 | libjq.zig | tiawl/libjq.zig | 2024-10-21T15:28:48Z | @jqlang C API packaged for @ziglang | trunk | 0 | 0 | 0 | 0 | https://api.github.com/repos/tiawl/libjq.zig/tags | Unlicense | [
"binding",
"jq",
"jqlang",
"zig",
"zig-package",
"ziglang"
] | 547 | false | 2025-05-07T10:20:14Z | true | true | 0.14.0 | github | [
{
"commit": "master",
"name": "toolbox",
"tar_url": "https://github.com/tiawl/toolbox/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/tiawl/toolbox"
},
{
"commit": "master",
"name": "oniguruma_zig",
"tar_url": "https://github.com/tiawl/oniguruma.zig/archive/m... | libjq.zig
This is a fork of <a>jqlang/jq</a> to package the libjq C API for <a>Zig</a>
Why this fork ?
The intention under this fork is to package <a>jqlang/jq</a> for <a>Zig</a>. So:
* Unnecessary files have been deleted,
* The build system has been replaced with <code>build.zig</code>,
* A cron runs every day to check <a>jqlang/jq</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>jqlang/jq</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>jqlang/jq</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>libjq.zig</strong>:
- as raw (see the <a>examples directory</a>),
- as a daily updated interface for your <a>Zig</a> binding of <a>jqlang/jq</a> (an available exemple is coming soon).
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>jqlang/jq</a>
CICD reminder
These repositories are automatically updated when a new release is available:
* (coming soon)
This repository is automatically updated when a new release is available from these repositories:
* <a>jqlang/jq</a>
* <a>tiawl/toolbox</a>
* <a>tiawl/oniguruma.zig</a>
<code>zig build</code> options
These additional options have been implemented for maintainability tasks:
<code>-Dfetch Update .references folder and build.zig.zon then stop execution
-Dupdate Update binding</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/138373494?v=4 | bibleparsing | scripturial/bibleparsing | 2025-01-15T14:23:30Z | Zig library to read Greek parsing codes commonly used in annotated Koine Greek text. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/scripturial/bibleparsing/tags | MIT | [
"biblical-greek",
"scripturial",
"zig",
"zig-package"
] | 51 | false | 2025-02-09T16:11:45Z | true | true | unknown | github | [
{
"commit": "efc0965909af0bafdb0122be3d8a35896b8887c0",
"name": "bibleparsing",
"tar_url": "https://github.com/scripturial/bibleparsing/archive/efc0965909af0bafdb0122be3d8a35896b8887c0.tar.gz",
"type": "remote",
"url": "https://github.com/scripturial/bibleparsing"
}
] | Bible Parsing
This library converts a bible parsing/tagging code into a compressed
u32 value, and allows writing a u32 value back to a string. Tested
using the parsing codes found in the Byzantine Text data files.
```zig
// Convert code 'A-DSN' to u32 value.
const in = try parse("A-DSN");
// Convert u32 value back to code.
var out = std.ArrayList(u8).init(allocator);
try byz.string(in, out);
try std.testing.expectEqualStrings(code, out.items);
// Incomplete or InvalidParsing errors may be returned.
try std.testing.expectEqual(Error.Incomplete, parse(""));
try std.testing.expectEqual(Error.InvalidParsing, parse("Z"));
```
There is no promise this code will work for you. It works for me for
my personal use cases. Feel free to use at your own risk. Released
into the public domain under the MIT license.
Sponsored by <a>Scripturial - Learn Biblical Greek</a> | [
"https://github.com/scripturial/bibleparsing"
] |
https://avatars.githubusercontent.com/u/131526244?v=4 | digit | 7R35C0/digit | 2024-11-18T09:26:32Z | The module contains functions that return the number of digits. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/7R35C0/digit/tags | MIT | [
"digit",
"digit-count",
"digit-number",
"zig",
"ziglang"
] | 24 | false | 2024-11-21T12:24:16Z | true | true | unknown | github | [] |
README
The module contains functions that return the number of digits for a <code>number</code>,
using various algorithms.
The code is based on following sources:
<ul>
<li><a>CodeMaze - What’s the Best Way to Count the Digits in a Number</a></li>
<li><a>GitHub</a></li>
<li><a>Daniel Lemire's blog - Computing the number of digits of an integer even faster</a></li>
<li><a>GitHub</a></li>
</ul>
📌 Implementation
All functions return the number of digits for a supported <code>number</code>,
otherwise <code>null</code>.
Supported <code>number</code> types and ranges:
<ul>
<li>.ComptimeInt, .Int: ∓340282366920938463463374607431768211455</li>
<li>min(i129) = -340282366920938463463374607431768211456 it is
accepted to cover the type</li>
<li>.ComptimeFloat, .Float:</li>
<li>comptime_float: ∓10384593717069655257060992658440193</li>
<li>f16: ∓2049</li>
<li>f32: ∓16777217</li>
<li>f64: ∓9007199254740993</li>
<li>f80: ∓36893488147419103234</li>
<li>f128: ∓10384593717069655257060992658440193</li>
</ul>
Note that for float numbers the type is important, for example:
<ul>
<li>2050 as f16: returns <code>null</code></li>
<li>2050 as f32: returns 4, same as for any type greater than f16</li>
</ul>
Negative numbers are converted to their absolute value.
📌 Final note
More information about digit counting algorithms can be found in the sources, links above. Also, some usage examples are in the <code>demo</code> files. | [] |
https://avatars.githubusercontent.com/u/66430760?v=4 | json-schema-validator | pascalPost/json-schema-validator | 2024-10-04T07:55:48Z | JSON schema validator for Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/pascalPost/json-schema-validator/tags | MIT | [
"json-schema",
"jsonschema",
"validation",
"validator",
"zig",
"ziglang"
] | 71 | false | 2025-01-27T19:30:18Z | true | true | unknown | github | [] | json-schema-validator
A JSON Schema validator implementation written in Zig, following the <a>Two-Argument Validation</a> interface specification.
Overview
This project aims to provide a robust JSON Schema validation solution implemented in Zig for the Zig ecosystem. It currently supports various JSON Schema draft-07 validation features and is actively being developed to support more.
Dependencies
<ul>
<li>Zig compiler</li>
<li>C++ Standard Library (for regex support)</li>
</ul>
Implementation Details
The validator currently uses C++ regex implementation for pattern matching, requiring linkage against the C++ standard library.
Features Implementation Status
<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> draft-07 tests
<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> additionalItems.json
<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> additionalProperties.json
<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> allOf.json
<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> anyOf.json
<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> boolean_schema.json
<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> const.json
<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> contains.json
<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> default.json
<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> definitions.json
<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> dependencies.json
<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> enum.json
<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> exclusiveMaximum.json
<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> exclusiveMinimum.json
<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> format.json
<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> if-then-else.json
<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> infinite-loop-detection.json
<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> items.json
<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> maxItems.json
<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> maxLength.json
<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> maxProperties.json
<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> maximum.json
<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> minItems.json
<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> minLength.json
<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> minProperties.json
<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> minimum.json
<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> multipleOf.json
<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> not.json
<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> oneOf.json
<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> pattern.json
<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> patternProperties.json
<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> properties.json
<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> propertyNames.json
<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> ref.json
<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> refRemote.json
<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> required.json
<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> type.json
<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> uniqueItems.json
Feature ideas
<ul>
<li>add option to set defaults (for a schema validation defaults are just annotations.)</li>
</ul>
Contributing
Contributions are welcome! Feel free to submit pull requests, especially for implementing pending features. | [] |
https://avatars.githubusercontent.com/u/311637?v=4 | aoc-zig | teilin/aoc-zig | 2024-10-01T08:14:48Z | Advent of Code solutions in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/teilin/aoc-zig/tags | - | [
"advent-of-code",
"aoc",
"zig"
] | 200 | false | 2025-01-31T10:59:34Z | true | true | unknown | github | [
{
"commit": "2e58c8e49a0da7075fc66e4ae499b7acc5ea5a3f",
"name": "clap",
"tar_url": "https://github.com/Hejsil/zig-clap/archive/2e58c8e49a0da7075fc66e4ae499b7acc5ea5a3f.tar.gz",
"type": "remote",
"url": "https://github.com/Hejsil/zig-clap"
}
] | AOC-ZIG
Advent of Code (AOC) solutions in Zig programming language.
Solutions
<ul>
<li><a>2023</a></li>
<li><a>2024</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/58425080?v=4 | zeros | okvik/zeros | 2024-09-26T22:29:45Z | Zig ecosystem for ROS 2 (WIP) | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/okvik/zeros/tags | MIT | [
"robotics",
"ros2",
"zig"
] | 43 | false | 2025-01-24T20:56:40Z | true | true | unknown | github | [] | Zeros (WIP)
A very much work in progress of an alternative ecosystem for ROS 2
development including a client library, message generation, package
build support, and so on; for developing simple and efficient robotics
applications while minimizing contact surface with awful languages,
dreadful compile times, (micro) dependency hell, and other common
afflictions.
Client library
A fully-featured (eventually) client library based on <code>rcl</code> and <code>rclc</code>.
TODO
<ul>
<li>Context</li>
<li>QoS</li>
<li>Subscriptions</li>
<li>Publishers</li>
<li>Services</li>
<li>Actions</li>
<li>Parameters</li>
<li>Timers</li>
<li>Executors</li>
<li>RMW specifics</li>
</ul>
Message generation
TODO
<ul>
<li>Decide on external code generator executable vs. comptime.
I'm not sure that fully comptime is even possible, given some
Zig limitations. It would be especially hard or impossible to
provide a nice API for the message types, so codegen is probably
the way to go.</li>
<li>A Zig message generator integrated into the ROS 2 build pipeline is
not something that matches with the goals of this project. As much
as practically possible we'd like to operate independent of the
standard ROS 2 build environment and only interface with its
artifacts as a dumb participant based on system interfaces and
established conventions.</li>
</ul>
Build support
TODO
<ul>
<li>Resource index</li>
<li>Discovering transitive dependencies</li>
</ul>
Other
Longer-term ideas
<ul>
<li>From source build of the entire ROS 2 core using the Zig build
system; for cross-compilation, static linking, better control over
the defaults, etc. (something a la microROS)</li>
<li>A lightweight replacement of the node launch system suitable for
integration with actual service managers. Likely just a set of tools
for building node parameter files out of system configurations.</li>
<li>A new client library built directly against a single chosen
middleware, likely Zenoh. This would mainly be done to remove
the layers of abstraction (complexity) at the lowest level,
while also allowing full use of the capabilities offered by
the middleware itself.</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/39087769?v=4 | zig-commit-emojis | GROOOOAAAARK/zig-commit-emojis | 2024-10-08T20:17:41Z | CLI made with Ziglang ⚡️ to get best suited emoji for git commits (inspired by gitmoji) | trunk | 3 | 0 | 0 | 0 | https://api.github.com/repos/GROOOOAAAARK/zig-commit-emojis/tags | MIT | [
"cli",
"commits",
"devtools",
"zig"
] | 30 | false | 2024-12-15T23:51:11Z | true | true | 0.13.0 | github | [
{
"commit": "9a94c4803a52e54c26b198096d63fb5bde752da2.tar.gz",
"name": "zig-cli",
"tar_url": "https://github.com/sam701/zig-cli/archive/9a94c4803a52e54c26b198096d63fb5bde752da2.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/sam701/zig-cli"
}
] | Zig Commit Emoji
Description
This project is a discovery of Zig through the following usecase: use a service to get a list of emojis usable in commit as well as a search feature to make sure to find the right one in any situation.
Requirements
<ul>
<li>Zig 0.13.0</li>
</ul>
Project
<code>bash
zig build run</code>
<code>bash
./zig-out/bin/zig-commit-emoji --help</code>
Features
List
What does it do ?
Will simply list all emojis available with their description.
How to use ?
<code>bash
./zig-commit-emoji list</code>
Search
What does it do ?
Will look for the keyword typed in all emojis descriptions.
How to use ?
<code>bash
./zig-commit-emoji search -k <keyword></code>
<code>bash
./zig-commit-emoji search -k "feat"</code> | [] |
https://avatars.githubusercontent.com/u/50000796?v=4 | Advent-of-Code-2024 | zachpeterson13/Advent-of-Code-2024 | 2024-12-01T23:02:07Z | Advent of Code 2024 in Ziglang | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/zachpeterson13/Advent-of-Code-2024/tags | - | [
"advent-of-code",
"advent-of-code-2024",
"advent-of-code-2024-zig",
"zig",
"ziglang"
] | 124,812 | false | 2024-12-06T20:48:42Z | false | false | unknown | github | [] | Advent of Code 2024
I am solving this year's problems in ⚡<a>Zig</a>⚡ | [] |
https://avatars.githubusercontent.com/u/60233333?v=4 | DSA_zig | rajrupdasofficial/DSA_zig | 2025-01-05T15:27:59Z | DSA problem solving repository using zig programming language | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/rajrupdasofficial/DSA_zig/tags | BSD-3-Clause | [
"dsa",
"dsa-algorithm",
"dsa-learning-series",
"dsa-practice",
"zig",
"ziglang"
] | 9 | false | 2025-04-11T16:41:27Z | true | true | unknown | github | [] | DSA problem solving using Zig programming language | [] |
https://avatars.githubusercontent.com/u/46852393?v=4 | zap-api-example | jonathan-foucher/zap-api-example | 2024-11-16T23:30:07Z | An example of Zig API with Zap | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/jonathan-foucher/zap-api-example/tags | - | [
"libpq",
"zap",
"zig"
] | 19 | false | 2025-05-08T15:59:53Z | true | true | 0.14.0 | github | [
{
"commit": "master",
"name": "zap",
"tar_url": "https://github.com/zigzap/zap/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/zigzap/zap"
}
] | Introduction
This project is an example of a Zig API using Zap, libpq and a postgres database.
Run the project
Database
Install postgres locally or run it through docker with :
<code>docker run -p 5432:5432 -e POSTGRES_DB=my_database -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres</code>
Application
Once the postgres database is started, you can build and start the Zig project and try it out.
Build the application
<code>zig build</code>
Start the application (built executable)
<code>zig-out/bin/zap_api_example</code>
Get all the movies
<code>curl --location 'http://localhost:3000/api/movies'</code>
Save a movie
<code>curl --request POST \
--url http://localhost:3000/api/movies \
--header 'Content-Type: application/json' \
--data '{
"id": 26,
"title": "Some movie title",
"release_date": "2022-02-26"
}'</code>
Delete a movie
<code>curl --request DELETE \
--url http://localhost:3000/api/movies/26</code> | [] |
https://avatars.githubusercontent.com/u/231984?v=4 | zig-linereader | taikedz/zig-linereader | 2024-10-10T22:00:55Z | A simple ASCII line reader for Zig, with line searching and self-cleanup | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/taikedz/zig-linereader/tags | LGPL-3.0 | [
"filereader",
"strings",
"zig"
] | 12 | false | 2024-11-04T13:02:52Z | true | true | unknown | github | [] | Zig LineReader
A general purpose library for Zig.
Provides a one-call utility to read text files and perform line-oriented operations. | [] |
https://avatars.githubusercontent.com/u/36650528?v=4 | tcp-server | Archisman-Mridha/tcp-server | 2024-11-23T14:31:28Z | Building a TCP server from scratch in each of : Rust, Zig and C | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Archisman-Mridha/tcp-server/tags | - | [
"c",
"rust",
"tcp",
"tcp-server",
"zig"
] | 34 | false | 2025-04-10T12:53:35Z | false | false | unknown | github | [] | Implementing a TCP server from scratch
Knowledge nuggets
<ul>
<li>The UT8 or ASCII encoding of 4,294,967,295 takes 10 bytes - 1 byte per digit. The binary encoding takes 4 bytes; quite the space saving! Conversely, the UTF8 or ASCII encoding of "63" uses just 2 bytes, versus the 4 byte if we're using a <strong>4-byte fixed length</strong>.</li>
</ul>
<blockquote>
There are variable-length binary encoding scheme, such as the <code>varint</code> used by Google's <strong>Protocol Buffer</strong>.
</blockquote>
<ul>
<li>
Some protocols use <strong>both delimiters and some type of prefix</strong>. HTTP, for example, uses delimiters for its headers, but the body's length is typically defined by the text-encoded Content-Length header. Redis also stands out as having a mix of both delimiters (for ease of human-readability) and text-encoded length prefix.
</li>
<li>
Elixir and Erlang have strong support for <strong>vectored I/O</strong>.
</li>
</ul>
REFERENCEs
<ul>
<li><a>TUN/TAP</a></li>
<li><a>TRANSMISSION CONTROL PROTOCOL</a></li>
<li><a>INTERNET PROTOCOL</a></li>
<li><a>Datagrams</a></li>
<li>
<a>SYN flood attack</a>
</li>
<li>
<a>What is the difference between a slice and an array in Rust?</a>
</li>
<li>
<a>TCP Server in Zig - Part 1 - Single Threaded</a>
</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/7083478?v=4 | mlir_toy | NaleRaphael/mlir_toy | 2025-01-24T12:33:07Z | Learn MLIR the hard way (probably) with Zig. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/NaleRaphael/mlir_toy/tags | MIT | [
"mlir",
"zig"
] | 474 | false | 2025-04-13T12:52:24Z | true | true | unknown | github | [] | mlir_toy
Learn MLIR the hard way (probably) with Zig.
<ul>
<li>Reimplement things in Zig if it's possible.</li>
<li>Use Zig build system to replace CMake if it's possible.</li>
<li>Minimize dependencies of LLVM internal libraries/tools.</li>
</ul>
I believe it's a way to make me learn more and gain a solid understanding of
LLVM/MLIR internals.
Prerequisites
<ul>
<li>Zig 0.13.0</li>
<li>LLVM 17</li>
</ul>
Build
LLVM/MLIR
Please check out <a>utils/llvm/README.md</a>.
Zig
```bash
Basic usage: build with specific chapter
$ zig build -Dllvm_dir=${LLVM_DIR} -Dmlir_dir=${MLIR_DIR} -Dchapters=${CHAPTER}
```
Please check out <a>build.sh</a> for more details.
Run and compare the output
```bash
- Run the output with data provided in MLIR toy example
$ ./zig-out/bin/toyc-chX ./toy_example/ChX/XXX [OPTIONS}
- Or compare the output with the binary compiled from official toy example
(remember to update the variables in this script based on your case)
$ ./compare_output.sh
```
<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>
It's recommended to create symlinks of compiled binaries of MLIR toy example
and data to this directory. Or you might need to change the default paths set
in <code>compare_output.sh</code> accordingly.
```bash
</blockquote>
Assume that you cloned LLVM source repo to "~/workspace/tool/llvm-17", and
ran the script "./utils/llvm/build_llvm_mlir.sh" to build MLIR.
$ LLVM_ROOT_DIR=~/workspace/tool/llvm-17
$ MLIR_INST_DIR=${LLVM_SRC_DIR}/out/mlir
$ ln -s ${MLIR_INST_DIR}/examples toy_bin
$ ln -s ${LLVM_ROOT_DIR}/mlir/test/Examples/Toy toy_examples
```
Tests
Port of tests for MLIR C-API
```bash
$ cd tests/mlir
Remember to update the variables <code>LLVM_DIR</code>, <code>MLIR_DIR</code>, <code>FILECHECK_BIN</code>
$ ./run_tests.sh
```
Compare the output with C++ implementation for a chapter
```bash
Usage: ./tests/compare_toyc_output.sh
- ChN: chapter number (0 ~ 7)
Environment variables:
- VERBOSE: (0 or 1) show details when running test
- ENABLE_DEBUG: (0 or 1) add debug options to CLI when running toyc binaries
Example: compare the outputs of C++ and our Zig implementation for Ch7, and
show the details while running.
$ VERBOSE=1 ./tests/compare_toyc_output.sh 7
```
<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>
When comparing the output for Ch7, the test would fail when <code>ENABLE_DEBUG=1</code>
because there is an extra canonicalizer pass added to the pipeline (see
<a>here</a>). It's considered as a redundant pass but it would
show the IR before & after processing because <code>--mlir-print-ir-before-all</code>
and <code>--mlir-print-ir-after-all</code> is enabled. So you can safely comment these
2 options out if you want to run the script with <code>ENABLE_DEBUG=1</code> for Ch7.
</blockquote>
Current Limitations and Workarounds
Here are things that cannot be done currently as initially planned, I would
come back to them if possible.
1. Build MLIR dialect library with Zig
The build of a MLIR dialect library heavily depends on things defined in CMake
modules like <a><code>AddMLIR.cmake</code></a> and <a><code>AddLLVM.cmake</code></a>.
Though I think it's possible to replicate those macros without using CMake,
it's really time-consuming and it requires to maintain if I want to switch to
different version of LLVM/MLIR.
But the major barrier stops me working on this for now is the lack of supports
for some compiler & linker features in <code>zig cc/c++</code>, e.g., <a>unsupported
linker arg: -rpath-link</a>. So my current workaround for this is
to use CMake within a build script <code>build_dialect.sh</code> and integrate this step
in <code>build.zig</code>. You can check this out in each chapter folder to know how it
works, and see also <a>"src/sample/"</a> for some notes and code I've
done while digging into this topic.
2. Implement dialect Ops with current MLIR C-API
If I understand correctly, currently it's not possible to implement Ops of
custom dialect without directly writing C++. Because they rely on C++'s CRTP
for type traits and supports of some internal features like IR verification.
So that's why we still keep some C++ implementations in "ChX/toy/cpp" folder.
Regarding passes, it's possible to work with zig and MLIR C-API directly. You
can check out how it work in <a>"tests/mlir/CAPI/pass.zig"</a>.
As for other things that're not support in current MLIR C-API, we have to extend
it by ourselves. See also "ChX/toy/c" folder for details.
Tips
<ul>
<li>If you ran into problems while compiling with C libraries, try adding flags
<code>--verbose-cc</code> and <code>--verbose-cimport</code> to get details for debugging.</li>
<li>Documents of C-APIs are mostly available in <code>$LLVM_SRC/mlir/include/mlir-c</code>,
but some C-APIs are defined in "Passes.td" files and they will be generated
as "<em>.capi.h" and "</em>.capi.cpp" files after being built.</li>
<li>Test cases in <code>tests/mlir/CAPI</code> are also resources to learn how to use MLIR
C-API in Zig.</li>
</ul>
Postscripts
Honestly, I didn't even know it's possible to complete this tutorial using Zig
and the MLIR C-API at first. But I just want to push my limits and see what I
could achieve, even though it's my first time building something related to a
compiler.
Using Zig forced me to learn more low-level details. It made me struggle at
times and exposed things I hadn't considered before, such as polymorphism via
vtable/static dispatch and memory management while handling errors.
Working with the MLIR C-API was also challenging, it pushed me to understand
how specific steps work behind the scenes in MLIR when I couldn't directly
manipulate data in C++.
And issues related to the build system (like <a>issue #1</a>) also
forced me to dive deeper into understanding how compilers, linkers and CMake
work when building ELFs.
But I really enjoyed it because I did learn a lot in this process.
Now this project is almost finished, though there are still plenty things to
learn to build the thing I want with MLIR. Working on this project has sparked
my interest in exploring other techs for building compilers without relying on
LLVM/MLIR. For instance, I really want to see how Zig compiler would evolve
after the <a>announcement</a> about removing LLVM-related
dependencies.
So, if you're looking to learn MLIR in an unconventional way, hope this project
would be helpful to you as well.
And here are more things that might interest you about Zig:
- <a>Andrew Kelley's talk about Data Oriented Design and Zig compiler</a>
- <a>Mitchell Hashimoto's blog series about Zig compiler</a>
- <a>Andrew Kelley's talk about Zig build system</a>
- <a>Validark's project to make Zig parser faster</a>
| [] |
https://avatars.githubusercontent.com/u/45996170?v=4 | tizen-zig-app | griffi-gh/tizen-zig-app | 2025-02-05T14:48:31Z | [experiment] trying to compile zig for tizen :p | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/griffi-gh/tizen-zig-app/tags | - | [
"galaxy-watch",
"tizen",
"tizen-studio",
"zig",
"zig-build",
"ziglang"
] | 59 | false | 2025-04-21T16:06:06Z | true | true | 0.13.0 | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/133709987?v=4 | zlam | cartersusi/zlam | 2024-09-05T22:06:52Z | null | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/cartersusi/zlam/tags | - | [
"huggingface",
"llama3",
"llm",
"transformers",
"zig"
] | 20 | false | 2024-10-27T14:44:37Z | false | false | unknown | github | [] | Setup
```
git clone https://github.com/cartersusi/zlam.git
cd zlam
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Tokens in credentials
huggingface-cli login
git remote add hf https://huggingface.co/cartersusi/zig-LLaMa
chmod +x run_peft.sh
./run_peft.sh
``` | [] |
https://avatars.githubusercontent.com/u/36650528?v=4 | ethereum-node-implementation | Archisman-Mridha/ethereum-node-implementation | 2024-09-16T05:53:12Z | Ethereum execution and consensus client implemented in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Archisman-Mridha/ethereum-node-implementation/tags | - | [
"ethereum",
"ethereum-consensus-client",
"ethereum-execution-client",
"ethereum-node",
"ethereum-zig",
"zig"
] | 47 | false | 2025-02-01T07:14:48Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/164030498?v=4 | zna | cherninlab/zna | 2024-11-08T23:44:42Z | zna (Zen Navigation Assistant) is a minimal, lightning-fast command-line directory navigator written in Zig. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/cherninlab/zna/tags | MIT | [
"cli",
"zig"
] | 7 | false | 2024-11-22T10:25:00Z | true | false | unknown | github | [] |
zna
<code>zna</code> (Zen Navigation Assistant) is a minimal, lightning-fast command-line directory navigator written in Zig.
Installation
From Binary (recommended)
```bash
Linux (x86_64)
curl -L https://github.com/cherninlab/zna/releases/latest/download/zna-linux-x86_64 -o zna
chmod +x zna
sudo mv zna /usr/local/bin/
```
From Source
<code>bash
git clone https://github.com/cherninlab/zna.git
cd zna
zig build -Drelease-safe
sudo cp zig-out/bin/zna /usr/local/bin/</code>
Usage
<code>bash
$ zna # Start navigation in current directory
Arrow keys to navigate # ↑↓ to select
Enter to go into dir # Enter directory
q to quit # Quit the program</code>
License
MIT | [] |
https://avatars.githubusercontent.com/u/44740171?v=4 | zig-ansi-parse | chardoncs/zig-ansi-parse | 2024-10-31T06:17:49Z | Comptime-proof ANSI format parsing library for Zig | main | 1 | 0 | 0 | 0 | https://api.github.com/repos/chardoncs/zig-ansi-parse/tags | MIT | [
"ansi-code",
"ansi-colors",
"ansi-terminal",
"colorization",
"parser",
"zig",
"ziglang"
] | 51 | false | 2025-03-07T03:43:30Z | true | true | 0.14.0 | github | [] | zig-ansi-parse
Comptime-proof ANSI format parsing library for Zig.
<a>How it works?</a>
Install
<ol>
<li>Fetch it in your project, <code><version></code> is the version you want</li>
</ol>
<code>bash
zig fetch --save https://github.com/chardoncs/zig-ansi-parse/archive/refs/tags/v<version>.tar.gz</code>
Or fetch the git repo for latest updates
<code>bash
zig fetch --save git+https://github.com/chardoncs/zig-ansi-parse</code>
<ol>
<li>Configure your <code>build.zig</code>.</li>
</ol>
<code>zig
const ansi_parse = b.dependency("ansi-parse", .{});
exe.root_module.addImport("ansi-parse", ansi_parse.module("ansi-parse"));</code>
At a glance
```zig
const std = @import("std");
const parseComptime = @import("ansi-parse").parseComptime;
const demo_text = parseComptime(
\Greetings! I'm <b>bold and blue
\Ignore this
\\
\<!TAB>tabbed<!LF>Ollal<!CR>Hello
\<!TAB*3>Three tabs
\
, .{} // Options
);
pub fn main() !void {
std.debug.print(demo_text, .{});
}
```
Options
| Name | Default value | Description |
|--------------|-----------------|-------------------------|
| branch_quota | 200,000 | (Comptime only) Evaluation branch quota. A larger quota can prevent the compiler from giving up caused by loops |
| out_size | <code>input.len * 4</code> | (Comptime only) Capacity of the output string, set a larger value if the output is truncated |</b> | [] |
https://avatars.githubusercontent.com/u/71959210?v=4 | ziggy-pydust-template | itsmeadarsh2008/ziggy-pydust-template | 2025-02-01T11:49:50Z | A template for building Python extensions in Zig using Pydust toolkit. (use with uv) | develop | 0 | 0 | 0 | 0 | https://api.github.com/repos/itsmeadarsh2008/ziggy-pydust-template/tags | Apache-2.0 | [
"extension",
"python",
"template",
"zig"
] | 265 | true | 2025-04-28T11:20:59Z | false | false | unknown | github | [] | Ziggy Pydust Template
This repository contains a template for writing and packaging native Python extension modules in Zig using <a>Pydust</a> framework.
This template includes:
<ul>
<li>A Python <code>uv</code> project.</li>
<li>A <code>src/</code> directory containing a Pydust Python module.</li>
<li>Pytest setup for running both Python and Zig unit tests.</li>
<li>GitHub Actions workflows for building and publishing the package.</li>
<li>VSCode settings for recommended extensions, debugger configurations, etc.</li>
</ul>
We recommend heading to <a>Getting Started</a>. | [] |
https://avatars.githubusercontent.com/u/93550458?v=4 | c-zig | thehxdev/c-zig | 2024-09-10T22:40:05Z | A simple example of how to use Zig compiler to compile both C and Zig source files into a single executable | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/thehxdev/c-zig/tags | - | [
"c",
"zig"
] | 2 | false | 2024-09-17T00:19:23Z | false | false | unknown | github | [] | C-Zig
Just a simple example of how to use Zig compiler to compile <code>adder.c</code> and <code>main.zig</code> file that includes a C header file called <code>adder.h</code>.
Read the <a>build.sh</a> file to learn more.
Build
Just run the <code>build.sh</code> script.
<code>bash
./build.sh</code>
Why a build script?
Zig is capable of compiling C source code. But the problem is Zig compiler needs to know where to find C headers (aka. Include directories like <code>/usr/include</code>).
In the command line you can literally do this in project's root directory:
<code>bash
zig build-exe -I. adder.c main.zig</code>
Zig compiler will compile both C and Zig source files into a single executable!
Here, I just included <code>adder.h</code> file in <code>main.zig</code>. So technically I just need to add the current directory <code>./</code> to be searched for header files.
So like C compilers we can use <code>-I</code> flag to add a directory to be searched for header files by zig compiler (<code>-I.</code>).
Then Zig compiler can find <code>adder.h</code>.
In case you want to use libc (like <code>stdio.h</code>) you need to find and add system include directories with <code>-I</code> flag.
Then you have to link the final executable against libc with <code>-lc</code> flag passed to zig compiler. So I created <code>build.sh</code> as an example for that.
Note that I didn't initialized any zig project with <code>zig init</code> command. If you are created a Zig project all of the things above can be declared in the <code>build.zig</code> file. | [] |
https://avatars.githubusercontent.com/u/66168396?v=4 | zig-explorer | Roeliefantje/zig-explorer | 2024-12-24T21:05:05Z | File explorer made in zig, meant to support tags in the future and file previews and other features I would like to see in my file explokrer. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Roeliefantje/zig-explorer/tags | - | [
"clay",
"fileexplorer",
"zig",
"ziglang"
] | 284 | false | 2025-01-02T15:46:37Z | true | true | unknown | github | [
{
"commit": "06c7feeeacc4eef3092f55748d6bb8d207ae4c41.tar.gz",
"name": "zclay",
"tar_url": "https://github.com/johan0A/clay-zig-bindings/archive/06c7feeeacc4eef3092f55748d6bb8d207ae4c41.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/johan0A/clay-zig-bindings"
},
{
"commit":... | 404 | [] |
https://avatars.githubusercontent.com/u/192349959?v=4 | ziglings-solutions | PedroRevesMD/ziglings-solutions | 2025-01-07T22:40:10Z | My Ziglings Solutions | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/PedroRevesMD/ziglings-solutions/tags | - | [
"zig",
"ziglang",
"ziglings",
"ziglings-exercises"
] | 1,433 | false | 2025-01-14T21:25:57Z | true | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/72021589?v=4 | ProceduralAnimation | roy-corentin/ProceduralAnimation | 2024-10-13T08:55:33Z | Expirmentation of procedural animation in Zig with Raylib | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/roy-corentin/ProceduralAnimation/tags | - | [
"procedural-animation",
"zig"
] | 27 | false | 2025-02-14T11:04:52Z | true | true | unknown | github | [
{
"commit": "devel.tar.gz",
"name": "raylib-zig",
"tar_url": "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/Not-Nik/raylib-zig"
}
] | 404 | [] |
https://avatars.githubusercontent.com/u/67933444?v=4 | langton.zig | 0xErwin1/langton.zig | 2024-08-18T13:46:54Z | Langton's ant made in Zig and Raylib | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/0xErwin1/langton.zig/tags | GPL-3.0 | [
"langton-ant",
"raylib",
"raylib-zig",
"zig"
] | 19 | false | 2024-08-18T13:51:04Z | true | true | unknown | github | [
{
"commit": "devel.tar.gz",
"name": "raylib-zig",
"tar_url": "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/Not-Nik/raylib-zig"
}
] | Langton's Ant in Zig
Rquirements
<ul>
<li>Zig: 0.13.0</li>
<li>Raylib: 3.7.0</li>
</ul>
Build
```bash
zig build
./zig-out/bin/langton
or
zig build run
``` | [] |
https://avatars.githubusercontent.com/u/104794884?v=4 | nimrod | OsakiTsukiko/nimrod | 2024-10-27T09:59:21Z | Blazingly fast decentralized authority signing API written in Zig. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/OsakiTsukiko/nimrod/tags | MIT | [
"api",
"zig"
] | 13 | false | 2024-11-26T11:54:49Z | true | true | unknown | github | [
{
"commit": "master",
"name": "zqlite",
"tar_url": "https://github.com/karlseguin/zqlite.zig/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/karlseguin/zqlite.zig"
},
{
"commit": "master",
"name": "zap",
"tar_url": "https://github.com/zigzap/zap/archive/maste... | 404 | [] |
https://avatars.githubusercontent.com/u/45214659?v=4 | emu | 0xdeb7ef/emu | 2024-11-09T14:55:18Z | A Zig library that offers some simple CPUs to emulate. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/0xdeb7ef/emu/tags | MIT | [
"chip-8",
"chip8",
"emulation",
"emulator",
"zig"
] | 16 | false | 2024-11-30T02:44:26Z | true | true | unknown | github | [
{
"commit": "master",
"name": "chip8_test_suite",
"tar_url": "https://github.com/Timendus/chip8-test-suite/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/Timendus/chip8-test-suite"
}
] | emu
This repo is ment to hold my attempts at emulating random stuff that I find interesting.
At the moment, there's only an unfinished CHIP-8 implementation.
My goal is to make it a sort of library that can be used to emulate various different CPUs
and/or hardware.
CHIP-8
All the CHIP-8 opcodes have been implemented and tested against the
<a>CHIP-8 Test Suite</a>.
The CHIP-8 core passes the the following test ROMs:
<ul>
<li><code>1-chip8-logo.ch8</code></li>
<li><code>2-ibm-logo.ch8</code></li>
<li><code>3-corax+.ch8</code></li>
<li><code>4-flags.ch8</code></li>
</ul>
The followings tests are currently skipped because they require functionality that
hasn't been implemented yet:
<ul>
<li><code>5-quirks.ch8</code></li>
<li><code>6-keypad.ch8</code></li>
<li><code>7-beep.ch8</code></li>
</ul>
Things left to do
<ul>
<li>The keyboard opcodes haven't been tested yet.</li>
<li>The core does not yet handle the sound and delay timers, so that needs a bit
of work to get working.</li>
<li>Based on the previous task, the whole emulation cycle needs to be worked on so it can
handle different speeds/frequencies, you could probably just do those manually for now
but it would be nicer to have the core handle it, maybe a <code>cycle()</code> function.</li>
</ul>
References
<ul>
<li><a>Guide to making a CHIP-8 emulator</a></li>
<li><a>Cowgod's CHIP-8 Technical Reference</a></li>
<li><a>CHIP-8 Variant Opcode Table</a></li>
<li>and many more... <a>emudev.org</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/84424661?v=4 | zig-first-example | gustavocadev/zig-first-example | 2024-08-29T19:43:21Z | null | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/gustavocadev/zig-first-example/tags | - | [
"zig"
] | 0 | false | 2024-08-29T19:45:46Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/44583679?v=4 | openwrt-led-night-mode | yhdgms1/openwrt-led-night-mode | 2024-08-09T15:37:23Z | Disable LED's in night time on router | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/yhdgms1/openwrt-led-night-mode/tags | - | [
"openwrt",
"zig"
] | 17 | false | 2024-08-13T12:19:36Z | true | true | 0.13.0 | github | [
{
"commit": "c9327827352354da246733e97535754ced64def8",
"name": "chameleon",
"tar_url": "https://github.com/tr1ckydev/chameleon/archive/c9327827352354da246733e97535754ced64def8.tar.gz",
"type": "remote",
"url": "https://github.com/tr1ckydev/chameleon"
}
] | openwrt-led-night-mode
It is a tool for managing the brightness of LEDs on OpenWRT routers.
It allows users to automatically adjust the brightness of their router's LEDs during specified night hours to reduce light pollution and save energy.
How it works
The program interacts with the router's cron system to schedule brightness adjustments for LEDs. By setting start and end times, you can turn off the LEDs during the night and restore them to normal brightness during the day.
Usage
You can also list all the LEDs by using <code>list</code> command.
<code>sh
openwrt-led-night-mode list</code>
Run the program with <code>install</code> command to add changes to cron. You can control night hours by providing <code>--start</code> and <code>--end</code> flags.
<code>sh
openwrt-led-night-mode install --start=22:00 --end=07:00</code>
You can control which LEDs to include by <code>--leds</code> flag with LEDs splitted by commas
<code>sh
openwrt-led-night-mode install --start=22:00 --end=07:00 --leds=green:status,green:wan</code>
You can run <code>uninstall</code> command for uninstalling configured cron's.
<code>sh
openwrt-led-night-mode uninstall</code> | [] |
https://avatars.githubusercontent.com/u/736007?v=4 | bluepill-zig | aleh/bluepill-zig | 2024-08-18T20:14:42Z | Bare Metal Zig on STM32 | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/aleh/bluepill-zig/tags | - | [
"bluepill",
"stm32",
"stm32f103",
"zig"
] | 23 | false | 2024-08-21T21:31:16Z | false | false | unknown | github | [] | Bare Metal Zig on STM32
This is about using <a>Zig</a> alone to directly program boards based on STM32F103xx MCU, such as "Blue
Pill" clones of Maple Mini.
Requirements
<ul>
<li>
A Blue Pill board or similar, see <a>here</a> for general and
physical info.
</li>
<li>
<a>Zig</a> to build our examples. (I used version 0.13.0 here.)
</li>
<li>
<a>ST-Link Tools</a> to flash them.
</li>
</ul>
Docs
<ul>
<li>
<a>Blue Pill Schematic</a>.
</li>
<li>
<a>STM32 Cortex®-M3 Programming Manual</a> for general info on Cortex-M3.
</li>
<li>
<a>STM32F10x Reference Manual</a> to know how to program all available peripherals.
</li>
<li>
<a>STM32F103x8 Datasheet</a> to know what exactly is available
in our MCU as the above reference manual describes the whole family.
</li>
<li>
<a>Info on Linker Scripts</a> to be able to describe memory layout to the linker.
</li>
</ul>
Target
One of the cool things about Zig is that (thanks to LLVM) it can compile for many architectures out of the box and yet
manages to keep its MacOS package size under 50MB without any external dependencies!
Zig expects its <code>-target</code> command line switch to be a dash-separated triple identifying architecture, operating system
and ABI (application binary interface) of the target system. See the whole list by running:
<code>zig targets | less
</code>
Our architecture is ARM, we don't have any OS and we don't care about any particular ABI, so we are going to use
<code>arm-freestanding-none</code> as our <code>-target</code>.
Another command line switch, <code>-mcpu</code>, should be used to specify the processor to generate the code for. STM32F103xx is
based on Cortext-M3, so consulting the list of supported targets the most logical choice seemed to be <code>cortex_m3</code>. I am
getting build errors when using one however (something about an instruction in <code>IT</code> block), so I decided to step back
to <code>cortex_m23</code> that seems to be a subset of Cortext-M3 instruction-wise, missing exactly the <code>IT</code> instruction. (I
don't expect the compiler to use "TrustZone" security extensions. We could also use <code>cortex_m0</code> to be 100% sure it
won't generate something unsupported.)
Before we go to the remaining compiler settings let's type in some code first. Let's make the classic "Blink" example toggling the on-board LED (see <code>v0/main.zig</code>). It's not going to be nice, but we'll improve it later.
Version 0
Looking at the Blue Pill Schematic we see that the LED is attached to PC13 of the MCU which can be controlled via port 13 of GPIO bank C. GPIO and the corresponding registers are described in Chapter 9 of the Reference Manual, while the base address of bank C, <code>0x4001_1000</code>, can be found in the STM32F103x8 Datasheet.
Before we can use the GPIO bank C however we need to enable it via one of the Reset and Clock Control (RCC) registers (base <code>0x4002_1000</code>), see chapter 7.3. GPIO bank C is controlled by bit 4 of <code>RCC_APB2ENR</code>, offset <code>0x18</code>:
<code>zig
reg(0x4002_1000 + 0x18).* |= 1 << 4;</code>
Where <code>reg()</code> is a simple wrapper that gets us a <code>volatile</code> pointer, which we need when working with memory mapped registers for Zig's optimizer to not try removing or reorder our reads/writes.
<code>zig
fn reg(comptime address: u32) *volatile u32 {
return @ptrFromInt(address);
}</code>
Before we can start toggling port 13 however we need to configure it as output via <code>GPIOx_CRH</code> register (offset <code>0x04</code>, see chapter 9.2.2). Each nibble in this register is responsible for configuration of ports 8-15:
<code>zig
reg(0x4001_1000 + 0x04).* |= 0b01_10 << (4 * (13 - 8)); // Relying on the reset value being 0b01_00.</code>
We'll be using <code>GPIOx_BSRR</code> register (offset <code>0x10</code> from the base, see chapter 9.2.5) to control the output state of our port. Setting bits 0-15 here sets the output on ports 0-15 to 1, while setting bits 16-32 <em>resets</em> the output on the same ports. (This register is more convenient than more traditional <code>GPIOx_ODR</code>, because there is no need to read its current state to modify a single bit.)
<code>zig
const GPIOC_BSRR = reg(0x4001_1000 + 0x10);
while (true) {
GPIOC_BSRR.* = 1 << (13 + 16);
delay(50);
GPIOC_BSRR.* = 1 << 13;
delay(950);
}</code>
To implement <code>delay()</code> we'll just do something in a long loop. (We'll return to better implementation in the next version of the example.)
<code>zig
fn delay_ticks(ticks: u32) void {
var i = ticks;
while (i > 0) {
// Reading any location to prevent the loop from being optimized out.
_ = reg(0x2000_0000).*;
i -= 1;
}
}</code>
To calculate the number of ticks we need to iterate to get a millisecond delay we need to know that after reset our CPU runs approximately at 8MHz and that every iteration in the above loop takes 6 CPU cycles (more on this below):
<code>zig
fn delay(comptime ms: u32) void {
delay_ticks(ms * 8_000 / 6);
}</code>
Linker Script
OK, now when we have a basic program (see <code>v0/main.zig</code>) we can try to compile it:
<code>zig build-exe -target arm-freestanding-none -mcpu cortex_m23 -O ReleaseSmall -femit-asm main.zig
</code>
The extra <code>-femit-asm</code> flag makes Zig produce assembly output which is handy when examining our code. For example, this is how we can calculate how many CPU clock cycles <code>delay_ticks()</code> spends per tick (comments added by me using info on <a>this page</a>):
<code>asm
main.delay_ticks: ; r0 contains the number of ticks already.
movs r1, #1
lsls r1, r1, #29 ; (1 << 29) is this 0x20000000 address we are reading from below.
.LBB1_1:
cbz r0, .LBB1_3 ; 1 cycle, branch not taken. (Jump out of the loop if tick counter in r0 is zero.)
ldr r2, [r1] ; 2 cycles. (Our fake read.)
subs r0, r0, #1 ; 1 cycle. (Decrement the tick counter in r0.)
b .LBB1_1 ; 2 cycles, branch is taken. (Repeat the loop.)
.LBB1_3:
bx lr ; Return from the function.</code>
Speaking of assembly, we could also disassemble the output file directly with <code>objdump -d main</code>, but it might be harder to see what's going on, here is the same <code>delay_ticks()</code> function:
<code>20130: 2101 movs r1, #1
20132: 0749 lsls r1, r1, #29
20134: b110 cbz r0, 0x2013c <.text+0x50> @ imm = #4
20136: 680a ldr r2, [r1]
20138: 1e40 subs r0, r0, #1
2013a: e7fb b 0x20134 <.text+0x48> @ imm = #-10
2013c: 4770 bx lr
</code>
Another thing that we can see with <code>objdump</code> is that our code starts at address <code>000200ec</code> which is quite wrong for our MCU where flash memory begins at <code>0x08000000</code>:
<code>main: file format elf32-littlearm
Disassembly of section .text:
000200ec <.text>:
200ec: 480c ldr r0, [pc, #48] @ 0x20120 <.text+0x34>
200ee: 6801 ldr r1, [r0]
200f0: 2210 movs r2, #16
...
</code>
Well, this is logical because Zig does not really know much about our MCU. We need to help it by writing a "linker script". The official documentation on the topic mentioned above is easy to read and actual scripts are fairly self-explanatory.
The first thing we do in our script (<code>v0/bluepill.ld</code>) is describing relevant memory regions, which is quite simple in our case as we have 128K of flash memory starting at <code>0x08000000</code> and 20K of RAM starting at <code>0x20000000</code> (see chapter 4 in the Datasheet):
<code>MEMORY {
flash (rx) : o = 0x08000000, l = 128K
sram (rw) : o = 0x20000000, l = 20K
}
</code>
(The names of the regions can be arbitrary here, the linker does not know what the "flash" is.)
The next part of the script tells what should be placed into the flash memory:
<code>SECTIONS {
.text : {
...
} >flash
</code>
We cannot tell it to begin filling with the code from the start as the first word has to be the value of the main stack pointer (MSP), as per chapter 2.1.2 of the Programming Manual:
<blockquote>
On reset, the processor loads the MSP with the value from address 0x00000000.
</blockquote>
(The address is from the start of the flash, <code>0x08000000</code> in our case.)
Next go interrupt vectors (see table 63 in the Reference Manual) of which we are only interested in the first one, Reset, as we don't use interrupts just yet:
<code>.text : {
/* The initial value of SP, past the end of RAM. */
LONG(ORIGIN(sram) + LENGTH(sram))
/* Reset vector. */
LONG(_start)
/* We should put a bunch of other vectors here, but since none are used yet we can use the space. */
/* So now goes our code. */
*(.text)
/* Then read-only data. */
*(.rodata.*)
*(.rodata)
} >flash
</code>
Next we tell that our writable data (static variables) is expected in RAM. We don't have such variables in our simple example yet, but that'll be handy later.
<code>.bss : {
*(.bss)
} >sram
</code>
And finally we exclude a few extra code segments that otherwise would increase the size of our binary:
<code>/DISCARD/ : {
/* I don't want to keep sections needed only when printing stack traces. */
*(.ARM.*)
}
</code>
Let's compile using our linker script now:
<code>zig build-exe -target arm-freestanding-none -mcpu cortex_m23 -femit-asm -O ReleaseSmall --script bluepill.ld main.zig
</code>
Disassembling with <code>objdump</code> shows that the addresses are correct now:
<code>main: file format elf32-littlearm
Disassembly of section .text:
08000000 <.text>:
8000000: 20005000 andhs r5, r0, r0
8000004: 08000009 stmdaeq r0, {r0, r3}
8000008: 6801480c stmdavs r1, {r2, r3, r11, lr}
...
</code>
The first word appears to be the desired stack pointer just beyond the RAM followed by the Reset vector pointing to the next word. The number is even to indicate Thumb mode. Let's add <code>--mcpu=cortex-m23</code> to force Thumb mode:
<code>08000000 <.text>:
8000000: 5000 str r0, [r0, r0]
8000002: 2000 movs r0, #0
8000004: 0009 movs r1, r1
8000006: 0800 lsrs r0, r0, #32
8000008: 480c ldr r0, [pc, #48] @ 0x800003c <.text+0x3c>
800000a: 6801 ldr r1, [r0]
800000c: 2210 movs r2, #16
...
</code>
OK, now the part starting at <code>0x8000008</code> looks like the code in our <code>.s</code> file.
Flashing
We'll be using <code>st-flash</code> utility which expects either a raw binary with the starting address passes separately or an Intel hex file that already contains addresses. Let's use the latter by converting our build to <code>.hex</code> with Zig:
<code>zig objcopy -O hex main main.hex
</code>
Flashing is then as simple as:
<code>st-flash --reset --format ihex write main.hex
</code>
You'll see something like this and your LED will hopefully start blinking every second:
<code>st-flash 1.8.0
2024-08-18T22:01:38 INFO common.c: STM32F1xx_MD: 20 KiB SRAM, 128 KiB flash in at least 1 KiB pages.
2024-08-18T22:01:38 INFO common_flash.c: Attempting to write 90 (0x5a) bytes to stm32 address: 134217728 (0x8000000)
-> Flash page at 0x8000000 erased (size: 0x400)
2024-08-18T22:01:38 INFO flash_loader.c: Starting Flash write for VL/F0/F3/F1_XL
2024-08-18T22:01:38 INFO flash_loader.c: Successfully loaded flash loader in sram
2024-08-18T22:01:38 INFO flash_loader.c: Clear DFSR
1/1 pages written
2024-08-18T22:01:38 INFO common_flash.c: Starting verification of write complete
2024-08-18T22:01:38 INFO common_flash.c: Flash written and verified! jolly good!
</code>
Also, as you can see our code is just 90 bytes, which is quite nice given all the required setup instructions.
V1
Now let's improve the example showing some power of Zig:
```zig
export fn _start() noreturn {
const bankC = GPIOBank(.C);
bankC.init();
<code>const led = bankC.port(13);
led.setOutput(.openDrain, .max2MHz);
while (true) {
led.reset();
delay(50);
led.set();
delay(950);
}
</code>
}
```
The <code>GPIOBank</code> is an abstraction that is more readable, more reusable (we can use all banks/ports) but does not add any overhead as all the selection of the bank and port happen at compile time. Our program is 94 bytes now, which is just 4 bytes larger only because we are not relying on the reset values when writing to <code>GPIOC_CRH</code> as we want to change pin configuration at runtime:
```zig
pub fn GPIOBank(comptime bank: GPIOBankIndex) type {
return struct {
/<em> ... </em>/
pub fn port(comptime pin: u4) type {
return struct {
fn reg(comptime offset: u32) *volatile u32 {
return @ptrFromInt(switch (bank) {
.A => 0x4001_0800,
.B => 0x4001_0C00,
.C => 0x4001_1000,
.D => 0x4001_1400,
.E => 0x4001_1800,
} + offset);
}
<code> fn setModeBits(comptime bits: u32) void {
const CRx = reg(if (pin >= 8) 0x04 else 0x00);
const shift = 4 * @as(u8, if (pin >= 8) pin - 8 else pin);
CRx.* = CRx.* & ~(@as(u32, 0xF) << shift) | (bits << shift);
}
const BSRR = reg(0x10);
pub fn set() void {
BSRR.* = 1 << pin;
}
/* ... */
};
}
};
</code>
}
```
As you can see <code>reg()</code> depends on the bank, but since both <code>bank</code> and <code>pin</code> are <code>comptime</code>, thus both <code>GPIOx_CRx</code> (L or H) and <code>GPIOx_BSRR</code> are picked at compile time as well and we always get highly optimized code.
V2
Here we are adding a <code>SysTick</code> timer for a better <code>delay()</code> along with <code>USART</code> to say the actual <code>Hello</code>. (I've moved all helpers into a module called <code>z41</code> here.)
Our binary is <code>792</code> bytes now, or <code>314</code> if we completely remove the line with <code>usart.writer.print</code>, and <code>432</code> if we keep it but don't output the number. In other words, the use of <code>std.fmt</code> adds overhead only when specifiers are actually used, something that would be hard to achieve with a <code>printf()</code>-style C/C++ function.
```zig
const std = @import("std");
const z41 = @import("z41");
export fn _start() noreturn {
const rcc = z41.RCC(.internalRC);
rcc.init();
<code>const SysTick = z41.SysTick(rcc.SYSCLK, 50);
SysTick.init();
const led = z41.GPIO(rcc, .C).port(13);
led.Bank.init();
led.setOutput(.openDrain, .max2MHz);
const usart = z41.USART(rcc, .usart1);
usart.init(115200);
usart.writeBytes("\nHello! It's V2\n\n");
while (true) {
led.reset();
SysTick.delay(50);
led.set();
SysTick.delay(950);
try usart.writer.print("\rUptime: {}s", .{SysTick.milliseconds() / 1000});
}
</code>
}
```
RegisterSet
I've added <code>RegisterSet</code> under the hood to help with definition of hardware registers. It's similar to this <code>reg()</code> helper from <code>v0</code>, but allows using structs as well. For example, this is how <code>STK_CTRL</code> is described in <code>SysTick</code> (you should appreciate Zig allowing anonymous enums like here in <code>CLKSOURCE</code>):
<code>zig
const STK_CTRL = regs.at(0, packed struct(u32) {
/// Counter enable.
ENABLE: bool,
TICKINT: bool,
CLKSOURCE: enum(u1) {
/// AHB/8.
AHB_8 = 0,
/// Processor clock (AHB).
AHB = 1,
},
_r1: u13 = 0,
COUNTFLAG: bool = false,
_r2: u15 = 0,
});</code>
You can still use raw <code>u32</code> registers where needed:
<code>zig
const STK_LOAD = regs.at(4, u32);</code>
The helper checks the type you pass to make sure it's <code>u32</code> or <code>u32</code>-backed <code>packed struct</code>:
<code>zig
pub fn at(comptime offset: u32, comptime reg_type: type) *volatile reg_type {
const valid = switch (@typeInfo(reg_type)) {
.Struct => |s| switch (s.layout) {
.@"packed" => s.backing_integer == u32,
else => false,
},
.Int => |i| i.bits == 32,
else => false,
};
if (!valid) {
@compileError("Expected `reg_type` to be u32 or a packed struct backed by u32");
}
return @ptrFromInt(base + offset);
}</code>
SysTick
A <code>SysTick</code> timer is described in the chapter 4.5 of the Programming Manual and is something common to all processors based on Cortex®-M3. It's a simple counter that is decremented on every (or every 8ths) CPU clock cycle and generates an interrupt when it reaches zero. It can be used to implement a notion of system time (e.g. milliseconds since system start) along with better delays, where we don't have to rely on how exactly our code is compiled.
We need to be able to handle interrupts for this helper and this is where our linker script needs to be changed. The handler itself is simple:
```zig
pub fn SysTick(comptime cpuFreq: u32, comptime msPerTick: u32) type {
return struct {
export fn SysTick_Vector() void {
total_ms +%= msPerTick;
}
<code> var total_ms: u32 = undefined;
...
</code>
```
It needs to be <code>export</code>ed for our linker script to place a pointer to it into an appropriate location. (Note that the export only happens when <code>SysTick</code> is used, something that would be hard to achieve in C/C++ without macros.)
Other than <code>export</code> no other attributes are needed here thanks to the clever way interrupts ("exceptions") are handled (see chapter 2.3.7 in the Programming Manual):
<ul>
<li>
registers <code>r0</code>-<code>r3</code> are automatically pushed to the stack along with flags when an interrupt occurs, while remaining registers are already expected to be preserved by the compiler even in regular functions;
</li>
<li>
unlike other architectures no special "return from interrupt" instruction is needed, because the return address in <code>LR</code> register is set to a special value that any return from function (<code>bx lr</code>) will be recognized as a return from an interrupt restoring <code>r0</code>-<code>r3</code>, etc.
</li>
</ul>
So we need to add a pointer to our handler into the interrupt vector table at the start of our code (see table 63 in the Reference Manual again):
<code>.text : {
...
LONG(_start);
/* We don't use any interrupt vectors before SysTick, so let's just fill. */
FILL(0); . = ADDR(.text) + 0x003C;
LONG(DEFINED(SysTick_Vector) ? SysTick_Vector : 0xDEAD);
/* Other vectors follow, but since we are not using them we can just start our code earlier. */
...
</code>
Note the use of <code>DEFINED</code>: it allows correct linking even when the target program does not need the <code>SysTick</code> timer. (By the way, the use of <code>0xDEAD</code> for undefined handlers is temporary here, a central "panic" handler halting the MCU would be a better option eventually.)
<code>build.zig</code>
I've been using a simple shell script to build and flash the first 2 examples:
```bash
!/bin/sh -e
zig build-exe \
-target arm-freestanding-none \
-mcpu cortex_m23 \
-femit-asm \
-O ReleaseSmall \
--script bluepill.ld \
main.zig
zig objcopy -O hex main main.hex
rm main main.o
st-flash --reset --format ihex write main.hex
```
However in this one we want to be able to pull our helpers from a "module" in <code>./lib</code>. This still could be described in a shell script of course, but I also was curious about Zig's build system, so I've added <code>build.zig</code>.
Now the example can be compiled with <code>zig build</code> or flashed with <code>zig build flash</code>.
| [] |
https://avatars.githubusercontent.com/u/116080000?v=4 | curve2ed | theinfinityway/curve2ed | 2024-10-13T14:45:44Z | Simple Zig library for Curve25519 <-> Ed25519 conversion | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/theinfinityway/curve2ed/tags | MIT | [
"curve25519",
"ecc",
"ed25519",
"zig"
] | 4 | false | 2024-10-13T15:29:02Z | true | true | unknown | github | [] | curve2ed
Simple Zig library for Curve25519 <-> Ed25519 conversion
Install
You can install the library using <a>zigmod</a>.
<ol>
<li>Add library to <code>zigmod.yml</code></li>
</ol>
2. <a>Integrate zigmod with <code>build.zig</code></a>
3. Run <code>zigmod fetch</code>
Example
```zig
const std = @import("std");
const c2ed = @import("curve2ed");
pub fn main() !void {
const inputHex = "d871fc80ca007eed9b2f4df72853e2a2d5465a92fcb1889fb5c84aa2833b3b40";
<code>var input: [inputHex.len / 2]u8 = undefined;
_ = std.fmt.hexToBytes(&input, inputHex) catch unreachable;
const result1 = c2ed.toEd25519(input);
const result2 = c2ed.toCurve25519(result1);
std.debug.print("Input: {s}\nEd25519: {s}\nCurve25519 (via library): {s}\n", .{ inputHex, std.fmt.bytesToHex(result1, .lower), std.fmt.bytesToHex(result2, .lower) });
</code>
}
``` | [] |
https://avatars.githubusercontent.com/u/2584714?v=4 | zig_origin | jjuel/zig_origin | 2024-10-17T21:34:34Z | Zig Origin (zo) is a command-line tool designed to replace and enhance the functionality of zig init. It provides a more flexible and feature-rich way to initialize Zig projects. | trunk | 0 | 0 | 0 | 0 | https://api.github.com/repos/jjuel/zig_origin/tags | MIT | [
"init",
"zig"
] | 31 | false | 2025-01-22T03:57:32Z | true | true | unknown | github | [] | Zig Origin (zo)
Zig Origin (zo) is a versatile command-line tool designed to streamline the initialization and management of Zig projects. It offers various templates and options to cater to different project types, including standard applications, minimal setups, embedded systems, and projects with Nix Flake integration.
Features
<ul>
<li>Initialize Zig projects with different templates:</li>
<li>Default: Standard Zig project setup</li>
<li>Minimal: Bare-bones Zig project structure</li>
<li>Embedded: Tailored for embedded systems development</li>
<li>Flake: Includes Nix Flake for Zig development environment</li>
<li>Embedded systems support with MicroZig integration</li>
<li>Optional version control system (VCS) initialization (Git, Mercurial, and Jujutsu)</li>
</ul>
Usage
Main Init Command
zo init [OPTIONS]
Initializes a <code>zig build</code> project in the current working directory.
Options:
<ul>
<li><code>-h, --help</code>: Print help and exit</li>
<li><code>-m, --minimal</code>: Initialize a minimal <code>zig build</code> project</li>
<li><code>-f, --flake</code>: Add a basic Nix Flake for creating a Zig dev environment</li>
<li><code>--e, --embedded</code>: Initialize an embedded project</li>
<li><code>--vcs <VCS></code>: Initialize a repo for the specified VCS (git, hg, or jj)</li>
</ul>
Embed Command
zo embed
Subcommands:
<ul>
<li><code>init</code>: Initialize a basic embedded Zig project using MicroZig</li>
</ul>
Options:
<ul>
<li><code>-h, --help</code>: Print help and exit</li>
<li><code>--vcs <VCS></code>: Initialize a repo for the specified VCS (git, hg, or jj)</li>
</ul>
Examples
<ol>
<li>Create a default Zig project:
zo init</li>
<li>Set up a minimal project with Git:
zo init -m --vcs git</li>
<li>Initialize a project with Nix Flake support:
zo init -f</li>
<li>Set up an embedded project using MicroZig:
zo embed init</li>
<li>Initialize an embedded MicroZig project with Mercurial:
zo embed init --vcs hg</li>
</ol>
Installation
The only option right now is from source.
1. Pull repo down
2. Run <code>zig build</code>
3. Move the executable to your $PATH
Dependencies
<ul>
<li>Zig compiler</li>
<li>Git, Mercurial, or Jujutsu (optional, for VCS initialization)</li>
<li>Nix (optional, for Flake support)</li>
<li>MicroZig (for embedded projects)</li>
</ul>
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. | [] |
https://avatars.githubusercontent.com/u/12181586?v=4 | sharkuana | ghostiam/sharkuana | 2024-10-10T23:54:27Z | Sharkuana - Wireshark plugin bindings for the ZIG language | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/ghostiam/sharkuana/tags | MIT | [
"wireshark",
"wireshark-dissector",
"wireshark-plugin",
"zig",
"ziglang"
] | 40 | false | 2024-12-22T23:32:13Z | true | true | unknown | github | [
{
"commit": null,
"name": "wireshark",
"tar_url": null,
"type": "relative",
"url": "wireshark"
}
] | Sharkuana - Wireshark plugin bindings for the ZIG language
A <strong>very early</strong>, API for creating Wireshark plugins in the ZIG language.
At the moment, only the ability to build for MacOS and Linux has been tested,
but as soon as the main functionality is completed, support for Windows will be implemented.
Build Wireshark libraries
To build the Wireshark libraries, you need to have <code>nix</code> installed.
<code>shell
nix develop --command ./scripts/build-wireshark-libs.bash</code>
If you don't have <code>nix</code>, you can use the fallback script
which will try using the
- <code>nix</code>;
- <code>docker</code> with <code>nix</code> (This build will only be for Linux);
- run script locally(You will need to install dependencies manually).
<code>shell
./nix-fallback.bash ./scripts/build-wireshark-libs.bash</code>
Building a minimal plugin
To quickly test the plugin, use the command:
<code>shell
zig build && mkdir -p ~/.local/lib/wireshark/plugins/4-4/epan && cp zig-out/lib/libsharkuana.dylib ~/.local/lib/wireshark/plugins/4-4/epan/libsharkuana.so && /Applications/Wireshark.app/Contents/MacOS/Wireshark --log-domains sharkuana --log-level noisy</code>
License
This project is licensed under the MIT License - see the <a>LICENSE</a> file for details. | [] |
https://avatars.githubusercontent.com/u/60233333?v=4 | zig_zap_explorer | rajrupdasofficial/zig_zap_explorer | 2024-12-25T15:55:32Z | Zig's framework zap based implementation of REST API | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/rajrupdasofficial/zig_zap_explorer/tags | BSD-3-Clause | [
"zap",
"zig",
"ziglang"
] | 5 | false | 2025-04-11T16:42:07Z | true | true | unknown | github | [
{
"commit": "master",
"name": "pg",
"tar_url": "https://github.com/karlseguin/pg.zig/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/karlseguin/pg.zig"
},
{
"commit": "master",
"name": "zap",
"tar_url": "https://github.com/zigzap/zap/archive/master.tar.gz",
... | Zap based REST API project
This project is a REST API project based on the ZAP framework. The project is a simple REST API that allows users to signup and store data in postgresql sql. The project is built using the ZAP framework, which is a lightweight and easy-to-use framework for building REST APIs.
This project is still under construction and is not yet complete. The project is being developed as part of my explorer. | [] |
https://avatars.githubusercontent.com/u/30412223?v=4 | ascii-game-of-life | Kiuh/ascii-game-of-life | 2024-08-19T11:51:18Z | zig terminal app of Conway's game of life with ascii graphics | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/Kiuh/ascii-game-of-life/tags | GPL-3.0 | [
"ascii-graphics",
"conways-game-of-life",
"game-of-life",
"zig",
"ziglang"
] | 1,262 | false | 2024-08-28T18:52:30Z | true | true | 0.13.0 | github | [
{
"commit": "0.9.1.tar.gz",
"name": "clap",
"tar_url": "https://github.com/Hejsil/zig-clap/archive/0.9.1.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/Hejsil/zig-clap"
}
] | Ascii game of life written in zig
A simple terminal implementation of <a>Conway`s game of life</a>. Implemented in <a>zig lang</a>, using <a>clap</a> for command line parsing.
Tested with zig version 0.13.0
Download and build
For downloading you can clone this repo.
<code>git clone https://github.com/Kiuh/ascii-game-of-life</code>
Move to root project directory.
<code>cd ascii-game-of-life</code>
Then build and run game.
<code>zig build run</code>
Run and test
To run application just execute it without arguments.
You can run <code>--help</code> to see run options.
This feature implemented with <code>clap</code> package.
Visual example
https://github.com/user-attachments/assets/32d3eb53-4d83-496d-8468-d435adb11620 | [] |
https://avatars.githubusercontent.com/u/15877106?v=4 | squeezelite | tsirysndr/squeezelite | 2024-08-30T07:05:02Z | Lightweight headless squeezebox player for Lyrion Media Server | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/tsirysndr/squeezelite/tags | NOASSERTION | [
"multiroom-audio",
"squeezebox",
"squeezelite",
"zig"
] | 719 | true | 2024-08-31T21:05:22Z | true | true | unknown | github | [] | Squeezelite v1.9.x, Copyright 2012-2015 Adrian Smith, 2015-2024 Ralph Irving.
See the squeezelite manpage for usage details.
https://ralph-irving.github.io/squeezelite.html
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <a>http://www.gnu.org/licenses/</a>.
Additional permission under GNU GPL version 3 section 7
If you modify this program, or any covered work, by linking or
combining it with OpenSSL (or a modified version of that library),
containing parts covered by the terms of The OpenSSL Project, the
licensors of this program grant you additional permission to convey
the resulting work. {Corresponding source for a non-source form of
such a combination shall include the source code for the parts of
OpenSSL used as well as that of the covered work.}
Contains dsd2pcm library Copyright 2009, 2011 Sebastian Gesemann which
is subject to its own license.
Contains the Daphile Project full dsd patch Copyright 2013-2017 Daphile,
which is subject to its own license.
Option to allow server side upsampling for PCM streams (-W) from
squeezelite-R2 (c) Marco Curti 2015, marcoc1712@gmail.com.
This software uses libraries from the FFmpeg project under
the LGPLv2.1 and its source can be downloaded from
https://sourceforge.net/projects/lmsclients/files/source/ | [] |
https://avatars.githubusercontent.com/u/88404826?v=4 | zutil | twilkinson3421/zutil | 2025-01-08T23:13:54Z | A simple collection of utilities for working with the Zig programming language | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/twilkinson3421/zutil/tags | Unlicense | [
"zig"
] | 2 | false | 2025-01-08T23:14:24Z | true | true | unknown | github | [] | ZUtil
A simple collection of utilities for working with the Zig programming language. Contains documentation in the source code.
Features
For Zig compiler version <code>0.13.0</code>. \
Updated for <em>ZUtil</em> <code>1.0.0</code>.
| Feature | Description |
| --------- | ---------------------------------------------------------------- |
| <code>andCopy</code> | Copies a value to a destination and returns the value. |
| <code>ToInt</code> | Converts a float type to a signed integer type of the same size. |
Installation
To get started, first fetch the library; replace the <code><commit-hash></code> with the commit hash for the version you wish to use:
<code>sh
zig fetch --save github.com/twilkinson3421/zutil/archive/<commit-hash>.tar.gz</code>
Then, add the library to your <code>build.zig</code> file:
<code>zig
const zutil = b.dependency("zutil", .{});
exe.root_module.addImport("zutil", zutil.module("zutil"));</code>
Contributing
Contributions are welcome! Please open an issue or pull request if you have any suggestions or improvements. Feel free to suggest whatever you want, fork the project, or include it in your own project.
License
This project is licensed under the <a>Unlicense</a>. | [
"https://github.com/twilkinson3421/zbinutils"
] |
https://avatars.githubusercontent.com/u/442455?v=4 | cimgui_toggle | dinau/cimgui_toggle | 2025-01-07T08:38:19Z | The wrapper library for C language to use imgui_toggle library written by C++. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/dinau/cimgui_toggle/tags | MIT | [
"cimgui",
"demo",
"example",
"imgui",
"nelua",
"nim",
"sw",
"toggle",
"wrapper",
"zig"
] | 1,879 | false | 2025-05-17T05:30:50Z | false | false | unknown | github | [] |
<ul>
<li><a>cimgui_toggle</a></li>
<li><a>Prerequisites</a></li>
<li><a>Build and run</a></li>
<li><a>Custom window</a></li>
</ul>
cimgui_toggle
<code>cimgui_toggle</code> is C language wrapper for <code>imgui_toggle</code> library
Based on https://github.com/cmdwtf/imgui_toggle
Prerequisites
<ol>
<li>Windows OS </li>
<li>MSys2/MinGW tools installed.
Install at least,</li>
</ol>
<code>sh
pacman -S make mingw-w64-ucrt-x86_64-{gcc,glfw,pkgconf}</code>
<ol>
<li>Linux OS (Ubuntu / Debian families)
Install at least,</li>
</ol>
<code>sh
$ sudo apt install make pkgconf xorg-dev lib{opengl-dev,gl1-mesa-dev,glfw3,glfw3-dev}</code>
<ol>
<li>Git installed</li>
</ol>
Build and run
<ol>
<li>Getting sources</li>
</ol>
<code>sh
git clone --recurse-submodules https://github.com/dinau/cimgui_toggle</code>
<ol>
<li>Build and run C language demo</li>
</ol>
<code>cd cimgui_toggle/demo/c
make run</code>
<ol>
<li>Build and run C++ language demo</li>
</ol>
<code>cd cimgui_toggle/demo/cpp
make run</code>
Custom window
| [] |
https://avatars.githubusercontent.com/u/134714087?v=4 | todo-zig | Kei-K23/todo-zig | 2024-10-04T14:26:36Z | Todo CLI application for learning Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Kei-K23/todo-zig/tags | - | [
"cli",
"todo",
"zig"
] | 4 | false | 2024-10-04T14:33:02Z | true | true | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/85331378?v=4 | STM32-ZIG | RafaelVVolkmer/STM32-ZIG | 2024-10-04T18:17:54Z | An approach to using the Zig language for embedded systems on STMicroeletronics evaluation boards for 32-bit Core M4 MCUs. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/RafaelVVolkmer/STM32-ZIG/tags | GPL-2.0 | [
"baremetal-programming",
"embedded-systems",
"hardware-abstraction-layer",
"registers",
"stm32",
"stm32f4",
"zig"
] | 11 | false | 2024-10-21T20:10:38Z | true | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/131526244?v=4 | singly_linked_list | 7R35C0/singly_linked_list | 2024-11-18T10:09:19Z | The module contains functions used in singly linked lists. | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/7R35C0/singly_linked_list/tags | MIT | [
"linked-list",
"singly-linked-list",
"zig",
"ziglang"
] | 31 | false | 2024-11-21T12:28:34Z | true | true | unknown | github | [] |
README
The module contains functions used in singly linked lists.
These functions do not make assertions, can lead to infinite loops in code and
cycles in nodes or lists.
As a general rule, cycles should be broken before any other changes.
Almost all functions are candidates for applying this rule. Keep this in mind
when infinite loops occur in code and their causes are not very obvious.
Some important facts about cycles:
<ul>
<li>a cycle always starts from the last node of node</li>
<li>where the last node points in node really matter:</li>
<li>to last node, n4 -> n4</li>
<li>to an inner node, n4 -> n2</li>
<li>to first node, n4 -> n0</li>
<li>where we break the cycle really matter, see the demos</li>
<li>any function that involves the last node in some way, for a cycle node or
list, leads to infinite loops in code</li>
</ul>
The code is based on following sources:
<ul>
<li><a>Zig Standard Library</a></li>
<li><a>GitHub</a></li>
</ul>
📌 Implementation
A singly linked list is a linear data structure that includes a series of
connected nodes.
The <code>Node</code> represents the type of nodes in a list
```zig
pub const Node = struct {
data: T,
next: ?*Node = null,
<code> // some implementation code
};
</code>
```
where field:
<ul>
<li><code>data</code> is a value for the node itself</li>
<li><code>next</code> is a pointer to the next node</li>
</ul>
The <code>SinglyLinkedList</code> type has a single field
```zig
pub fn SinglyLinkedList(comptime T: type) type {
return struct {
head: ?*Node = null,
<code> // some implementation code
};
}
</code>
```
where field <code>head</code> is a pointer to the first node in list.
Above structures use an optional pointer <code>?*Node</code>, with default value <code>null</code>.
The meaning of <code>null</code> depends on context:
<ul>
<li>for a list <code>.head == null</code></li>
<li>the list is empty, there are no nodes in list</li>
<li>in many cases this check is done separately, it is a special case for a list</li>
<li>for a node <code>.next == null</code></li>
<li>the node is not linked or is the last node in a list, end of list</li>
<li>general case for this check is when the operations are on a single node,
even if a function accepts only one node as parameter, the node itself can
be linked to another, and another, and so on</li>
<li>the check becomes more important in needs to avoid node cycles, either by
pointing back to the node itself or to another node already existing in list</li>
</ul>
📌 Final note
More information about cycles in nodes and singly linked list can be found in
<a>IMPORTANT</a> file. Also, more detailed examples are in the <code>demo</code> files. | [] |
https://avatars.githubusercontent.com/u/187177835?v=4 | todo | oppensauce/todo | 2024-12-05T09:38:28Z | To-Do List application implemented in various programming languages. | release | 0 | 0 | 0 | 0 | https://api.github.com/repos/oppensauce/todo/tags | MIT | [
"c",
"cpp",
"csharp",
"elixir",
"erlang",
"golang",
"java",
"javascript",
"js",
"programming-languages",
"python",
"rust",
"todo",
"ts",
"typescript",
"zig",
"ziglang"
] | 17 | false | 2024-12-05T09:44:41Z | false | false | unknown | github | [] | Nidexingg To-Do
Welcome to the To-Do List Application repository! This project showcases a simple yet effective To-Do List application implemented in various programming languages. The goal of this project is to demonstrate how similar functionality can be achieved using different programming paradigms and features offered by each language.
Various of Programming Languages Used
This repository contains implementations of the To-Do List application in the following programming languages:
<ul>
<li><strong>C</strong>: High performance and low-level control make it suitable for system-level programming.</li>
<li><strong>C++</strong>: Combines object-oriented features with performance, ideal for complex applications.</li>
<li><strong>C#</strong>: Rich framework support and cross-platform capabilities through .NET enhance development speed.</li>
<li><strong>Rust</strong>: Offers memory safety and concurrency without sacrificing performance.</li>
<li><strong>Go</strong>: Simple syntax with built-in support for concurrency, making it great for scalable applications.</li>
<li><strong>Java</strong>: Platform-independent with a robust ecosystem of libraries and frameworks.</li>
<li><strong>Python</strong>: Easy to learn with extensive libraries, perfect for rapid application development.</li>
<li><strong>JavaScript</strong>: Essential for web development, enabling dynamic user interfaces and asynchronous programming.</li>
<li><strong>TypeScript</strong>: Adds static typing to JavaScript, improving code quality and developer productivity.</li>
<li><strong>Zig</strong>: Low-level control with safety features, allowing for optimized performance at compile time.</li>
<li><strong>Elixir</strong>: Excellent concurrency support and fault tolerance, ideal for real-time applications.</li>
<li><strong>Erlang</strong>: Designed for distributed systems with high availability and fault tolerance.</li>
</ul>
Each implementation includes core features such as:
[x] Adding tasks
[x] Viewing tasks
[x] Removing tasks
[x] Clearing all tasks
[x] Persistent storage as txt files
Features
<ul>
<li><strong>Cross-Language Comparison</strong>: Explore how different programming languages handle similar tasks.</li>
<li><strong>File I/O</strong>: Each implementation demonstrates how to read from and write to files for task persistence.</li>
<li><strong>User Interaction</strong>: All lang versions provide a user-friendly command-line interface for user interaction.</li>
</ul>
Getting Started
To run any of the applications, follow these steps:
1. Clone this repository
<code>bash
git clone https://github.com/nidexingg/todo.git</code>
2. Open your favorite language directory and run the application
C
cd C
and run this command:
gcc app.c -o app && ./app
C++
cd C++
and run this command:
g++ app.cpp -o app
C
cd CSharp
and run this command:
dotnet run app.cs
Rust
cd Rust
and run this command:
cargo run --bin app
Go
cd Go
and run this command:
go run app.go
Java
cd Java
and run this command:
javac app.java && java app
Python
cd Python
and run this command:
python app.py
JavaScript
cd JavaScript
and run this command:
node app.js
TypeScript
cd TypeScript
and run this command:
tsc app.ts && node app.js
Zig
cd Zig
and run this command:
zig build-exe app.zig && ./app
Elixir
cd Elixir
and run this command:
elixir app.exs
Erlang
cd Erlang
and run this command:
erl -s app start -noshell -s init stop | [] |
https://avatars.githubusercontent.com/u/41696364?v=4 | chip8-zig | Crystal4B/chip8-zig | 2025-01-15T19:30:27Z | Chip8 emulator written in zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Crystal4B/chip8-zig/tags | - | [
"chip-emulator",
"chip8",
"zig"
] | 15 | false | 2025-02-08T20:25:47Z | true | true | 0.11.0 | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/2539760?v=4 | zig-ts-interpreter | colevoss/zig-ts-interpreter | 2024-12-12T06:43:37Z | A TypeScript interpreter written in Zig for some fucking reason | main | 1 | 0 | 0 | 0 | https://api.github.com/repos/colevoss/zig-ts-interpreter/tags | - | [
"typescript",
"zig"
] | 18 | false | 2024-12-12T23:10:50Z | true | true | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/177685?v=4 | advent_of_code_2024 | lithammer/advent_of_code_2024 | 2024-12-02T21:27:56Z | Advent of Code 2024 | trunk | 0 | 0 | 0 | 0 | https://api.github.com/repos/lithammer/advent_of_code_2024/tags | MIT | [
"advent-of-code-2024",
"advent-of-code-2024-zig",
"aoc2024",
"zig"
] | 5 | false | 2024-12-13T08:16:35Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/200686?v=4 | zig-sdl3-test | deckarep/zig-sdl3-test | 2024-11-12T20:43:47Z | Bootstrapping Zig to compile against SDL3 | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/deckarep/zig-sdl3-test/tags | - | [
"dylib",
"dynamic-linking",
"framework",
"gamedev",
"macos",
"sdl",
"sdl3",
"zig",
"ziglang"
] | 2,300 | false | 2024-11-12T20:46:26Z | true | true | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/9214692?v=4 | composable-string | vsvsv/composable-string | 2024-10-06T01:10:17Z | A UTF-8 string library made for Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/vsvsv/composable-string/tags | MIT | [
"string",
"utf-8",
"zig"
] | 62 | false | 2025-03-18T01:10:16Z | true | true | unknown | github | [] | composable-string
A work-in-progress string library for the Zig programming language
<a></a>
<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 library is a work-in-progress! Future API changes might break backward compatibility. Please use it at your own risk.
</blockquote>
Goals (a. k. a. Why another one?)
This library was created as an attempt to write the missing UTF-8 string processing library for the Zig programming language.
The main priority is to design the simplest and hassle-free API possible, which closely resembles standard library APIs.
Because of manual memory management in Zig, many existing libraries tend to overcomplicate their interfaces
by making them overly explicit, which makes usage of such libraries very unfun.
For such an essential language feature as string processing, library users should be able to concentrate on the actual logic
of the application, rather than constantly performing a correct ritual for low-level APIs, e. g. preparing and passing
a correct allocator <em>every time</em> for trivial actions such as string concatination or trimming.
Main design goals:
* Full UTF-8 support by default
* Do not reinvent the wheel; use functions from <code>std</code> for an already implemented logic, otherwise, adapt already proven effecient UTF-8 algorithms
* API should as simple and minimalist as possible
Usage
Library is implemented in a single file <code>src/composable-string.zig</code>.
<code>Str</code> struct provides <em>mutable</em> string implementation with common methods:
```zig
const std = @import("std");
const Str = @import("composable-string.zig").Str;
pub fn main() !void {
// Use your favorite allocator
const a = std.heap.c_allocator;
<code>var str = try Str.init(a, "Hello");
defer str.deinit();
try str.concat(", composable-string!");
var another = try Str.initFmt(a, " (this is {s} {s})", .{"concatinated", "Str"});
defer another.deinit();
try str.concat(another);
std.debug.print("str = {}\n", .{str});
var str_with_spaces = try Str.initFmt(a, " A string with {s} \t\n\t\n ", .{"whitespaces, newlines and tabs"});
defer str_with_spaces.deinit();
str_with_spaces.trim();
std.debug.print("'str_with_spaces' after trim(): \"{s}\"\n", .{str_with_spaces});
var non_ascii = try Str.init(a, "Один, 二, さん"); // character count: 11
defer non_ascii.deinit();
std.debug.print(
"Non-ascii string: \"{}\", length in bytes: {}, length in characters: {}\n",
.{ non_ascii, non_ascii.byteCount(), non_ascii.charCount() },
);
</code>
}
```
Checklist of implemented functions
<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>Str.init</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>Str.initFmt</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>Str.initEmpty</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>Str.deinit</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>Str.capacity</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>Str.set</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>Str.clear</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>Str.clone</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>Str.concat</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>Str.concatFmt</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>Str.trim</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>Str.trimStart</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>Str.trimEnd</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>Str.asSlice</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>Str.byteCount</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>Str.charCount</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>Str.isValidUTF8</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>Str.iterator</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>Str.writer</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>Str.fixedWriter</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>Str.toUpperCase</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>Str.toLowerCase</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>Str.capitalize</code>
Supported Zig versions
The <code>master</code> branch tries to support the most recent <a>Zig</a> version from <code>master</code> branch.
Alternatives
<ul>
<li><a>JakubSzark/zig-string</a></li>
<li><a>dude_the_builder/zigstr</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/146390816?v=4 | cpputest | allyourcodebase/cpputest | 2024-12-27T14:08:23Z | Package for CppUTest | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/allyourcodebase/cpputest/tags | MIT | [
"zig",
"zig-package"
] | 2 | false | 2025-01-12T13:10:51Z | true | true | unknown | github | [
{
"commit": "refs",
"name": "cpputest",
"tar_url": "https://github.com/cpputest/cpputest/archive/refs.tar.gz",
"type": "remote",
"url": "https://github.com/cpputest/cpputest"
}
] | CppUTest Zig
Using zig build system to build <a>CppUTest</a> unit test library.
Adding It to your project
First update your <em>build.zig.zon</em> with:
<code>bash
zig fetch --save git+https://github.com/lcp5y3/cpputest-zig.git#v4.0.0</code>
After that you can link <code>CppUTest</code> with your project by adding the following
lines to your <code>build.zig</code>
```zig
const cpputest_dep = b.dependency("cpputest_zig", .{
.target = target,
.optimize = optimize,
});
exe.linkLibrary(cpputest_dep.artifact("CppUTest"));
exe.linkLibrary(cpputest_dep.artifact("CppUTestExt"));
```
Building the lib
If you only want to build CppUTest to get .a and header, run:
<code>bash
zig build</code> | [
"https://github.com/allyourcodebase/cpputest"
] |
https://avatars.githubusercontent.com/u/78876133?v=4 | cfmt | IOKG04/cfmt | 2025-01-26T18:53:16Z | sprintf() like formatting entirely in zig - sometimes std.fmt is just too weak | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/IOKG04/cfmt/tags | 0BSD | [
"formatting",
"sprintf-style",
"zig"
] | 15 | false | 2025-01-27T09:20:40Z | true | false | unknown | github | [] | cfmt
Zig's <code>@import("std").fmt</code> may be good, but in some cases you just need a little bit more functionality.
Now why not just link in <code>libc</code> and use <code>sprintf()</code> and such?
Either because you are on some device where there isn't (yet) a <code>libc</code> to link against,
because you just don't <em>want</em> to link against <code>libc</code>,
or lastly because you're using some types c doesn't understand (<code>u19</code>, <code>f128</code>, etc.) and want a native zig solution.
That being said, this is not a drop in replacement, the format specifiers are a little different from c's.
I did design them to be as close as possible though, requiring little rethinking if you're already used to c.
A lot of what's written here isn't implemented yet, I am working on it though.
Also any ideas are appreciated, making this more feature rich would be nice :3
Also also, I will add a <code>build.zig.zon</code> once this can be reasonably used as a library.
Might even make it so you can compile it to a static/dynamic library to use with other languages.
Format specifier
Format specifiers in <code>cfmt</code> look something like this:
<code>zig
"%s" // a string
"%.4f" // a floating-point value rounded to 4 digits after the period
"%-4.8i" // a left alligned integer of at least 4 and at most 8 digits</code>
They can be split into five parts in this exact order:
A <code>%</code> character,
<a>flags</a>,
<a>minimum width</a>,
<a>precision</a> and lastly
the <a>specifier</a>.
All besides the specifier are optional.
The only exception to this is the specifier for writing a <code>%</code> character, which is <code>%%</code>.
Specifiers
Specifiers tell <code>cfmt</code> what kind of type you're formatting and how you want it formatted.
The following specifiers exist:
<strong>Integers:</strong>
- <code>i</code>: Decimal integer
- <code>b</code>: Binary integer
- <code>o</code>: Octal integer
- <code>x</code>: Hexadecimal integer (lowercase)
- <code>X</code>: Hexadecimal integer (uppercase)
<strong>Floating-point:</strong>
- <code>f</code>: Decimal floating-point
<strong>Other:</strong>
- <code>s</code>: String
- <code>c</code>: Character
- <code>p</code>: Pointer (hexadecimal lowercase)
- <code>P</code>: Pointer (hexadecimal uppercase)
<strong>Special:</strong>
*cricket noises*
For better compatibility with c's format specifiers, <code>d</code> and <code>u</code> work the same as <code>i</code>.
Minimum width
If a minimum width is specified and the formatted string isn't that long, the string will be padded with space characters.
The minimum width can either be a decimal number, such as <code>4</code>, <code>9</code> or <code>142</code>,
or a <code>*</code>, in which case an <code>usize</code> is read from the arguments and its value is used as the minimum width.
If a <code>*</code> is used, the dynamic minimum width must be given before the value to be formatted (and the dynamic precision if used).
Please note that the decimal number may not have a leading zero as that could interfere with the <a><code>0</code> flag</a>.
By default, the formatted contents will be right alligned (space characters on the left),
though this behavior can be changed with the <a><code>-</code> flag</a>.
Precision
What exactly <em>precision</em> means depends on the type to be formatted:
If it's a floating point value, precision is the amount of digits after the decimal separator.
If it's a string, precision defines the maximum amount of characters written.
When truncation happens, the last characters are cut off.
If it's a character, it will be repeated <em>precision</em> times.
Does it make sense to call that precision? No.
Could it still be a useful functionality? Yes.
For any other type, precision doesn't do anything.
To set the precision, a <code>.</code> followed by a number or a <code>*</code> is used, similar to <a>minimum width</a> except with a <code>.</code> character.
Here however, the precision is put <em>between</em> the dynamic minimum width and value to be formatted.
If neither a <code>*</code> or a number follows the <code>.</code>, precision is set to <code>0</code>.
Flags
Flags change some parts of formatting.
The following flags exist:
- <code>-</code>: Allign to the left instead of right (space characters on the right)
- <code>+</code>: Always write <code>+</code> and <code>-</code> sign for numeric types
- <code></code>: (space) Write a space character at start of positive numeric values
- <code><</code>: Write sign before any padding
- <code>0</code>: Pad with <code>0</code> characters instead of space characters
| [] |
https://avatars.githubusercontent.com/u/12974685?v=4 | loxig | kemingy/loxig | 2024-09-29T15:37:57Z | A Lox language interprete implemented in Zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/kemingy/loxig/tags | - | [
"interpreter",
"learning-by-doing",
"zig",
"ziglang"
] | 62 | false | 2024-11-05T09:44:49Z | true | true | 0.13.0 | github | [] | LoXig
This is a <a>Lox</a> interpreter written in Zig.
This is a starting point for Zig solutions to the
<a>"Build your own Interpreter" Challenge</a>.
This challenge follows the book
<a>Crafting Interpreters</a> by Robert Nystrom. | [] |
https://avatars.githubusercontent.com/u/34104395?v=4 | zdb | skytwosea/zdb | 2025-01-01T03:36:36Z | functional translation to Zig of Sy Brand's sdb: Building a Debugger (No Starch Press) | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/skytwosea/zdb/tags | - | [
"debugger",
"zig"
] | 8 | false | 2025-01-10T15:46:41Z | true | true | unknown | github | [
{
"commit": null,
"name": "libzdb",
"tar_url": null,
"type": "relative",
"url": "lib"
}
] | debian
requires libedit.dev : apt install libedit-dev | [] |
https://avatars.githubusercontent.com/u/108023692?v=4 | bench_web_server_v1.1 | Hayatto9217/bench_web_server_v1.1 | 2024-11-26T13:39:30Z | 各言語でのベンチマークからわかる考察 | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/Hayatto9217/bench_web_server_v1.1/tags | MIT | [
"benchmark",
"deno",
"go",
"rust",
"zig"
] | 4,143 | false | 2024-11-27T02:51:21Z | false | false | unknown | github | [] | Deno, Go, Rust, Zig: A Benchmark 考察入り
Intro
Zig のOS自作中にふと気がついたのですが,Webでベンチマークするとどれぐらいの比較があるのか確認したくなりました。
*ZigのVersionが変更されたことによって、標準ライブラリーが削除されているという...(先月修正したばかりなのに)
StreamServerライブラリが削除されている.....
ベンチマーク
| Language | Requests per second | Time per request |
| :------- | :---------------------- | :---------------- |
| deno | 32913.58 [#/sec] (mean) | 0.304 [ms] (mean) |
| go | 85736.82 [#/sec] (mean) | 0.117 [ms] (mean) |
| node | 11187.35 [#/sec] (mean) | 0.894 [ms] (mean) |
| rust | 20267.08 [#/sec] (mean) | 0.493 [ms] (mean) |
| zig | <strong>測定不能</strong> | <strong>測定不能</strong> |
ということで、<strong>Go が一番速い</strong>
<strong>注意</strong>
<strong>この計測は、特定の言語やフレームワークを批判するものではないので
それぞれの言語やフレームワークには、それぞれの良いところ、悪いところがあると思っていますのでご了承ください。
また、計測方法や各言語の最適化ができていないと思います。
間違いがあったときは申し訳ございません。</strong>
ベンチマークの実行
install(MacOSで検証)
<code>sh
brew install httpd</code>
run
<code>sh
ab -k -c 10 -n 100000 http://127.0.0.1:3000/</code>
ベンチマークのコード
Go
```go
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html")
fmt.Fprintf(w, "
Hello World")
})
http.ListenAndServe(":3000", nil)
}
```
Rust
```rust
use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};
use std::thread;
fn main() {
let listener = TcpListener::bind("127.0.0.1:3000").unwrap();
println!("Server running on 127.0.0.1:3000");
<code>for stream in listener.incoming() {
let stream = stream.unwrap();
thread::spawn(move || {
handle_connection(stream);
});
}
</code>
}
fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 1024];
<code>// request
if let Err(e) = stream.read(&mut buffer) {
eprintln!("Failed to read from stream: {}", e);
return;
}
// HTTPレスポンス
let response = b"HTTP/1.1 200 OK\r\n\r\n<h1>Hello World</h1>";
if let Err(e) = stream.write(response) {
eprintln!("Failed to write to stream: {}", e);
return;
}
if let Err(e) = stream.flush() {
eprintln!("Failed to flush stream: {}", e);
return;
}
</code>
}
```
Zig
```zig
const std = @import("std");
const net = std.net;
const StreamServer = net.StreamServer;
const Address = net.Address;
pub const io_mode = .evented;
pub fn main() anyerror!void {
var stream_server = StreamServer.init(.{});
defer stream_server.close();
const address = try Address.resolveIp("127.0.0.1", 3000);
try stream_server.listen(address);
while (true) {
const client = try stream_server.accept();
const response = "HTTP/1.1 200 OK\r\n\r\n
Hello World";
try client.write(response);
}
}
```
Deno
```ts
const server = Deno.listen({ port: 3000 });
for await (const conn of server) {
serveHttp(conn);
}
async function serveHttp(conn: Deno.Conn) {
const httpConn = Deno.serveHttp(conn);
for await (const requestEvent of httpConn) {
const body = "
Hello World";
requestEvent.respondWith(
new Response(body, {
status: 200,
})
);
}
}
```
Makefile
```makefile
.phony:
build-go:
go build go/main.go && ./main
build-rust:
rustc rust/main.rs && ./main
build-zig:
zig build-exe zig/main.zig && ./main
run-go:
go run go/main.go
run-deno:
deno run --allow-net deno/main.ts
bench:
ab -k -c 10 -n 10000 http://127.0.0.1:3000/
bench-go:
ab -k -c 10 -n 10000 http://127.0.0.1:3000/ > bench/go.txt
bench-rust:
ab -k -c 10 -n 10000 http://127.0.0.1:3000/ > bench/rust.txt
bench-deno:
ab -k -c 10 -n 10000 http://127.0.0.1:3000/ > bench/deno.txt
bench-zig:
ab -k -c 10 -n 10000 http://127.0.0.1:3000/ > bench/zig.txt
check-port:
echo 'sudo lsof -i :3000'
stop apachectl stop command
'sudo apachectl stop'
```
考察
各処理系のバージョンを明記しておいて他の方が同じ条件で追試を行うことが重要かと思った。
abだと遅いので、他のベンチマークツールがあると教えていただきたいです。
そもそもベンチマークまとめたリポジトリとかってあるのかな...
自分が知る限りはShell自作するとかしてやりたいところ
試したいリスト
https://github.com/codesenberg/bombardier
bunもやってみるといいのかもしれない
Denoも'Deno.serve'を使うと速いかなと思ったりして。
雑談
Rust の場合ですが、そもそも TCPListener でのシングルスレッド処理なので遅いのは仕方ないのかなという気持ちです。非同期処理したいなら、パッケージ入れるしかないかなと... | [] |
https://avatars.githubusercontent.com/u/1970306?v=4 | zig_how_it_works | rustkas/zig_how_it_works | 2024-12-03T09:02:38Z | Исходные коды к статье о языке программирования Zig "Как работает Zig?" | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/rustkas/zig_how_it_works/tags | - | [
"tutorial",
"zig",
"ziglang"
] | 9 | false | 2024-12-03T10:05:05Z | true | true | unknown | github | [] | Как работает Zig?
Исходные коды к статье о языке программирования Zig <a>"Как работает Zig?"</a>
<a>Оригинал статьи</a>
<a>Исходный код автора</a>
Создание нового проекта:
<code>zig init</code> | [] |
https://avatars.githubusercontent.com/u/18556?v=4 | aoc.zig | derveloper/aoc.zig | 2024-12-03T20:03:13Z | advent of code in zig | main | 0 | 0 | 0 | 0 | https://api.github.com/repos/derveloper/aoc.zig/tags | - | [
"advent-of-code",
"adventofcode",
"aoc",
"zig"
] | 34 | false | 2024-12-09T20:46:17Z | true | true | unknown | github | [
{
"commit": null,
"name": "ansi",
"tar_url": null,
"type": "remote",
"url": "zig-ansi"
}
] | 404 | [] |
https://avatars.githubusercontent.com/u/6529548?v=4 | Valdala | TheOnlySilverClaw/Valdala | 2024-09-20T15:58:32Z | null | development | 0 | 0 | 0 | 0 | https://api.github.com/repos/TheOnlySilverClaw/Valdala/tags | BSD-3-Clause | [
"3d-game",
"game",
"voxel-game",
"webgpu",
"zig"
] | 17,091 | false | 2025-05-20T20:06:49Z | true | true | 0.14.0 | github | [
{
"commit": "main.zip",
"name": "TrueType",
"tar_url": "https://codeberg.org/andrewrk/TrueType/archive/main.zip.tar.gz",
"type": "remote",
"url": "https://codeberg.org/andrewrk/TrueType"
},
{
"commit": "develop.zip",
"name": "webgpu",
"tar_url": "https://codeberg.org/Silverclaw/z... | Valdala
Valdala is supposed to become a game... eventually.
Currently, it is primarly my excuse to tinker with technologies I'm interested in.
How it started
Like most of my projects, the idea started with me being unsatisfied with something. In this case, Minecraft.
I liked building houses and towns, but after a construction project was finished, it was just... there... decoratively.
There's no practical real reason in Minecraft to build anything fancy.
A slightly bigger hole in the ground could contain everything you would need to survive the game.
Also, modding in Minecraft has so many unnecessary hoops to jump through, it's a miracle the community managed to do it.
That said, Valdala will not be: a Minecraft clone or a generic voxel renderer demo.
The goal is to create a solid base engine focused on performance, maintainability and extensibility from the ground up.
Something like <a>Luanti</a>, <a>Terasology</a> or <a>Vintage Story</a>, just... my own.
And while I'm aware I could just be modding one of those... I don't wanna.
And on top of that, provide core plugins forming a coherent and distinct game experience.
Idea
Valdala plays in a procedurally generated 3D world made of blocks.
You start with some basic survival gear and have to sustain yourself by gathering ressources.
You can craft basic tools and weapons and build basic shelter by yourself.
However, to get a stable source of food, more sophisticated equipment and solid housing, you need help of villagers.
Countless hostile creatures roam the world and most villagers are willing to work for you in exchange for protection.
You can guide your loyal villagers to develop their settlement, establish diplomatic ties with friendly neighbors and fight monsters and bandits to protect your towns and trade routes.
Technology
I want to build Valdala on a foundation of high quality, future-proof technologies and as few external dependencies as reasonably possible.
Currently, the tech stack looks like this:
<ul>
<li><a>Zig</a> as the primary programming language for the engine</li>
<li>a fast, modern, type-safe and expressive scripting language (<a>to be decided</a>)</li>
<li><a>WebGPU</a> via wgpu-native as a cross-platform graphics API</li>
<li><a>GLFW</a> for cross-platform window management and input handling</li>
<li>well supported open source file formats for everything, like <a>QOI</a> for textures, <a>glTF</a> for 3D assets, etc.</li>
</ul>
Help Appreciated
Valdala is a passion project and I'm willing to spend countless hours trying to make it work on my own.
However, if anyone is willing to help out and learn a thing or two on the way, I'd appreaciate that.
Since this project does not generate revenue and probably never will, there's no promise of compensation beyond that.
Contribution Guildelines
Zig version
The project currently builds with Zig version 0.14.0
I recommend to use the same one locally, as you might have issues with the build system and other breaking changes otherwise.
Formatting
We generally follow the official Zig style guide: https://ziglang.org/documentation/0.14.0/#Style-Guide
Additionally, please make use of extra line breaks after function signatures and between bigger blocks of logic.
Try to avoid abbreviations unless the names would get really unwieldy otherwise.
Declaration order
This is not too strictly enforced, but I generally try to keep this order per file:
<ol>
<li>import std</li>
<li>imports of other Zig standard libary modules</li>
<li>imports of project dependencies</li>
<li>imports of project modules</li>
<li>imported functions</li>
<li>imported types</li>
<li>simple nested types, like Error</li>
<li><code>Self = @This</code></li>
<li>constants</li>
<li>functions</li>
</ol>
Changes
Small changes like typos and formatting of few lines can be made directly on the development branch.
For bigger changes, please create a separate branch and then a pull request.
Try to keep pull requests focused on a task, preferably linked to an issue.
In particular, seprate new features and other impprovements from bigger renaming, reorganizing and reformatting sprees.
Dependencies
Try to keep the dependency on third parties to a minimum.
If feasible, we write and maintain it ourselves.
If maintaing a certain feature is too much work, prefer dependencies that are:
- up to date with our Zig version
- actively maintained
- focused on a specific task
Ask before adding new dependencies.
Current State
Tile grid works!
| [] |
https://avatars.githubusercontent.com/u/73619102?v=4 | aoc-2023 | benyakirten/aoc-2023 | 2024-09-14T21:36:27Z | Advent of code 2023 | main | 1 | 0 | 0 | 0 | https://api.github.com/repos/benyakirten/aoc-2023/tags | MIT | [
"advent-of-code-2023",
"zig"
] | 134 | false | 2024-09-29T11:54:05Z | false | false | unknown | github | [] | Advent of Code 2023
I have recently found myself with the desire to try out advent of code. Since I don't really want to start an entirely new project at this time, I figure this is a good place as any to get practice with Zig. | [] |
https://avatars.githubusercontent.com/u/37193744?v=4 | tzfile | nicolasbauw/tzfile | 2025-01-26T16:56:59Z | Low level parsing of system timezone files. | master | 0 | 0 | 0 | 0 | https://api.github.com/repos/nicolasbauw/tzfile/tags | MIT | [
"iana",
"parse",
"timezome",
"tz",
"tzfile",
"zig"
] | 37 | false | 2025-03-02T14:15:20Z | true | true | unknown | github | [] | tzfile
This library reads the system timezone information files (TZ Files) provided by IANA, and returns its data arranged in a struct.
The TZfile fields are described in the man page (<a>http://man7.org/linux/man-pages/man5/tzfile.5.html</a>). | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.