泡杯茶,过来坐坐
小网客 · 共 581 篇文章
Mysql查询某database的所有表的记录数
需求: 查询某固定db中所有表的记录数,然后排序 实现: select table_name,table_rows from information_schema.tables where table_schema='yourdb' order by table_rows desc;
2018-11-28 18:05 · DB · 评论(0)
linux下获取某文件的总行数
需求: linux下获取某文件的总行数 实现: 方案一: echo `cat logfile.txt | wc -l` 方案二: more logfile.txt |wc -l 摘自: http://www.xhuojia.com/zhuanlan/2779749052.html
2018-08-29 16:58 · Linux · 评论(0)
shell查找某字符在文件中出现行数
需求: linux脚本统计某字符串在文件中那行出现 实现: more logfile.txt |grep 'headee' -n 摘自: http://www.xhuojia.com/zhuanlan/2755510772.html
2018-08-29 16:57 · Linux · 评论(0)
linux截取指定行数范围内的内容
需求: linux下对文件按照行数进行切割 实现: sed -n '10,100p' logfile.txt > lognew.txt 摘自: http://www.xhuojia.com/zhuanlan/1891238847.html
2018-08-29 16:56 · Linux · 评论(0)
Java中的非对称加密算法RSA实现
需求: 实现RSA非对称加密算法 实现: public static class RSACoder { public static final String KEY_ALGORITHM = "RSA"; private static final int KEY_SIZE = 512; private static final String PUBLIC_KEY = "RSAPublicKey"; private static final String PRIVATE_KEY = "RSAPrivateKey"; public static Map<String, Object> initKe…
2018-08-01 11:14 · Java · 评论(0)
apache common包的configuration2使用
需求: 利用apache的common包中的configuration2进行属性文件的操作 实现: public static PropertiesConfiguration loadProperties(File file) throws ConfigurationException { Parameters params = new Parameters(); PropertiesConfiguration configuration = new FileBasedConfigurationBuilder<PropertiesConfiguration>( PropertiesConfi…
2018-08-01 11:13 · Java · 评论(0)
Java标准库提取URL的域名
需求: 基于Java的标准库提取URL对应的域名并拼接成basePath 实现: public static String extactBasePath(String line) { try { java.net.URL url = new java.net.URL(line); StringBuilder sb = new StringBuilder(); return sb.append(url.getProtocol()).append("://").append(url.getHost()) .toString(); } catch (MalformedURLException e)…
2018-08-01 11:12 · Java · 评论(0)
shell之命令行参数传递
需求: shell脚本的命令行传递赋值与参数问题 实现: echo "Shell 传递参数实例!"; echo "执行的文件名:$0"; echo "第一个参数为:$1"; echo "第二个参数为:$2"; echo "第三个参数为:$3"; 执行 ./test.sh www.someabcd.com www.xhuojia.com 输出: ./test www.someabcd.com www.xhuojia.com 摘自: http://www.xhuojia.com/zhuanlan/1043056773.html
2018-07-30 15:17 · Linux · 评论(0)
shell读取文件内容并进行变量赋值
需求: shell读取文件内容,然后把内容赋值给变量然后进行字符串处理 实现: dataline=$(cat /root/data/data.txt) echo $dataline 摘自: http://xhuojia.com/zhuanlan/1832921069.html
2018-07-30 15:08 · Linux · 评论(0)
mysql查询某表索引
查询某表所有索引列 mysql> show index from tablename; mysql> show keys from tablename; 其他说明: Index_type: (BTREE, FULLTEXT, HASH, RTREE) 默认为BTREE 摘自: http://www.xhuojia.com/zhuanlan/1113302892.html
2018-07-19 16:45 · 其他 · 评论(0)
linux系统下查看nginx配置文件路径
需求: 有时候需要查看nginx的配置文件路径 实现: 直接nginx -t即可 如果nginx没有在path中的话那么需要进入安装目录执行 sbin/nginx -t 摘自: http://www.someabcd.com/java/1636077204.html
2018-07-19 11:20 · 其他 · 评论(0)
class.getResources("/")报空指针
需求: 获取class所在的目录的时候通过Test.class.getResources("/");报空指针 分析: linux下没有任何问题,不以/开头的比如window文件系统,那么就会报空指针 解决方式: Test.class.getResources("."); Test.class.getResources(""); Test.class.getResources("class所在的路径下某一个文件"); 摘自: http://www.someabcd.com/java/822831497.html
2018-07-19 11:18 · 其他 · 评论(0)
freemarker模板中long类型的逗号问题
背景: 在用freemarker做模板的时候碰到了long类型对数字做了格式化,用逗号分隔,id的时候容易出问题 解决方案: 模板文件中直接tostring输出: ${num.toString()} 在模板中直接加<#setting number_format="#"> 使用?c控制,如 ${num?c} 一次性java文件中解决通过freemarker.template.Configuration的config.setNumberFormat("#")来设定freemarker对数值的格式化 摘自: http://www.someabcd.com/java/862667751.html
2018-06-12 14:55 · J2ee · 评论(0)
linux之shell遍历目录下所有文件
有时候需要写脚本批量处理数据对某目录进行遍历通知执行相关操作 for file in 03/* do if test -f $file then echo $file fi if test -d $file then echo $file fi done
2018-05-19 13:02 · Linux · 评论(0)
Mysql之Incorrect string value: '\xF0\x9F\x98\x89 \xE6...'
错误信息如下: Incorrect string value: '\xF0\x9F\x98\x89 \xE6...' 问题产生的原因是字符串不兼容4字节的unicode导致的,一般我们常见的表情编码等 解决方案: 1.数据库支持,配置文件是my.cnf [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-se…
2018-05-18 13:44 · DB · 评论(1)