2022/03/06

BlockChain 相关电子书

@copyright of Sam Chadwick  - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper


Blockchain Papers

A curated list of blockchain-related academic papers.

General

Consensus

Cryptography

Block generation parameters

Stake

Attacks

Wallets

Crime

Economics

Marketplaces and Trust

Privacy

Sidechains, Higher layer and Scalability

Fungibility

Network

Smart Contracts

Formal Methods

Proof of work

Survey, Sociological & Anthropological

2020/05/05

用 Visual C++ Build Tool 编译 Lua 5.3 源代码

Windows 下用 Microsoft Visual C++ Build Tool 来编译 Lua 5.3 源代码 其实很简单。
  1. 打开一个编译命令行窗口
  2. 解开 Lua 5.3.x 的源代码到 C:\Lua53
  3. 进入src目录, 执行下面的命令
REM cd src
del *.o *.obj *.res
cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
ren lua.obj lua.o
ren luac.obj luac.o
IF EXIST wmain.obj ren wmain.obj wmain.o
link /DLL /OUT:lua53.dll *.obj
link /OUT:lua53.exe lua.o lua53.lib
lib /OUT:lua53a.lib *.obj
link /OUT:luac.exe luac.o lua53a.lib
IF NOT EXIST wlua.rc goto DEPLOY
rc wlua.rc
link /subsystem:windows /OUT:lua53w.exe wmain.o lua.o wlua.res lua53.lib
del /y *.o *.obj *.res
:DEPLOY
move /y *.exe ..
mkdir /y ..\lib
move /y *.lib ..\lib\

2020/01/28

利用 socat 搭建一个简易 VPN 的服务端脚本

Server Side - Bash

#!/bin/bash

[[ $# -lt 3 ]] && echo "Usage: $0 tunID udp-port remote.lan.ip/net" && exit 255

TUN_ID=$(echo $1 | tr -d '[a-zA-Z]+')
[[ "$TUN_ID" != "$(( $TUN_ID / 1 ))" ]] && echo "tunID:\"$1\" must suffix with a number!" && exit 254

## Debug
TUN_DEV=$1
LOCAL_INT="192.168.2.$(( $TUN_ID % 64 * 4 + 1 ))/30"
REMOTE_INT="192.168.2.$(( $TUN_ID % 64 * 4 + 2 ))"
UDP_PORT=$2
REMOTE_LAN=$3

# kill exists
pkill -f "tun-name=$TUN_DEV"

socat tun:$LOCAL_INT,tun-name=$TUN_DEV,up udp4-listen:$UDP_PORT,fork &
sleep 3

# tunX options
ip link set $TUN_DEV mtu 1452

shift 2

# Add all the given subnet to SNAT
for net in $*;do 
  ip route add $net dev $TUN_DEV
  iptables -t nat -I POSTROUTING -s $net -j SNAT --to-source $(hostname -i) 
done

Client Side - BusyBox

#!/bin/sh

[[ $# -lt 2 ]] && echo "Usage: $0 tunID remote.ip.udp:port" && exit 255

TUN_ID=$(echo $1 | tr -d '[A-Za-z]+')
[[ "$TUN_ID" != "$(( $TUN_ID / 1 ))" ]] && echo "tunID:\"$1\" must suffix with a number!" && exit 254

TUN_DEV=$1
LOCAL_INT="192.168.2.$(( $TUN_ID % 64 * 4 + 2 ))/30"
REMOTE_INT="192.168.2.$(( $TUN_ID % 64 * 4 + 1 ))"
REMOTE_UDP=$2

kill $(ps | grep tun-name=$TUN_DEV | cut -d ' ' -f 1) 2>/dev/null

socat tun:$LOCAL_INT,tun-name=$TUN_DEV,up udp4-connect:$REMOTE_UDP &
sleep 3

# MTU
ip link set $TUN_DEV mtu 1452

# IP Route2
ip route add default via $REMOTE_INT table $TUN_DEV
ip rule add from $REMOTE_INT table $TUN_DEV


2019/12/28

如何在 OpenWRT 下产生随机数:

MY_RANDOM=$(head /dev/urandom | tr -dc "0123456789" | head -c4)

如果是的Bash, Zsh, 或者BusyBox启用了RANDOM, 是可以直接使用内置的 $RANDOM 变量

MY_RANDOM=$RANDOM

如果需要限定数字的大小,可以使用 Shell 内置的运算表达式 $(( expr ))

MY_VAL=$(( MY_RANDOM % 200 + 1 ))

2019/03/07

拼音加加双拼输入方案

为Windows 10 添加拼音加加双拼输入方案

把下面的内容保存为 ppp.reg, 然后双击导入注册表,Pinyin PlusPlus双拼输入方案就有了。

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS]
"UserDefinedDoublePinyinScheme0"="Pinyin PlusPlus*1*^*uivsfgdwrtqbjhkmlqynypbxchxvzovx"

2018/09/03

vimrc 备份

  1 "" Let's start VIM journey
  2 set nocompatible
  3 
  4 "" Include default settings
  5 "source $VIMRUNTIME/vimrc_example.vim
  6 "source $VIMRUNTIME/gvimrc_example.vim
  7 
  8 "" shell settings
  9 let $PATH="$HOME/bin;C:/msys64/usr/bin;C:/msys64/mingw64/bin;C:/Windows;C:/Windows/System32"
 10 set shell=bash.exe
 11 set shellslash
 12 
 13 "" Don't need ugly files
 14 set backupdir=c:/temp/vim/backup
 15 set directory=c:/temp/vim/swap
 16 set nobackup
 17 set swapfile
 18 set undodir=c:/temp/vim/undo
 19 set undofile
 20 set writebackup
 21 
 22 "" UI settings
 23 set cmdheight=2
 24 "set guioptions-=t
 25 set laststatus=2
 26 set lazyredraw
 27 set lines=35 columns=160
 28 set number
 29 set renderoptions=type:directx
 30 set ruler
 31 set showcmd
 32 set wildmenu
 33 
 34 "colorscheme torte
 35 colorscheme koehler
 36 
 37 "" Tab/Space related
 38 set expandtab
 39 set shiftwidth=4
 40 set softtabstop=4
 41 set tabstop=4
 42 
 43 "" IME settings
 44 if has("multi_byte")
 45   set encoding=utf-8
 46   "let &termencoding = &encoding
 47   set termencoding=unicode
 48   " Set default encoding as UTF-8 with BOM
 49   setglobal fileencoding=utf-8 "bomb "bomb introduce problem for *nix
 50   set fileencodings=ucs-bom,utf-8,gb18030,cp936,cp950,latin1
 51   " Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2
 52   augroup i18n
 53     autocmd!
 54     autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif
 55   augroup END
 56 endif
 57 
 58 "" Enable the Chinese characters
 59 "set guifont=Fira_Code:h11:cANSI,NSimSun:h12:cGB2312
 60 set guifont=Iosevka:h12:cANSI:qDRAFT ",SimHei:h12:cGB2312:qDRAFT
 61 "set guifontwide=SimHei:h12:cGB2312
 62 "set guifontwide=Microsoft_YaHei:h12:cGB2312
 63 set guifontwide=Noto_Mono:h12:cGB2312
 64 
 65 "" IME
 66 if has('multi_byte_ime')
 67   "未开启IME时光标背景色
 68   hi Cursor guifg=bg guibg=Orange gui=NONE
 69   "开启IME时光标背景色
 70   hi CursorIM guifg=NONE guibg=Skyblue gui=NONE
 71   " 关闭Vim的自动切换IME输入法(插入模式和检索模式)
 72   set iminsert=0 imsearch=0
 73   " 插入模式输入法状态未被记录时,默认关闭IME
 74   inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
 75 endif
 76 
 77 "" Useful Plugins
 78 packadd vim-fugitive
 79 "" Plugin - airline
 80 let g:airline_theme='solarized'
 81 let g:airline_detect_iminsert=1
 82 let g:airline_highlighting_cache = 1
 83 let g:airline_powerline_fonts = 1
 84 let g:airline#extensions#tabline#enabled = 1
 85 packadd vim-airline
 86 packadd vim-airline-themes
 87 
 88 "" Plugins
 89 packadd! emmet-vim
 90 packadd! ctrlp.vim
 91 packadd! nerdtree
 92 
 93 "" Key Maps
 94 "" display the syntax name under the cursor
 95 map <F12>   :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")<CR>
 96 "" We can navigate the list by using the <F3> and <S-F3>
 97 map <F3>    :cnext<CR>
 98 map <S-F3>  :cprevious<CR>
 99 "" Let's help the tab navigation a little
100 map <F4>    :try\|:next\|finish\|catch\|:tabnext\|endtry<CR>
101 map <S-F4>  :bdelete<CR>
102 "" Tlist and NERDTree
103 map <F5>    :NERDTreeToggle<CR>
104 map <S-F5>  :Tlist<CR>
105 set tags=./tags,../tags,../../tags,../../../tags
106 "" open Terminal
107 tmap <F9>   <C-W>:$tabnew +:term<CR><C-W>o
108 map <F9>    :$tabnew +:term<CR><C-W>o
109 
110 

2017/09/10

LeEco Le Pro3 三方ROM不完全集合

= 国外大神团队制作的 Android N v7.1.x 的 ROM = 

LineagoOS v13.0, v14.1 - http://www.lineagoos.org 

三方ROM的鼻祖,历史最有旧,传承自CyanogenMod;各方面都挺完善。文档最完备。 但是WIFI EAP-TLS密钥模式无法工作
download: https://download.lineageos.org/zl1

Paranoid Android - http://www.aospa.co 

很优雅,WIFI EAP-TLS密钥模式可以工作。 但是对App的管控不严,而且没法手动调整,耗电比较快
download: http://get.aospa.co/official/zl1

OmniRom v7.1.2 - https://omnirom.org/ 

总体来说是一个非常严谨的ROM, 所有功能都可用包括NFC卡模拟, 耗电控制很好, 可以通过 Security --> App Ops 来控制自启动; OmniSwitch 让人很有控制感,虽然界面有些粗糙
download: http://dl.omnirom.org/zl1/

AICP v12.1 - http://www.aicp-rom.com/ 

定制内核, 这个还没来得及尝试!
download: http://dwnld.aicp-rom.com/?device=zl1

AospExtended v4.2 - http://www.aospextended.com/ 

基于AOSP开发的, https://forum.xda-developers.com/le-pro3/development/rom-aospextended-rom-v4-2-t3609490 还没有尝试过
download: http://downloads.aospextended.com/zl1/

ResurrectionRemix v5.8.4 - http://www.resurrectionremix.com/ 

基于 LineageOS, 没有尝试过!
download: https://sourceforge.net/projects/resurrectionremix/files/zl1/

= 提示 = 

NFC 卡模拟功能在大多数的ROM上都不行, 貌似是缺少 Smartcard Service 可以尝试这个: https://www.androidfilehost.com/?fid=673368273298973070

= 其他 = 

MoKee - http://www.mokeedev.com/ 

基于 LineageOS 添加了 XposedInstaller, 宙斯盾防启动, 自带ROOT; 中规中矩。主要是中国开发者,生存状态让人比较纠结,特别是下载 //sigh

MANOSP - MIUI and EMUI mod - http://www.manosp.com 

微博 mandfx 小神之作, 内置了 ROOT 和 Xposed Framework。 适合那些超级爱折腾的用户
download http://www.manosp.com/archives/category/letv/x720/

2017/06/03

在 MinTTY 内运行为 windows cmd 准备的程序

Git for Windows 自带的 MinTTY 是一个非常不错的命令行终端模拟器, 它是从PuTTY的代码里派生的,在MinGW32/W64 和 MSYS1/2 都有使用。 但是MinTTY对于那些为Windows Console (CMD) 定制的程序就有些行为异常。  在这种情况下 就要用到 WinPty.exe 了。

比如我在 MSYS 里面创建了一个脚本:/usr/bin/perl6 它来调用 perl6 MoarVM, 但是MoarVM 是用VC编译的,需要执行在 Windows CMD里面,脚本内容如下:


#!/bin/bash
/bin/winpty.exe /c/rakudo/bin/moar.exe --execname='C:\rakudo\bin\perl6.bat' --libpath="C:/rakudo/share/nqp/lib" --libpath="C:/rakudo/share/nqp/lib" --libpath="C:/rakudo/share/perl6/lib" --libpath="C:/rakudo/share/perl6/runtime" C:/rakudo/share/perl6/runtime/perl6.moarvm $*

没有 winpty.exe的话, moar.exe 和MinTTY 的交互行为就比较奇怪。

关于WinPty的更多信息: https://github.com/rprichard/winpty
Windows 上 Unix PTY 模拟程序的一些介绍: https://blog.toonormal.com/2012/11/17/gcc-msys-mintty-pdcurses-winpty-and-good-times-in-the-shell/

2017/05/13

如何发现Google的所有 IP地址 / howto discover all the IP addresses of Google

Google 其实自己告诉你了,  只不过你需要掌握正确的方法来获取。

  1. nslookup
    使用DNS 查询工具
  2. set server 8.8.8.8
    设置 使用google的 Public DNS 服务器
  3. set type=txt
    查询 TXT 字段
  4. google.com
    查询 google.com
  5.  _spf.google.com
    查询 网段信息
  6. _netblocks.google.com

BlockChain 相关电子书

@copyright of Sam Chadwick   - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper Blockchain Papers A c...