Skip to content

Instantly share code, notes, and snippets.

@pkemb
pkemb / 0001-add-adb-connect-vm-port-serial.patch
Created August 4, 2024 13:40
add 'adb connect vm:<port>,<serial>'
From 9f07d84dae8787a15fea017ccc70aadb1aa23797 Mon Sep 17 00:00:00 2001
From: pkemb <pkemb@outlook.com>
Date: Sun, 4 Aug 2024 21:27:22 +0800
Subject: [PATCH] add 'adb connect vm:<port>,<serial>'
Change-Id: Ie89a4dc59f0272e148eff41fdfe996dee4780afa
Signed-off-by: pkemb <pkemb@outlook.com>
---
adb.h | 2 ++
client/transport_local.cpp | 34 ++++++++++++++++++++++++++++
@pkemb
pkemb / LocalDouban.py
Created October 4, 2023 03:51
基于acdzh/douban-book-api 的calibre-web搜索插件。根据搜索关键字,自动识别是ISBN、douban id、text。
import re
import time
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
from functools import lru_cache
import json, isbnlib
from urllib.parse import urlparse, parse_qs, urljoin, urlunparse
from cps.services.Metadata import MetaRecord, MetaSourceInfo, Metadata
DOUBAN_SEARCH_JSON_URL = "http://doubanapi.pk.inc/"
DOUBAN_BOOK_CAT = "1001"
@pkemb
pkemb / Makefile
Created April 28, 2023 14:05
tiny_hello x86
CC=gcc
LD=ld
PROGRAM += tiny_hello
all: ${PROGRAM}
%: %.c
${CC} -c -g -fno-builtin $<
${LD} -static -e nomain $@.o -o $@
@pkemb
pkemb / mlock.md
Last active April 17, 2023 13:22
mlock - 将进程的虚拟地址空间锁在RAM,避免swap

手册

https://man7.org/linux/man-pages/man2/mlock.2.html

限制

对于普通用户进程,mlock的内存总量不能超过RLIMIT_MEMLOCK。可以通过cat /proc/pid/limits查看,。如果要超过RLIMIT_MEMLOCK,需要有权限CAP_IPC_LOCK

pi@pi4b:/devspace/test-api $ cat /proc/self/limits
@pkemb
pkemb / dl_iterate_phdr.md
Created April 12, 2023 15:03
遍历共享库列表 dl_iterate_phdr
@pkemb
pkemb / single-instance.md
Last active April 1, 2023 12:54
Linux C单实例模式

利用flock()实现单实例。利用了进程退出时kernel会释放进程所有资源的特点,进程无论是正常退出还是异常退出,都可以保证文件锁释放了。

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/file.h>
#include <unistd.h>

int main(int argc, char *argv[])
@pkemb
pkemb / gitBash_windows.md
Created March 12, 2022 15:34 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so