Skip to content

Instantly share code, notes, and snippets.

View XiangpengHao's full-sized avatar

Xiangpeng Hao XiangpengHao

View GitHub Profile
@XiangpengHao
XiangpengHao / ht_ref.rs
Created July 4, 2024 15:28
Rust borrow checker
use std::{
cell::RefCell,
collections::{hash_map::Entry, HashMap},
rc::Rc,
};
type BlockId = u64;
type InodeId = u64;
@XiangpengHao
XiangpengHao / setup.sh
Last active April 24, 2024 19:39
CloudLab setup
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common byobu \
fish numactl libssl-dev pkg-config clang llvm-dev vim ipython3 curl git git-lfs \
htop shellcheck valgrind cpufrequtils cloc python3-pip cmake sysstat pre-commit
byobu-enable
#include <sys/mman.h>
#include <cstdint>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cassert>
static const uint64_t pool_size = 1024ull * 1024 * 1024;
static const char *pool_path = "/mnt/pmem0/test_mmap";
### Keybase proof
I hereby claim:
* I am xiangpenghao on github.
* I am haoxiangpeng (https://keybase.io/haoxiangpeng) on keybase.
* I have a public key whose fingerprint is 7B4D 504F 4EBE 0A92 38FF CCDC 669C 630E 6D6D 049B
To claim this, I am signing this object:
@XiangpengHao
XiangpengHao / test_clwb.cpp
Last active January 19, 2021 09:42
Code used for testing clwb instruction. https://blog.haoxp.xyz/posts/is-clwb-implemented/
#include <glog/logging.h>
#include <x86intrin.h>
#include <chrono>
#include <iostream>
using namespace std::chrono;
#define TIME_BODY(name, body) \
do { \
auto start = high_resolution_clock::now(); \
@XiangpengHao
XiangpengHao / setup.sh
Last active December 11, 2020 04:30
raspi setup
sudo apt update
sudo apt upgrade -y
# setup shell
sudo apt install -y byobu fish vim ipython3 curl git
byobu-enable
curl -L https://get.oh-my.fish > install
fish install --path=~/.local/share/omf --config=~/.config/omf
omf install bobthefish
echo 'set -g theme_date_format "+%a %H:%M"' >> ~/.config/fish/conf.d/omf.fish
@XiangpengHao
XiangpengHao / jupyter_nginx.conf
Created August 10, 2017 07:48
A Jupyter reverse proxy
server {
listen 80;
server_name jupyter.haoxp.xyz;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host;
@XiangpengHao
XiangpengHao / site.conf
Created December 12, 2016 04:04
A simple Nginx config template
server{
listen 80;
server_name file.zjuqsc.com;
return 301 https://$host$request_uri;
}
server {
listen 12081;
listen 443 ssl http2;
server_name file.zjuqsc.com;
ssl_certificate /srv/ssl/file.zjuqsc.com.crt;