How to Yubikey: a configuration cheatsheet
tags: Yubikey source: “How to Yubikey: A Configuration Cheatsheet,” March 1, 2023. https://debugging.works/blog/yubikey-cheatsheet/.
tags: Yubikey source: “How to Yubikey: A Configuration Cheatsheet,” March 1, 2023. https://debugging.works/blog/yubikey-cheatsheet/.
tags: Python, High Performance source: Textual Documentation. “Textual - Overhead of Python Asyncio Tasks,” March 8, 2023. https://textual.textualize.io/blog/2023/03/08/overhead-of-python-asyncio-tasks/. Tasks of asyncio from create to run, then shutdown is about: 260K tasks per second.
tags: Yubikey source: BHIS. “How to Weaponize the Yubikey.” Black Hills Information Security (blog), May 2, 2019. https://www.blackhillsinfosec.com/how-to-weaponize-the-yubikey/.
tags: Online Tools,Microstartup source: https://twitter.com/vikingmute/status/1597417185470992384 HTTPS: Let’s Encrypt(acme.sh) 企业邮箱: ym.163.coom(3G 容量) zoho.com.cn/mail/ landing page 搭建 https://tailblocks.cc/ https://landing.ant.design/ 图标素材 fontawesome.com iconfinder.com 音乐素材 https://uppbeat.io 插画 https://undraw.co/illustrations https://www.manypixels.co/gallery storyset.com CDN cloudflare.com jsdelivr.com 静态托管 pages.cloudflare.com(无限请求和无线带宽) vercel.com(1G 带宽限制) 免费域名 freenom.com 免费 PS photopea.com 非关系数据库 AWS DynamoDB 25GB 存储 + 1G 传输,https://aws.amazon.com/cn/dynamodb/ Azure CosmosDB 25GB 存储,兼容 MongoDB 以及 PostgresQL 关系型数据库 https://planetscale.com 5GB 存储,每月 10亿行读,1000万行写。 监控工具 https://uptimerobot.com/ 对象存储 网易云 nos https://163yun.com/nos/free 50GB 存储,20GB下行流量/月 又拍云联盟 https://upyun.com/league 10GB 存储,25GB流量/月 https://cloudinary.com/(国外),易用、强大、25GB存储,每月 25,000 次图片转换,25GB 流量。 客户信息 ...
tags: Ethereum Before EIP 1559 The miner receive both fees and block reward. After EIP 1559 The fee divide to 2 parts: Base Fee Priority Fee The miner receive priority fee and block reward, the base fee will be burned.
source: https://github.com/papers-we-love/papers-we-love tags: Papers
source: The Refreshingly Rewarding Realm of Research Papers, 2015. https://www.youtube.com/watch?v=8eRx5Wo3xYA. tags: Papers Finding Something to Read Sources: Colleagues Papers We Love the morning paper With some topics/categories, to search on ACM Classification System(Require membership) Librarian Reading & Comprehending 3 Passes: Go though: title/sections/concclusions/references. (10min) Read more closely (1-2 hours) Mark unread References Step though closely Summarize in 1-2 sentences; outline major contributes; note strengths/weaknesses (couple hours) Implementing Use familar tools, except the paper used specific tool. Be aware to pseudo code. Prepare to work and results Test early. Test often. Interacting with the authors.
tags: Database, PostgresQL source: Crunchy Data. “Five Tips For a Healthier Postgres Database in the New Year.” Accessed February 13, 2023. https://crunchydata.com/blog/five-tips-for-a-healthier-postgres-database-in-the-new-year.
tags: Ethereum,Blockchain,Tron source: https://ethereum.stackexchange.com/a/110498 const data = '0x7ff36ab50000000000000000000000000000000000000000000000bc18ba4144048bbab00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0c5eb43e2df059e3be6e4fb0284c283caa5991900000000000000000000000000000000000000000000000000000000614d87a80000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000008ba0619b1e7a582e0bce5bbe9843322c954c340'; ethers.utils.defaultAbiCoder.decode( ['uint256', 'address[]', 'address', 'uint256'], ethers.utils.hexDataSlice(data, 4) ) // gives: [e, ["0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "0x08ba0619b1e7A582E0BCe5BBE9843322C954C340"], "0xC0C5eb43E2dF059e3Be6E4fb0284C283CAa59919", e] (4) Online tools: Playground.
tags: Blockchain
tags: Emacs source: http://bjornwestergard.com/log/2022-04-19-hypertext-emacs.gmi C-x C-f M-n to find-file-at-point.
tags: Solana, Solana 101: 2. Anchor What is Program Derived Address(PDA)?1 A Program Derived Address is simply an account owned by the program, but has no private key. Instead it’s signature is obtained by a set of seeds and a bump (a nonce which makes sure it’s off curve). “Generating” a Program Address is different from “creating” it. Generating One can generate a PDA using Pubkey::find_program_address in Rust or PublicKey.findProgramAddressSync in JavaScript; Creating a PDA essentially means to initialize the address with space and set the state to it. #+end_quote ...
tags: Nginx One Endpoint for Both WebSocket and Normal Requests,Solana,Solana 101: Create an Escrow dApp I met a lot network issues about connecting to RPC node of Solana, so I’m using a nginx server as a reverse proxy to bypass this problem: location / { # https://serverfault.com/a/923254 try_files /nonexistent @$http_upgrade; } location @ { proxy_pass https://api.testnet.solana.com; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_set_header Host "api.testnet.solana.com"; } location @websocket { proxy_redirect off; proxy_pass https://api.testnet.solana.com; proxy_http_version 1.1; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }
tags: Linux
tags: Nginx source: https://serverfault.com/a/923254 server { # ... location / { # If "Websocket" is in Upgrade header, then @websocket will take effect, # otherwise @ will take effect. try_files /nonexistent @$http_upgrade; } location @websocket { # websocket related stuff } location @ { # web related stuff } }
参考 https://github.com/RobbieXie/2020DecorationNote Ideas 在马桶旁边要留一个插座,用于智能马桶垫; 厨房油烟机机一个光滑斜面可以在餐厅坐着看锅里的情况; 全屋六类线预留 AP 和插座,最好能扩大弱电箱能放进去个 NAS; 面向扫地机器人装修;
tags: Ethereum Knowning Layer 2 Chain Rollup(or bundle) transactions off-chain to reduce fee and scale capacity, such as Bitcoin Lightning. Two layer 2 rollups Optimistic Rollups Zero-Knowledge Rollups Record on-chain state by writing calldata to L1(Ethereum), which more cheaper than change state on L1 chain. Fees Some layer 2 chain like Optimism should plus l1 fee when executing transaction on layer 1.1 Many Ethereum applications display estimated fees to users by multiplying the gas price by the gas limit. However, as discussed earlier, users on Optimism are charged both an L2 execution fee and an L1 data fee. As a result, you should display the sum of both of these fees to give users the most accurate estimate of the total cost of a transaction. ...
tags: Go Elem() Returns Value type T struct { } t := &T{} v := reflect.New(reflect.TypeOf(t)).Elem() // type of v is `T` Interface() Returns Pointer type T struct { } t := &T{} v := reflect.New(reflect.TypeOf(t)).Interface() // type of v is `&T`
tags: Solana 101: Create an Escrow dApp
tags: Solana 101: Create an Escrow dApp 连接钱包 安装 Phantom 钱包; 使用 @solana/wallet-adapter 连接钱包。官方提供了 React 相关的实现,Vue 可以通过社区提供的库:https://github.com/lorisleiva/solana-wallets-vue。 npm install solana-wallets-vue @solana/wallet-adapter-wallets 创建 SPL Token 安装依赖 npm install --save @solana/spl-token 创建代币 通过 Token Program 创建 Token,Solana 通过其特有的账号机制,通过创建一个账号并将 Owner 设置为一个统一的 Token Program 即可发行一种代币。1 发行代币 要持有代币必须创建一个对应的 Associated Token Account(ATA),也就是要接收一个代币首先要检查有没有对应代币的 ATA,没有则创建,然后给对应的 ATA 转移代币。 代币转帐 燃烧代币 SPL Token 交互:授权 Program 转帐 Libraries: spl_associated_token_account Steps: Delegate token to Program – in frontend. Create a Associated Token Account for Program to hold token. Q: How to avoid duplicated initialization? A: data size of account. Program: Transfer token from wallet to Program USDT ↩︎ ...
tags: Solana 101: Create an Escrow dApp
tags: Solana 101: Create an Escrow dApp 链上数据存储 账号所有权 账号可以通过 Metadata 指定一个 Program 作为拥有者(Owner); Program 作为拥有者可以: 修改账号数据; 可以使用该 PDA 进行签名。 PDA(Program Derived Address) 1 使用 PDA 进行合约状态链上存储。 PDA 只有一个类似公钥的地址,但是没有对应的私钥; 链下生成:通过 PublicKey.findProgramAddress 生成 PDA,seeds 用于生成多个 PDA; 链上创建:将 PDA 作为账号传递给 Program 进行链上创建:填充足够的 lamports 用于支付租金、开辟空间、指定 program 作为 Owner。 创建一个计数器 部署智能合约; 生成一个 PDA 并进行链上创建; 增加计数器; 其他账号获取 PDA,并增加计数器; 使用 Anchor 重写计数器 安装 Anchor 安装 Yarn 安装 avm cargo install --git https://github.com/project-serum/anchor avm --locked --force 使用 avm 安装 anchor avm install latest avm use latest 创建 anchor 项目 anchor init hello-anchor anchor 项目结构 Understanding Program Derived Addresses ↩︎ ...
tags: Solana 101: Create an Escrow dApp Account UTXO Unspend Transaction Output. EVM Accounts1 EOA(Externally-owned acount) - 用户用私钥控制的账号; 合约账号(Contract account) - 代码控制的账号,用于部署智能合约代码。 账号模型通过用户地址为用户开辟一块单独的存储,简单的理解就是用公私钥导出的唯一地址作为主键存储在节点的存储系统里(RocksDB); 这样只要将链上转账或者智能合约产生的结果或副作用存储在账号下面即可。 Solana Account Model Accounts2 账号用于提供给智能合约(Program)跨交易存储状态,类似文件系统; 包含元数据(metadata)说明谁有权限访问这些状态; Solana 独特的创新:账号伴有生命周期,也就是对应的私钥并不完全拥有一个账号,而是从链上租借(rent)了一个账号,并支付对应的租金,当租借过期且没有足够的余额(lamports)支付租金的情况下,账号下的数据将被链回收; 一笔交易里可以参与的账号类型有: Signers 一笔交易可以包含一个或多个签名者,表示授权此笔交易(多签机制); Read-only 交易里对该账号只读; Executable 其账号可以作为智能合约进行调用(将其账号对应的公钥地址作为 program id); Programs or Smart Contract3 账号被标记为 Executable 可以部署代码(Program)作为智能合约。两种类型的智能合约: Native Programs – 区块链系统提供的标准库; On Chain Programs – 用户开发部署到链上的智能合约。 同时智能合约可以控制多个其他账号,并且只能修改它所拥有的账号数据,但是可以读取其他账号的数据。 Solana 的 Program 可以被更新。 搭建开发环境 命令行钱包 sh -c "$(curl -sSfL https://release.solana.com/stable/install)" 连接到测试节点 solana config set --url https://api.testnet.solana.com 官方文档是连接到本地节点,这里不太推荐,因为使用测试节点可以结合链浏览器比较直观的观测结果。 ...
tags: Solana 101: Create an Escrow dApp 聊聊区块链 一个完整的区块链系统生态: 主币:进行 gas 费结算:BitCoin / ETH / TRX 等等 节点服务(JSONRPC 2.0):提供数据查询、广播交易,交易广播(P2P -> 挖矿节点); 交易验证:挣取 gas 费,出块奖励(挖矿); PoW(Proof of Work):通过算力证明提供交易验证(出块);sha256(nonce + body) -> sha256 import hashlib from typing import Tuple raw_block = b'block data' dificulty = 5 def proof_my_work(dificulty, raw_block) -> Tuple[int, str]: nonce = 1 while True: body = bytes(nonce) + raw_block h = hashlib.sha256(body) hex_value = h.hexdigest() if hex_value[:dificulty] == '0' * dificulty: return nonce, hex_value nonce += 1 proof_my_work(dificulty, raw_block) PoS(Proof of Stake):通过质押主币提供交易验证,一旦被发现作弊则扣除质押的主币; 链浏览器:通过 Web UI 进行链上数据查询; 钱包 == 私钥:资产证明,交易授权,公钥导出地址,私钥则是证明拥有该地址; 智能合约(Smart Contract):对资产进行编程; 代币(Tokens):基于智能合约实现,Fungible Tokens(ERC20 / TRC20) 和 Non-Fungible Tokens (ERC721) dApp:通过桥接钱包和链上智能合约实现一定的链上操作; 从智能合约来看各个区块链生态之间的区别 主要是虚拟机的区别,为了执行智能合约,区块链系统需要虚拟机来执行代码,目前主流的虚拟机包括: ...
tags: Solana
tags: Python _ = ( 255, lambda V ,B,c :c and Y(V*V+B,B, c -1)if(abs(V)<6)else ( 2+c-4*abs(V)**-0.4)/i ) ;v, x=1500,1000;C=range(v*x );import struct;P=struct.pack;M,\ j ='<QIIHHHH',open('M.bmp','wb').write for X in j('BM'+P(M,v*x*3+26,26,12,v,x,1,24))or C: i ,Y=_;j(P('BBB',*(lambda T:(T*80+T**9 *i-950*T **99,T*70-880*T**18+701* T **9 ,T*i**(1-T**45*2)))(sum( [ Y(0,(A%3/3.+X%v+(X/v+ A/3/3.-x/2)/1j)*2.5 /x -2.7,i)**2 for \ A in C [:9]]) /9) ) ) It generates a Mandelbrot like the code likes:
tags: GTK GTK_DEBUG=interactive my-gtk-app
tags: Cheatsheet, macOS Retrieve Bundle ID osascript -e 'id of app "/usr/local/MacGPG2/libexec/pinentry-mac.app"' osascript -e 'id of app "Finder"'
tags: PostgresQL, Cheatsheet Create User and Role Docs: Examples of Create Role CREATE ROLE whoami WITH LOGIN PASSWORD 'P@ssw0rd'; Create Database Docs: Examples of Create Database CREATE DATABASE sales OWNER whoami;
tags: GPG, GnuPG Agent,Cheatsheet Stop GPG Agent gpg-connect-agent killagent /bye obsolete option “write-env-file” - it has no effect set -gx GPG_TTY (tty) set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket) gpgconf --launch gpg-agent
tags: DeFi, Blockchain, Uniswap, Uniswap V3 I need derive price from decentralized exchanges, and I have finished some research about Uniswap v3. It’s brand new for me, and after that I want to share some ideas about DeFi, and I think it would be helpful for you to understand Uniswap and some other decentralized exchanges. DeFi from Scratch We exchange stuffs very often, and we can exchange tokens in a centralized exchange. For example, Alice owns some ETH, and Bob owns some DAI. Now, Alice want to swap some ETH for DAI, and Bob want to swap some DAI for ETH. How could they do? ...
tags: Uniswap V3 source: Shao, 田少谷. “Uniswap v3 Features Explained in Depth.” Taipei Ethereum Meetup (blog), July 20, 2021. https://medium.com/taipei-ethereum-meetup/uniswap-v3-features-explained-in-depth-178cfe45f223. Tick is a price range Each tick is a price range with upper bound and lower bound. Tick price from index: \(p(i) = 1.0001 ^ i\) 1.0001 ** 138162 # 999_998 Tick index from price: \(log_{1.0001}p\) import math math.log(1000_000, base=1.0001) # 138162.01321981344
tags: Uniswap The Graph: Uniswap V3 Subgraph
tags: Blockchain
tags: Blockchain,Ethereum,DeFi
tags: Blockchain,Ethereum source: “Graphical Guide to Understanding Uniswap - EthHub.” Accessed August 23, 2022. https://docs.ethhub.io/guides/graphical-guide-for-understanding-uniswap/. ERC20 tokens are the most common type of token built on top of Ethereum. They are fungible in nature, meaning that there isn’t a distinction between individual tokens. For example, if I have 100 metal marbles in my hand that are all the same size and color, it doesn’t matter which one I give you. In the same way, if I have 100 of the same ERC20 token, it doesn’t matter which one I give you. This contrasts with ERC721 tokens which are non-fungible tokens (NFTs) such as cryptokitties. ...
tags: Makefile source: Davis-Hansson, Jacob. “Your Makefiles Are Wrong.” Jacob Davis-Hansson on Tech, December 15, 2019. https://tech.davis-hansson.com/p/make/. Best Makefile Defaults # Always use bash as the shell. SHELL := bash # Enable bash strict mode. .SHELLFLAGS := -eu -o pipefail -c ## Change some Defaults of Make. # Ensures each Make recipe is ran as one single shell session, # rather than one new shell per line. .ONESHELL: # Delete it's target file if a Make rule fails. .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules # Always use GNU Make. ifeq ($(origin .RECIPEPREFIX), undefined) $(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later) endif # Use '>' to instead of tab. .RECIPEPREFIX = >
tags: Online Tools website: https://www.castfeedvalidator.com/
tags: Solana, Solana 101: 1. Develop Model Account: a Memory region The solana term for a memory region is “account”. Some programs own thousands of independent accounts. Programs own accounts, aka the owner of accounts. Transactions and Accounts You can make a program read and write data by sending transactions. Programs provide endpoints that can be called via transactions (In reality it’s a bit more complex than that but frameworks like Anchor abstract away this complexity). A function signature usually takes the following arguments: ...
tags: Solana, Solana 101: 1. Develop Model Program Owns Accounts And each memory region has a program that manages it (sometimes called the “owner”). How to Communicate with Solana Programs? Off-chain This means your programs aren’t on-chain program, you can submit transactions with instructions to the network, it could be done via the JSON RPC API or any SDK built on top this API. On-chain TODO
tags: Rust source: Johnston, Dylan R. “Formally Verifying Rust’s Opaque Types,” August 1, 2022. https://dylanj.xyz/posts/rust-coq-opaque-types/. Prelude trait ToString { fn to_string(&self) -> String; } Static Dispatch fn yell<S: ToString>(stringable: S) { println!(stringable.to_string().to_uppercase()) } Dynamic Dispatch fn yell(stringable: &dyn ToString) { println!(stringable.to_string().to_uppercase()) } impl Trait fn yell(stringable: impl ToString) { println!(stringable.to_string().to_uppercase()) }
tags: Flutter,GUI,macOS souce: https://github.com/flutter/flutter/issues/73122 To solve this problem we should specify MACOSX_DEPLOYMENT_TARGET: I would imagine that there is Apple documentation on managing build settings in Xcode, but I don’t have a link offhand. There’s no Flutter-specific documentation of the process, if that’s what you mean; it isn’t any different in a Flutter macOS application as it would be any other macOS application. If you don’t want to use Xcode, you can change MACOSX_DEPLOYMENT_TARGET directly in Runner.xcodeproj/project.pbxproj. ...
macOS Press Command + Shift + Control + D to enter debug mod. Then you can open url in brower: Help -> Debug -> 「浏览器 webview 相关-系统浏览器打开网页」
tags: GUI
tags: Rust,Flutter,iOS source: “Using Dummy Headers - Flutter_rust_bridge.” Accessed July 25, 2022. http://cjycode.com/flutter_rust_bridge/integrate/ios_headers.html. Recently, I met a problem that the iOS app didn’t work properly in release mode. After a little searching, I found it’s a Flutter app and invoked a Rust function by FFI. The inital call were not invoked during app startup, and it should be. I finally resolved the problem by following: https://github.com/fzyzcjy/flutter_rust_bridge/issues/496 http://cjycode.com/flutter_rust_bridge/integrate/ios_headers.html In short: Xcode will strip the unused symbols in release mode, and won’t realize the FFI invocation; So we need add some dummy invocations to the AppDelegate.swift to make sure it have been used. Next, add this line to ios/Runner/Runner-Bridging-Header.h: ...