均为原创,转载请注明出自(https://github.com/jiajianrong)
浏览器localstorage缓存静态资源 + 服务器端合并请求
react controlled input - 实时错误提示
mysql:
show variables like 'character%';
Chrome mock Android:
"D:\Program Files\Google\Chrome\Application\chrome.exe" --user-agent="Android"
npm:
npm config set prefix "D:\node8\env\node-global"
npm config set cache "D:\node8\env\node-cache"
npm config set tmp "D:\node8\env\node-tmp"
npm config ls
npm config ls -l
npm i -g cnpm --registry=https://registry.npm.taobao.org
RegExp:
"金融街第三方所发生的".replace(/(?<=.{1}).(?=.{1})/g, '*')
shell:
find /home/work/trace-analysis/new-trace-analysis/infoData/ -name "2017-12*" |awk '{print "rm -rf " $1}'|sh
curl:
curl "https://xxx/nodeapi/getUserInfo?" -H "content-type: application/x-www-form-urlencoded;charset=utf-8" -H "x-requested-with: Fetch" -H "Cookie: abc=xyz; nodejs_cas=abc;"
curl http://localhost:8018/nodeapi/getUserInfo --cookie "shiroCookie=a5d36948-2fd9-441b-8d55-ce1721aea048; _ga=GA1.1.800869426.1545637552; nodejs_finsys_cas=f6476bcfddfb72242652f87f7a1e249d; nodejs_finsys_cas.sig=jKWBXYCynFt1hrEh_w4HTaLYys8"
curl http://localhost:8018/finance/funder/findFunderData?version=1 --cookie "shiroCookie=a5d36948-2fd9-441b-8d55-ce1721aea048; _ga=GA1.1.800869426.1545637552; nodejs_finsys_cas=f6476bcfddfb72242652f87f7a1e249d; nodejs_finsys_cas.sig=jKWBXYCynFt1hrEh_w4HTaLYys8"
curl http://localhost:8018/order/list --cookie "shiroCookie=a5d36948-2fd9-441b-8d55-ce1721aea048; _ga=GA1.1.800869426.1545637552; nodejs_finsys_cas=f6476bcfddfb72242652f87f7a1e249d; nodejs_finsys_cas.sig=jKWBXYCynFt1hrEh_w4HTaLYys8" -X POST -d "pageSize=10¤tPage=1&source=-1&buyCity=-1&fundCode=-1&userName=&mobile=&idCardNo=&saleDeparts=-1&saleName=&orderId=&orderType=-1&spCompanyId=-1&beginTime=2018-12-18&endTime=2019-03-18&workflowNodes=-1&nodeStatus=-1&carDetectStatus=-1&increseAmountStatus=-1&advanceLoan=-1&closeStatus=-1&saleDepart=-1"
ab:
ab -c 5 -n 10 -H "Cookie: shiroCookie=a5d36948-2fd9-441b-8d55-ce1721aea048; _ga=GA1.1.800869426.1545637552; nodejs_finsys_cas=f6476bcfddfb72242652f87f7a1e249d; nodejs_finsys_cas.sig=jKWBXYCynFt1hrEh_w4HTaLYys8" http://localhost:8018/finance/funder/findFunderData?version=1
ab -c 5 -n 10 -p "D:/ab-post-param.txt" -T "application/x-www-form-urlencoded" -H "Cookie: shiroCookie=a5d36948-2fd9-441b-8d55-ce1721aea048; _ga=GA1.1.800869426.1545637552; nodejs_finsys_cas=f6476bcfddfb72242652f87f7a1e249d; nodejs_finsys_cas.sig=jKWBXYCynFt1hrEh_w4HTaLYys8" http://localhost:8018/order/list
ab-post-param.txt
pageSize=10¤tPage=1&source=-1&buyCity=-1&fundCode=-1&userName=&mobile=&idCardNo=&saleDeparts=-1&saleName=&orderId=&orderType=-1&spCompanyId=-1&beginTime=2018-12-18&endTime=2019-03-18&workflowNodes=-1&nodeStatus=-1&carDetectStatus=-1&increseAmountStatus=-1&advanceLoan=-1&closeStatus=-1&saleDepart=-1
on server2, copy a file from server1 to server2:
login server2
cd /home/work/.ssh
ssh-keygen -t rsa
copy id_rsa.pub content
login server1
cd /home/work/.ssh
touch authorized_keys
append server2@id_rsa.pub content into authorized_keys
chmod 600 ~/.ssh/authorized_keys
login server2
(10.48.160.26=server1)
scp work@10.48.160.26:/opt/web.tar.gz /opt/web.tar.gz
ssh-keygen command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
[图解SSH](https://www.jianshu.com/p/33461b619d53)
tar
tar -czvf a.tar.gz *.html // 压缩当前目录所有html文件
tar -czvf a.tar.gz static // 压缩static目录
tar -xzvf a.tar.gz
git
基于当前分支master 创建branchA
git branch branchA
git checkout branchA
coding
git push origin branchA:branchA
将当前分支branchA 合并回master
当前branchA
git checkout master
git merge branchA
将当前分支branchA 合并回master
页面操作
git checkout master
git pull
回退已push的记录
git log
git reset --hard <commit-id>
git push origin HEAD --force
hive建表
use hdp_ershouche_defaultdb;
CREATE EXTERNAL TABLE IF NOT EXISTS finance_static_site(json string)
PARTITIONED BY (day_id string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
STORED AS TEXTFILE
hive入表
use hdp_ershouche_defaultdb;
alter table hdp_ershouche_defaultdb.finance_static_site add partition(day_id='20190401') location '/home/hdp_ershouche/rawdata/finance_static_site/20190401/';
hive查询
use hdp_ershouche_defaultdb;
SELECT * FROM hdp_ershouche_defaultdb.finance_static_site where day_id='20190401'
跨域
ctx.set('Access-Control-Allow-Origin', ctx.headers.origin);
ctx.set('Access-Control-Allow-Headers', 'cache-control,content-type,referer-url');
ctx.set('Access-Control-Allow-Methods', 'OPTIONS,GET,HEAD,PUT,POST,DELETE,PATCH');
ctx.set('Access-Control-Allow-Credentials', true);
端口|进程
lsof -i tcp:PORT
ps -ef|grep PID
netstat -antup
ps -eo pid,lstart,cmd|grep node
网络
sudo iptables -nL
sudo iptables -I INPUT -p TCP --dport 8080 -j REJECT --reject-with tcp-reset
sudo iptables -I OUTPUT -p TCP --dport 8080 -j REJECT --reject-with tcp-reset
sudo iptables -I FORWARD -p TCP --dport 8080 -j REJECT --reject-with tcp-reset
sudo iptables --flush
sudo iptables -I INPUT -p TCP --dport 8080 -j DROP
sudo iptables -I OUTPUT -p TCP --dport 8080 -j DROP
sudo iptables -I FORWARD -p TCP --dport 8080 -j DROP
docker
docker rm -f $(docker ps -q)
sudo kubectl get pod -n mastergo -l app=mysql -o jsonpath='{.items[0].metadata.name}'
sudo kubectl exec -it $POD_NAME -n mastergo -- sh -c 'mysql -uroot -p'
查看文件大小
du -ahd 1 . # -a all -h 显示大小时使用 K,M,G 等可读单位 -d 目录深度
du -ahd 1 /
du -ad 1 . |sort -nr
du -ad 1 / |sort -nr
du -sh /*
du -sh ./*
du -s /* |sort -nr
du -s ./* |sort -nr
du -sh * | sort -nr
du -sh /home/admin/* | fgrep G
查看硬盘
lsblk
查看文件是否被打开
lsof faas.log
查看文件被哪个进程打开
lsof | grep faas.log
babel
babel-cli / babel-core: 命令行/API
babel-register / babel-node: 编译服务端代码
babel-polyfill: core-js/stable & regenerator-runtime;{useBuiltIns: entry|usage}
babel-runtime: runtime helper & regenerator-runtime;api转换使用局部变量,不修改原型
babel-plugin-transform-runtime: helpers定义改为引用;自动引用
React
- TypeScript类型支持
- 同时支持 Class 与 React.FC 组件
- 友好的异步操作
- 支持按需加载
- 少重复样板代码
- 符合函数式特性(immutable,computed,memoization...)
- 支持状态互相依赖
- 高内聚,低耦合
- 支持react-router状态管理
- API清晰简洁
- 丰富的生态体系
wget安装nodejs
- dnf info nodejs
- https://developer.aliyun.com/article/980198
- wget -c https://npmmirror.com/mirrors/node/v16.15.0/node-v16.15.0-linux-x64.tar.xz
- tar Jxf node-v16.15.0-linux-x64.tar.xz -C /usr/local/
- echo "export PATH=/usr/local/node-v16.15.0-linux-x64/bin/:$PATH" >> .bashrc
- source .bashrc
- node -v
SQL优化
select someKeys from order_table
where user_id='1234'
order by id limit 23000,100;
select a.someKeys from order_table a,
(select id from order_table where user_id='1234' order by id limit 23000,100) b
where a.id=b.id
order by a.id;