commit 5ccfaba2c3c37055114193834eea24d50ac01c8b Author: zr <892955278@msn.cn> Date: Wed Nov 2 10:41:53 2022 +0800 feat: first commt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e1d4ba8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*.json + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* \ No newline at end of file diff --git a/work常用/GIT操作.md b/work常用/GIT操作.md new file mode 100644 index 0000000..f119454 --- /dev/null +++ b/work常用/GIT操作.md @@ -0,0 +1,42 @@ +* 创建本地及远程仓库 + + ```shell + # 从命令行创建一个新的仓库 + touch README.md + git init + git add README.md + git commit -m "first commit" + git remote add origin http://x.x.x.x:1314/X6738/yfzx-yn-cloudmirror-group-v3.0.git + git push -u origin master + + # 从命令行推送已经创建的仓库 + git remote add origin http://x.x.x.x:1314/X6738/yfzx-yn-cloudmirror-group-v3.0.git + git push -u origin master + ``` + +* 常用命令 + +```shell +# 列出本地分支及最后一次提交 +git branch -v +# 检出远程地址 +git clone xxxxxxx.git +# 检出远程分支 +git clone -b xxx xxxxx.git +# 把指定暂存区文件提交到本地仓库 +git commit -m "<描述信息>" xxx.java +# 提交全部 +git commit -m "<描述信息>" * +# 从远程仓库获取最新的版本到本地tmp分支 +git fetch <远程主机名> <分支名> +# 显示提交记录 +git log +# 本地仓库分支推送到远程仓库 +git push <远程仓库> <本地分支名>:<远程分支名> +# 列出远程仓库详细信息 +git remote -v +# 查看本地仓库状态 +git status +# 从远程仓库获取最新版本 +git pull +``` diff --git a/work常用/PG 常用SQL.md b/work常用/PG 常用SQL.md new file mode 100644 index 0000000..a0a269a --- /dev/null +++ b/work常用/PG 常用SQL.md @@ -0,0 +1,94 @@ +* 批量like + + ```sql + like any (array['%.jpg','%.jpeg']) + ``` + +* 创建序列 + + ```sql + create SEQUENCE id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + alter table kx_hospital ALTER COLUMN id set DEFAULT nextval('_id_seq') + ``` +* 获取当前时间绝对秒 + + ```sql + select floor(extract(epoch from now())) + ``` +* 雪花ID函数 + + ```sql + create SEQUENCE table_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + CREATE OR REPLACE FUNCTION "public"."snow_next_id"(OUT "result" int8) + RETURNS "pg_catalog"."int8" AS $BODY$ + DECLARE + our_epoch bigint := 1314220021721; + seq_id bigint; + now_millis bigint; + shard_id int := 5; + BEGIN + seq_id := nextval('table_id_seq') % 1024; + SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp()) * 1000) INTO now_millis; + result := (now_millis - our_epoch) << 23; + result := result | (shard_id << 10); + result := result | (seq_id); + END; + $BODY$ + LANGUAGE plpgsql VOLATILE + COST 100 + ``` + +* count统计过滤及去重 + + ```sql + count(distinct(speaker_id||speak_time||content)) FILTER (where t.mark='text') ----- 使用distinct 去重 filter用于过滤 + ``` + +* PG 操作schema + + ```sql + drop SCHEMA "public" CASCADE --强制删除,包含模式下所有对象(表、函数等) + create SCHEMA "public" --创建 + alter schema name RENAME TO new_name -- 修改模式名称 + alter schema name OWNER TO new_owner -- 修改拥有者 + ``` +* 获取单位时间间隔时间 + + ```sql + -- 获取6个月前时间 + select to_char((select now() - interval '6 month'),'yyyy-MM-dd hh24:mi:ss') + ``` + +* 窗口函数分组统计(根据collect_code分组,并以collect_time 倒序) + + ```sql + select collect_value,row_number() over(PARTITION by collect_code ORDER BY collect_time desc) from nc_data_collect_value_test + ``` + +* lead函数获取上一条记录,并计算增量 + + ```sql + select create_date,node_value as total,next_day_total,next_day_total::int8-node_value::int8 as increment from ( + with a as (SELECT create_date, node_value FROM nc_data_node_value_detail WHERE node_code = '' ORDER BY create_date DESC ) + select create_date,node_value,lead(node_value,1) over (ORDER BY create_date) next_day_total FROM a ORDER BY create_date desc) tt + ``` + +* lag函数获取下一条记录 + + ```sql + select create_date,node_value as total,next_day_total,abs(next_day_total::int8-node_value::int8) as increment from ( + with a as (SELECT create_date, node_value FROM nc_data_node_value_detail WHERE node_code = '' ORDER BY create_date DESC ) + select create_date,node_value,lag(node_value,1) over (ORDER BY create_date) next_day_total FROM a ORDER BY create_date desc) tt + ``` diff --git a/work常用/PG-雪花ID.md b/work常用/PG-雪花ID.md new file mode 100644 index 0000000..425b853 --- /dev/null +++ b/work常用/PG-雪花ID.md @@ -0,0 +1,24 @@ +create SEQUENCE table_id_seq +START WITH 1 +INCREMENT BY 1 +NO MINVALUE +NO MAXVALUE +CACHE 1; + +CREATE OR REPLACE FUNCTION "public"."snow_next_id"(OUT "result" int8) + RETURNS "pg_catalog"."int8" AS $BODY$ +DECLARE + our_epoch bigint := 1314220021721; + seq_id bigint; + now_millis bigint; + shard_id int := 5; +BEGIN + seq_id := nextval('table_id_seq') % 1024; + SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp()) * 1000) INTO now_millis; + result := (now_millis - our_epoch) << 23; + result := result | (shard_id << 10); + result := result | (seq_id); +END; +$BODY$ + LANGUAGE plpgsql VOLATILE + COST 100 diff --git a/work常用/PG12 导入导出sql文件.md b/work常用/PG12 导入导出sql文件.md new file mode 100644 index 0000000..dba27ce --- /dev/null +++ b/work常用/PG12 导入导出sql文件.md @@ -0,0 +1,7 @@ +```sql +导出: +export PGPASSWORD=密码 && /opt/pgsql/bin/pg_dump -U 业务用户名 -d 库名 -h 127.0.0.1 --port=端口 -w > bak.sql + +导入: +export PGPASSWORD=密码 && /opt/pgsql/bin/psql -U 业务用户名 -d 库名 -h 127.0.0.1 --port=端口 -w -f bak.sql +``` diff --git a/work常用/PG12 建库.md b/work常用/PG12 建库.md new file mode 100644 index 0000000..35f1d3d --- /dev/null +++ b/work常用/PG12 建库.md @@ -0,0 +1,13 @@ +``` +cd /home/NebulaBS_Dbn_PG_Safe_Tool-install-1.0.0 + +编辑globe.common.conf 文件 + +执行sh install.sh 参数 + +脚本参数说明user 添加用户, db 创建库 ,access 添加访问权限 + +新建库并且新建用户时,命令执行顺序user ---> db ---> access + +注:新增ip时,需要把原有IP注释 +``` diff --git a/work常用/beeline.md b/work常用/beeline.md new file mode 100644 index 0000000..8c29749 --- /dev/null +++ b/work常用/beeline.md @@ -0,0 +1 @@ +beeline -u "jdbc:hive2://x.x.x.x:10000/default;principal=hive/host@DC1.FH.COM;hive.server2.proxy.user=abc=abccc" diff --git a/work常用/power-shell.md b/work常用/power-shell.md new file mode 100644 index 0000000..7e2f71c --- /dev/null +++ b/work常用/power-shell.md @@ -0,0 +1,5 @@ +* 批量删除某类文件 + + ```sql + get-childitem * -include *.jar -recurse|remove-item + ``` diff --git a/work常用/python 打包exe.md b/work常用/python 打包exe.md new file mode 100644 index 0000000..c3b7ded --- /dev/null +++ b/work常用/python 打包exe.md @@ -0,0 +1,8 @@ +1. 安装pyinstaller + + [Pyinstall3.6及依赖包.zip](assets/Pyinstall3.6及依赖包-20220524173110-02m5h8w.zip) +2. 在需要打包的入口文件目录下执行 ,会生成release 文件夹 + + ```sql + pyinstaller -F --distpath release test.py + ``` diff --git a/work常用/常用linux命令.md b/work常用/常用linux命令.md new file mode 100644 index 0000000..29d043a --- /dev/null +++ b/work常用/常用linux命令.md @@ -0,0 +1,107 @@ +* 显示前N个 + + ``` + ll -lht|head -n 20 + ``` + +* 压缩命令过长 + + ```shell + find ./ -name '*' -print |zip files -@ + ``` + +* 合并文件 + + ```sql + cat *.txt > target.txt + ``` + +* 配置定时任务 + + ```sql + root 用户 + vim /etc/crontab + + SHELL=/bin/bash + PATH=/sbin:/bin:/usr/sbin:/usr/bin + MAILTO=root + + # For details see man 4 crontabs + + # Example of job definition: + # .---------------- minute (0 - 59) + # | .------------- hour (0 - 23) + # | | .---------- day of month (1 - 31) + # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... + # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat + # | | | | | + # * * * * * user-name command to be executed + 20 04 * * * root reboot + + # 加载配置 + crontab /etc/crontab + + # 重启crontab服务 + systemctl restart crond.service + ``` + +* 查看上一次启动 + + ```sql + who -b + ``` + +* 切分文件 + + ```sql + # 按大小切分 + split -b 100m xxxx + # 按行切分 + split -l xxxx + # 设置拆分后文件名,指定数字后缀 + split -b 100m -d xxxx xxxx_part_ + ``` + +* 显示文件大小 + + ```sql + du -sh xxxx + ``` + +* grep + + ```sql + # 高亮查找结果 + grep --color "test" catalina.out + # 显示在第几行 + grep -n test catalina.out + ``` + +* zip + + ```shell + # 压缩 + zip -r ./xxx.zip ./* + # 解压 + unzip xxx.zip + # 查看压缩文件内容 + unzip -v xxx.zip + # 从zip中删除xxx.txt文件 + zip xxx.zip -d xxx.txt + ``` +* 软链接 + + ```shell + ln -s 源文件名 软链接文件名 + ``` + +* 查看端口占用情况 + + ```shell + # 查看所有 + lsof -i + # 查看指定端口 + lsof -i:8080 + # 查看文件进程 + lsof xxx.txt + ``` diff --git a/work常用/常用公式.md b/work常用/常用公式.md new file mode 100644 index 0000000..7751f03 --- /dev/null +++ b/work常用/常用公式.md @@ -0,0 +1,5 @@ +* 计算组合数 + + $$ + x=n(n-1)/2 + $$