Skip to content

Instantly share code, notes, and snippets.

View Zai-Kun's full-sized avatar
🌴
Life is good when you understand pointers

Zai Zai-Kun

🌴
Life is good when you understand pointers
View GitHub Profile
@Zai-Kun
Zai-Kun / shmem_example.rs
Created January 19, 2025 15:30
Shared memory example using nix crate (only for *nix systems)
// [dependencies]
// nix = { version = "0.29.0", features = ["fs", "mman"], default-features = false }
use std::num::NonZeroUsize;
use nix::fcntl::OFlag;
use nix::sys::mman::{self, shm_unlink, MapFlags, ProtFlags};
use nix::sys::stat::Mode;
use nix::unistd::ftruncate;
@Zai-Kun
Zai-Kun / tic_tac_toe.py
Last active November 2, 2023 16:53
My implementation of the Minimax algorithm in Python for Tic Tac Toe.
import os
def get_all_max_numbers(input_list):
if not input_list:
return []
max_value = max(input_list)[0]
max_numbers = [num for num in input_list if num[0] == max_value]
return max_numbers
@darwing1210
darwing1210 / async_download_files.py
Last active August 30, 2025 07:33
Script to download files in a async way, using Python asyncio
import os
import asyncio
import aiohttp # pip install aiohttp
import aiofile # pip install aiofile
REPORTS_FOLDER = "reports"
FILES_PATH = os.path.join(REPORTS_FOLDER, "files")
def download_files_from_report(urls):