Skip to content

Instantly share code, notes, and snippets.

@kougazhang
kougazhang / Dockerfile
Last active September 15, 2021 11:11
分阶段打包 #Dockfile
FROM golang:1.6 as builder
RUN mkdir -p /home/filex
RUN mkdir -p /disk/ssd1
WORKDIR /home/filex
ARG project
COPY ./filex/$project .
FROM builder as job
# 注意,如果 stage 中想要使用 ARG 需要重新在此重新定义
@kougazhang
kougazhang / batch-remove-docker-images.sh
Created September 15, 2021 10:59
批量删除镜像 #shell #docker
# delete images that contains none.
docker images|grep none|awk '{print $3}'|xargs -n1 -I{} docker rmi {}
@kougazhang
kougazhang / tool.sh
Last active February 28, 2022 00:55
#shell #delete #rsync
# clean the same relative path in echo disk. the disk name like /disk/sata01, /disk/sata02
for i in {1..12};do
if [ $i -lt 10 ]; then
i=0$i
fi
rm -rf /disk/sata$i/<filepath>
done
@kougazhang
kougazhang / clean-hdfs.awk
Last active January 17, 2023 04:03
#shell #awk
# run command: hdfs dfs -ls /cdn-logs/<pvdName>/raw/*/*/*|awk -f ./clean.awk
BEGIN{
# file expiration date
remaining = 25 * 24 * 3600
}
{
# $8 is filepath, get datetime from filepath
@kougazhang
kougazhang / git_sync.sh
Created October 20, 2021 06:25
#shell #git
#!/usr/bin/env bash
# sync src to git repository.
# src is file
src=$1
# dest is dir
dest=$2
cp $src $dest
@kougazhang
kougazhang / my.cnf
Last active October 28, 2021 01:11 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated February 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@kougazhang
kougazhang / scan.lua
Created November 1, 2021 08:30
#lua #redis
-- scan whole keys in redis by key_pattern and filter
-- key_pattern: key regexp
-- count: match count for once scan
-- filter: one function that accepts the value of key as param.
local scan=function(key_pattern, count, filter)
local start = "-1"
local lst = {}
while (start ~= "0") do
if (start == "-1") then
@kougazhang
kougazhang / fctl.sh
Created November 10, 2021 02:39
#shell #render #template
#!/usr/bin/env bash
function exitIfEmpty() {
if [ -z "$2" ]; then
echo "$1 is empty"
exit 1
fi
}
function initJob() {
cmake_minimum_required(VERSION 3.15)
project(run_curl C)
set(CMAKE_C_STANDARD 99)
# 设置头文件
set(INC_DIR ./curl/include)
# 设置源码
set(LINK_DIR ./curl/lib)
  • 声明变量都加 $
  • 调用类 a 的方法b 使用 $a->b

php 执行文件需要写:

<? php
  echo "hello"
?>