Skip to content

Instantly share code, notes, and snippets.

View Shitaibin's full-sized avatar
💬
Web3, Blockchain, k8s

大彬 Shitaibin

💬
Web3, Blockchain, k8s
View GitHub Profile
@Shitaibin
Shitaibin / a.md
Created September 23, 2019 08:59
CGO panic memory vailation
// 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)
@Shitaibin
Shitaibin / pipeline-fan-benchmark.md
Last active November 28, 2018 08:50
pipeline-fan-benchmark

提示性能

增加函数

func PipelineFan() {
	in := producer(10)

	// FAN-OUT
	c1 := square(in)
@Shitaibin
Shitaibin / pipeline-fan-ret
Created November 27, 2018 11:35
result of pipeline fan model
➜ 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
@Shitaibin
Shitaibin / py_grep.py
Last active March 12, 2019 02:50
Grep for big file
# 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:
@Shitaibin
Shitaibin / gtest_build_install.txt
Last active March 9, 2017 07:09
Install Google Test
## 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
@Shitaibin
Shitaibin / simple_malloc.c
Created April 14, 2016 10:55
A Malloc Tutorial
#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;
@Shitaibin
Shitaibin / string_repalce.cpp
Last active April 6, 2016 03:17
C++字符串替换函数
// 参考《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;
@Shitaibin
Shitaibin / LIS.cpp
Last active June 24, 2016 13:28
动态规划合集 -- 动态规划的主程序不应该复杂,不然泛化能力差,过度拟合了
// 最长递增子数列
// 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];