增加函数
func PipelineFan() {
in := producer(10)
// FAN-OUT
c1 := square(in)| // 参考《C++编程思想卷2》 | |
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| string& replace_all(string& context, const string& from, const string& to) { | |
| size_t look_here = 0; | |
| size_t found_here; |
| // 最长递增子数列 | |
| // O(N^2) | |
| // dp[i] = max{dp[j]+1 | [i] > [j], 0<=j<i} | |
| // result: max{dp[i] | 0<=i<n} | |
| class Solution { | |
| static const int bufsize = 10000; | |
| int dp[bufsize]; | |
| ## unzip and go into googletest directory | |
| ➜ Downloads unzip googletest-master.zip | |
| Archive: googletest-master.zip | |
| aa148eb2b7f70ede0eb10de34b6254826bfb34f4 | |
| creating: googletest-master/ | |
| ... | |
| inflating: googletest-master/travis.sh | |
| ➜ Downloads | |
| ➜ Downloads ls | |
| googletest-master googletest-master.zip pixman_0.30.2.orig.tar.gz redis-3.2.0 redis-3.2.0.tar.gz |
| ➜ awesome git:(master) ✗ time go run hi.go | |
| go run hi.go 10.49s user 4.42s system 303% cpu 4.917 total | |
| ➜ awesome git:(master) ✗ time go run hi-simple.go | |
| go run hi-simple.go 4.81s user 2.65s system 176% cpu 4.233 total |
| # I found grep is very slow for big files, I made a simpe python version | |
| import sys | |
| def search(file_name, wants): | |
| with open(file_name, 'r') as file: | |
| for line in file: | |
| for w in wants: | |
| if w in line: |
// SM2Sign signs
func SM2Sign(signKey interface{}, msg []byte) ([]byte, error) {
sm2Eckey := signKey.(*Sm2EcKey)
hash := sm3.New()
hash.Write(msg)
h := hash.Sum(nil)
sig := make([]byte, 128, 128)| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <sys/resource.h> | |
| #include <sys/types.h> | |
| typedef struct s_block* t_block; | |
| struct s_block { | |
| size_t size; |