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 / 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
use std::{
future::Future,
sync::{
mpsc::{sync_channel, Receiver, SyncSender},
Arc, Mutex,
},
task::{Poll, Waker, Context},
thread,
time::Duration,
};
@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
@bitristan
bitristan / word_recognizer.l
Created December 12, 2022 03:40
带符号表的单词识别程序 flex
%{
/*
* 带符号表的单词识别程序
*/
enum {
LOOKUP = 0, /* 默认查找 */
VERB,
ADJ,
ADV,
@bitristan
bitristan / gradle_user_guide_note.md
Created July 21, 2021 07:48
gradle reference note
  1. When Gradle executes a Groovy build script (.gradle), it compiles the script into a class which implements Script. This means that all of the properties and methods declared by the Script interface are available in your script.

  2. When Gradle executes a Kotlin build script (.gradle.kts), it compiles the script into a subclass of KotlinBuildScript. This means that all of the visible properties and functions declared by the KotlinBuildScript type are available in your script. Also see the KotlinSettingsScript and KotlinInitScript types respectively for settings scripts and init scripts.

  3. An important feature of the resulting file collections is that they are live. In other words, when you combine file collections in this way, the result always reflects what’s currently in the source file collections, even if they change during the build.

  4. Define custom gradle plugin

plugins {
    `java-gradle-plugin`
@bitristan
bitristan / ExampleUnitTest.java
Created June 30, 2021 10:30
Create hello world by asm tool
public class ExampleUnitTest {
@Test
public void helloWorldByAsm() {
ClassWriter cw = new ClassWriter(0);
cw.visit(V1_8, ACC_PUBLIC, "Hello", null, "java/lang/Object", null);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC,
"main", "([Ljava/lang/String;)V", null, null);
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
mv.visitLdcInsn("Hello, World");
@bitristan
bitristan / MyLinearLayoutManager.java
Created February 8, 2021 07:13
A simple cusstom linearlayout manager
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
public class MyLinearLayoutManager extends RecyclerView.LayoutManager {
private int mOffsetY = 0;
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
@bitristan
bitristan / minigrep.rs
Last active August 1, 2020 03:34
minigrep demo from rust book.
use std::env;
use std::process;
use std::fs;
use std::error::Error;
fn main() {
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err|{
println!("Problem parsing arguements: {}", err);
@bitristan
bitristan / ContactUtil.kt
Created July 31, 2020 03:17
读写通讯录
import android.app.Activity
import android.content.*
import android.database.Cursor
import android.provider.ContactsContract
import android.util.Log
object ContactUtil {
private const val TAG = "ContactUtil"
fun getContacts(context: Context): StringBuilder {
import android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaRecorder
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.View
import android.widget.Button
import java.io.*