Skip to content

Instantly share code, notes, and snippets.

View cryptowen's full-sized avatar
🎯
Focusing

Owen cryptowen

🎯
Focusing
View GitHub Profile
@cryptowen
cryptowen / sui-dev-suggestions.md
Last active September 30, 2022 07:12
SUI development suggestions

Support View Functions and Associated Query API

If we want to query the state of a module, the only way now is to do that is query related objects and read the data.

There are some cases we want to store some data, but get calculated results based on the stored data.

For example, we have a complex mechanism to calculate reward based on many parameters, and it changes according to time. Since there is no such view functions in sui Move and associated query API, we have to implement the calculation methods in both the contract and the frontend.

More Efficient Objects Queries

@cryptowen
cryptowen / Playground.hs
Created February 18, 2022 02:26
Plutus Playground Smart Contract
import Control.Monad (void)
import Ledger (Address, ScriptContext, PaymentPubKeyHash)
import Ledger.Constraints qualified as Constraints
import Ledger.Typed.Scripts qualified as Scripts
import Ledger.Value (Value)
import Playground.Contract
import Plutus.Contract
import PlutusTx qualified
import PlutusTx.Prelude hiding (Applicative (..))
@cryptowen
cryptowen / dive_into_ethereum.md
Last active October 29, 2024 14:49
Dive Into Ethereum

深入理解以太坊

-w1544

目标

  • 理解以太坊的底层运行机制
    • 本文主要关注为什么这么做、基本原理、实现效果,2/8法则,花 20% 的精力掌握 80% 的内容
    • 细节实现会留 reference,如果想研究,建议用以下方式:1. 走一遍 demo,搞清楚所有的细节,例如 EVM 合约的执行流程;2. 自己实现一遍,比如 MPT、EVM,甚至整个以太坊客户端。
  • 概览以太坊生态全景
@cryptowen
cryptowen / weak.rs
Last active September 18, 2019 17:00
rust weak self reference
use std::cell::RefCell;
use std::rc::{Rc, Weak};
struct Bank {
vm: RefCell<Weak<VM>>,
}
impl Bank {
fn call(&self, addr: &str, method: &str) {
println!("bank: {} {}", addr, method);
@cryptowen
cryptowen / trie.go
Last active April 18, 2019 04:06
ehtereum trie in golang and python
package main
import (
"bytes"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/trie"
)
@cryptowen
cryptowen / mymodule.c
Created March 5, 2019 06:16
Add module in micropython example
// Add module in micropython example.
// See: https://micropython-dev-docs.readthedocs.io/en/latest/adding-module.html
#include <stdio.h>
#include "py/mpconfig.h"
#include "py/nlr.h"
#include "py/obj.h"
#include "py/runtime.h"
#include "py/binary.h"
@cryptowen
cryptowen / log.py
Last active March 21, 2017 10:07
config logging in python
import sys
import logging
def teset():
print 'hello'
# create logger
logger_name = "default-log"
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
@cryptowen
cryptowen / property_example.py
Created February 21, 2017 15:30
python property demo
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
zhihu question demo: https://www.zhihu.com/question/55594368
'''
class Mat(object):
"""动态读,class 内部只存 temp 的值,每次取 pro 的时候实时计算"""
def __init__(self, t):
self.temp = t
@cryptowen
cryptowen / pandas_decimal.py
Created February 21, 2017 15:06
convert value to demical when read_csv in pandas
# -*- coding: utf-8 -*-
import pandas as pd
import io
import decimal as D
temp = u"""a,b,c,d
0.1,0.2,0.1,0.2"""
df = pd.read_csv(
io.StringIO(temp), converters={'c': D.Decimal,
'd': D.Decimal})
@cryptowen
cryptowen / flask_async_test.py
Created July 1, 2016 08:46
flask 同步/异步性能对比
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
Author : Hu Wenchao
Description : flask 同步/异步性能对比
# 同步方式启动app:
$ python app.py sync
# 异步方式启动app: