Skip to content

Instantly share code, notes, and snippets.

View iaGuoZhi's full-sized avatar
🗺️
active

iaGuoZhi

🗺️
active
View GitHub Profile
flex
bison
libelf-dev
libssl-dev
pkg-config
libncurses-dev
// myvector.h
//in case mutliple files in a project include strvector,
//this instruction says only compile this file once!
#ifndef STRVECTOR_H
#define STRVECTOR_H
#include <algorithm>
#include <iostream>
template<typename T>
@iaGuoZhi
iaGuoZhi / global_variable_llvm.c
Created July 18, 2022 08:54
get global variable's value in llvm
Constant *c;
if (isa<GlobalValue>(c)) {
GlobalValue *gvalue = dyn_cast<GlobalValue>(c);
GlobalVariable *gv = dyn_cast<GlobalVariable>(gvalue);
ConstantInt *ci = dyn_cast<ConstantInt>(gv->getInitializer());
errs() << ci->getValue();
}
@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;
#!/usr/bin/python3
# Mastery Check-in Quiz Framework built by Sathya Edamadaka for 106L Interview
# This script runs one or more tests as indicated in the file "test_cases", and
# prints out any information about any test failures. Heavily inspired by the CS111
# autograder, but fundamentally different in usage and structure.
# Usage:
# autograder [test_case_file]
# If test_case_file is provided, it name a file containing test case
# descriptions; otherwise information is read from the file "test_cases."
@iaGuoZhi
iaGuoZhi / .ctags
Created May 4, 2022 02:04
ctags for Rust
--langdef=Rust
--langmap=Rust:.rs
--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(static|const)[ \t]+(mut[ \t]+)?([a-zA-Z0-9_]+)/\4/c,consts,static constants/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\3/t,traits,traits/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+(for)[ \t]+)?([a-zA-Z0-9_]+)/\5 \7 \8/i,impls,trait implementations/
use std::collections::HashMap;
let rand = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().subsec_micros();
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
static int nthread = 1;
static int round = 0;
struct barrier {
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
#include <sys/time.h>
#define NBUCKET 5
#define NKEYS 100000
@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