江苏快三开奖结果

++wythern++

X presents Y for a better Z

2019年11月28日 #

在truffle或其他測試環境下如何得到contract的返回值

江苏快三开奖结果    1. SHIYONGpureHUOZHEviewHANSHU,ZHIJIENADAOFANHUIZHI,DANBUSHISUOYOUDEHANSHUDOUNENGSHENGMINGCHENGpure/view。

    2. SHIYONGeventBAOZHUANGFANHUIZHI,DANSHIZAIemitZHIQIANFANHUIDEHANSHUSHIMEIYOUeventDE,RUGUOXUYAOMEITIAOpathDOUFANHUIYOUYIYIDEreturn value,KENENGXUYAODINGYIHENDUOGEevent。(BUKAOLVrequire throwDEQINGKUANGXIA)

江苏快三开奖结果    3. SHIYONGweb3.eth.Contract.call,XUYAOABIHEdeployed address,ZHEGEYONGFAYOUGEQUEDIANSHIJIANGHANSHUBIANCHENGLEconstantDE,JIHE1YIYANGWUFAGAIBIANHEYUENEIBUZHUANGTAI,ZHINENGSHUOZAITEDINGDECHANGJINGXIAYOUYONG。

    4. EIP-758(),FANHUIreturnDataZAIsubscribeDETONGDAOSHANG,DANSHIKANMUQIANDEZHUANGTAIHUANSHIdraft。


posted @ 2019-11-28 18:13 wythern 閱讀(9) | 評論 (0)編輯 收藏

2019年3月27日 #

[轉]CRLF和LF在跨平臺工作時候帶來的煩惱以及解決方法

原文

江苏快三开奖结果ZAISHIYONGgitTIJIAODAIMASHIHOU,YOUSHIHOUHUIYUDAOYIGEWENTI,JIUSHIZIJIMINGMINGZHIXIUGAILEQIZHONGJIXING,TIJIAOSHANGQUYIHOUFAXIANZHENGGEWENJIANDOUBEIXIUGAILE,ZAISHEZHILEGESHIFENGGEYIHOUHUANHUIYOUTIJIAOBUSHANGQUDEQINGKUANG,ZHEGESHIHOUJINGCHANGRANGRENMOBUDAOTOUNAO,QISHIJIUSHICRLFHELFZAIZUOGUAI

CRLF LF CR 都是什么意思:

  • CRLF: SHIcarriagereturnlinefeedDESUOXIE。ZHONGWENYISISHIHUICHEHUANXING。

  • 江苏快三开奖结果LF: SHIline feedDESUOXIE,ZHONGWENYISISHIHUANXING。

  • CR: SHIcarriagereturnDESUOXIE。ZHONGWENYISISHIHUICHE。

簡單的換行回車為什么會引出這么多的問題呢,關鍵在于操作系統之間的分歧:

ZAOQIDEmacXITONGSHIYONGCRDANGZUOHUANXING,XIANZAIYEYIJINGTONGYICHENGLELF

江苏快三开奖结果Unix(BAOHANXIANZAIDALIANGSHIYONGDElinux)XITONGSHIYONGLF

江苏快三开奖结果windowsXITONGSHIYONGLFCRDANGZUOHUANXING(ZIZUOCONGMINGDEJIANRONGXING??)

江苏快三开奖结果YEZHENGSHIYINWEIBUTONGXITONGDEFENQI,ZAIDUORENXIEZUOGONGTONGKAIFADESHIHOU,KENENGDAOZHITIJIAODAIMASHIHOUCHANSHENGWENTI。

解決方法:

Android StudioNEIBUKEYISHEZHIBUTONGMOSHI,JUTIWEIZHIZAIsetting-->SOUSUOcode styleJIANXIATU:





















設置格式

QIZHONGYOUSIGEXUANXIANGSystem-Dependent LF CR CRLF,MORENSHISystem-Dependent,YEJIUSHIGENJUNISHISHENMEXITONGXUANZESHENMELEIXING,RUGUOXIANGYAOZIDINGYIDEHUAKEYIZAIZHELISHEZHI,YIHOUCHUANGJIANDEXINDAIMAYEMORENYONGSHEZHIDEFANGSHI

江苏快三开奖结果ERRUGUOXIANGDANDUXIUGAIMOUGEWENJIANDELEIXING,YEKEYIZAIYOUXIAJIAOJINXINGXIUGAI,JIANXIATU:

單獨修改某個文件

跨平臺合作時候的解決方式:

DANGWOMENSHIYONGgitKUTIJIAODAIMADESHIHOU,YOUDERENKENENGSHIYONGmac,YOUDERENSHIYONGlinux,YOUDERENSHIYONGwindows,BUTONGDEKAIFAHUANJINGRUGUODOUSHIANZHAOZIJIXITONGDEFANGSHIRENYIXIUGAIHUANXINGLEIXING,NANMIANHUIRANGDAIMAKUZHENGTIHUNLUANHUOZHECHANSHENGXUDUOMEIYOUBIYAODEDAIMAGENGXIN

那么解決該問題的方式有:core.autocrlf命令

gitWEILEFANGZHIYISHANGWENTIRAOLUANKUAPINGTAIHEZUOKAIFA,SHIYONGMINGLINGKEYIZHUANHUALFHECRLF

JUTITIXIANWEI:

  • git config --global core.autocrlf true


江苏快三开奖结果Git可以在你push時自動地把行結束符CRLF轉換成LF,而在pull代碼時把LF轉換成CRLF。用core.autocrlf來打開此項功能,如果是在Windows系統上,把它設置成true,這樣當簽出代碼時,LF會被轉換成CRLF

  • git config --global core.autocrlf input

江苏快三开奖结果LinuxHUOMacXITONGSHIYONGLFZUOWEIXINGJIESHUFU;DANGYIGEYICRLFWEIXINGJIESHUFUDEWENJIANBUXIAOXINBEIYINRUSHINIKENDINGXIANGJINXINGXIUZHENG,BAcore.autocrlfSHEZHICHENGinputLAIGAOSU Git ZAIpushSHIBACRLFZHUANHUANCHENGLF,pullSHIBUZHUANHUAN

  • git config --global core.autocrlf false

江苏快三开奖结果ZAIBENDIHEDAIMAKUZHONGDOUBAOLIUCRLF,WULUNpullHUANSHIpushDOUBUBIAN,DAIMAKUSHENMEYANG,BENDIHUANSHISHENMEYANGZI

當然在多人跨平臺工作時候,最好還是約定使用LF,還是CRLF,然后不同系統進行對應的設置,這樣是工作規范,也有利于提高工作效率,希望以上可以幫助大家。



作者:sososun
鏈接:http://www.jianshu.com/p/dd7464cf32b5
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權并注明出處。

posted @ 2019-03-27 13:29 wythern 閱讀(70) | 評論 (0)編輯 收藏

2019年1月17日 #

How to shuffle arrays and slices in Go

原文Go沒有為slice提供shuffle函數,所以需要自己想辦法。由于我只需要隨機一次遍歷1 -> N,所以這段code最匹配。
func main() {
  vals := []int{10, 12, 14, 16, 18, 20}
  r := rand.New(rand.NewSource(time.Now().Unix()))
  for _, i := range r.Perm(len(vals)) {
    val := vals[i]
    fmt.Println(val)
  }
}

似乎go不像scala有那種惰性求值的特性,所以這里的r.Perm()還是產生了一個slice,如果N很大可能是個問題。



posted @ 2019-01-17 20:27 wythern 閱讀(66) | 評論 (0)編輯 收藏

2018年8月14日 #

go test 用args帶參數

測試中想通過命令行傳遞一些參數給test func,網上找了一些資料但過程不是很順利,這里記錄一下。
首先go test有一個-args的參數說可以達到這個目的,但實測下來發現有沒有沒區別。。。
google查到的大部分也是用到了flag類型。
flag.go的注釋寫的比較清楚
/*
    Package flag implements command-line flag parsing.

    Usage:

    Define flags using flag.String(), Bool(), Int(), etc.

    This declares an integer flag, -flagname, stored in the pointer ip, with type *int.
        import "flag"
        var ip = flag.Int("flagname", 1234, "help message for flagname")
    If you like, you can bind the flag to a variable using the Var() functions.
        var flagvar int
        func init() {
            flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
        }
    Or you can create custom flags that satisfy the Value interface (with
    pointer receivers) and couple them to flag parsing by
        flag.Var(&flagVal, "name", "help message for flagname")
    For such flags, the default value is just the initial value of the variable.

    After all flags are defined, call
        flag.Parse()
    to parse the command line into the defined flags.

*/
因此需要做的事情就是:
1. 定義flag,這個需要在main()執行之前完成,我這里在test文件里面用全局變量完成,但a可以放在函數里面。
var (
    
// Define global args flags.
    pA = flag.Int("a"0,  "a.")
    a 
= 0
)
2. parse flag,這個要在test func執行之前,所以可以考慮加入一個init()在test文件里。
func init() {
    flag.Parse()
    a 
= *pA
}
后面使用這些變量就沒有問題了,比如這樣
func TestInit(t *testing.T) {
    flag.Parse()
    t.Log(
"a = ", a)
}
這里用到的主要是flag的功能,測試用發現有沒有-args問題不大,所以這個用法可能不是很符合go test的要求,先用起來再說了。
REF
1. http://www.golangtc.com/t/584cbd16b09ecc2e1800000b
2. http://stackoverflow.com/.../process-command-line-arguments-in-go-test
3. http://hsulei.com/2017/08/23/gotest如何使用自定義參數/

posted @ 2018-08-14 17:04 wythern 閱讀(440) | 評論 (0)編輯 收藏

[轉]shell中if條件字符串、數字比對,[[ ]]和[ ]區別

原文

學習shell的時候總是被shell里的條件判斷方式搞得頭疼,經常不知道改 用[],[[]],(())還是test,let,而很少有書把它們的關系講解的很清楚(應該是我悟性差或是看書太少),今天總結一下,基礎的東西如它們 的使用方法不再贅述,重點說說它們的區別的使用時應該注意的地方。

先說[]和test,兩者是一樣的,在命令行里test expr和[ expr ]的效果相同。test的三個基本作用是判斷文件、判斷字符串、判斷整數。支持使用與或非將表達式連接起來。要注意的有:

1.test中可用的比較運算符只有==和!=,兩者都是用于字符串比較的,不可用于整數比較,整數比較只能使用-eq, -gt這種形式。無論是字符串比較還是整數比較都千萬不要使用大于號小于號。當然,如果你實在想用也是可以的,對于字符串比較可以使用尖括號的轉義形式, 如果比較"ab"和"bc":[ ab \< bc ],結果為真,也就是返回狀態為0.

然后是[[ ]],這是內置在shell中的一個命令,它就比剛才說的test強大的多了。支持字符串的模式匹配(使用=~操作符時甚至支持shell的正則表達 式)。簡直強大的令人發指!邏輯組合可以不使用test的-a,-o而使用&&,||這樣更親切的形式(針對c、Java程序員)。當 然,也不用想的太復雜,基本只要記住
江苏快三开奖结果1.字符串比較時可以把右邊的作為一個模式(這是右邊的字符串不加雙引號的情況下。如果右邊的字符串加了雙引號,則認為是一個文本字符串。),而不僅僅是一個字符串,比如[[ hello == hell? ]],結果為真。

江苏快三开奖结果LINGWAIYAOZHUYIDESHI,SHIYONG[]HE[[]]DESHIHOUBUYAOLINSEKONGGE,MEIYIXIANGLIANGBIANDOUYAOYOUKONGGE,[[ 1 == 2 ]]DEJIEGUOWEI“JIA”,DAN[[ 1==2 ]]DEJIEGUOWEI“ZHEN”!HOUYIZHONGXIANRANSHICUODE


3.最后就是let和(()),兩者也是一樣的(或者說基本上是一樣的,雙括號比let稍弱一些)。主要進行算術運算(上面的兩個都不行),也比較適合進 行整數比較,可以直接使用熟悉的<,>等比較運算符。可以直接使用變量名如var而不需要$var這樣的形式。支持分號隔開的多個表達式

posted @ 2018-08-14 16:44 wythern 閱讀(68) | 評論 (0)編輯 收藏

2018年8月1日 #

一張圖了解公鏈和私鏈

圖片來源:http://blog.slock.it/public-vs-private-chain-7b7ca45044f

posted @ 2018-08-01 14:05 wythern 閱讀(69) | 評論 (0)編輯 收藏

2018年7月21日 #

Full go tool list (keep constructing)

REF:  http://dominik.honnef.co/posts/2014/12/an_incomplete_list_of_go_tools/

go get github.com/golang/lint/golint
go get github.com/kisielk/errcheck
go get golang.org/x/tools/cmd/benchcmp
go get github.com/cespare/prettybench
go get github.com/ajstarks/svgo/benchviz
go get golang.org/x/tools/cmd/stringer
go get github.com/josharian/impl
go get golang.org/x/tools/cmd/goimports
go get sourcegraph.com/sqs/goreturns
go get code.google.com/p/rog-go/exp/cmd/godef
go get github.com/nsf/gocode
go get golang.org/x/tools/cmd/oracle
go get golang.org/x/tools/cmd/gorename
go get github.com/kisielk/godepgraph

posted @ 2018-07-21 14:09 wythern 閱讀(122) | 評論 (0)編輯 收藏

2018年7月14日 #

Some materials about RPC transaction call.

Introduction

Solidiay doc about ABI and contract access.
http://solidity.readthedocs.io/en/develop/abi-spec.html
http://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts.html?highlight=selfdestruct
http://www.ethdocs.org/en/latest/contracts-and-transactions/accessing-contracts-and-transactions.html
http://ethdocs.org/en/latest/contracts-and-transactions/contracts.html#testing-contracts-and-transactions
http://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=suicide [global variables like msg.sender]
ABI intro in Ethereum Wiki.
http://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#argument-encoding
http://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial
JAON rpc api of Eth.
http://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-api
http://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods
Deploy a contract using RPC.
http://github.com/rsksmart/rskj/wiki/Deploying-contracts-using-RPC-calls
A tool to generate the grpc server code for a contract
http://github.com/getamis/grpc-contract

How to test.

http://ethereum-tests.readthedocs.io/en/latest/test_types/transaction_tests.html
http://github.com/ethereum/cpp-ethereum/blob/develop/doc/generating_tests.rst
go-ethereum里面有一批vm和contract相關的tests,結合ABI和contract的定義,可以很容易的寫一批自己定制的測試,從web3js或者直接在go project里面調用都可以。

posted @ 2018-07-14 17:00 wythern 閱讀(84) | 評論 (0)編輯 收藏

2017年6月19日 #

What is shade jar, and what is its purpose.

http://stackoverflow.com/questions/13620281/what-is-the-maven-shade-plugin-used-for-and-why-would-you-want-to-relocate-java


江苏快三开奖结果Uber JAR, in short, is a JAR containing everything.

江苏快三开奖结果Normally in Maven, we rely on dependency management. An artifact contains only the classes/resources of itself. Maven will be responsible to find out all artifacts (JARs etc) that the project depending on when the project is built.

An uber-jar is something that take all dependencies, and extract the content of the dependencies and put them with the classes/resources of the project itself, in one big JAR. By having such uber-jar, it is easy for execution, because you will need only one big JAR instead of tons of small JARs to run your app. It also ease distribution in some case.

江苏快三开奖结果Just a side-note. Avoid using uber-jar as Maven dependency, as it is ruining the dependency resolution feature of Maven. Normally we create uber-jar only for the final artifact for actual deployment or for manual distribution, but not for putting to Maven repository.


Update: I have just discovered I haven't answered one part of the question : "What's the point of renaming the packages of the dependencies?". Here is some brief updates and hopefully will help people having similar question.

江苏快三开奖结果Creating uber-jar for ease of deployment is one use case of shade plugin. There are also other common use cases which involve package renaming.

For example, I am developing Foo library, which depends on a specific version (e.g. 1.0) of Bar library. Assuming I cannot make use of other version of Bar lib (because API change, or other technical issues, etc). If I simply declare Bar:1.0 as Foo's dependency in Maven, it is possible to fall into a problem: A Qux project is depending on Foo, and also Bar:2.0 (and it cannot use Bar:1.0 because Qux needs to use new feature in Bar:2.0). Here is the dilemma: should Qux use Bar:1.0 (which Qux's code will not work) or Bar:2.0 (which Foo's code will not work)?

In order to solve this problem, developer of Foo can choose to use shade plugin to rename its usage of Bar, so that all classes in Bar:1.0 jar are embedded in Foo jar, and the package of the embedded Bar classes is changed from com.bar to com.foo.bar. By doing so, Qux can safely depends on Bar:2.0 because now Foo is no longer depending on Bar, and it is using is own copy of "altered" Bar located in another package.

posted @ 2017-06-19 11:23 wythern 閱讀(80) | 評論 (0)編輯 收藏

2017年5月18日 #

[Collection] Spark partition related things.

Partition:
Understanding:
1. http://www.dezyre.com/article/how-data-partitioning-in-spark-helps-achieve-more-parallelism/297
2. http://dev.sortable.com/spark-repartition/ -- example of partition & repartition to avoid data-imbalance.
3. http://acadgild.com/blog/partitioning-in-spark/ -- real case on existing partitioner & self-created partitioner.

Programming guidence.
Avoid using GroupByKey http://databricks.gitbooks.io/databricks-spark-knowledge-base/content/best_practices/prefer_reducebykey_over_groupbykey.html

Reference 1 says: Applying transformations that return RDDs with specific partitioners. Some operation on RDDs that hold to and propagate a partitioner are-
  • Join
  • LeftOuterJoin
  • RightOuterJoin
  • groupByKey
  • reduceByKey
  • foldByKey
  • sort
  • partitionBy
  • foldByKey
groupByKey is one of them, My understanding is such operations may cause extra shuffle, but repartition also helps relieve data imbalance if well considered, so use head please! :)

posted @ 2017-05-18 14:29 wythern 閱讀(73) | 評論 (0)編輯 收藏