Skip to content

Instantly share code, notes, and snippets.

View Jamlee's full-sized avatar
🐛
Focusing

JamLee Jamlee

🐛
Focusing
View GitHub Profile
@Jamlee
Jamlee / cgo_manual_compile.sh
Last active July 3, 2025 15:03
This script manually compiles a Go program with CGO (Go-C interoperability) by replicating the internal steps of the Go toolchain. It handles CGO preprocessing, compiles generated C files with Clang, links C objects, generates import stubs for Go-C bindings, compiles Go code, and finally links all components into an executable. Designed for debu…
#!/bin/bash
# @author: jamlee
# date: 20250703
# platform: mac pro m3
# 设置工作目录(模拟原始流程中的$WORK/b001)
rm -fr tmp
mkdir tmp
WORK_DIR=$(pwd)/tmp
@Jamlee
Jamlee / busybox.md
Last active June 24, 2025 13:48
使用 busybox 制作内存文件系统 initramfs
  1. 下载解压 busybox 并配置环境变量

    wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2
    tar -xf busybox-1.36.1.tar.bz2
    cd busybox-1.36.1
    # 配置环境变量
    export ARCH=arm64
    export CROSS_COMPILE=aarch64-linux-gnu-
@Jamlee
Jamlee / cscope_maps.vim
Created April 2, 2024 03:09 — forked from cyeong/cscope_maps.vim
enable cscope shortcuts and functions in vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CSCOPE settings for vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" This file contains some boilerplate settings for vim's cscope interface,
" plus some keyboard mappings that I've found useful.
"
" USAGE:
" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a
" 'plugin' directory in some other directory that is in your
@Jamlee
Jamlee / README.md
Created April 23, 2023 11:33
QEMU + Ubuntu ARM aarch64

QEMU + Ubuntu ARM aarch64

These are the steps I used to get Ubuntu ARM aarch64 running with QEMU on OSX.

Get Ubuntu Image and QEMU EFI:

wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-arm64-uefi1.img
wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
@Jamlee
Jamlee / reset.stp
Last active April 28, 2022 17:10
stap 脚本
#!/usr/bin/env stap
// Linux 172-19-0-11 5.4.0-109-generic #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
//tencent cloud centos 7.2 20220429
// tcp_send_active_reset 检测
probe kernel.statement("*@net/ipv4/tcp.c:2054") {
if (execname() == "node") {
printf("tcp_send_active_reset: %s\n", pp())
}
}
@Jamlee
Jamlee / fake_driver.c
Last active April 27, 2022 18:08
Linux 系统内核例子
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/of.h>
@Jamlee
Jamlee / exsi.sh
Last active May 22, 2022 16:32
hyper-v install ubtuntu cloud image
# usage
# ./exsi.sh 192.168.31.31 192.168.50.31
# apt install cloud-utils
hostname=$(echo $1 | sed s/\\./-/g)
{ echo instance-id: $hostname; echo local-hostname: $hostname; } > meta-data
cat > user-data <<EOF
#cloud-config
users:
- default
@Jamlee
Jamlee / yield-embed.php
Created July 9, 2021 08:16
PHP 中 yield:嵌套展平 yield 表达式
function stackedCoroutine(\Generator $gen)
{
$stack = new \SplStack;
$exception = null;
for (;;) {
try {
if ($exception) {
$gen->throw($exception);
$exception = null;
continue;
@Jamlee
Jamlee / main.go
Created November 3, 2020 12:19
golang: exec 时继承父级进程数据
package main
import (
"fmt"
"golang.org/x/sys/unix"
"os"
"os/exec"
"syscall"
)
@Jamlee
Jamlee / install.sh
Last active April 5, 2020 08:55
theia: cpp 配置, go 配置。目前还是测试版本
#!/bin/bash
prefix="/root/.theia-ide"
# go
snap install go --classic # 较新的版本
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef