Skip to content

Instantly share code, notes, and snippets.

@alvendarthy
alvendarthy / mmap_zcopy
Created February 23, 2022 09:41 — forked from laoar/mmap_zcopy
an example of kernel space to user space zero-copy via mmap, and also the comparing mmap with read/write
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <asm/uaccess.h>
#define MAX_SIZE (PAGE_SIZE * 2) /* max size mmaped to userspace */
#define DEVICE_NAME "mchar"
@alvendarthy
alvendarthy / debug assembly with gdb.md
Last active February 23, 2022 10:28
debug assembly with gdb

compile with debug

gcc yourfile.c -o test -g

debug

  1. start gdb with -tui flag so that you can see C source file while debuging.
gdb test -tui
  1. enable assembly next line
@alvendarthy
alvendarthy / how to install bpftrace on raspberry pi.md
Last active February 24, 2022 15:48
how to install bpftrace on raspberry pi
  1. install snap
sudo apt update
sudo apt install snapd
  1. reboot system
sudo reboot
  1. install snap core

vim ~/.pip/pip.conf, make sure the ~/.pip directory exists. fill pip.conf with:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

you can replace the tsinghua mirror with any of:

set ts=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent

set hlsearch
set backspace=2
set autoindent

vim /etc/docker/daemon.json

{
"registry-mirrors": [
  "https://ung2thfc.mirror.aliyuncs.com",
  "https://registry.docker-cn.com",
  "http://hub-mirror.c.163.com",
  "https://docker.mirrors.ustc.edu.cn"
 ]

git config credential.helper store

@alvendarthy
alvendarthy / open_2_more_instances_of_wechat_app.md
Created April 16, 2022 08:06
open 2 more instances of Wechat app
nohup /Applications/WeChat.app/Contents/MacOS/WeChat > /dev/null 2>&1 &
# copy as many lines as instances you want to open.
nohup /Applications/WeChat.app/Contents/MacOS/WeChat > /dev/null 2>&1 &
# define our own classmethod decorator
class myClassMethod():
    # init a Decorator obj, see the Decorator protocol here: https://docs.python.org/3/glossary.html#term-descriptor
    def __init__(self,func):
        self._func = func
    
    # Decorator obj as an attibute, this method handlers the getattr call.
    def __get__(self, obj, obj_type = None):
 # warp the original function