//参数bytes是文件大小字节数(整数) 参数precision是小数点后面的位数 function readableFileFize(bytes, precision) { if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; if (bytes <= 0) { return '0'; } if (typeof precision === 'undefined') precision = 1; var units = ['B', 'KB…

2021-01-09 0条评论 1044点热度 0人点赞 admin 阅读全文

编写Linux脚本的时候,有时需要等待用户输入变量,然后根据变量不同来执行接下来的操作, 举例如下: #!/bin/sh echo -n "Enter file name and press [ENTER]: " read file_name echo "file name is: $file_name" if [ -z "$file_name" ]; then echo 'empty file name, exit' else #执行接下来的操作 #... fi  

2021-01-09 0条评论 1054点热度 0人点赞 admin 阅读全文

我们可以通过设定iptables防火墙来做到让特定的IP访问网站,但是有时候需要网站可以全部访问,但是只针对某个页面(比如管理页面)只运行特定IP访问,这个时候可以用nginx来设置 假设需要让/admin只允许202.202.xxx.0-255来访问,而且如果不允许的IP访问,会显示404,以为是网页不存在,nginx如下设定即可 server { #省略部分配置 #这样做,让403 forbiden 也显示成404,外面访问的人以为 page 不存在 error_page 403 404 /404.html; …

2021-01-08 0条评论 827点热度 0人点赞 admin 阅读全文

比如执行SUM的时候,如果没有数据,有时候会返回NULL,但我们有时候希望返回0,可以简化程序的判断 NVL(Expr1,Expr2) --如果Expr1为NULL,返回Expr2的值,否则返回Expr1的值 select NVL(SUM(MONEY) ,0) from TEST_TABLE select COALESCE(sum(momeny),0) as sm from test_table ...    

2021-01-07 0条评论 784点热度 0人点赞 admin 阅读全文

需求: 根据某个主键查询,如果存在某条记录,就更新这条记录,否则新增一条记录 假设student表,结构如下 +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | id | int | NO | PRI | NULL | | …

2021-01-06 0条评论 757点热度 0人点赞 admin 阅读全文

先准备好工具类: package com.terrynow.test.imagecompare; import java.awt.image.BufferedImage; public class HistogramFilter { private int redBins; private int greenBins; private int blueBins; public HistogramFilter() { redBins = greenBins = blueBins = 4; } public void …

2021-01-05 0条评论 950点热度 0人点赞 admin 阅读全文

首先看下怎么在JSP里使用: JSP头部增加: <% request.setAttribute("call", new Call()); %> 需要调用的静态方法,如Utils.java package com.terrynow.test.utils public class Utils { public static String testMethod(String args, String arg2) { //省略 return "xxxx" } } JSP的代码里这样调用: <%-- 带参数…

2021-01-04 0条评论 1229点热度 0人点赞 admin 阅读全文

#Ubuntu cat /etc/lsb-release #CentOS cat /etc/redhat-release #or lsb_release -a uptime top #内存(按MB) free -m #内存(按GB) free -g #硬盘 df -h netstat -ant #查看谁在使用端口8080 lsof -i:8080 hostname #CentOS hostnamectl status date  

2021-01-03 0条评论 857点热度 0人点赞 admin 阅读全文

#查看CPU信息 cat /proc/cpuinfo #查看CPU统计信息 lscpu #归纳 cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c #输出如下(看到有8个逻辑CPU, 也知道了CPU型号) 8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz #详细的 cat /proc/meminfo #简单的 free #内存单位是MB free -m #内存单位是GB free -g #查看内存硬件信息 dmidecode -t …

2021-01-02 0条评论 1733点热度 0人点赞 admin 阅读全文

有时候网站维护可能需要一段时间,为了给用户看到一个比较友好的提示,可以在nginx上配置公告页面,用户访问的所有页面都定向到这个页面。 server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; #以下放到nginx的config中,然后注释掉原来location中的/的部分, #维护好了以后,maintain.html redirect到/ #rewrite…

2021-01-01 1条评论 1410点热度 1人点赞 admin 阅读全文