Skip to content

Instantly share code, notes, and snippets.

View iaGuoZhi's full-sized avatar
🗺️
active

iaGuoZhi

🗺️
active
View GitHub Profile
@iaGuoZhi
iaGuoZhi / virt_to_phys_user.c
Created July 10, 2022 08:02 — forked from a9QrX3Lu/virt_to_phys_user.c
Convert virtual address to physical address in user space
#define _XOPEN_SOURCE 700
#include <fcntl.h> /* open */
#include <stdint.h> /* uint64_t */
#include <stdio.h> /* printf */
#include <stdlib.h> /* size_t */
#include <unistd.h> /* pread, sysconf */
typedef struct {
uint64_t pfn : 55;
unsigned int soft_dirty : 1;
@iaGuoZhi
iaGuoZhi / install_xelatex_on_mac.txt
Created April 21, 2022 14:07 — forked from peterhurford/install_xelatex_on_mac.txt
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
brew install pandoc
brew tap homebrew/cask
brew install --cask basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2020basic/bin/x86_64-darwin`
sudo tlmgr update --self
sudo tlmgr install texliveonfly
sudo tlmgr install xelatex
sudo tlmgr install adjustbox
sudo tlmgr install tcolorbox
@iaGuoZhi
iaGuoZhi / helloproc.c
Created April 17, 2022 08:52 — forked from BrotherJing/helloproc.c
write a kernel module, which create a read/write proc file
#include<linux/module.h>
#include<linux/init.h>
#include<linux/proc_fs.h>
#include<linux/sched.h>
#include<linux/uaccess.h>
#include<linux/fs.h>
#include<linux/seq_file.h>
#include<linux/slab.h>
static char *str = NULL;
@iaGuoZhi
iaGuoZhi / .clang-format
Created April 6, 2022 10:20 — forked from elmarco/.clang-format
qemu .clang-format
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
Language: Cpp
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false # although we like it, it creates churn
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: false # churn
@iaGuoZhi
iaGuoZhi / gist:435cfa0de9780dee4a4e13313ae00473
Created March 4, 2022 06:44 — forked from jwebcat/gist:5122366
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <assert.h>
#include <sys/time.h>
#define LOOPS 100000
@iaGuoZhi
iaGuoZhi / IOMMU support in Linux kernel.md
Created November 16, 2021 06:10 — forked from abelardojarab/IOMMU support in Linux kernel.md
Verifying IOMMU support in Linux kernel

Basic stuff

ACPI enumerates and lists the different DMA engines in the platform, and device scope relationships between PCI devices and which DMA engine controls them.

How is IOVA generated?

@iaGuoZhi
iaGuoZhi / jd.py
Created October 3, 2021 12:53 — forked from a9QrX3Lu/jd.py
Auto buying script for jd
#!/usr/bin/python3
#coding:utf-8
import time
from selenium import webdriver
# enter username and password below
jd_up={"ue":"***","pd":"***"}
chrome=webdriver.Chrome()
chrome.get(url="https://passport.jd.com/new/login.aspx?")
chrome.find_element_by_xpath("//*[@id=\"content\"]/div/div[1]/div/div[3]/a").click()
@iaGuoZhi
iaGuoZhi / commands.md
Last active October 29, 2021 06:50 — forked from stdrc/commands.md
常用命令

常用小命令

Linux 用户相关

sudo 免密码:

su - # 进入 root shell
visudo
# 添加 user-name ALL=(ALL) NOPASSWD:ALL
@iaGuoZhi
iaGuoZhi / setup-sjtu-vpn.sh
Last active September 25, 2021 13:17 — forked from yuq-1s/setup-sjtu-vpn.sh
Setup SJTU VPN connection from Ubuntu 18.04 desktop
# Install dependencies
sudo apt install libcurl4-openssl-dev libip4tc-dev libiptc-dev autoconf libgmp3-dev libssl-dev pkg-config
# Install StrongSwan
wget http://download.strongswan.org/strongswan-5.6.1.tar.bz2
tar xjvf strongswan-5.6.1.tar.bz2 && cd strongswan-5.6.1
# FIXME: Some of these options may be redundant, but they work on my laptop.
autoconf && ./configure \
--prefix=/usr/local \