??xml version="1.0" encoding="utf-8" standalone="yes"?>ս:C++博客 - սƵ2019|սع//www.pppqb.icu/wythern/X presents Y for a better Zzh-cnMon, 16 Sep 2019 00:26:41 GMTMon, 16 Sep 2019 00:26:41 GMT60[转]CRLF和LF在跨q_工作时候带来的烦恼以及解决Ҏ - սƵ2019|սع//www.pppqb.icu/wythern/archive/2019/03/27/216318.htmlwythernwythernWed, 27 Mar 2019 05:29:00 GMT//www.pppqb.icu/wythern/archive/2019/03/27/216318.html//www.pppqb.icu/wythern/comments/216318.html//www.pppqb.icu/wythern/archive/2019/03/27/216318.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/216318.html//www.pppqb.icu/wythern/services/trackbacks/216318.html在此

在用git提交代码时候,有时候会遇到一个问题,是自己明明只修改了其中几行Q提交上M后发现整个文仉被修改了Q在讄了格式风g后还会有提交不上ȝ情况Q这个时候经常让人摸不到头脑Q其实就是CRLF和LF在作?/p>

CRLF LF CR 都是什么意思:

  • CRLF: 是carriagereturnlinefeed的羃写。中文意思是回R换行?/p>

  • LF: 是line feed的羃写,中文意思是换行?/p>

  • CR: 是carriagereturn的羃写。中文意思是回R?/p>

单的换行回RZ么会引出q么多的问题呢,关键在于操作pȝ之间的分歧:

早期的macpȝ使用CR当做换行Q现在也已经l一成了LF

Unix(包含现在大量使用的linux)pȝ使用LF

windowspȝ使用LFCR当做换行Q自作聪明的兼容性?Q)

也正是因Z同系l的分歧Q在多h协作共同开发的时候,可能D提交代码时候生问题?/p>

解决ҎQ?/h2>

Android Studio内部可以讄不同模式Q具体位|在setting-->搜烦code style见下图:





















讄格式

其中有四个选项System-Dependent LF CR CRLFQ默认是System-DependentQ也是Ҏ你是什么系l选择什么类型,如果惌自定义的话可以在q里讄Q以后创建的C码也默认用设|的方式

而如果想单独修改某个文g的类型,也可以在右下角进行修改,见下图:

单独修改某个文g

跨^台合作时候的解决方式Q?/h2>

当我们用git库提交代码的时候,有的人可能用macQ有的h使用linuxQ有的h使用windowsQ不同的开发环境如果都是按照自ql的方式L修改换行cdQ难免会让代码库整体混ؕ或者生许多没有必要的代码更新

那么解决该问题的方式有:core.autocrlf命o

gitZ防止以上问题Cؕ跨^台合作开发,使用命o可以转化LF和CRLF

具体体现为:

  • git config --global core.autocrlf true


Git可以在你push时自动地把行l束WCRLF转换成LFQ而在pull代码时把LF转换成CRLF。用core.autocrlf来打开此项功能Q如果是在Windowspȝ上,把它讄成trueQ这样当{և代码ӞLF会被转换成CRLF

  • git config --global core.autocrlf input

Linux或Macpȝ使用LF作ؓ行结束符Q当一个以CRLFl束W的文g不小心被引入时你肯定惌行修正,把core.autocrlf讄成input来告?Git 在push时把CRLF转换成LFQpull时不转换

  • git config --global core.autocrlf false

在本地和代码库中都保留CRLFQ无论pullq是push都不变,代码库什么样Q本地还是什么样?/p>

当然在多q_工作时候,最好还是约定用LFQ还是CRLFQ然后不同系l进行对应的讄Q这h工作规范Q也有利于提高工作效率,希望以上可以帮助大家?/strong>



作者:sososun
链接Qhttps://www.jianshu.com/p/dd7464cf32b5
来源Q简?br />书著作权归作者所有,M形式的{载都误pM者获得授权ƈ注明出处?/div>

wythern 2019-03-27 13:29 发表评论
]]>How to shuffle arrays and slices in Go - սƵ2019|սع//www.pppqb.icu/wythern/archive/2019/01/17/216208.htmlwythernwythernThu, 17 Jan 2019 12:27:00 GMT//www.pppqb.icu/wythern/archive/2019/01/17/216208.html//www.pppqb.icu/wythern/comments/216208.html//www.pppqb.icu/wythern/archive/2019/01/17/216208.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/216208.html//www.pppqb.icu/wythern/services/trackbacks/216208.html在此

׃Go没有为slice提供shuffle函数Q所以需要自己想办法。由于我只需要随Zơ遍? -> NQ所以这Dcode最匚w?br />
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)
  }
}

ggo不像scala有那U惰性求值的Ҏ,所以这里的r.Perm()q是产生了一个sliceQ如果N很大可能是个问题?br />




wythern 2019-01-17 20:27 发表评论
]]>
go test 用args带参?/title><link>//www.pppqb.icu/wythern/archive/2018/08/14/215845.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Tue, 14 Aug 2018 09:04:00 GMT</pubDate><guid>//www.pppqb.icu/wythern/archive/2018/08/14/215845.html</guid><wfw:comment>//www.pppqb.icu/wythern/comments/215845.html</wfw:comment><comments>//www.pppqb.icu/wythern/archive/2018/08/14/215845.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/wythern/comments/commentRss/215845.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/wythern/services/trackbacks/215845.html</trackback:ping><description><![CDATA[<div class="dpun">试中想通过命o行传递一些参数给test funcQ网上找了一些资料但q程不是很顺利,q里记录一下?/div> <div class="dpun"></div> <div class="dpun">首先go test有一?args的参数说可以辑ֈq个目的Q但实测下来发现有没有没区别。。?/div> <div class="dpun">google查到的大部分也是用到了flagcd?/div> <div class="dpun">flag.go的注释写的比较清?/div> <div class="dpun"> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> //www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008000; ">/*</span><span style="color: #008000; "><br />     Package flag implements command-line flag parsing.<br /> <br />     Usage:<br /> <br />     Define flags using flag.String(), Bool(), Int(), etc.<br /> <br />     This declares an integer flag, -flagname, stored in the pointer ip, with type *int.<br />         import "flag"<br />         var ip = flag.Int("flagname", 1234, "help message for flagname")<br />     If you like, you can bind the flag to a variable using the Var() functions.<br />         var flagvar int<br />         func init() {<br />             flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")<br />         }<br />     Or you can create custom flags that satisfy the Value interface (with<br />     pointer receivers) and couple them to flag parsing by<br />         flag.Var(&flagVal, "name", "help message for flagname")<br />     For such flags, the default value is just the initial value of the variable.<br /> <br />     After all flags are defined, call<br />         flag.Parse()<br />     to parse the command line into the defined flags.<br /> <img src="//www.pppqb.icu/Images/dot.gif" alt="" /><br /> </span><span style="color: #008000; ">*/</span></div> </div> <div class="dpun"></div> <div class="dpun">因此需要做的事情就是:</div> <div class="dpun">1. 定义flagQ这个需要在main()执行之前完成Q我q里在test文g里面用全局变量完成Q但a可以攑֜函数里面?/div> <div class="dpun"> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> //www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">var (<br />     </span><span style="color: #008000; ">//</span><span style="color: #008000; "> Define global args flags.</span><span style="color: #008000; "><br /> </span><span style="color: #000000; ">    pA </span><span style="color: #000000; ">=</span><span style="color: #000000; "> flag.Int(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">a</span><span style="color: #000000; ">"</span><span style="color: #000000; ">, </span><span style="color: #000000; ">0</span><span style="color: #000000; ">,  </span><span style="color: #000000; ">"</span><span style="color: #000000; ">a.</span><span style="color: #000000; ">"</span><span style="color: #000000; ">)<br />     a </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; "><br /> )</span></div> </div> <div class="dpun">2. parse flagQ这个要在test func执行之前Q所以可以考虑加入一个init()在test文g里?/div> <div class="dpun"> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> //www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">func init() {<br />     flag.Parse()<br />     a </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">*</span><span style="color: #000000; ">pA<br /> }</span></div> </div> <div class="dpun">后面使用q些变量没有问题了Q比如这?/div> <div class="dpun"> <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> //www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">func TestInit(t </span><span style="color: #000000; ">*</span><span style="color: #000000; ">testing.T) {<br />     flag.Parse()<br />     t.Log(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">a = </span><span style="color: #000000; ">"</span><span style="color: #000000; ">, a)<br /> }<br /> </span></div> </div> <div class="dpun"></div> <div class="dpun">q里用到的主要是flag的功能,试用发现有没有-args问题不大Q所以这个用法可能不是很W合go test的要求,先用h再说了?/div> <div class="dpun"></div> <div class="dpun"></div> <div class="dpun"></div><div class="dpun"></div><div class="dpun">REF</div> <div class="dpun">1. https://www.golangtc.com/t/584cbd16b09ecc2e1800000b</div> <div class="dpun">2. https://stackoverflow.com/.../process-command-line-arguments-in-go-test</div><div class="dpun">3. https://hsulei.com/2017/08/23/gotest如何使用自定义参?</div> <div class="dpun"><cite><br /></cite></div> <div class="dpun"></div><img src ="//www.pppqb.icu/wythern/aggbug/215845.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.pppqb.icu/wythern/" target="_blank">wythern</a> 2018-08-14 17:04 <a href="//www.pppqb.icu/wythern/archive/2018/08/14/215845.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]shell中if条g字符丌Ӏ数字比对,[[ ]]和[ ]区别 - սƵ2019|սع//www.pppqb.icu/wythern/archive/2018/08/14/215844.htmlwythernwythernTue, 14 Aug 2018 08:44:00 GMT//www.pppqb.icu/wythern/archive/2018/08/14/215844.html//www.pppqb.icu/wythern/comments/215844.html//www.pppqb.icu/wythern/archive/2018/08/14/215844.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/215844.html//www.pppqb.icu/wythern/services/trackbacks/215844.html原文在此

学习shell的时候L被shell里的条g判断方式搞得头疼Q经怸知道?用[],[[]],(())q是test,letQ而很有书把它们的关p讲解的很清?应该是我悟性差或是看书太少)Q今天ȝ一下,基础的东西如它们 的用方法不再赘qͼ重点说说它们的区别的使用时应该注意的地方?br />
先说[]和testQ两者是一LQ在命o行里test expr和[ expr ]的效果相同。test的三个基本作用是判断文g、判断字W串、判断整数。支持用与或非表辑ּq接h。要注意的有Q?br />
1.test中可用的比较q算W只?=?=Q两者都是用于字W串比较的,不可用于整数比较Q整数比较只能?eq, -gtq种形式。无论是字符串比较还是整数比较都千万不要使用大于号小于号。当Ӟ如果你实在想用也是可以的Q对于字W串比较可以使用括L转义形式Q?如果比较"ab"?bc"Q[ ab \< bc ]Q结果ؓ真,也就是返回状态ؓ0.

然后是[[ ]]Q这是内|在shell中的一个命令,它就比刚才说的test强大的多了。支持字W串的模式匹配(使用=~操作W时甚至支持shell的正则表?式)。简直强大的令h发指Q逻辑l合可以不用test?a,-o而?amp;&,||q样更亲切的形式(针对c、JavaE序?。当 Ӟ也不用想的太复杂Q基本只要记?br />1.字符串比较时可以把右边的作ؓ一个模式(q是双的字W串不加双引L情况下。如果右边的字符串加了双引号Q则认ؓ是一个文本字W串。)Q而不仅仅是一个字W串Q比如[[ hello == hell? ]]Q结果ؓ真?/p>

另外要注意的是,使用[]和[[]]的时候不要吝啬空|每一两辚w要有I格Q[[ 1 == 2 ]]的结果ؓ“?#8221;Q但[[ 1==2 ]]的结果ؓ“?#8221;Q后一U显然是错的


3.最后就是let?())Q两者也是一L(或者说基本上是一LQ双括号比letE弱一?。主要进行算术运?上面的两个都不行)Q也比较适合q?行整数比较,可以直接使用熟悉?lt;,>{比较运符。可以直接用变量名如var而不需?varq样的Ş式。支持分号隔开的多个表辑ּ



wythern 2018-08-14 16:44 发表评论
]]>
一张图了解公链和私?/title><link>//www.pppqb.icu/wythern/archive/2018/08/01/215813.html</link><dc:creator>wythern</dc:creator><author>wythern</author><pubDate>Wed, 01 Aug 2018 06:05:00 GMT</pubDate><guid>//www.pppqb.icu/wythern/archive/2018/08/01/215813.html</guid><wfw:comment>//www.pppqb.icu/wythern/comments/215813.html</wfw:comment><comments>//www.pppqb.icu/wythern/archive/2018/08/01/215813.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/wythern/comments/commentRss/215813.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/wythern/services/trackbacks/215813.html</trackback:ping><description><![CDATA[<div class="dpun"><img src="https://cdn-images-1.medium.com/max/1600/0*s0QUH2j9SAetBKQv." alt="" longdesc="private_and_public_chain" /><img src="//www.pppqb.icu/images/cppblog_com/wythern/0_x2A_s0QUH2j9SAetBKQv..png" alt="" longdesc="private_and_public_chain" /></div><div class="dpun">囄来源Qhttps://blog.slock.it/public-vs-private-chain-7b7ca45044f</div><img src ="//www.pppqb.icu/wythern/aggbug/215813.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.pppqb.icu/wythern/" target="_blank">wythern</a> 2018-08-01 14:05 <a href="//www.pppqb.icu/wythern/archive/2018/08/01/215813.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Full go tool list (keep constructing) - սƵ2019|սع//www.pppqb.icu/wythern/archive/2018/07/21/215794.htmlwythernwythernSat, 21 Jul 2018 06:09:00 GMT//www.pppqb.icu/wythern/archive/2018/07/21/215794.html//www.pppqb.icu/wythern/comments/215794.html//www.pppqb.icu/wythern/archive/2018/07/21/215794.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/215794.html//www.pppqb.icu/wythern/services/trackbacks/215794.html
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


wythern 2018-07-21 14:09 发表评论
]]>
Some materials about RPC transaction call. - սƵ2019|սع//www.pppqb.icu/wythern/archive/2018/07/14/215784.htmlwythernwythernSat, 14 Jul 2018 09:00:00 GMT//www.pppqb.icu/wythern/archive/2018/07/14/215784.html//www.pppqb.icu/wythern/comments/215784.html//www.pppqb.icu/wythern/archive/2018/07/14/215784.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/215784.html//www.pppqb.icu/wythern/services/trackbacks/215784.html

Introduction

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

How to test.

//ethereum-tests.readthedocs.io/en/latest/test_types/transaction_tests.html
https://github.com/ethereum/cpp-ethereum/blob/develop/doc/generating_tests.rst
go-ethereum里面有一批vm和contract相关的testsQ结合ABI和contract的定义,可以很容易的写一批自己定制的试Q从web3js或者直接在go project里面调用都可以?/div>



wythern 2018-07-14 17:00 发表评论
]]>What is shade jar, and what is its purpose. - սƵ2019|սع//www.pppqb.icu/wythern/archive/2017/06/19/215009.htmlwythernwythernMon, 19 Jun 2017 03:23:00 GMT//www.pppqb.icu/wythern/archive/2017/06/19/215009.html//www.pppqb.icu/wythern/comments/215009.html//www.pppqb.icu/wythern/archive/2017/06/19/215009.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/215009.html//www.pppqb.icu/wythern/services/trackbacks/215009.html

https://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.



wythern 2017-06-19 11:23 发表评论
]]>
[Collection] Spark partition related things. - սƵ2019|սع//www.pppqb.icu/wythern/archive/2017/05/18/214946.htmlwythernwythernThu, 18 May 2017 06:29:00 GMT//www.pppqb.icu/wythern/archive/2017/05/18/214946.html//www.pppqb.icu/wythern/comments/214946.html//www.pppqb.icu/wythern/archive/2017/05/18/214946.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/214946.html//www.pppqb.icu/wythern/services/trackbacks/214946.htmlUnderstanding:
1. https://www.dezyre.com/article/how-data-partitioning-in-spark-helps-achieve-more-parallelism/297
2. //dev.sortable.com/spark-repartition/ -- example of partition & repartition to avoid data-imbalance.
3. https://acadgild.com/blog/partitioning-in-spark/ -- real case on existing partitioner & self-created partitioner.

Programming guidence.
Avoid using GroupByKey https://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! :)


wythern 2017-05-18 14:29 发表评论
]]>
ubuntu switch window in current workspace. - սƵ2019|սع//www.pppqb.icu/wythern/archive/2017/04/17/214859.htmlwythernwythernMon, 17 Apr 2017 02:21:00 GMT//www.pppqb.icu/wythern/archive/2017/04/17/214859.html//www.pppqb.icu/wythern/comments/214859.html//www.pppqb.icu/wythern/archive/2017/04/17/214859.html#Feedback0//www.pppqb.icu/wythern/comments/commentRss/214859.html//www.pppqb.icu/wythern/services/trackbacks/214859.html
[ref]https://unix.stackexchange.com/questions/171964/restrict-alttab-to-the-current-workspace-in-gnome-3

սƵ2019 2017-04-17 10:21 发表评论
]]>