Skip to content

Instantly share code, notes, and snippets.

@pruidong
pruidong / java_gen_multistage_zip_file.java
Last active April 25, 2022 03:42
Java生成多级ZIP压缩文件
// log: 使用Lombok的@Slf4j.
/**
*
* 获取zip文件
*
*/
@GetMapping("/get-zip")
public void getZip(
HttpServletResponse response) {
@pruidong
pruidong / ESRestProdClientConfig.java
Created March 17, 2022 02:41
Spring Data ElasticSearch连接ElasticSearch.
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.elasticsearch.client.RestClient;
@pruidong
pruidong / sql_to_es_mapping.py
Last active March 2, 2022 05:49
MySQL DDL转ElasticSearch Mapping(用于在Kibana中创建索引).
'''
MySQL DDL转ElasticSearch Mapping(用于在Kibana中创建索引).
输出(示例):
新增索引:
PUT /t_comm_demo
{
@pruidong
pruidong / canal_sync_mysql_data_to_es7.md
Last active March 2, 2022 02:54
Canal同步MySQL数据至ElasticSearch7.x

使用步骤

  1. 使用步骤参考官方文档;
  2. 先安装及配置Canal Server;
  3. 安装配置Canal Adapter;
  4. 在ElasticSearch中配置索引;
  5. 启动Canal Adapter,向需要同步的表执行增删改操作.
  6. 同步成功!

参考教程: https://zhuanlan.zhihu.com/p/424550462

@pruidong
pruidong / batch_decrypt_excel.py
Created January 29, 2022 03:37
Python使用密码批量解密Excel XLS文件
import msoffcrypto
import os
import logging
'''
使用正确密码,批量解密XLS文件(非暴力破解)
特性:
1. 指定文件夹目录中所有文件(默认仅包含.xls文件);
@pruidong
pruidong / fedora_install_openjdk.md
Last active October 25, 2021 03:31
Fedora安装OpenJDK

查找JDK

rpm -qa|grep jdk

删除所有JDK

rpm -e --nodeps [search result]

再次确认已经完全删除.

rpm -qa|grep jdk

输出试一下

@pruidong
pruidong / base64str_to_image.py
Created September 26, 2021 07:03
Python处理Base64字符串转为图片
import base64
imgdata = base64.b64decode('base64str')
filename = 'base64decode.jpeg'
with open(filename, 'wb') as f:
f.write(imgdata)
@pruidong
pruidong / python_pip_upgrade_all.md
Created September 12, 2021 16:09
pip升级本地所有软件包

Windows PowerShell:

pip freeze | %{$.split('==')[0]} | %{pip install --upgrade $}

@pruidong
pruidong / batch_write_file.py
Created April 12, 2021 07:41
批量写文件
#!coding=utf-8
'''
批量写文件.
内容一致,但是文件名不同.
2021-04-12
'''
@pruidong
pruidong / genTestDataByHTMLTag.py
Created February 8, 2021 11:55
根据HTML标签内容,生成测试json数据.
#!coding=utf-8
'''
根据HTML标签内容,生成测试json数据.
2021-02-08
'''