View tz.sh
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
View list_tuples_to_string.py
a = [('a', 'etwrfb', 'casdf'), ('1', 2, '35235')] | |
res = '\n'.join(','.join(map(str, i)) for i in a) | |
# 'a,etwrfb,casdf\n1,2,35235' |
View createt_tb.sql
CREATE TABLE if not exists `test` ( | |
`id` BIGINT(20) NOT NULL AUTO_INCREMENT, | |
`result` VARCHAR(128), | |
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
KEY id (id)) | |
ENGINE=InnoDB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1 | |
PARTITION BY RANGE ( TO_DAYS(update_time) ) ( | |
-- PARTITION BY hash (TO_DAYS(update_time)) partitions 31; | |
PARTITION p_first VALUES LESS THAN (TO_DAYS('2019-01-07 00:00:00')), | |
PARTITION p20190107 VALUES LESS THAN (TO_DAYS('2019-01-08 00:00:00')), |
View mysql_connection_poll.py
# COPY FROM https://stackoverflow.com/questions/32658679/how-to-create-a-mysql-connection-pool-or-any-better-way-to-initialize-the-multip | |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import time | |
import mysql.connector.pooling | |
dbconfig = { | |
"host":"127.0.0.1", |
View containerd.service
[Unit] | |
Description=containerd container runtime | |
Documentation=https://containerd.io | |
After=network.target | |
[Service] | |
ExecStartPre=/sbin/modprobe overlay | |
ExecStart=/usr/bin/docker-containerd | |
KillMode=process | |
Delegate=yes |
View connect.txt
mysql+pymysql://root:xxxx@localhost:3306/qin?charset=utf8 |
View delete-none-containers-and-images.sh
#!/bin/bash | |
set -ex | |
containers=$(docker ps -a -q --filter status=exited) | |
if [[ ! -z ${containers} ]]; then | |
docker rm -f -v ${containers} | |
fi |
View check.sh
#!/bin/bash | |
set -ex | |
if [[ "$1" =~ ^[0-9]+$ ]]; then | |
echo "yes" | |
else | |
echo "no" | |
fi |
View process_inside_container_restart.sh
#!/bin/bash | |
set -ex | |
sleep_time=5 | |
regex_name='server1.py' | |
cmd="python ${regex_name} &>> logs/test.log &" | |
bash -c "${cmd}" |
View shell_err.sh
# https://zh-google-styleguide.readthedocs.io/en/latest/google-shell-styleguide/environment/ | |
err() { | |
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2 | |
} | |
if ! do_something; then | |
err "Unable to do_something" | |
exit "${E_DID_NOTHING}" | |
fi |
NewerOlder