This file contains 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
# System Info: | |
1. `uname -a`: | |
Linux arch 5.14.9-arch2-1 #1 SMP PREEMPT Fri, 01 Oct 2021 19:03:20 +0000 x86_64 GNU/Linux | |
2. `lsb_release -a`: | |
LSB Version: 1.4 | |
Distributor ID: Arch | |
Description: Arch Linux |
This file contains 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
var MAX_PARALLEL = 50 | |
var sem = make(chan int, MAX_PARALLEL) | |
var f = "./ids.csv" | |
func bizFunc(id int64) { | |
defer func(){<-sem}() | |
// biz code. | |
} | |
func parallelWork() { |
This file contains 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
{ | |
"size": 0, | |
"aggs": { | |
"path": { | |
"filter": { | |
"bool": { | |
"filter": [ | |
{"term": {"file_type": 150}} | |
] | |
} |
This file contains 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
import subprocess | |
def progress_exist(name): | |
ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE) | |
job = subprocess.Popen(['grep', name], stdin=ps.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
ps.stdout.close() | |
out, err = job.communicate() | |
out = out.decode() | |
no_grep_out = 0 | |
if len(out) > 0: |
This file contains 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
import csv | |
filename = './test.csv' | |
with open(filename, 'r') as f: | |
data_csv = csv.DictReader(f, delimiter=',') | |
for data in data_csv: | |
print (data['clip_id']) |
This file contains 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/bradfitz/slice" | |
) | |
type ArtistUidInfo struct { | |
ArtistId int64 |
This file contains 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
type operate func(x, y int) int | |
func calculate(x int, y int, op operate) (int, error) { | |
if op == nil { | |
return 0, error.New("no op") | |
} | |
return op(x, y), nil | |
} | |
var add = func (x, y int) int { |
This file contains 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
// 传址会修改原数据 | |
func main() { | |
x := [3]int{1,2,3} | |
func(arr *[3]int) { | |
(*arr)[0] = 7 | |
fmt.Println(arr) // &[7 2 3] | |
}(&x) | |
fmt.Println(x) // [7 2 3] | |
} |
This file contains 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
img_rows, img_cols = 28, 28 | |
num_classes = 10 | |
def prep_data(raw): | |
y = raw[:, 0] | |
out_y = keras.utils.to_categorical(y, num_classes) | |
x = raw[:,1:] | |
num_images = raw.shape[0] | |
out_x = x.reshape(num_images, img_rows, img_cols, 1) |
This file contains 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
WITH time AS | |
( | |
SELECT DATE(block_timestamp) AS trans_date | |
FROM `bigquery-public-data.crypto_bitcoin.transactions` | |
) | |
SELECT COUNT(1) AS transactions, | |
trans_date | |
FROM time | |
GROUP BY trans_date | |
ORDER BY trans_date |
NewerOlder