DecimalFormat

DecimalFormat 我们经常要将数字进行格式化,比如取2位小数,这是最常见的。Java 提供 DecimalFormat类,帮你用最快的速度将数字格式化为你需要的样子。下面是一个例子: importjava.text.DecimalFormat; publicclassTestNumberFormat{ publicstaticvoidmain(String[]args){ doublepi=3.1415927;//圆周率 //取一位整数 System.out.println(newDecimalFormat(“0”).format(pi));//3 //取一位整数和两位小数 System.out.println(newDecimalFormat(“0.00”).format(pi));//3.14 //取两位整数和三位小数,整数不足部分以0填补。 System.out.println(new DecimalFormat(“00.000”).format(pi));// 03.142 //取所有整数部分 System.out.println(newDecimalFormat("#").format(pi));//3 //以百分比方式计数,并取两位小数 System.out.println(new DecimalFormat("#.##%").format(pi));//314.16% longc=299792458;//光速 //显示为科学计数法,并取五位小数 System.out.println(newDecimalFormat("#.#####E0").format(c));//2.99792E8 //显示为两位整数的科学计数法,并取四位小数 System.out.println(newDecimalFormat(“00.####E0”).format(c));//29.9792E7 //每三位以逗号进行分隔。 System.out.println(newDecimalFormat(",###").format(c));//299,792,458 //将格式嵌入文本 System.out.println(newDecimalFormat(“光速大小为每秒,###米。”).format(c)); } } DecimalFormat 类主要靠 # 和 0 两种占位符号来指定数字长度。0 表示如果位数不足则以 0 填充,# 表示只要有可能就把数字拉上这个位置。上面的例子包含了差不多所有的基本用法,如果你想了解更多,请参考 DecimalFormat 类的文档。 https://blog.csdn.net/wangchangshuai0010/article/details/8577982

2019-03-18 · 1 min · 45 words · -

霍桑效应

霍桑效应 20 年代时,在芝加哥郊外一个名为"霍桑"的工厂里,研究人员在研究照明条件对工人绩效表现的影响。研究人员最初认为,随着工厂照明条件的改善,工人的生产率应当会随之提升。但事实却并非如此,研究人员后来才发现,工人绩效的提升是因为他们感觉受到了公司的关注,从而增强了工作动机,这就是"霍桑效应"的产生。 https://www.infoq.cn/article/gU*236UQhE5FYgDsYXoB?utm_source=rss&utm_medium=article

2019-03-18 · 1 min · 4 words · -

ansible 管理工作站配置, linux初始化

‘ansible 管理工作站配置, linux初始化’ # archlinux 直接从仓库里安装就是最新版本 sudo pacman -S git ansible ubuntu,debian ubuntu 默认 apt 安装的ansible版本可能是旧版本, 建议参照ansible官网文档安装新版本的ansible https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#latest-releases-via-apt-debian Add the following line to /etc/apt/sources.list: deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main Then run these commands: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 sudo apt-get update sudo apt-get install ansible 编写ansible 脚本 vim local.yml - hosts: localhost become: true tasks: - name: Install htop apt: name=htop 提交到 github git add local.yml git commit -m "initial commit" git push origin master 执行脚本 ansible-pull模式 sudo ansible-pull -U https://github.com/wiloon/ansible.git 本地执行 ansible-playbook ansible/local.yml --extra-vars "user_name=wiloonwy" https://linux.cn/article-10434-1.html

2019-03-16 · 1 min · 88 words · -

SSL 故障分析

SSL 故障分析 openssl s_client -connect host0:port0 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' openssl verify foo.pem openssl s_client -connect host0:port0 -state -showcerts 解码根证书 openssl x509 -text -in roch.pem https://www.ibm.com/developerworks/cn/linux/l-cn-sclient/index.html

2019-03-15 · 1 min · 29 words · -

clonezill

clonezill download clonezill iso from https://clonezilla.org/downloads.php install balenaEtcher dd bs=1M conv=fdatasync if=./clonezilla-live-3.2.0-5-amd64.iso of=/dev/sdx start clonezilla device-image nfs_server dhcp nfs4 192.168.50.227 /backup_xxxx/ beginner save parts clonezill https://clonezilla.org/ https://clonezilla.org/liveusb.php#macos-setup Download the Clonezilla Live iso file. Insert a USB flash drive on the Mac machine. Erase it using the standard Mac Disk Utility (exFAT works fine). Download balenaEtcher for macOS, then follow its document to burn the image to the USB flash drive. Eject the USB drive. Thanks to Hans Palm for providing this info. ...

2019-03-15 · 1 min · 141 words · -

diffie-hellman

diffie-hellman openssl dhparam -out dhparam.pem 2048 # 如果你的机器性能足够强大,可以用 4096 位加密

2019-03-15 · 1 min · 10 words · -

idea 快捷键, keymap

idea 快捷键, keymap alt + shift + up, move line up Key Command ctrl+g line/column ctrl+t Class… ctrl+] move caret to code block end ctrl+alt=b Go to Implementation(s), 接口的实现类

2019-03-12 · 1 min · 29 words · -

无障碍设计规范,GB50763—2012

无障碍设计规范,GB50763—2012 2012年9月1日,住房和城乡建设部、国家质检总局联合发布的修订后的《无障碍设计规范》 (GB50763-2012) 国家标准正式实施。 为配合国家《无障碍环境建设条例》的制定、贯彻实施,切实为我国无障碍环境建设提供技术支持,使无障碍建设更适应我国经济社会发展和广大残疾人、老年人等社会成员的需求,2009年开始,住房和城乡建设部、中国残联等部门组织相关单位、专家启动了对2001年实施的《城市道路和建筑物无障碍设计规范》的修订工作。规范修订是在广泛深入调查研究,认真总结我国近年来无障碍建设的实践经验,研究分析无障碍建设的现状和发展,参考有关国际标准和国外先进技术,并在广泛征求全国有关单位的意见基础上,反复讨论、修改和完善形成的。与2001年实施的《城市道路和建筑物无障碍设计规范》相比,规范由行业标准上升为国家标准,提高了规范执行强制力;名称改为《无障碍设计规范》,增加了农村地区道路、公共服务设施无障碍设计的要求;增加了城市绿地、历史文物、加油加气站、高速公路服务区、信息无障碍等无障碍建设和改造内容;扩大了建筑类型以及无障碍设施的类型;对坡道扶手设置、缘石坡道起始处与地面高差等细节部分进行了调整,使无障碍设计更加人性化。 《无障碍设计规范》的实施,对于进一步规范我国无障碍建设,特别是配合《无障碍环境建设条例》实施,加快我国无障碍建设发展,切实保障残疾人、老年人等社会成员参与社会生活权益具有重要意义。 来源:中国残联维权部 http://www.cdpf.org.cn/special/wzajstl/xcgcdt/201209/t20120913_267583.html

2019-03-09 · 1 min · 8 words · -

MySQL dml

MySQL dml DML iNSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ); https://blog.51cto.com/lustlost/1224775

2019-03-08 · 1 min · 16 words · -

google authenticator databases

google authenticator databases https://eduncan911.com/technology/hardware/google-authenticator-databases-move-copy-fix.html /data/data/com.google.android.apps.authenticator2/databases/databases

2019-03-06 · 1 min · 5 words · -

google domain, invalid City

google domain, invalid City 填写联系人资料的时候国家选择中国,填写城市 的时候要写成 Dalian Shi Google Domain 填写出错 http://www.flaskfox.com/2015/11/16/google-domain-%e5%a1%ab%e5%86%99%e5%87%ba%e9%94%99/embed/#?secret=2UAujlnd36

2019-03-04 · 1 min · 12 words · -

java data convert

java data convert NumberFormat formatter = new DecimalFormat("#0.00"); System.out.println(formatter.format(4.0));

2019-03-01 · 1 min · 9 words · -

intellij idea 配置 git ssh key

intellij idea 配置git ssh key 把私钥放入目录 C:\Users\user0\.ssh, 私钥不需要转换成 ppk 格式. https://blog.csdn.net/u010348570/article/details/81204371 1 安装git,登录官网https://www.git-scm.com/download/ ,选择相应系统版本,下载后安装好。 公司网慢的可以用第三方的软件管家下载。 2 打开git bash,不需要进入任何目录,直接输入 ssh-keygen -t rsa -C ‘xxx@xxx.com’,‘xxx@xxx.com’为gitlab上的登录账户。一路回车。 3 打开生成的密钥文件,目录为当前系统登录者的用户目录 4 将id_rsa.pub文件里面的内容拷贝,登录公司gitlab服务器,找到ssh key配置位置Settings。有的在左侧目录处,有的则需要在自己头像的位置单击。 5 点击SSH Keys ,将上一步拷贝的内容拷贝到key下的方框中。Title可以填写一个自己的标识。 6 打开intellij idea , File -> Settings,输入git,配置下git.exe 7 选择 VCS -> Checkout from Version Control -> Git,将gitlab上面项目的ssh路径复制,点击Test,提示Connection successful,后面一路点击next即可 作者: 叫我放猪之人 来源: CSDN 原文: https://blog.csdn.net/u010348570/article/details/81204371 版权声明: 本文为博主原创文章,转载请附上博文链接!

2019-02-27 · 1 min · 58 words · -

archlinux ip forward, ip_forward

archlinux ip forward, ip_forward 开启数据包转发 vim /etc/sysctl.d/30-ipforward.conf net.ipv4.ip_forward=1 net.ipv6.conf.default.forwarding=1 net.ipv6.conf.all.forwarding=1 sysctl -a |grep net.ipv4.ip_forward 配置 nftables 的转发规则 nftables 默认在 forward 链抛掉所有数据。 如果启用了 nftables, 一定修改一下 nftables 的默认配置文件。否则报文在 iptables 的 forward 链 accept 之 后会被 nftables 规则抛掉。 https://wiki.archlinux.org/index.php/Internet_sharing ip_forward 与路由转发 https://blog.51cto.com/u156838989/1880744

2019-02-24 · 1 min · 39 words · -

diff command

diff command diff 的三种格式 正常格式 上下文格式 合并格式 git 格式 Git’s diff is a variant of unified diff, so unified diff is preferred. # unified diff diff -u foo bar diff 是 Unix 系统的一个很重要的工具程序。它用来比较两个文本文件的差异,是代码版本管理的基石之一。 diff 的三种格式 正常格式(normal diff) 上下文格式(context diff) 合并格式(unified diff) 命令格式 diff [参数] [文件1或目录1] [文件2或目录2] diff -B -b -r --exclude="*.vscode" --exclude="*.svn" /etc/nginx/ /etc/foo-nginx/ diff -r \ --exclude="*~" \ --exclude=".svn" \ --exclude=".git" \ --exclude="*.zip*" \ --exclude="*.gz" \ --exclude="*.tar" \ # -B 或--ignore-blank-lines 不检查空白行。 # -b 或--ignore-space-change 不检查空格字符的不同。 # -r 递归比较子目录中的文件 # -x 或--exclude 不比较选项中所指定的文件或目录。 # -w 或--ignore-all-space 忽略全部的空格字符。 # -q 或--brief 仅显示有无差异,不显示详细的信息。 # -a 将所有的比对文件都当作文本文件处理 比较两个文件 diff foo.log bar.log 3c3 < 2014-03 --- > 2013-03 8c8 < 2013-07 --- > 2013-08 11,12d10 < 2013-11 < 2013-12 说明 3c3 用来说明变动位置, 分为三个部分, 第一个数字表示 foo.log 的第 3 行有变化, 中间的 c 表示变动模式是内容改变 (change), 后面的 3 表示 变动后变成 bar.log 文件的第3行. < 2014-03, 分为两个部分, 前面的小于号表示 foo.log 比 bar.log 少了这一行, 2014-03 是该行的内容 — 分隔线, 用于分隔 foo.log bar.log 2013-03, 大于号表示 bar.log 增加了这行 ...

2019-02-22 · 3 min · 437 words · -

redis config redis 配置

redis config redis 配置 sample, 单机 redis server 配置 bind 0.0.0.0 protected-mode no port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize no pidfile /var/run/redis_6379.pid loglevel notice logfile "" databases 16 always-show-logo no set-proc-title yes proc-title-template "{title} {listen-addr} {server-mode}" stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb rdb-del-sync-files no dir /var/lib/redis replica-serve-stale-data yes replica-read-only yes repl-diskless-sync yes repl-diskless-sync-delay 5 repl-diskless-sync-max-replicas 0 repl-diskless-load disabled repl-disable-tcp-nodelay no replica-priority 100 acllog-max-len 128 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no lazyfree-lazy-user-del no lazyfree-lazy-user-flush no oom-score-adj no oom-score-adj-values 0 200 800 disable-thp yes appendonly no appendfilename "appendonly.aof" appenddirname "appendonlydir" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes aof-use-rdb-preamble yes aof-timestamp-enabled no slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-listpack-entries 512 hash-max-listpack-value 64 list-max-listpack-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-listpack-entries 128 zset-max-listpack-value 64 hll-sparse-max-bytes 3000 stream-node-max-bytes 4096 stream-node-max-entries 100 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit replica 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 dynamic-hz yes aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes https://raw.githubusercontent.com/redis/redis/6.0/redis.conf ...

2019-02-22 · 7 min · 1353 words · -

kde config, kde 配置

kde config, kde 配置 显示器亮度问题 通过 dbus 设置亮度 dbus-send --session --print-reply \ --dest=org.kde.Solid.PowerManagement \ /org/kde/Solid/PowerManagement/Actions/BrightnessControl \ org.kde.Solid.PowerManagement.Actions.BrightnessControl.setBrightness \ int32:6000 kde idea 图标消失 Open folder /home/USERNAME/.local/share/applications/ Find jetbrains-idea.desktop Right mouse click on it, then select Properties Open Application tab Next to the Command section click Browse… button and select idea.sh file in /pathToIntelliJ/bin folder. (In my case the path was already correct, but it seems that selection the file again rewrite something and Icon works ok now). ...

2019-02-20 · 1 min · 79 words · -

idea install

idea install default plugins build tool ant - disable maven gradle version control cvs - disable mercurial - disable git subversion github test tools junit testng-j - disable swing - disable android - disable othre tools plugin development - disable

2019-02-20 · 1 min · 40 words · -

android basic

android basic

2019-02-19 · 1 min · 2 words · -

grafana

grafana docker pull grafana/grafana:12.0.2 docker run -d --name=grafana -e "GF_SECURITY_ADMIN_PASSWORD=password0" -p 3000:3000 -v grafana-storage:/var/lib/grafana -v /etc/localtime:/etc/localtime:ro grafana/grafana:12.0.2 # podman podman run \ -d \ --name=grafana \ -e "GF_SERVER_ROOT_URL=http://grafana.wiloon.com" \ -e "GF_SECURITY_ADMIN_PASSWORD=password0" \ -p 3100:3000 \ -v grafana-storage:/var/lib/grafana \ -v /etc/localtime:/etc/localtime:ro \ grafana/grafana:8.5.6 # in pod podman run \ -d \ --name=grafana \ -e "GF_SERVER_ROOT_URL=http://grafana.wiloon.com" \ -e "GF_SECURITY_ADMIN_PASSWORD=password0" \ --pod monitor \ -v grafana-storage:/var/lib/grafana \ -v /etc/localtime:/etc/localtime:ro \ grafana/grafana variable for host SHOW TAG VALUES ON "telegraf" FROM "system" WITH KEY = "host" Q. How do I use the second y axis, secondYAxis function does not work ...

2019-02-17 · 3 min · 427 words · -