Skip to content

Instantly share code, notes, and snippets.

View pidb's full-sized avatar
I need a lot of coffee...

Jackson Xu pidb

I need a lot of coffee...
View GitHub Profile
@pidb
pidb / dive_into_ethereum.md
Created April 16, 2024 15:49 — forked from stonegao/dive_into_ethereum.md
Dive Into Ethereum

深入理解以太坊

-w1544

目标

  • 理解以太坊的底层运行机制
    • 本文主要关注为什么这么做、基本原理、实现效果,2/8法则,花 20% 的精力掌握 80% 的内容
    • 细节实现会留 reference,如果想研究,建议用以下方式:1. 走一遍 demo,搞清楚所有的细节,例如 EVM 合约的执行流程;2. 自己实现一遍,比如 MPT、EVM,甚至整个以太坊客户端。
  • 概览以太坊生态全景
@pidb
pidb / dive_into_ethereum.md
Created April 14, 2024 13:13 — forked from cryptowen/dive_into_ethereum.md
Dive Into Ethereum

深入理解以太坊

-w1544

目标

  • 理解以太坊的底层运行机制
    • 本文主要关注为什么这么做、基本原理、实现效果,2/8法则,花 20% 的精力掌握 80% 的内容
    • 细节实现会留 reference,如果想研究,建议用以下方式:1. 走一遍 demo,搞清楚所有的细节,例如 EVM 合约的执行流程;2. 自己实现一遍,比如 MPT、EVM,甚至整个以太坊客户端。
  • 概览以太坊生态全景
# disable keyboard
sc config i8042prt start= disabled
# enable keyboard
sc config i8042prt start= auto
@pidb
pidb / wsl-sshd-proxy.ps1
Created August 28, 2022 03:33
The script can help you proxy wsl2 ssh service.
# define proxy address
$addr='0.0.0.0';
$port=22222
# Get wsl2 ip addres
$wsl_ip_all = wsl.exe hostname -I
$wsl_ip = $wsl_ip_all.Split(" ")[0]
$wsl_ssh_port = 22222
use std::io::Write;
use std::sync::atomic::{self, AtomicU8};
use std::sync::Arc;
use std::thread::{self};
struct SpinLock {
flag: AtomicU8,
}
impl SpinLock {
@pidb
pidb / zsh-fancify.sh
Created May 12, 2022 01:54 — forked from anthonyaxenov/zsh-fancify.sh
Installing zsh / oh-my-zsh / Powerlevel10k on Ubuntu 20.04
#!/bin/bash
# Based on:
# https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions
# https://github.com/ohmyzsh/ohmyzsh
# https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
# https://gist.github.com/dogrocker/1efb8fd9427779c827058f873b94df95
# https://linuxhint.com/install_zsh_shell_ubuntu_1804/
echo "*********************************************"
echo " zsh fancifier"
@pidb
pidb / lower_bound_and_insert_here.cpp
Created December 20, 2021 13:16
Find the index position of the lower boundary in the array, then insert the data to the index, and move the index to all elements backward by one
#include <iostream>
#include <string>
int main() {
std::string s("ABCCDDEEFF");
int l = 0;
int r = s.size() - 1;
int mid;
char c = 'G';
while (l <= r) {
@pidb
pidb / ref_traits.rs
Created November 25, 2021 15:23
[rust] References to traits in structs
/// see https://stackoverflow.com/questions/26212397/references-to-traits-in-structs
#![allow(unused)]
use std::borrow::Borrow;
trait Type {
fn type_to_string(&self) -> String;
}
struct BoolType {}
impl Type for BoolType {
@pidb
pidb / slice_ptr_mutual_conversion.rs
Created November 23, 2021 15:24
slice and raw pointer mututal conversions in rust
#![allow(unused)]
fn to_mut_ptr(data: Vec<u8>) -> *mut u8 {
unsafe { data.to_owned().as_mut_ptr() }
}
fn main() {
let s = String::from("hello world");
let mut storage = vec![0; s.len()];
@pidb
pidb / serialize_u32_to_bytes.rs
Last active November 21, 2021 10:59
Serialize u32 to bytes and Deserialize u32 from bytes
/// idea from https://docs.rs/byteorder/1.4.3/src/byteorder/lib.rs.html
#![allow(unused)]
fn main() {
let mut x: Vec<u8> = Vec::new();
x.reserve(16);
let y: u32 = 12;
unsafe {
// write y to byte array