Skip to content

Instantly share code, notes, and snippets.

@jtr109
jtr109 / current.sh
Created December 5, 2018 12:50
get path of the executed bash file
#!/bin/bash
# reference: https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
currentDir=$(
cd $(dirname "$0")
pwd
)
echo -n "current "
@jtr109
jtr109 / count.sh
Created December 5, 2018 09:58
obtain the count of cpu cores
# reference https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l
@jtr109
jtr109 / README.md
Last active December 3, 2018 05:50
创建数据表以适应 utf8mb4

Python3 PyMySQL Raise Incorrect String Value When Inserting UTF-8 Data

Description

Python3 + PyMySQL 的环境, 如果在数据库中写入中文, 会出现报错:

pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE6\\xB5\\x8B\\xE8\\xAF\\x95' for column 'description' at row 1")
@jtr109
jtr109 / README.md
Last active December 3, 2018 13:39
Cheat Sheet of Kubernetes
@jtr109
jtr109 / README.md
Created November 7, 2018 02:46
Cheat Sheet of MySQL
@jtr109
jtr109 / gunicorn.sh
Last active November 1, 2018 06:45
ipv6 notes
# listen ipv6 and ipv4 at the same time by gunicorn
# http://docs.gunicorn.org/en/stable/settings.html#bind
gunicorn -b 0.0.0.0:5000 -b '[::1]:5000' test:app
@jtr109
jtr109 / kill.sh
Last active September 20, 2018 07:45
close process with name pattern
// if you want to kill all processes match "pname"
ps aux | grep pname | grep -v grep | awk '{print $2}' | xargs kill
@jtr109
jtr109 / README.md
Last active September 13, 2018 07:11
git/SSH 使用 Socket 代理
@mixin multiple-lines ($count) {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $count;
/* autoprefixer: off */
-webkit-box-orient: vertical;
/* autoprefixer: on */
}