Skip to content

Instantly share code, notes, and snippets.

@yijia2413
yijia2413 / insert.sh
Created Apr 22, 2019
MySQL insert duplicate key
View insert.sh
insert into proc_runtime (vm, procname) values ('100', 'wechat.exe') on duplicate key update vm = values(vm), procname = values(procname), day_runtime =day_runtime + values(day_runtime)
View README.md

Config Ingress Nginx

  • mandatory.yml, do not use hostNetwork, # hostNetwork: true
  • cloud-generic.yml, add externalIPs
    kind: Service
    apiVersion: v1
    metadata:
      name: ingress-nginx
      namespace: ingress-nginx
      labels:
    
@yijia2413
yijia2413 / k8s_op.sh
Last active Mar 1, 2019
k8s operations
View k8s_op.sh
# start proxy allow remote access
kubectl proxy --address=0.0.0.0 --port=80 --accept-hosts='^*$'
# check pod startup issue
kubectl describe pod [my-pod-name] -n [kube-system](namespace)
# show all pods
kubectl get pods --all-namespaces
# delete pod and restart again
@yijia2413
yijia2413 / tz.sh
Last active Apr 19, 2019
chang timezone
View tz.sh
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# for linux
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# for alpine
RUN apk add --no-cache tzdata
ENV TZ Asia/Shanghai
@yijia2413
yijia2413 / list_tuples_to_string.py
Created Jan 11, 2019
list of tuples to string with split
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",
@yijia2413
yijia2413 / containerd.service
Created Dec 28, 2018
离线安装 Docker 和 DockeCompose
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
You can’t perform that action at this time.