Skip to main content

· One min read

notebook

cat > config.json
{
"NotebookApp": {
"password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$TvqWSGeQsqj2qsztGA7rmw$k0YNPHZM/u8V67dVVst9pw"
}
}
pwd: 1~8
notebook --ip=0.0.0.0 --port=5000 --allow-root --config=./config.json
nohup jupyter notebook --ip=0.0.0.0 --port=5000 --allow-root --config=./config.json &
http://10.231.9.124:5000/tree
# 把 a.ipynb 提取出 a.py
jupyter nbconvert --to script a.ipynb
# 把 a.ipynb 提取出 a.html
jupyter nbconvert --to html a.ipynb

· One min read

python -m

cat b.json | python -m json.tool # json
python -m http.server 3333 # local file

pip加速

pip install tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
[global]
index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/

[install]
trusted-host=mirrors.cloud.aliyuncs.com

@deprecated

warnings.warn("弃用", DeprecationWarning)

venv

pip install virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple
virtualenv --no-site-packages venv

anaconda

conda create -n py39 python=3.9 anaconda

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

opencv

· 2 min read

kubectl

export KUBECONFIG=~/Desktop/www/work-book/env/sandbox/1_kubernetes/kubeconfig

kubectl get pod -A

kubectl run hello-minikube --image=zx5435/go-fs:v1 --port=8080

kubectl delete -n default deployment hello-minikube

kubectl logs -f pod-gim-uat-app-2
kubectl logs --tail=50 -f pod-gim-uat-app-2

install

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/windows/amd64/kubectl.exe

config

namespace

kubectl config set-context --current --namespace=$(basename $PWD)
kubectl config set-context --current --namespace=ccm-perf
kubectl config set-context $(kubectl config current-context) --namespace=ccm-perf

run

kubectl run hello-minikube --image=zx5435/go-fs:v1 --port=8080

delete 批量

kubectl -nccm-uat get pod --field-selector=status.phase!=Running
kubectl -nccm-uat get pod --field-selector=status.phase==Failed

port-forward

# outside:inside 左外右内
kubectl -nzx5435 port-forward --address 0.0.0.0 service/air-ticket 7777:80

kubectl -nzx5435 expose deployment air-ticket --type=LoadBalancer --name=my-service

configmap

kubectl -nccm-perf create configmap mq-conf --from-file=activemq

kustomize

kubectl builtins

# kustomization.yaml
# k apply -k config/
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
generatorOptions:
# disableNameSuffixHash: true
labels:
type: generated
annotations:
note: generated
configMapGenerator:
- name: gim-fs
files:
- pii.yml
- activemq.xml
- broker.ks
- name: ept-env
literals:
- ACTIVEMQ_PASSWORD=admin

install

# install
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash

kustomize build | kubectl apply -f -

config tpl

# kustomization.yaml
namespace: gimc-prod
generatorOptions:
# disableNameSuffixHash: true
labels:
type: generated
annotations:
note: generated
configMapGenerator:
- name: gimc-cfgs
files:
- pii.yml
- name: ept-env
literals:
- MYSQL_DB_NAME=gimc-prod
secretGenerator:
- name: gimc-https
files:
- tls.key
- tls.crt

· One min read

安装 https://blog.csdn.net/sun8112133/article/details/79944531

使用 apt-get 命令 安装后的 tomcat 7的目录结构说明
/etc/tomcat8 :全局配置
/usr/share/tomcat8/ :程序主目录
/usr/share/tomcat8/conf/Catalina/localhost/ :本机部署的 Catalina 配置
/var/lib/tomcat8/ :工作主目录
/var/lib/tomcat8/webapps :应用文件实际存放于此
/var/lib/tomcat8/work :动态工作目录(动态编译的 .jsp 存放于此)

docker

# 把war放当前目录,会自动解压缩
docker run -it --rm -p 8888:8080 -v $PWD:/usr/local/tomcat/webapps tomcat:8.5.39-jre8-alpine

tar.gz install https://www.jb51.net/article/143185.htm

wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.17/bin/apache-tomcat-9.0.17.tar.gz
tar -zxvf apache-tomcat-9.0.17.tar.gz

jetty

wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.16.v20190411/jetty-distribution-9.4.16.v20190411.tar.gz
tar -zxvf jetty-distribution-9.4.16.v20190411.tar.gz

· 2 min read
yum -y install bind bind-utils

service named start

vi /etc/named.conf 修改any

service named restart

netstat -antlpe | grep named

# 验证配置文件是否有错误
named-checkzone test.com /var/named/test.com.zone

本地配置 dns

vi /etc/resolv.conf

# Generated by NetworkManager
nameserver 172.16.30.28
nameserver 202.96.202.5
nameserver 114.114.114.114

cd /var/named/ cp -p named.localhost named.inner

demo hk.com

$TTL 1D
@ IN SOA dns.hk.com. root.hk.com. (
0 ; serial
1H ; refresh
1H ; retry
1H ; expire
1H ) ; minimum
NS dns.hk.com.
dns A 172.16.30.11
www A 172.16.30.22
news A 172.16.30.33

vi /var/named/named.inner

$TTL 1D
@ IN SOA @ root.inner.test.tianshengcm.com. (
0 ; serial
1H ; refresh
1H ; retry
1H ; expire
1H ) ; minimum
IN NS @
IN A 172.16.30.28
@ IN A 172.16.30.28
ynh-app IN A 172.16.30.28
ynh-rcm IN A 172.16.30.28
ynh-cs IN A 172.16.30.28
fhh-app IN A 172.16.30.28
fhh-rcm IN A 172.16.30.28
fhh-cs IN A 172.16.30.28
* IN A 172.16.30.28

追加 vi /etc/named.rfc1912.zones

zone "hk.com" IN {
type master;
file "hk.com";
allow-update { none; };
};
zone "inner.test.tianshengcm.com" IN {
type master;
file "named.inner";
allow-update { none; };
};

dig inner.test.tianshengcm.com

· One min read

抓包 mitmproxy

doc

https://zhuanlan.zhihu.com/p/23931921

  • ? 进入 帮助
  • 按z清空请求列表
  • 按用j,k或者上下方向键在列表上浏览
  • 按回车进入详情界面
  • 按q,返回列表界面
  • 按tab键或者h,l,在Request,Response,Detail三个tab之间切换。按j,k或者上下方向键可以滚动查看详情
  • 按G跳到最新一个请求
  • 按g跳到第一个请求
  • 按d删除当前选中的请求,按D恢复刚才删除的请求

install

brew install mitmproxy

https

safari http://mitm.it iPhone => 关于本机 => 证书信任设置

view_filter

https://docs.mitmproxy.org/stable/concepts-filters/

~d regex Domain ~d regex baidu ~d xdq ~b bank_name

· One min read

编写简洁漂亮,可维护的 React 应用 https://github.com/shimohq/react-cookbook

  • 前言
  • 组件声明
  • 计算属性
  • 事件回调命名
  • 组件化优于多层 render
  • 状态上移优于公共方法
  • 容器组件
  • 纯函数的 render
  • 始终声明 PropTypes
  • Props 非空检测
  • 使用 Props 初始化
  • classnames

· One min read

rabbitmq

docker pull rabbitmq:3.7.8

docker run -d --name rabbitmq-1 rabbitmq:3.7.8

docker run -d --name rabbitmq -p 5671:5671 -p 5672:5672 -p 4368:4368 -p 25672:25672 -p 15671:15671 -p 15672:15672 rabbitmq:management

docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:3.7.8-management
http://0.0.0.0:15672
guest/guest

demo

<?php

namespace app\console\controllers;

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
use yii\console\Controller;

class QueueController extends Controller
{

public function actionIn($n = 1)
{
$connection = new AMQPStreamConnection('172.16.30.123', 5672, 'guest', 'guest');
$channel = $connection->channel();

// if not exist
$channel->queue_declare('hello', false, false, false, false);

$msg = 'hello_' . date('H_i_s');
$msg = new AMQPMessage($msg);
$channel->basic_publish($msg, '', 'hello');

echo "Send: {$msg->body}\n";
$channel->close();
$connection->close();
}

public function actionExec()
{
$connection = new AMQPStreamConnection('172.16.30.123', 5672, 'guest', 'guest');
$channel = $connection->channel();

// if not exist
$channel->queue_declare('hello', false, false, false, false);

echo "Start\n";
$callback = function ($msg) use ($channel) {
/** @var AMQPMessage $msg */
echo "Get: {$msg->body}\n";

// ack
$delivery_tag = $msg->delivery_info['delivery_tag'];
$channel->basic_ack($delivery_tag);
};

$channel->basic_consume('hello', '', false, false, false, false, $callback);

while (count($channel->callbacks)) {
$channel->wait();
}
}

}

· 2 min read

docker image

# https://github.com/graalvm/container/pkgs/container/graalvm-ce
# ghcr.io/graalvm/$IMAGE_NAME[:][$os_version][-$java_version][-$version][-$build_number]
docker pull ghcr.io/graalvm/jdk:ol8-java17-22

docker tag ghcr.io/graalvm/jdk:ol8-java17-22 wolanx/java:jdk17-graalvm22
docker push wolanx/java:jdk17-graalvm22

docker tag ghcr.io/graalvm/jdk:ol8-java17-22 wolanx/java:latest
docker push wolanx/java:latest

doc

面试题

优化 jvm

spring

db

jmap 分析

字段详细解释 https://www.cnblogs.com/kongzhongqijing/articles/3621163.html
jmap -heap 1
jmap -dump:file=jmap.dump 1
jmap -dump:format=b,file=jmap.hprof 1
tar -zcvf a.tar.gz jmap.hprof
k cp dep-monitor-center-577f76bb89-xjfwg:/a.tar.gz a.tar.gz
https://www.eclipse.org/mat/

java基础

常用命令

# .java => .class
javac HelloWorld.java

# 运行 .class
java HelloWorld
java -classpath /www/demo HelloWorld

# .class => .jar
jar -cvf hello.jar Hello.class
# 运行 jar
java -jar 1.jar

# .jar => .exe
javaFX

# .jar => folder
jar xvf etp-cs-i18n.jar

decode

.class => .java
java -jar ~/Desktop/app/fernflower/build/libs/fernflower.jar classes src/main/java-temp