Skip to content

Instantly share code, notes, and snippets.

View bitristan's full-sized avatar
😀
happy coding everyday

Ting Sun bitristan

😀
happy coding everyday
View GitHub Profile
@bitristan
bitristan / word_recognizer.l
Created December 12, 2022 03:40
带符号表的单词识别程序 flex
%{
/*
* 带符号表的单词识别程序
*/
enum {
LOOKUP = 0, /* 默认查找 */
VERB,
ADJ,
ADV,
@bitristan
bitristan / hd.c
Created June 20, 2023 05:44
read ide disk
#include <kernel/hd.h>
extern s_sys_var *sys_var;
/*
* read_block : 读块数据
* - u32 hd_dev_id : 块设备类型
* - u32 lba : 线性编号
* - void *data : 数据地址
* return : void
use std::{
future::Future,
sync::{
mpsc::{sync_channel, Receiver, SyncSender},
Arc, Mutex,
},
task::{Poll, Waker, Context},
thread,
time::Duration,
};
@bitristan
bitristan / linux-kernel-2.6.26.patch
Created November 15, 2023 13:17
ubuntu16.04编译linux-2.6.26源码修复编译错误
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index b7ad9f8..40bf07d 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -69,7 +69,7 @@ vdso32.so-$(VDSO32-y) += sysenter
vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
+VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
@bitristan
bitristan / build.gradle.kts
Created July 24, 2024 05:41 — forked from benigumocom/build.gradle.kts
Dagget-Hilt + KSP
// Project
plugins {
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt) apply false
}
// Module
plugins {
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
@bitristan
bitristan / pcm_to_ogg.cpp
Created September 25, 2024 23:45
convert pcm to ogg opus
#include <opusenc.h>
#include <vector>
#include <fstream>
#include <iostream>
std::vector<unsigned char> readFile(const std::string &filename) {
std::ifstream file(filename, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
throw std::runtime_error("Failed to open file: " + filename);
}
@bitristan
bitristan / mkrootfs.sh
Last active August 16, 2025 00:02
Create a simple rootfs img by busybox for linux kernel launch.
#!/bin/bash
set -e
# 配置参数
ROOTFS_DIR="./rootfs" # 根文件系统目录
OUTPUT_IMG="rootfs.img" # 输出镜像文件名
IMG_SIZE="64M" # 镜像大小
ARCH="aarch64" # 目标架构 (x86_64/arm/aarch64)
KERNEL_PATH="./bzImage" # 内核路径
@bitristan
bitristan / DuolingoMethodTrace.kt
Created September 11, 2025 02:28 — forked from chenglaihuang/DuolingoMethodTrace.kt
duolingo-method-trace
/*
* Copyright 2025 Duolingo, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software