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
// usage: Tar("~/home", "home.tar.gz") | |
func Tar(src, dst string) (err error) { | |
// 创建文件 | |
fw, err := os.Create(dst) | |
if err != nil { | |
return | |
} | |
defer fw.Close() | |
// 将 tar 包使用 gzip 压缩,其实添加压缩功能很简单, |
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 ( | |
"encoding/json" | |
"flag" | |
"fmt" | |
"io/fs" | |
"log" | |
"os" | |
"path/filepath" |
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
#!/bin/zsh | |
root=<ProjectRoot> | |
pushd $root | |
diff=`git diff` | |
tm=`date +"%Y-%m-%d"` | |
file=$root/diff-history/$tm | |
echo $diff > $file | |
curl -X POST -H "Content-Type: application/json" \ | |
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"file://$file\"}}" \ | |
<飞书Api> |
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
-- 返回 set 中非 download 状态的成员。 | |
local setName = KEYS[1] | |
local val = redis.call("sscan", setName, KEYS[2]) | |
-- set 为空 | |
if (val[1] == "0") then | |
return {} | |
end | |
local res = {} |
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
#!/bin/bash | |
providers=("jingdong") | |
project=/home/filex/download | |
etc=$project/etc | |
cfg=$project/cfg | |
log=$project/log/$(date "+%Y-%m-%d_%H-%M-%S") | |
parallism=8 | |
echo "start to check missing log time point" |
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
gitHash=$(shell git rev-parse HEAD) | |
built=$(shell date +"%Y-%m-%d_%H:%M:%S") | |
build_check: | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(gitHash) -X main.built=$(built) " -trimpath -o filex/share/check ./jobs/check | |
cp -rf ./jobs/check/etc/check.json ./filex/etc | |
cp ./jobs/check/check ./filex/bin | |
build_download: | |
cp -rf ./jobs/download/etc/* ./filex/etc | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(gitHash) -X main.built=$(built) " -trimpath -o filex/share/download ./jobs/download |
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
var dataUnitPattern, _ = regexp.Compile(`(\d+)\s*([a-zA-Z]+)`) | |
func ParseDataStorage(s string) (int64, error) { | |
all := dataUnitPattern.FindAllStringSubmatch(s, -1) | |
if len(all) != 1 || len(all[0]) != 3 { | |
return 0, fmt.Errorf("invalid %s", s) | |
} | |
d, u := all[0][1], all[0][2] | |
num, err := strconv.ParseInt(d, 10, 32) | |
if err != nil { |
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
import org.apache.flink.api.java.io.TextOutputFormat; | |
import org.apache.flink.core.fs.Path; | |
import java.io.IOException; | |
public class GZIPOutputFormat<T> extends TextOutputFormat<T> { | |
public GZIPOutputFormat(Path outputPath) { | |
super(outputPath); | |
} |
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
func Difference(a, b []string) []string { | |
res := make([]string, 0) | |
for _, aItem := range a { | |
var same bool | |
for _, bItem := range b { | |
if aItem == bItem { | |
same = true | |
break | |
} | |
} |
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
@Test | |
public void toUpyunLog2() throws Exception { | |
InputStream in = getClass().getResourceAsStream("/aliyun-3"); | |
BufferedReader in2 = new BufferedReader(new InputStreamReader(in)); | |
String lineTxt; | |
// System.getProperty("user.home") 获取用户主目录 | |
File file = new File(System.getProperty("user.home") + "/aliyun-3-wanted"); | |
// 文件不存在则创建 | |
file.createNewFile(); | |
FileWriter fw = new FileWriter(file); |
OlderNewer