Skip to content

Instantly share code, notes, and snippets.

View kmalloc's full-sized avatar
🍊
I may be slow to respond.

Mingdong Liao kmalloc

🍊
I may be slow to respond.
View GitHub Profile
@kmalloc
kmalloc / layer2-intro.md
Last active August 25, 2023 09:03
layer 2 简介

区块链是分布式的共识账本, 网络中节点众多, 各节点达成共识需要复杂的协议交互(POW 算哈希/POS 投票), 导致系统整体并发能力低下, 无法支持大规模大范围应用(TPS极其低), 拥挤的结果是区块空间异常昂贵, 解决的方法是减少底层 transaction 数量, 把部分计算和存储移到线下.

image

state channel

bitcoin 上的闪电网络采取的方案, 基本思路是交互双方很多的中间交易是不必全部放到区块链中的, 此时可以通过把钱放到一个合约里面, 线下双方双签维护金额的变化即可, 无需其它无关人士来参与并协调达成共识, 具体例子参考[5]. image

@kmalloc
kmalloc / memory_layout.md
Created July 26, 2018 01:55 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@kmalloc
kmalloc / procstat.c
Created April 18, 2018 09:41 — forked from arbinish/procstat.c
/proc/<PID>/stat information
/*
* Displays linux /proc/pid/stat in human-readable format
*
* Build: gcc -o procstat procstat.c
* Usage: procstat pid
* cat /proc/pid/stat | procstat
*
* Homepage: http://www.brokestream.com/procstat.html
* Version : 2009-03-05
*
@kmalloc
kmalloc / cloudSettings
Last active September 3, 2021 11:16
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-09-03T11:16:36.410Z","extensionVersion":"v3.4.3"}
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <poll.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <iostream>
#include <assert.h>
const int OP_MAX = 9;
@kmalloc
kmalloc / ipow.c
Last active August 29, 2015 14:06 — forked from orlp/ipow.c
int64_t ipow(int32_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1