Skip to content

Instantly share code, notes, and snippets.

View selfboot's full-sized avatar
🎯
Focusing

selfboot selfboot

🎯
Focusing
View GitHub Profile
@selfboot
selfboot / microgpt.py
Created February 12, 2026 04:28 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@selfboot
selfboot / core_share.cpp
Created January 10, 2025 09:47
A simple example demonstrating the coredump problem
#include <iostream>
#include <thread>
#include <unordered_map>
#include <shared_mutex>
#include <vector>
#include <random>
class DataManager {
private:
std::shared_mutex mutex_;
std::unordered_map<std::string, std::string> m_data;
@selfboot
selfboot / skiplist_benchmark.cpp
Created September 24, 2024 07:59
Performance benchmark of leveldb skiplist, compared with unordered_map
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include "benchmark/benchmark.h"
#include "db/skiplist.h"
@selfboot
selfboot / chatgpt-export.js
Created July 29, 2024 09:33
chatgpt-export
// ==UserScript==
// @name chatgpt-export
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add a copy button next to LaTeX formulas
// @author You
// @match https://chat.openai.com/*
// @grant none
// ==/UserScript==
@selfboot
selfboot / demo.yaml
Created December 25, 2023 12:57
clash yaml
mixed-port: 7890
allow-lan: true
bind-address: '*'
mode: rule
log-level: info
external-controller: '127.0.0.1:9090'
dns:
enable: true
listen: 0.0.0.0:53
ipv6: true
@selfboot
selfboot / lawer_train.py
Last active September 5, 2025 10:09
Train a classification task, see Full Introduction https://selfboot.cn/2023/12/06/bert_nlp_classify/
#!pip install torch
#!pip install transformers
#!pip install scikit-learn
#!pip install numpy
import json
from sklearn.model_selection import train_test_split
import random
from datetime import datetime
from transformers import BertTokenizer, BertModel
import torch
@selfboot
selfboot / automator_cosupload
Created October 30, 2023 01:43
mac automator tool,Monitor folder, automatically compress and upload images to COS.
on run {input, parameters}
set currentDate to do shell script "date '+%Y%m%d'"
tell application "System Events"
repeat with i in input
set filePath to POSIX path of i
set fileExtension to name extension of i
set folderName to do shell script "dirname " & filePath
set fileName to name of i
set AppleScript's text item delimiters to "."
set baseName to first text item of fileName
#include <zip.h>
#include <iostream>
#include <string>
#include <vector>
struct FileInfo {
std::string htmltemlate;
std::string filename;
};
@selfboot
selfboot / FP_dynamic_demo
Created October 17, 2023 03:28
In the case of dynamic linking, if there are third-party dependencies in the middle without the compilation option '-fno-omit-frame-pointer', theoretically it should be the same as static linking, and the stack information will be out of order
$ tree
.
├── dynamic_A
│   ├── dynamic_A.cpp
│   └── dynamic_A.h
├── dynamic_B
│   ├── dynamic_B.cpp
│   └── dynamic_B.h
├── main.cpp
├── Makefile