This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
// oneshot_channel make sender/receiver | |
func oneshot_channel() (chan<- int, <-chan int) { | |
ch := make(chan int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"github.com/google/uuid" | |
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" | |
"github.com/sirupsen/logrus" | |
"log" | |
"math/rand" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"github.com/google/uuid" | |
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" | |
"github.com/sirupsen/logrus" | |
"log" | |
"math/rand" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
输入一个数字数组,找出数组的中位数 | |
找出其中的bug | |
*/ | |
function findMedian(arr) { | |
arr.sort(); | |
mid = arr.length / 2; | |
if (arr.length % 2 === 1) { | |
return arr[mid]; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/davecgh/go-spew/spew" | |
) | |
type adjList []int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 计算函数的最低点,也就是最优化问题 | |
# f(x) = (x-1)^2 + 2,理论解为(1,2) | |
def f(x): | |
return (x-1)*(x-1) + 2 | |
# 计算导数(梯度),数值计算的方式 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reference: https://hyperledger-fabric-ca.readthedocs.io/en/latest/users-guide.html#fabric-ca-server | |
# | |
# 本文件是由fabric-ca-server生成,由 | |
# fabric-ca-server init -b admin:adminpw | |
# 或是 | |
# fabric-ca-server start -b admin:adminpw | |
# 生成 | |
# | |
# 如果不通过命令行指定 -u <parent-fabric-ca-server-URL> | |
# 默认生成的是self-signed CA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package embintf | |
import ( | |
"github.com/sirupsen/logrus" | |
"time" | |
) | |
type Cat struct { | |
ID int64 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package embintf | |
import ( | |
"github.com/sirupsen/logrus" | |
"time" | |
) | |
type Cat struct { | |
ID int64 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foobarbaz | |
type Bar struct { | |
X int | |
Y int | |
} | |
// ProvideBar returns a Bar: a negative Foo. | |
func ProvideBar(foo Foo, y int) Bar { | |
return Bar{X: -foo.X, Y: y} |
NewerOlder