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... |
0 | repos | repos/zig-overlay/sources.json | {
"master": {
"2021-02-13": {
"x86_64-linux": {
"url": "https://ziglang.org/builds/zig-linux-x86_64-0.8.0-dev.1140+9270aae07.tar.xz",
"version": "0.8.0-dev.1140+9270aae07",
"sha256": "b86aea4d977e3e42f3b226ca3a4618c964fd6e03d1bbddbcae78f369f1facf0e"
},
"aarch64-linux": {
... |
0 | repos | repos/zig-overlay/README.md | # Nix Flake for Zig
This repository is a Nix flake packaging the [Zig](https://ziglang.org)
compiler. The flake mirrors the binaries built officially by Zig and
does not build them from source.
This repository is meant to be consumed primarily as a flake but the
`default.nix` can also be imported directly by non-flak... |
0 | repos | repos/zig-overlay/flake.nix | {
description = "Zig compiler binaries.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
# Used for shell.nix
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nix... |
0 | repos | repos/zig-overlay/flake.lock | {
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type... |
0 | repos/zig-overlay/templates | repos/zig-overlay/templates/init/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/zig-overlay/templates | repos/zig-overlay/templates/init/flake.nix | {
description = "An empty project that uses Zig.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
zig.url = "github:mitchellh/zig-overlay";
# Used for shell.nix
flake-compat = {
url = "github:edolstra/flake-compat";
flak... |
0 | repos/zig-overlay/templates | repos/zig-overlay/templates/compiler-dev/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/zig-overlay/templates | repos/zig-overlay/templates/compiler-dev/flake.nix | {
description = "Zig compiler development.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Used for shell.nix
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,... |
0 | repos/zig-overlay/templates | repos/zig-overlay/templates/compiler-dev/flake.lock | {
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type... |
0 | repos | repos/astroz/README.md | # ASTROZ
[![CI][ci-shd]][ci-url]
[![CD][cd-shd]][cd-url]
[![DC][dc-shd]][dc-url]
<img src="https://repository-images.githubusercontent.com/819657891/291c28ef-4c03-4d0e-bb0c-41d4662867c3" width="100" height="100"/>
## Astronomical and Spacecraft Toolkit Written in Zig for Zig!
### Features / Plans
#### Spacecraft
... |
0 | repos | repos/astroz/build.zig.zon | .{
.name = "astroz",
.version = "0.1.0",
.dependencies = .{
.zigimg = .{
.url = "git+https://github.com/zigimg/zigimg/?ref=HEAD#d9dbbe22b5f7b5f1f4772169ed93ffeed8e8124d",
.hash = "122013646f7038ecc71ddf8a0d7de346d29a6ec40140af57f838b0a975c69af512b0",
},
.cfits... |
0 | repos | repos/astroz/build.zig | const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const root_source_file = b.path("src/lib.zig");
// Module
const astroz_mod = b.addModule("astroz", .{
.target = target,
.optim... |
0 | repos/astroz | repos/astroz/src/Spacecraft.zig | //! Base struct that takes the inputs needed to determine future orbit paths.
const std = @import("std");
const Tle = @import("Tle.zig");
const Datetime = @import("Datetime.zig");
const constants = @import("constants.zig");
const calculations = @import("calculations.zig");
const CelestialBody = constants.CelestialBody... |
0 | repos/astroz | repos/astroz/src/calculations.zig | const std = @import("std");
const Tle = @import("Tle.zig");
const OrbitalElements = @import("Spacecraft.zig").OrbitalElements;
const constants = @import("constants.zig");
pub fn degreesToRadians(degrees: f64) f64 {
return (degrees * std.math.pi) / 180.0;
}
pub fn radiansToDegrees(degrees: f64) f64 {
return (d... |
0 | repos/astroz | repos/astroz/src/Ccsds.zig | //! CCSDS Data Structure.
const std = @import("std");
const Ccsds = @This();
header: HeaderMetadata,
primary_header: []const u8,
secondary_header: ?[]const u8,
packets: []const u8,
raw_data: []const u8,
allocator: std.mem.Allocator,
pub fn init(pl: []const u8, allocator: std.mem.Allocator, config: ?Config) !Ccsds {... |
0 | repos/astroz | repos/astroz/src/Tle.zig | //! The proper TLE struct
//! You should only call this when you are parsing a TLE
//! The FirstLine and SecondLine are being built by the parse method
const std = @import("std");
const DateTime = @import("Datetime.zig");
const Tle = @This();
first_line: FirstLine,
second_line: SecondLine,
allocator: std.mem.Allocat... |
0 | repos/astroz | repos/astroz/src/EquatorialCoordinateSystem.zig | //! Equatorial Coordinate System is a commonly used coordinate system in astronomy as it doesnt rely on
//! the position of the viewer. Allowing you to find what you're looking easily without conversion
const std = @import("std");
const Datetime = @import("Datetime.zig");
const constants = @import("constants.zig");
co... |
0 | repos/astroz | repos/astroz/src/WorldCoordinateSystem.zig | //! World Coordinate System is commonly used
const std = @import("std");
const constants = @import("constants.zig");
const calculations = @import("calculations.zig");
const Tle = @import("Tle.zig");
const Spacecraft = @import("Spacecraft.zig");
const Matrix3x3 = [3][3]f64;
const Vector3 = [3]f64;
const WorldCoordina... |
0 | repos/astroz | repos/astroz/src/parsers.zig | const std = @import("std");
const Ccsds = @import("Ccsds.zig");
const Vita49 = @import("Vita49.zig");
/// Semi-generic function that takes either Vita49 or CCSDS as the Frame type.
pub fn Parser(comptime Frame: type) type {
return struct {
ip_address: []const u8,
port: u16,
buffer_size: u64... |
0 | repos/astroz | repos/astroz/src/Vita49.zig | //! The Vita49 packet type which will be used by the Parser
const std = @import("std");
const Vita49 = @This();
header: Header,
stream_id: ?u32,
class_id: ?ClassId,
i_timestamp: ?u32,
f_timestamp: ?u64,
payload: []const u8,
trailer: ?Trailer,
allocator: std.mem.Allocator,
end: usize,
// private
raw_data: []const u8... |
0 | repos/astroz | repos/astroz/src/constants.zig | const std = @import("std");
/// Gravity
pub const G = 6.6743e-11;
/// Speed of light
pub const c = 299792458;
/// Planck constant
pub const h = 6.62607015e-34;
/// Astronomical unit
pub const au = 1.49597871e+11;
/// Year 2000
pub const j2k = 2000.0;
pub const CelestialBody = struct {
mass: f64, // kg
mu: f64... |
0 | repos/astroz | repos/astroz/src/lib.zig | const std = @import("std");
pub const Tle = @import("Tle.zig");
pub const Ccsds = @import("Ccsds.zig");
pub const Vita49 = @import("Vita49.zig");
pub const Datetime = @import("Datetime.zig");
pub const constants = @import("constants.zig");
pub const Parser = @import("parsers.zig").Parser;
pub const Spacecraft = @impor... |
0 | repos/astroz | repos/astroz/src/Fits.zig | const std = @import("std");
const zigimg = @import("zigimg");
const cfitsio = @import("cfitsio").c;
const Fits = @This();
allocator: std.mem.Allocator,
fptr: ?*cfitsio.fitsfile,
file_path: []const u8,
hdus: []HduInfo,
pub fn open(file_path: []const u8, allocator: std.mem.Allocator) !Fits {
var status: c_int = 0;... |
0 | repos/astroz | repos/astroz/src/Datetime.zig | //! Custom datetime object for dealing with a variety of datetime formats.
const std = @import("std");
const Datetime = @This();
instant: ?std.time.Instant,
doy: ?u16,
days_in_year: u16,
year: ?u16,
month: ?u8,
day: ?u8,
hours: ?u8,
minutes: ?u8,
seconds: ?f16,
/// for dates only
pub fn initDate(year: u16, month: u... |
0 | repos/astroz | repos/astroz/examples/orbit_prop.zig | const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const constants = astroz.constants;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.alloc... |
0 | repos/astroz | repos/astroz/examples/orbit_phase_change.zig | const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const Impulse = Spacecraft.Impulse;
const constants = astroz.constants;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deini... |
0 | repos/astroz | repos/astroz/examples/parse_ccsds.zig | const std = @import("std");
const astroz = @import("astroz");
const Ccsds = astroz.Ccsds;
const Parser = astroz.Parser;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const file_name = "./test/ccsds.bin".*;
const... |
0 | repos/astroz | repos/astroz/examples/wcs.zig | const std = @import("std");
const astroz = @import("astroz");
const Tle = astroz.Tle;
const WorldCoordinateSystem = astroz.WorldCoordinateSystem;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const test_tle =
... |
0 | repos/astroz | repos/astroz/examples/parse_fits_file.zig | const std = @import("std");
const astroz = @import("astroz");
const Fits = astroz.Fits;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var fits_png = try Fits.open_and_parse(allocator);
defer fits_png.close();
}
|
0 | repos/astroz | repos/astroz/examples/create_ccsds_packet_config.zig | const std = @import("std");
const astroz = @import("astroz");
const Ccsds = astroz.Ccsds;
const Config = Ccsds.Config;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const config_file = try std.fs.cwd().readFileAlloc(... |
0 | repos/astroz | repos/astroz/examples/create_ccsds_packet_config.json | {
"secondary_header_length": 12
}
|
0 | repos/astroz | repos/astroz/examples/simple_spacecraft_orientation.zig | const std = @import("std");
const astroz = @import("astroz");
const Tle = astroz.Tle;
const constants = astroz.constants;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const raw_... |
0 | repos/astroz | repos/astroz/examples/parse_vita49.zig | const std = @import("std");
const astroz = @import("astroz");
const Vita49 = astroz.Vita49;
const Parser = astroz.Parser;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const P = Parser(Vita49);
const ip = "127.0.... |
0 | repos/astroz | repos/astroz/examples/parse_vita49_callback.zig | const std = @import("std");
const astroz = @import("astroz");
const Vita49 = astroz.Vita49;
const Parser = astroz.Parser;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const P = Parser(Vita49);
const ip = "127.0.... |
0 | repos/astroz | repos/astroz/examples/parse_tle.zig | const std = @import("std");
const astroz = @import("astroz");
const Tle = astroz.Tle;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const test_tle =
\\1 55909U 23035B 24187.51050877 .00023579 00000+0 160... |
0 | repos/astroz | repos/astroz/examples/create_ccsds_packet.zig | const std = @import("std");
const astroz = @import("astroz");
const Ccsds = astroz.Ccsds;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const raw_test_packet: [16]u8 = .{ 0x78, 0x97, 0xC0, 0x00, 0x00, 0x0A, 0x01, 0x0... |
0 | repos/astroz | repos/astroz/examples/parse_ccsds_file_sync.zig | const std = @import("std");
const astroz = @import("astroz");
const Ccsds = astroz.Ccsds;
const Parser = astroz.Parser;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const file_name = "./test/ccsds.bin".*;
const ... |
0 | repos/astroz | repos/astroz/examples/orbit_plane_change.zig | const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const constants = astroz.constants;
const Impulse = Spacecraft.Impulse;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deini... |
0 | repos/astroz | repos/astroz/examples/orbit_prop_impulse.zig | const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const constants = astroz.constants;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.alloc... |
0 | repos/astroz | repos/astroz/examples/precess_star.zig | const std = @import("std");
const astroz = @import("astroz");
const Datetime = astroz.Datetime;
const EquatorialCoordinateSystem = astroz.EquatorialCoordinateSystem;
pub fn main() !void {
const declination = EquatorialCoordinateSystem.Declination.init(40, 10, 10);
const ra = EquatorialCoordinateSystem.RightAsc... |
0 | repos | repos/zig-tutorial/README.md | # Zig Tutorial
Just a simple Zig tutorial to explore the basics about the language.
|
0 | repos | repos/zig-tutorial/build.zig.zon | .{
// This is the default name used by packages depending on this one. For
// example, when a user runs `zig fetch --save <url>`, this field is used
// as the key in the `dependencies` table. Although the user can choose a
// different name, most users will stick with this provided value.
//
// ... |
0 | repos | repos/zig-tutorial/build.zig | const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... |
0 | repos/zig-tutorial | repos/zig-tutorial/src/root.zig | const std = @import("std");
const testing = std.testing;
export fn add(a: i32, b: i32) i32 {
return a + b;
}
test "basic add functionality" {
try testing.expect(add(3, 7) == 10);
}
|
0 | repos/zig-tutorial | repos/zig-tutorial/src/main.zig | const std = @import("std");
const user = @import("models/user.zig");
const User = user.User;
const MAX_POWER = user.MAX_POWER;
pub fn main() !void {
const goku = User{
.power = 9001,
.name = "Goku",
};
std.debug.print("{s}'s power is {d}.\n", .{ goku.name, goku.power });
User.diagnose... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/models/user.zig | const std = @import("std");
pub const MAX_POWER = 100_000;
pub const User = struct {
power: u64,
name: []const u8,
pub const SUPER_POWER = 9000;
pub fn diagnose(user: User) void {
if (user.power >= SUPER_POWER) {
std.debug.print("it's over {d}!!!\n", .{SUPER_POWER});
}
... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/switch.zig | const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
var x: i8 = 10;
switch (x) {
-1...1 => {
x = -x;
},
10, 100 => print("x: {d}\n", .{x}),
else => {},
}
var count: u8 = 1;
while (count <= 15) : (count += 1) {
const ... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/if_statement.zig | const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
const a: bool = true;
var x: u16 = 0;
if (a) {
x += 1;
} else {
x += 2;
}
print("x = 1? {}\n", .{x == 1});
x += if (x == 1) 1 else 2;
print("x now is: {d}\n", .{x});
}
|
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/slices.zig | const std = @import("std");
const print = std.debug.print;
const Slice = []bool;
pub fn main() !void {
var array = [5]i32{ 1, 2, 3, 4, 5 };
const end: usize = 4;
const slice = array[1..end];
print("len: {}\n", .{slice.len});
print("first: {}\n", .{slice[0]});
for (slice) |elem| {
prin... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/pointer.zig | const std = @import("std");
const print = std.debug.print;
const Single = *bool;
const Many = [*]bool;
const Null = ?*bool;
pub fn main() !void {
var v = false;
const ptr = &v;
print("pointer: {}\n", .{ptr});
ptr.* = true;
print("value: {}\n", .{ptr.*});
const const_ptr: *bool = &v;
cons... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/array.zig | const std = @import("std");
pub fn main() !void {
std.debug.print("Listing elements from: a\n", .{});
for (a) |elem| {
std.debug.print("elem: {}\n", .{elem});
}
std.debug.print("Listing elements from: b\n", .{});
for (b) |elem| {
std.debug.print("elem: {}\n", .{elem});
}
s... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/while.zig | const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
var a: usize = 0;
var b: usize = 0;
var c: usize = 0;
var d: usize = 0;
while (a < 2) {
print("a: {}\n", .{a});
a += 1;
}
while (b < 2) : (b += 1) {
print("b: {}\n", .{b});
}
... |
0 | repos/zig-tutorial/src | repos/zig-tutorial/src/examples/for.zig | const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
var array = [_]u32{ 1, 2, 3 };
for (array) |elem| {
print("by val: {}\n", .{elem});
}
for (&array) |*elem| {
elem.* += 100;
print("by ref: {}\n", .{elem.*});
}
for (array, &array) |val, *... |
0 | repos | repos/proxy-wasm-cloud-logging-trace-context/docker-compose.yml | ---
version: "3.8"
services:
envoy:
image: envoyproxy/envoy:v1.23.0
ports:
- ${PORT-8080}:8080
volumes:
- ./test/envoy.yaml:/etc/envoy/envoy.yaml
- ./zig-out/bin/proxy-wasm-cloud-logging-trace-context.wasm:/etc/envoy/proxy-wasm-cloud-logging-trace-context.wasm
command: /docker-entry... |
0 | repos | repos/proxy-wasm-cloud-logging-trace-context/README.md | # proxy-wasm-cloud-logging-trace-context
A [proxy-wasm](https://github.com/proxy-wasm/spec) compliant WebAssembly module for making proxies integrate with [Google Cloud Logging](https://cloud.google.com/logging/).
## Overview
In order to generate logs associated with [Google Cloud Trace](https://cloud.google.com/tra... |
0 | repos | repos/proxy-wasm-cloud-logging-trace-context/build.zig | const std = @import("std");
pub fn build(b: *std.build.Builder) void {
b.setPreferredReleaseMode(std.builtin.Mode.ReleaseSafe);
const exe = b.addExecutable("proxy-wasm-cloud-logging-trace-context", "src/main.zig");
exe.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .wasi });
exe.addPackage(.{
.n... |
0 | repos | repos/proxy-wasm-cloud-logging-trace-context/LICENSE.md | MIT License
Copyright (c) 2021 Yuki Ito
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribu... |
0 | repos/proxy-wasm-cloud-logging-trace-context | repos/proxy-wasm-cloud-logging-trace-context/src/main.zig | const std = @import("std");
const proxywasm = @import("proxy-wasm-zig-sdk");
extern fn __wasm_call_ctors() void;
const cloudTraceHeaderKey = "x-cloud-trace-context";
const cloudLoggingTraceHeaderKey = "x-cloud-logging-trace-context";
pub fn main() void {
proxywasm.setNewRootContextFunc(newRootContext);
}
fn new... |
0 | repos/proxy-wasm-cloud-logging-trace-context | repos/proxy-wasm-cloud-logging-trace-context/test/envoy.yaml | static_resources:
listeners:
- name: test
address:
socket_address:
address: 0.0.0.0
port_value: 8080
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
'@type': type.googleapis.com/... |
0 | repos | repos/zig-ryu/clean.sh | #!/bin/sh
rm -rf ryu/third_party/double-conversion/build-ryu
rm -rf build
rm -f bench-reference
rm -f bench-zig
|
0 | repos | repos/zig-ryu/build.sh | #!/bin/sh
set -e
mkdir -p build
echo "building double-conversion dependency"
cd ryu/third_party/double-conversion
mkdir -p build-ryu
cd build-ryu
cmake .. -DCMAKE_BUILD_TYPE=Release > /dev/null
make -j4 > /dev/null
cp double-conversion/libdouble-conversion.a ../../../../build
cd ../../../..
echo "building reference... |
0 | repos | repos/zig-ryu/README.md | Conversion of https://github.com/ulfjack/ryu to [zig](https://ziglang.org/).
## Install
```
git clone --recurse-submodules https://github.com/tiehuis/zig-ryu
```
## Benchmarks
Requires `sh`, `make`, `cmake`, `c++`, `zig`
```
./build.sh
./bench-reference # reference timing
./bench-zig # zig timing
```
## Tod... |
0 | repos/zig-ryu | repos/zig-ryu/src/internal.zig | pub usingnamespace @import("internal/tables_digits.zig");
pub usingnamespace @import("internal/common.zig");
pub usingnamespace @import("internal/intrinsics.zig");
|
0 | repos/zig-ryu | repos/zig-ryu/src/ryu.zig | pub const ryu64 = struct {
pub const max_buf_size = struct {
// TODO: Some of these bounds can be tightened
pub const scientific = 2000;
pub const fixed = 2000;
pub const hex = 32;
pub const shortest = 25;
};
pub const printScientific = @import("ryu64/print_scientifi... |
0 | repos/zig-ryu | repos/zig-ryu/src/ryu_c.zig | // C interface for testing.
//
// This matches ryu.h from the reference implementation.
const std = @import("std");
const ryu = @import("ryu.zig");
var allocator = std.heap.c_allocator;
export fn d2s_buffered_n(f: f64, result: [*]u8) c_int {
const s = ryu.ryu64.printShortest(result[0..25], f);
return @intCas... |
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/parse.zig | const std = @import("std");
usingnamespace struct {
pub usingnamespace @import("../internal.zig");
pub usingnamespace @import("tables_shortest.zig");
};
inline fn floor_log2(x: u64) u32 {
return 63 - @clz(u64, x);
}
pub const ParseError = error{
TooShort,
TooLong,
Malformed,
};
pub fn parse(... |
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/print_scientific.zig | const std = @import("std");
usingnamespace struct {
pub usingnamespace @import("../internal.zig");
pub usingnamespace @import("tables_fixed_and_scientific.zig");
};
pub fn printScientific(result: []u8, d: f64, precision_: u32) []u8 {
var precision = precision_;
const bits = @bitCast(u64, d);
cons... |
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/test_scientific.zig | const std = @import("std");
const ryu64 = @import("../ryu.zig").ryu64;
fn ieeeFromParts(sign: bool, exponent: u32, mantissa: u64) f64 {
std.debug.assert(exponent <= 2047);
std.debug.assert(mantissa <= (@as(u64, 1) << 53) - 1);
return @bitCast(f64, ((@as(u64, @boolToInt(sign)) << 63) | (@as(u64, exponent) <... |
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/print_fixed.zig | //! Print an f64 as a fixed-precision.
const std = @import("std");
usingnamespace struct {
pub usingnamespace @import("../internal.zig");
pub usingnamespace @import("tables_fixed_and_scientific.zig");
};
/// Print an f64 in fixed-precision format. Result must be at least XXX bytes but need not be
/// more, a... |
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/print_hexadecimal.zig | const std = @import("std");
pub fn printHex(result: []u8, d: f64) []u8 {
// TODO
}
|
0 | repos/zig-ryu/src | repos/zig-ryu/src/ryu64/test_shortest.zig | const std = @import("std");
const ryu64 = @import("../ryu.zig").ryu64;
fn ieeeFromParts(sign: bool, exponent: u32, mantissa: u64) f64 {
std.debug.assert(exponent <= 2047);
std.debug.assert(mantissa <= (@as(u64, 1) << 53) - 1);
return @bitCast(f64, ((@as(u64, @boolToInt(sign)) << 63) | (@as(u64, exponent) <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.