前端发展很快,现代浏览器原生 API 已经足够好用。我们并不需要为了操作 DOM、Event 等再学习一下 jQuery 的 API。同时由于 React、Angular、Vue 等框架的流行,直接操作 DOM 不再是好的模式,jQuery 使用场景大大减少。本项目总结了大部分 jQuery API 替代的方法,并结合具体的例子说明。
这是一个关于Wordpress完整的Nginx配置例子,配置有url rewrite 。
基本配置
server {
listen 80;
server_name www.hooyes.net;
#include restrictions.conf;
location / {
# 简单地址重写
#if (!-e $request_filename) {
# rewrite (.*) /index.php;
#}
# 完整地址重写
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
root /wwwroot/wordpress/;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /wwwroot/wordpress/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
目录安全配置 restrictions.conf
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# 禁止访问所有的隐藏文件例如 .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
}
# 禁止访问uploads目录中的任何php文件
location ~ ^/wp-content/uploads/.*\.php$ {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
例如我们有一个20以内的质数{2,3,5,7,11,13,17,19}的乱序数组,我们使用Java冒泡法排序。
public class Main {
public static void main(String[] args) {
int[] a = {2,3,19,5,11,7,13,17 };
int j = 0;
while(j<a.length) {
for(int i=0;i<a.length-j-1;i++) {
/* Hooyes 注
升序 a[i]>a[i+1]
降序 a[i]<a[i+1]
*/
if(a[i]>a[i+1]) {
int t = a[i];
a[i]= a[i+1];
a[i+1]= t;
}
}
j++;
}
// 打印排序后的数组
for(int s:a) {
System.out.print(s+" ");
}
}
}
可能会有人疑惑为什么不用 Arrays.sort() ,我说别捣乱啊,这篇文章是研究冒泡排序法的原理,而不教你使用一个封装好的方法,哈。