首页 文章 精选 留言 我的

精选列表

搜索[TDSQL-C PostgreSQL 版],共10000篇文章
优秀的个人博客,低调大师

巧解决阿里云虚拟主机免费版被DDOS攻击问题

相信很多站长都有遇到收到阿里云主机攻击断网通知邮件的经历,原因是网站所在的虚拟主机被DDOS攻击,影响了同机房其它服务器的正常运行,万网为了降低因攻击给服务器及同机房用户造成的安全风险,对您被攻击主机进行了关停处理。如果攻击行为停止,4小时后网站会自动开通。 遇到这种情况,一般来说很多服务商给出2种解决方案: 1、升级到ECS服务器,避免攻击牵连。 2、购买昂贵的高防ip与攻击者死扛。 这两种方案固然都不错,可以彻底解决攻击问题,但付出的代价也太高了:ECS云服务器,即便通过万维景盛这样的阿里云分销商折上折优惠,像样的配置也得上千元;再说说高防ip,原价高达16800元/月,优惠价也有142800元,这都不是一般个人和企业能够承受的。那么,有没有更实惠的办法来解决这个问题呢? 答案是有的。 以下方法对于易受牵连被攻击且不需要总是上传更新网站内容的用户适用,那就是通过万维景盛等阿里云代理商多购买几个6元阿里云虚拟主机,将相同的内容上传到所有主机,当一个主机被攻击断网时,只需要将域名解析到另外一个主机ip即可立即恢复网站访问。这种方法简单易用,成本也不高。如果你的主机已经被攻击,进不了ftp,可以联系万维景盛客服帮你解决。

优秀的个人博客,低调大师

网易云音乐数据交互—async&await实现版(完结篇)

我们的网易云音乐系列课,尾声了,今天我们要将一个最重要的东西--关于ES7 async结合Fetch异步编程问题。 ES7 async/await被称作异步编程的终极解决方案,我们先不管这个称呼,咱们先总结一下,过去5次分享我们一路走来异步编程是如何产生,到最后如何解决的。 第一次分享我们学会了切图和动态计算响应式rem布局,第二次分享我们体会了如何学习使用原生js进行学习轮播图,第三次分享了H5 audio这块,进而引出了第四次的异步请求歌词ajax和第五次的Fetch+promise解决方案。 但是每一种方案都不完美,我们通过代码来说明。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script> var a = 12; //模拟数据交互需要等1秒钟 function loadData() { setTimeout(function () { a = 666; }, 1000) } loadData(); console.log(a); </script> </head> <body> </body> </html> 不用想,这个结果就是 12 而不是666,因为程序不会等1s才往下执行,但是有时候又必须使用数据,所以只能嵌套。但是嵌套多了又会出现下面的问题,案例来自SF的朋友,特此感谢。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script> setTimeout(function () { console.log("第一个异步回调了!") setTimeout(function () { console.log("第二个异步回调了!") setTimeout(function () { console.log("第三个异步回调了!") setTimeout(function () { console.log("第四个异步回调了!") setTimeout(function () { console.log("第五个异步回调了!") }, 1000); }, 1000); }, 1000); }, 1000); }, 1000); </script> </head> <body> </body> </html> 我特意写了一个程序,这下大家就能体会他的缺陷。 那我们怎么解决呢? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script> function timeout(ms) { return new Promise((resolve, reject) => { setTimeout(resolve, ms, "finish"); }); } timeout(2000) .then(value => { console.log("第一层" + value); return timeout(2000); }) .then(value => { console.log("第二层" + value); return timeout(2000); }) .then(value => { console.log("第三层" + value); return timeout(2000); }) .then(value => { console.log("第四层" + value); return timeout(2000); }) .then(value => { console.log("第五层" + value); return timeout(2000); }) .catch(err => { console.log(err); }); </script> </head> <body> </body> </html> Promise改成了链式,但是不够完美,重点来了,今天的知识如何使用ES7 的async和await 让我们跟我们写日常普通代码一样写异步代码呢? 大家发现了吧,这样写是不是正确并且简单了啊,仅仅是加了两个单词而已,完整代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script> function timeout(ms) { return new Promise((resolve, reject) => { setTimeout(resolve, ms, "finish"); }); } async function asyncTimeSys() { await timeout(1000); console.log("第一层异步结束!") await timeout(1000); console.log("第二层异步结束!") await timeout(1000); console.log("第三层异步结束!") await timeout(1000); console.log("第四层异步结束!") await timeout(1000); console.log("第五层异步结束!") return "all finish"; } asyncTimeSys().then((value) => { console.log(value); }); </script> </head> <body> </body> </html> 好,我们不整没用的我们看看实际项目里面怎么搞的,还是拿网易云举例: ok,感觉天都亮了。 简单吧,通过这个系列课程的学习大家已经完整的了解了一个项目的大体开发过程,同时也了解了一些容易出错的方方面面,重点是涵盖了ES6和ES7的新知识。 当然,完全靠我讲大家体会不深,还是希望大家能够真的自己认真练习,把这个项目做出来,而不是变成听听而已。 本系列教程就到这,欢迎有问题想交流的同学,或者有专门技能提升需求的同学,到留言区里互相交流。·END·

优秀的个人博客,低调大师

JDK 11 进入 Rampdown 第二阶段,正式版已在路上

之前我们曾报道过 JDK 11 已于6月底进入 Rampdown Phase One 阶段,当时 JDK 11 的所有新特性就已被冻结,不再加入新的 JEP 。 就在前两天,JDK 11 进入 Rampdown Phase Two 。之前的第一阶段持续一个月,主要修复 P1-P3 级错误;进入第二阶段后,将主要修复 P1-P2 级错误,并遵循 JEP 3 进行改进: RDP 1 candidate bugs RDP 2 candidate bugs Bug-Deferral Process Late-Enhancement Request Process 随着时间的临近,再有两个预览版本,JDK 11 就将迎来正式版本。 JDK 11 总共包含 17 个新的 JEP ,分别为: 181:Nest-Based Access Control(基于嵌套的访问控制) 309:Dynamic Class-File Constants(动态类文件常量) 315:Improve Aarch64 Intrinsics(改进Aarch64 Intrinsics) 318:Epsilon: A No-Op Garbage Collector(Epsilon — 一个无操作的垃圾收集器) 320:Remove the Java EE and CORBA Modules(删除 Java EE 和 CORBA 模块) 321:HTTP Client (Standard) 323:Local-Variable Syntax for Lambda Parameters(用于 Lambda 参数的局部变量语法) 324:Key Agreement with Curve25519 and Curve448(Curve25519和Curve448算法的密钥协议) 327:Unicode 10 328:Flight Recorder 329:ChaCha20 and Poly1305 Cryptographic Algorithms(ChaCha20 和 Poly1305 加密算法) 330:Launch Single-File Source-Code Programs(启动单一文件的源代码程序) 331:Low-Overhead Heap Profiling(低开销的Heap Profiling) 332:Transport Layer Security (TLS) 1.3(支持 TLS 1.3) 333:ZGC: A Scalable Low-Latency Garbage Collector(Experimental)(可伸缩低延迟垃圾收集器) 335:Deprecate the Nashorn JavaScript Engine(弃用 Nashorn JavaScript 引擎) 336:Deprecate the Pack200 Tools and API(弃用 Pack200 工具和 API)

优秀的个人博客,低调大师

leetcode算法题解(Java版)-5-简单模拟,字符串处理

一、简单贪心 题目描述 Given n non-negative integers a1 , a2 , ..., an , where each represents a point at coordinate (i, ai ). n vertical lines are drawn such that the two endpoints of line i is at (i, ai ) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You may not slant the container. 思路 这题在一分钟内就想了个笨方法,迅速敲完,KO! 因为题目还是很简单,不考虑将装水的容器倾斜,所以只要考虑梯形中最短的边和底边的乘积就行了:正反两遍循环数组,第一遍从0~len,先固定最左边的边,从右往左遍历数组,如果碰到大于等于最左边边长的边,那就判断是否大于当前的最大盛水体积并跟新,然后就停止这次循环,将最左边的边向右移动一格,重复操作;第二遍从len~0,和第一遍一样。 代码 public class Solution { public int maxArea(int[] height) { int len=height.length; if(len==0){ return 0; } int maxW=0; for(int i=0;i<len;i++){ for(int j=len-1;j>i;j--){ if(height[j]>=height[i]){ if(height[i]*(j-i)>maxW){ maxW=height[i]*(j-i); } break; } } } for(int i=len-1;i>0;i--){ for(int j=0;j<i;j++){ if(height[j]>=height[i]){ if(height[i]*(i-j)>maxW){ maxW=height[i]*(i-j); } break; } } } return maxW; } } 思路2 好吧,虚心学习,看了一下其他人的代码。发现一个好方法: 从两边往中间走,每次舍弃较短的边,因为宽度减小,要通过高度的增加来弥补 代码 public class Solution { public int maxArea(int[] height) { int len=height.length; if(len==0){ return 0; } int l=0; int r=len-1; int maxW=0; while(l<r){ maxW=Math.max(maxW,Math.min(height[l],height[r])*(r-l)); if(height[l]<height[r]){ l++; } else{ r--; } } return maxW; } } 二、简单回文数字 题目描述 Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers.Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that the reversed integer might overflow. How would you handle such case? There is a more generic way of solving this problem. 思路 题目有个限制,就是不能开辟新的空间。 那就和一般的回文串做法不同了,可以这么来搞:干脆求出它翻转过来的整型,最后比较是否值相等。 想到这个思路,是因为int型的特殊基本数据类型,特别对待,哈哈哈 代码 public class Solution { public boolean isPalindrome(int x) { if(x<0){ return false; } int reverse=0; int x_rel=x; while(x!=0){ reverse=reverse*10+x%10; x/=10; } return reverse==x_rel; } } 三、字符串,模拟 题目描述Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front. spoilers alert... click to show requirements for atoi.Requirements for atoi: The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned. 思路 细节要求比较多,正负号,非法字符,溢出等都要考虑。 代码 public class Solution { public int atoi(String str) { if(str==null||str.length()==0){ return 0; } int pos=0; while(str.charAt(pos)==' '){ pos++; } int flag=1; if(str.charAt(pos)=='-'){ flag=-1; pos++; } if(str.charAt(pos)=='+'){ flag=1; pos++; } int len=str.length(); int res=0; for(int i=pos;i<len;i++){ char c=str.charAt(i); if(c<'0'||c>'9'){ break; } if(res>Integer.MAX_VALUE/10||(res==Integer.MAX_VALUE/10&&c>'7')){ if(flag>0){ return Integer.MAX_VALUE; } else{ return Integer.MIN_VALUE; } } res=res*10+(c-'0'); } return res*flag; } }

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码