Unnamed: 0 int64 0 0 | repo_id stringlengths 5 186 | file_path stringlengths 15 223 | content stringlengths 1 32.8M ⌀ |
|---|---|---|---|
0 | repos | repos/tokamak/README.md | # tokamak
> I wrote a short blog post about the **[motivation and the design of the
> framework](https://tomsik.cz/posts/tokamak/)**
>
> I am doing some breaking changes, so maybe check one of the [previous
> versions](https://github.com/cztomsik/tokamak/tree/629dfd45bd95f310646d61f635604ec393253990)
> if you want to ... |
0 | repos | repos/tokamak/build.zig.zon | .{
.name = "tokamak",
.version = "0.0.1",
.paths = .{
"build.zig",
"build.zig.zon",
"src",
"LICENSE",
"README.md",
},
}
|
0 | repos | repos/tokamak/build.zig | const std = @import("std");
const log = std.log.scoped(.tokamak);
pub fn build(b: *std.Build) !void {
const embed = b.option([]const []const u8, "embed", "Files to embed in the binary") orelse &.{};
const root = b.addModule("tokamak", .{
.root_source_file = .{ .path = "src/main.zig" },
});
tr... |
0 | repos/tokamak | repos/tokamak/example/build.zig.zon | .{
.name = "example",
.version = "0.0.0",
.dependencies = .{ .tokamak = .{ .path = ".." } },
.paths = .{
"",
},
}
|
0 | repos/tokamak | repos/tokamak/example/build.zig | const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "src/example.zig" },
.target = target,
... |
0 | repos/tokamak/example | repos/tokamak/example/src/example.zig | const std = @import("std");
const tk = @import("tokamak");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var server = try tk.Server.start(gpa.allocator(), handler, .{ .port = 8080 });
server.wait();
}
const handler = tk.chain(.{
tk.logger(.{}),
... |
0 | repos/tokamak | repos/tokamak/src/response.zig | const std = @import("std");
const Request = @import("request.zig").Request;
pub const Response = struct {
req: *Request,
responded: bool = false,
keep_alive: bool = true,
sse: bool = false,
status: std.http.Status = .ok,
headers: std.ArrayList(std.http.Header),
out: ?std.http.Server.Respons... |
0 | repos/tokamak | repos/tokamak/src/server.zig | const std = @import("std");
const log = std.log.scoped(.server);
const Injector = @import("injector.zig").Injector;
const Request = @import("request.zig").Request;
const Response = @import("response.zig").Response;
pub const Options = struct {
injector: Injector = .{},
hostname: []const u8 = "127.0.0.1",
p... |
0 | repos/tokamak | repos/tokamak/src/middleware.zig | const std = @import("std");
const Context = @import("server.zig").Context;
const Handler = @import("server.zig").Handler;
/// Returns a middleware that executes given steps as a chain. Every step should
/// either respond or call the next step in the chain.
pub fn chain(comptime steps: anytype) Handler {
const han... |
0 | repos/tokamak | repos/tokamak/src/monitor.zig | const std = @import("std");
const log = std.log.scoped(.monitor);
/// Runs the given processes in parallel, restarting them if they exit.
///
/// The processes are tuples of the form:
/// .{ "name", &fn, .{ ...args } }
///
/// Example:
/// pub fn main() !void {
/// // do some init checks and setup if need... |
0 | repos/tokamak | repos/tokamak/src/main.zig | const std = @import("std");
pub const config = @import("config.zig");
pub const monitor = @import("monitor.zig").monitor;
pub const Injector = @import("injector.zig").Injector;
pub const Server = @import("server.zig").Server;
pub const ServerOptions = @import("server.zig").Options;
pub const Handler = @import("server... |
0 | repos/tokamak | repos/tokamak/src/config.zig | const std = @import("std");
const log = std.log.scoped(.config);
const DEFAULT_PATH = "config.json";
const ReadOptions = struct {
path: []const u8 = DEFAULT_PATH,
cwd: ?std.fs.Dir = null,
parse: std.json.ParseOptions = .{ .ignore_unknown_fields = true },
};
pub fn read(comptime T: type, allocator: std.me... |
0 | repos/tokamak | repos/tokamak/src/request.zig | const std = @import("std");
pub const Request = struct {
allocator: std.mem.Allocator,
raw: std.http.Server.Request,
method: std.http.Method,
path: []const u8,
query_params: []const QueryParam,
pub const QueryParam = struct {
name: []const u8,
value: []const u8,
};
pub... |
0 | repos/tokamak | repos/tokamak/src/mime.zig | const root = @import("root");
const std = @import("std");
// This can be overridden in your root module (with `pub const mime_types = ...;`)
// and it doesn't have to be a comptime map either
pub const mime_types = if (@hasDecl(root, "mime_types")) root.mime_types else std.ComptimeStringMap([]const u8, .{
.{ ".htm... |
0 | repos/tokamak | repos/tokamak/src/injector.zig | const std = @import("std");
/// Hierarchical, stack-based dependency injection context implemented as a
/// fixed-size array of (TypeId, *anyopaque) pairs.
///
/// The stack structure is well-suited for middleware-based applications, as it
/// allows for easy addition and removal of dependencies whenever the scope
///... |
0 | repos/tokamak | repos/tokamak/src/router.zig | const std = @import("std");
const Context = @import("server.zig").Context;
const Handler = @import("server.zig").Handler;
const chain = @import("middleware.zig").chain;
/// Returns GET handler which can be used as middleware.
pub fn get(comptime pattern: []const u8, comptime handler: anytype) Handler {
return rout... |
0 | repos/tokamak | repos/tokamak/src/static.zig | const builtin = @import("builtin");
const embed = @import("embed");
const std = @import("std");
const mime = @import("mime.zig").mime;
const Context = @import("server.zig").Context;
const Handler = @import("server.zig").Handler;
const E = std.ComptimeStringMap([]const u8, kvs: {
var res: [embed.files.len]struct { ... |
0 | repos | repos/zig-idioms/README.md | # Zig idioms
[](https://github.com/zigcc/zig-idioms/actions/workflows/ci.yml)
> Zig, despite its simplicity, harbors unique features rarely found in other programming languages. This project aims to collect these techniques, serving as a valua... |
0 | repos/zig-idioms | repos/zig-idioms/examples/build.zig | const std = @import("std");
pub fn build(b: *std.Build) !void {
var run_all_step = b.step("run-all", "Run all examples");
inline for (1..4) |num| {
// This will padding number like 01, 02, .. 99
const seq = std.fmt.comptimePrint("{d:0>2}", .{num});
const exe = b.addExecutable(.{
... |
0 | repos/zig-idioms/examples | repos/zig-idioms/examples/src/02.zig | const std = @import("std");
const Rect = struct {
w: usize,
h: usize,
fn init(w: usize, h: usize) Rect {
return .{ .w = w, .h = h };
}
fn getArea(self: Rect) usize {
return self.w * self.h;
}
};
pub fn main() !void {
const rect = Rect.init(1, 2);
std.debug.print("Area... |
0 | repos/zig-idioms/examples | repos/zig-idioms/examples/src/03.zig | const std = @import("std");
const Rect = struct {
w: usize,
h: usize,
};
const Color = enum { Red, Green, Blue };
fn mySquare(x: usize) usize {
return x * x;
}
pub fn main() !void {
const rect: Rect = .{ .w = 1, .h = 2 };
const rect2 = .{ .w = 1, .h = 2 };
std.debug.print("Type of rect is {a... |
0 | repos/zig-idioms/examples | repos/zig-idioms/examples/src/Foo.zig | pub var a: usize = 1;
b: usize,
const Self = @This();
pub fn inc(self: *Self) void {
self.b += 1;
}
|
0 | repos/zig-idioms/examples | repos/zig-idioms/examples/src/01.zig | const std = @import("std");
const Foo = @import("Foo.zig");
pub fn main() !void {
var foo = Foo{ .b = 100 };
std.debug.print("Type of Foo is {any}, foo is {any}\n", .{
@TypeOf(Foo),
@TypeOf(foo),
});
foo.inc();
std.debug.print("foo.b = {d}\n", .{foo.b});
}
|
0 | repos | repos/ArrayVec/CODE_OF_CONDUCT.md | # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex ch... |
0 | repos | repos/ArrayVec/README.md | # ArrayVec
[](https://opensource.org/licenses/MIT)

A library with an ArrayList-like API, except its a static array |
0 | repos | repos/ArrayVec/build.zig | const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const lib = b.addStaticLibrary("ArrayVec", "src/array.zig");
lib.setBuildMode(mode);
var main_tests = b.addTest("src/array.zig");
main_tests.setBuildMode(mode);
const test_s... |
0 | repos/ArrayVec | repos/ArrayVec/src/array.zig | pub const ArrayError = error{CapacityError};
pub fn ArrayVec(comptime T: type, comptime SIZE: usize) type {
return struct {
array: [SIZE]T,
length: usize,
const Self = @This();
fn set_len(self: *Self, new_len: usize) void {
self.length = new_len;
}
///... |
0 | repos | repos/zig-overlay/shell.nix | (import
(
let
flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat;
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz";
sha256 = flake-compat.locked.narHash;
}
)
{src = ./.;})
.she... |
0 | repos | repos/zig-overlay/default.nix | {
pkgs ? import <nixpkgs> {},
system ? builtins.currentSystem,
}: let
inherit (pkgs) lib;
sources = builtins.fromJSON (lib.strings.fileContents ./sources.json);
# mkBinaryInstall makes a derivation that installs Zig from a binary.
mkBinaryInstall = {
url,
version,
sha256,
}:
pkgs.stdenv.m... |
End of preview. Expand in Data Studio
Zig LLama
This dataset is used to fine-tune meta-llama/Meta-Llama-3.1-8B-Instruct.
Dataset Details
The dataset uses ~1100 of the most popular and recently updated Zig repos on GitHub.
Dataset Sources
The full list of source repos used.
The folder of source repos used.
- Downloads last month
- 14