Skip to content

Instantly share code, notes, and snippets.

@doccaico
doccaico / main.zig
Created April 10, 2024 08:54
shift zig implementation (naive ver.)
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const print = std.debug.print;
const assert = std.debug.assert;
const expect = std.testing.expect;
pub var allocator: std.mem.Allocator = undefined;
pub fn main() !void {
@doccaico
doccaico / main.odin
Last active January 8, 2024 09:12
Odinlang Updater in Odinlang (Windows only)
package main
import "core:c/libc"
import "core:encoding/json"
import "core:fmt"
import "core:mem"
import "core:os"
import "core:path/filepath"
import "core:strings"
@doccaico
doccaico / CMakeLists.txt
Last active December 7, 2023 06:19
Triangle (SDL2) on Windows (MSVC + CMake + Ninja)
cmake_minimum_required(VERSION 3.25)
### Debug mode
# $ cmake -S . -B build-debug -GNinja -DCMAKE_BUILD_TYPE=Debug
# $ cmake --build build-debug
# $ cmake --install build-debug # SDL2.dllをコピー
# $ cmake --build build-debug && build-debug\game.exe
### Release mode
# $ cmake -S . -B build-release -GNinja -DCMAKE_BUILD_TYPE=Release
@doccaico
doccaico / main.zig
Last active February 7, 2025 15:14
How To Make HTTP Requests(Get) in Zig (Zig version: 0.13.0-dev.46+3648d7df1)
const std = @import("std");
const print = std.debug.print;
pub fn main() !void {
// Create an allocator.
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Parse the URI.
@doccaico
doccaico / main.zig
Last active November 25, 2023 05:39
Readline in Ziglang (using streamUntilDelimiter function)
const std = @import("std");
const builtin = @import("builtin");
const print = std.debug.print;
// zig version: 0.12.0-dev.1717+54f4abae2
// test: cmd.exe and powershell.exe
const DELIMITER = if (builtin.os.tag == .windows) '\r' else '\n';
pub fn main() !void {
@doccaico
doccaico / cat.go
Last active December 2, 2023 17:30
Naive cat In Golang and Rust
package main
// http://www.nct9.ne.jp/m_hiroi/golang/abcgo33.html#chap02
import (
"bufio"
"flag"
"fmt"
"os"
"strings"
@doccaico
doccaico / build.bat
Last active August 29, 2024 06:26
CL Runner (msvc, cl.exe, raylib, stb) bat, cmd
@echo off
REM Based on https://github.com/michal-z/cgame/blob/main/build.bat
SETLOCAL
SET NAME=main
IF "%1" == "" ( SET MODE=D && GOTO :MAIN
) ELSE IF "%1" == "--debug" ( SET MODE=D && GOTO :MAIN
@doccaico
doccaico / Chat_GPT.zig
Last active June 22, 2023 13:55
Chat to AI (ChatGPT) in Ziglang
const builtin = @import("builtin");
const std = @import("std");
const ChildProcess = std.ChildProcess;
const fs = std.fs;
const io = std.io;
const json = std.json;
const math = std.math;
const mem = std.mem;
const process = std.process;
@doccaico
doccaico / zig_update.zig
Last active August 21, 2024 15:18
Ziglang Updater in Ziglang
// Date: 2024/08/22
// Zig version: 0.14.0-dev.1224+16d74809d
// Build: zig build-exe -Doptimize=ReleaseFast zig_update.zig
// 必要なソフト
// Windows: curl, 7za
// その他(Linux、Macなど): curl
// zigディレクトリの位置
// Windows: c:\Langs\zig
@doccaico
doccaico / main1.go
Last active June 26, 2023 01:20
Reverse Polish Notation in Nimlang, Ziglang, Golang and Rust
package main
// runtime error
import (
"errors"
"fmt"
"os"
"strconv"
"strings"