A Pen by Akhil a.k.a Enforcer007 on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use image::{Rgb, RgbImage}; | |
| use minimp4::Mp4Muxer; | |
| use openh264::{ | |
| encoder::Encoder, | |
| formats::{RgbSliceU8, YUVBuffer}, | |
| }; | |
| use std::io::{Cursor, Read, Seek, SeekFrom}; | |
| use std::time::Duration; | |
| const WIDTH: u32 = 512; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from pathlib import Path | |
| import subprocess | |
| import os | |
| import sys | |
| import json | |
| STARTUP_SH="start.sh" | |
| REFID="4501dd11ea6060740fd764b2f6006173c68b28ae" | |
| WORKDIR=Path("/workspace") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Licensed under the MIT license. | |
| # See https://opensource.org/licenses/MIT for license details. | |
| import sys | |
| import os | |
| from pathlib import Path | |
| def main(): | |
| if len(sys.argv)>1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| // Cache requires a function (lambda) to be called when there's no cache hit and an other function(args_to_u64) that can compute args | |
| // of the function to u64 that becomes the identifier to compare same arguments. | |
| pub fn Cache(lambda: anytype, args_to_u64: fn (anytype) u64) type { | |
| const lambda_info = @typeInfo(@TypeOf(lambda)); | |
| if (lambda_info != .@"fn") { | |
| @compileError("lambda should be a function type"); | |
| } | |
| const return_type = lambda_info.@"fn".return_type orelse @compileError("No return type"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Error output | |
| @❯ zig build test | |
| test | |
| └─ run test | |
| └─ zig test Debug native 1 errors | |
| /home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: error: file exists in multiple modules | |
| /home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: note: root of module xev0 | |
| /home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: note: root of module xev | |
| /home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/dynamic.zig:5:22: note: imported from module xev |
Here's my partial build.zig file of dependency containing the examples folder to build some test artifacts:
const examples_dir_lz = b.path("examples");
const examples_path = examples_dir_lz.getPath2(b, null);
var examples_dir = try std.fs.openDirAbsolute(examples_path, .{ .iterate = true });
var examples_dir_iter = try examples_dir.walk(b.allocator);
defer examples_dir_iter.deinit();
while (try examples_dir_iter.next()) |entry| {
switch (entry.kind) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // benchmark on master [!] is 📦 v0.1.0 via 🦀 v1.88.0 took 3m22s | |
| // ❯ cargo run --release | |
| // Compiling benchmark v0.1.0 (/home/akhil/practice/benchmark) | |
| // Finished `release` profile [optimized] target(s) in 17.35s | |
| // Running `target/release/benchmark` | |
| // Inital memory: 22581248 bytes | |
| // ==========ARROW WRITE=========== | |
| // nth record batch: 0,n_rows:1, size:2147508784bytes, memory_consumed: 2171830272bytes, record_batch_generation_duration: 838.356722ms | |
| // nth record: 0, rb_write_time: 1.001391512s | |
| // nth record batch: 1,n_rows:1, size:2147508784bytes, memory_consumed: 2172235776bytes, record_batch_generation_duration: 836.583332ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const Complex = struct { i64, i64 }; | |
| fn mul(complex1: Complex, complex2: Complex) Complex { | |
| // std.debug.print("{any}:{any}\n", .{ complex1, complex2 }); | |
| return .{ (complex1.@"0" * complex2.@"0") - (complex1.@"1" * complex2.@"1"), (complex1.@"0" * complex2.@"1") + (complex1.@"1" * complex2.@"0") }; | |
| } | |
| fn add(complex1: Complex, complex2: Complex) Complex { | |
| return .{ complex1.@"0" + complex2.@"0", complex1.@"1" + complex2.@"1" }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| fn part1(buffer: []const u8, allocator: std.mem.Allocator) !void { | |
| var n_iterator = std.mem.splitScalar(u8, buffer, ','); | |
| var hashset = std.AutoHashMap(u32, void).init(allocator); | |
| defer hashset.deinit(); | |
| var total: u32 = 0; | |
| while (n_iterator.next()) |size| { | |
| const _size = try std.fmt.parseInt(u32, size, 10); | |
| if (hashset.get(_size)) |_| continue; | |
| try hashset.put(_size, {}); |