Skip to content

Instantly share code, notes, and snippets.

@Ljzn
Ljzn / byzantine.txt
Created September 23, 2017 10:12
The Byzantine Generals Problem
Reliable systems must hanlde conflicting information.
The problem is slovable if and only if more than two-thirds loyal generals.
If messages unforgeable, the problem is solvable for any number of generals.
The algorithm must guarantee:
A. All royal generals decide upon the same plan of action.
B. A small number of traitors cannot cause the loyal generals to adpot a bad plan.
@Ljzn
Ljzn / pbft.txt
Created September 25, 2017 13:14
[1999.2]Practical Byzantine Fault Tolerance
It uses only one message round trip to execute read-only operations and two to execute read-write operations.
Survives in asynchronous networks.
Messages contain public-key signatures, message authentication codes, and message digests produced by collision-resistant hash functions.
<m>sign(i): message m signed by node i.
D(m): digest of message m.
NEO_VERSION=2.7.5
NEO_DOWNLOAD_URL=https://github.com/neo-project/neo-cli/releases/download/v$NEO_VERSION/neo-cli-linux-x64.zip
NEO_BLOCK_URL=http://static.neo.org/client/chain.acc.test.zip
# dotnet
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1.200
# neo-cli deps
op_5 OP_TOALTSTACK
0 OP_TOALTSTACK
OP_FROMALTSTACK
OP_FROMALTSTACK
OP_DUP
3 OP_PICK
OP_1ADD
OP_SWAP
OP_TOALTSTACK
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<canvas id="canvas"></canvas>
<button id="start">START</button>
@Ljzn
Ljzn / bone.ts
Last active February 28, 2019 11:11
// A tool for creating new deno project.
//
// Download this file, then add `alias bone="deno -A bone.ts"` to your ~/.bashrc.
//
// Usage: bone [task]
//
// Examples:
//
// bone new PATH - Creates a new deno project at the given path
//
@Ljzn
Ljzn / aliyunmail.ex
Created July 16, 2019 16:59
阿里云邮件推送 elixir sdk. aliyun mail elixir sdk
defmodule Aliyunmail do
@url "https://dm.ap-southeast-1.aliyuncs.com"
@access_key_id "LTAIBXtSnSsfyHPB"
@secret "xxxxx&"
def send_mail(to_address, html_body) do
unsigned = %{
"Action" => "SingleSendMail",
@Ljzn
Ljzn / rainbow.ex
Created July 18, 2019 19:39
Concurrent Rainbow 7 个进程相互之间并不通信, 它们只和一个中心通信, 最后 7 个进程都拥有了各自独特的颜色
defmodule Rainbow do
@moduledoc """
Documentation for Rainbow.
"""
@colors ~w(赤 橙 黄 绿 青 蓝 紫)
def start do
node = spawn(fn ->
loop([])
const FundamentalObjects = [
Object,
Function,
Boolean,
Symbol,
Error
]
const NumbersAndDates = [
Number,