Skip to content

Instantly share code, notes, and snippets.

View jw910731's full-sized avatar

jw910731 jw910731

View GitHub Profile
@jw910731
jw910731 / bmp_displayer.c
Created March 29, 2023 16:46
A simple terminal bmp displayer
#include <stdint.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
@jw910731
jw910731 / main.swift
Created June 23, 2023 10:19
Numlock Enabler CLI
import Foundation
import IOKit
import IOKit.hid
class KeyboardCapture {
var manager: IOHIDManager
init() {
manager = IOHIDManagerCreate(kCFAllocatorDefault, IOOptionBits(kIOHIDOptionsTypeNone))
@jw910731
jw910731 / sort_range.cxx
Last active November 17, 2023 06:41
merge sort with c++20 ranges library
#include <ranges>
#include <type_traits>
#include <vector>
#include <list>
#include <iostream>
template <typename T> requires std::ranges::sized_range<T>
T &&merge_sort(T &&arr) {
if (std::ranges::size(arr) < 2) return std::forward<T>(arr);
auto mid_len = std::ranges::size(arr) / 2;
@jw910731
jw910731 / list.c
Created November 16, 2023 13:17
Reverse List
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct list {
struct list *next;
int n;
};
struct list *new_list(int *arr, size_t n) {
@jw910731
jw910731 / hexagram.py
Created February 2, 2025 08:48
易經 base64
GUA = [63, 0, 17, 34, 23, 58, 2, 16, 55, 59, 7, 56, 61, 47, 4, 8, 25, 38, 3, 48, 41, 37, 32, 1, 57, 39, 33, 30, 18, 45, 28, 14, 60, 15, 40, 5, 53, 43, 20, 10, 35, 49, 31, 62, 24, 6, 26, 22, 29, 46, 9, 36, 52, 11, 13, 44, 54, 27, 50, 19, 51, 12, 21, 42] # fmt: skip
def bit2gua(bit6: int) -> str:
return chr(0x4DC0 + GUA.index(bit6 & 0x3F))
def byte_segment(in_byte: bytes) -> bytearray:
ret: bytearray = []
rem = 0
@jw910731
jw910731 / flake.nix
Last active May 24, 2025 21:29
Hellish python2 nix flake
{
inputs = {
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-public-keys =