首页 文章 精选 留言 我的

精选列表

搜索[es 2],共10000篇文章
优秀的个人博客,低调大师

《大前端开发》培训2周小结

经过两周的培训,以及大家的努力,每个人的成长都非常的快。零基础的同学也已开始对HTML、CSS以及JavaScript有了比较形象的认识,开始建立起了编程思维,可以开始独自编写页面代码了。 这两周的课程进度比我原先预计的要快得多,我也在不断的对课程的结构做了一些优化调整。原先打算将前端和后端的内容先独立分开来讲的,但是在讲课的过程中,发现穿插在一起讲能更好的让同学们理解前端和后端的异同和各自的职责,以及相互间的关系等,可以更好的建立软件开发的大局观,从更高的角度来认识编程。然后,尽量让同学们在了解某个具体技术知识点的同时,也让他们了解这些技术在整个软件开发和部署的体系中所处的角色和位置。 这段时间里,我们从HTML、CSS、JavaScript的基础讲起,尤其以JavaScript作为核心课程,反复循环讲解和练习JavaScript的知识点,把最重要的东西完全搞明白,力图做到: 不要写一行你自己都没理解的代码 除了这些基础知识,我们也开始引入介绍一些以后需要用到的内容,比如:Nginx、MongoDB的基本用法,微信小程序和网页应用开发的技术关联性,HTTP协议中几个重要方法(GET,POST,PUT,DELETE)的基本概念,Cookie、Request、Response、Session的概念,以及如Express/Koa/Egg框架的中间件机制的概念和原理等等。我也不指望大家在学习短短两周的时候内就掌握这些东西,而是慢慢将这些概念引入课程中来,经过一段时间的耳濡目染,到真正学习这些内容的时候,不至于太陌生。 在讲解基础知识的同时,我们也非常注重将这些基础知识通过做一些实际的demo程序来进行联系和巩固,下面这些是我们最近的实训例子:一个计算器程序,一个模拟打地鼠游戏,另外一个是参考“芝麻信用”的页面自己写一个页面出来。 计算器 打地鼠 模拟芝麻信用页面 通过开发这些demo程序,同学们对HTML和CSS在搭建界面方面的使用,以及使用DOM事件进行对用户交互的处理,都有了一个更加形象的认识。 在讲课的过程中,我觉得自己也得到了非常大的成长,比如当同学们遇到比较难理解的知识点,我会想方设法、不断的组织自己的语言、编制各种容易理解的例子,让自己能将它们解释清楚;以及在课程内容上,我会不断的去思考如何将前一天课和后一天课的内容更好的衔接起来;另外,在实时问答、实时编写代码解答问题方面,我也慢慢的更加得心应手了。 总之,这次的培训对我和参与的同学们来说应该都是挺有收获的。我们的课程还将继续下去,我们也将继续成长。

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

Tomcat架构解析之2 connector BIO

在上文已介绍过,connector组件是service容器中的一部分。 它主要是接收,解析HTTP请求,然后调用本service下的相关Servlet Tomcat从架构上采用的是一个分层结构,因此根据解析过的HTTP请求,定位到相应的Servlet也是一个相对比较复杂的过程 整个Connector实现了从接收 Socket到调用 Servlet的全部过程 先看 Connector的执行逻辑 接收socket 从socket获取数据包,并解析成HttpServletRequest对象 从engine容器开始走调用流程,经过各层valve,最后调用Servlet完成业务逻辑 返回response,关闭socket 可看出,整个Connector组件是Tomcat运行主干,之前介绍的各个模块都是Tomcat启动时,静态创建好的,通过Connector将这些模块串起 网络吞吐一直是整个服务的瓶颈所在,Connector的运行效率在一定程度上影响了Tomcat的整体性能。相对来说,Tomcat在处理静态页面方面一直有一些瓶颈,因此通常的服务架构都是前端类似Nginx的web服务器,后端挂上Tomcat作为应用服务器(当然还有些其他原因,例如负载均衡等) Tomcat在Connector的优化上做了一些特殊的处理,这些都是可选的,通过部署,配置方便完成,例如APR(Apache Portable Runtime),BIO,NIO等 目前Connector支持的协议是HTTP和AJP。 AJP是Apache与其他服务器之间的通信协议。通常在集群环境中,例如前端web服务器和后端应用服务器或servlet容器,使用AJP会比HTTP有更好的性能,这里引述apache官网上的一段话 本篇主要针对HTTP协议的Connector进行阐述 先来看一下Connector配置,在server.xml里 熟悉的80端口不必说了。protocol这里是指这个Connector支持的协议。 具体到HTTP协议,这个属性可以配置的值有 HTTP/1.1 org.apache.coyote.http11.Http11Protocol –BIO实现 org.apache.coyote.http11.Http11NioProtocol –NIO实现 定制的接口 配置HTTP/1.1和org.apache.coyote.http11.Http11Protocol效果一样,因此Connector的HTTP协议实现默认支持BIO的 无论BIO/NIO都是实现一个org.apache.coyote.ProtocolHandler接口,因此如果需要定制,也必须实现这个接口 来看看默认状态下HTTP connector的架构及其消息流 Connector的三大件 HTTP11Protocol Mapper CoyoteAdapter HTTP11Protocol 类全路径org.apache.coyote.http11.Http11Protocol,这是支持HTTP的BIO实现 包含了JIoEndpoint对象及Http11ConnectionHandler对象。 Http11ConnectionHandler对象维护了一个Http11Processor对象池,Http11Processor对象会调用CoyoteAdapter完成http request的解析和分派。 JIoEndpoint维护了两个线程池,Acceptor及Worker。Acceptor是接收socket,然后从Worker线程池中找出空闲的线程处理socket,如果worker线程池没有空闲线程,则Acceptor将阻塞。Worker是典型的线程池实现。Worker线程拿到socket后,就从Http11Processor对象池中获取Http11Processor对象,进一步处理。除了这个比较基础的Worker线程池,也可以通过基于java concurrent 系列的java.util.concurrent.ThreadPoolExecutor线程池实现,不过需要在server.xml中配置相应的节点,即在connector同级别配置<Executor>,配置完后,使用ThreadPoolExecutor与Worker在实现上没有什么大的区别,就不赘述了。 <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> 图中的箭头代表了消息流。 Mapper 类全路径org.apache.tomcat.util.http.mapper.Mapper,此对象维护了一个从Host到Wrapper的各级容器的快照 它主要是为了,当HTTP request被解析后,能够将HTTP request绑定到相应的servlet进行业务处理。前面的文章中已经说明,在加载各层容器时,会将它们注册到JMX中。 所以当 Connector启动,会从JMX中查询出各层容器,然后再创建这个Mapper对象中的快照 CoyoteAdapter 全路径org.apache.catalina.connector.CoyoteAdapter,此对象负责将HTTP request解析成HttpServletRequest对象,之后绑定相应的容器,然后从engine开始逐层调用valve直至该servlet。 在Session管理中,已经说明,根据request中的jsessionid绑定服务器端的相应session。 这个jsessionid按照优先级或是从request url中获取,或是从cookie中获取,然后再session池中找到相应匹配的session对象,然后将其封装到HttpServletRequest对象。所有这些都是在CoyoteAdapter中完成的。 看一下将request解析为HttpServletRequest对象后,开始调用servlet的代码;connector.getContainer().getPipeline().getFirst().invoke(request, response); connector的容器就是StandardEngine,代码的可读性很强,获取StandardEngine的pipeline,然后从第一个valve开始调用逻辑,相应的过程请参照tomcat架构分析(valve机制)。

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

用 Python 分析《红楼梦》(2)

6 词频统计 完成分词以后,词频统计就非常简单了。我们只需要根据分词结果把片段切分开,去掉长度为一的片段(也就是单字),然后数一下每一种片段的个数就可以了。 这是出现次数排名前 20 的单词: (括号内为频数) 可以跟之前只统计出现次数,不考虑切分问题的排名做个对比: (括号内为频数) 通过分词后的词频,我们发现《红楼梦》中的人物戏份由多到少依次是宝玉、凤姐、贾母、袭人、黛玉、王夫人和宝钗。然而,这个排名是有问题的,因为”林黛玉”这个词的出现次数还有 267 次,需要加到黛玉的戏份里,所以其实黛玉的戏份比袭人多。同理,“老太太”一般是指贾母,所以贾母的戏份加起来应该比凤姐多。正确的排名应该是宝玉、贾母、凤姐、黛玉、袭人、王夫人和宝钗。 此外,我们还发现《红楼梦》中的人物很爱笑,因为除了人名以外出现次数最多的单词就是“笑道” : ) 我把完整的词频

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

Hadoop 2.x环境搭建准备

一:下载Hadoop image.png 二:安装说明 http://hadoop.apache.org/docs/r2.5.2/hadoop-project-dist/hadoop-common/SingleCluster.html 三:查看是否安装jdk 四:强力卸载已将安装的JDK 空格分开卸载项。利用--nodeps参数强力卸载 image.png 5:上传文件Hadoop和jdk image.png :6:解压jdk文件到指定目录 tar -zxvf jdk-7u67-linux-x64.tar.gz -C /opt/modules/ 7:设置jdk环境变量 vi /etc/profile 末尾添加java环境变量 image.png 8:环境变量生效 source /etc/profile image.png 9:解压hadoop tar -zxvf hadoop-2.5.0.tar.gz -C /opt/modules/ image.png 10:修改hadoop环境文件 vi /opt/modules/hadoop-2.5.0/etc/hadoop/hadoop-env.sh image.png 修改java环境变量 image.png 11、hadoop三种启动模式 本地模式 未分布式模式 分布式模式 12、本地模式Local (Standalone) Mode 说明:part-r-00000 表示是MapReduce跑出来的结果。 以dfs开始a-z不限的结果只有一个。 样例 统计下面文本中各单词出现的次数 命令说明:jar 命令运行MapReduce样例 传入参数统计 wcinput目录下所有文件各单词出现的次数,并把结果输出到wcoutput目录下 查看执行结果 image.png 13、配置core-site.xml 设置HDFS地址 <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://192.168.57.192:8020</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/modules/hadoop-2.5.0/data/tmp</value> </property> </configuration> 14、配置hdfs-site.xml 文件分布式存储备份个数 <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration> 15、格式化HDFS的NAMENODE bin/hdfs namenode -format 16启动HDFS的主节点NameNode 启动命令:sbin/hadoop-daemon.sh start namenode 说明:hadoop-daemon.sh 是hadoop的守护进程,利用它启动HDFS的主节点。 image.png 17、启动HDFS的从节点DataNode sbin/hadoop-daemon.sh start datanode 18、查看是否启动成功 jps 19、开通8020/50070端口 vi /etc/sysconfig/iptables 20、访问HDFS的web页面 image.png 21、进入HDFS文件系统 image.png 22、创建HDFS文件目录 创建HDFS文件系统目录bin/hdfs dfs -mkdir -p /user/beifeng/mapreduce/wordcount/input 23、上传wc.input 文本文件 上传wc.input命令:bin/hdfs dfs -put wcinput/wc.input /user/beifeng/mapreduce/wordcount/input 把wc.input 文件上传到/user/beifeng/mapreduce/wordcount/input目录下 image.png 24、报错:datanode 错误。解决方法 25、上传文件成功并查看 上传用命令:-put image.png 26、通过HDFS服务器系统统计单词数量 命令:bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar wordcount /user/beifeng/mapreduce/wordcount/input/ /user/beifeng/mapreduce/wordcount/output image.png 27、查看 命令bin/hdfs dfs -cat /user/beifeng/mapreduce/wordcount/output/part* image.png image.png

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

Python字符串对象详解(2)

首先Python中的字符串对象依赖于str类,类里面包含了我们多使用到的所有方法,代码详见如下: class str(basestring): """String object.""" def __init__(self, object=''): """Construct an immutable string.#构造一个不可变的字符串,初始化对象使用 :type object: object """ pass def __add__(self, y): """The concatenation of x and y.#连接x和y x,y均为字符串类型 :type y: string :rtype: string """ return b'' def __mul__(self, n): """n shallow copies of x concatenated.#n浅层副本x连接。就是字符串的n倍出现连接 :type n: numbers.Integral :rtype: str """ return b'' def __mod__(self, y): #求余 """x % y. :rtype: string """ return b'' def __rmul__(self, n): """n shallow copies of x concatenated.#n浅层副本x连接。就是字符串的n倍出现连接 :type n: numbers.Integral :rtype: str """ return b'' def __getitem__(self, y): """y-th item of x, origin 0. #实现类似slice的切片功能 :type y: numbers.Integral :rtype: str """ return b'' def __iter__(self): #迭代器 """Iterator over bytes. :rtype: collections.Iterator[str] """ return [] def capitalize(self): """Return a copy of the string with its first character capitalized #实现首字母大写 and the rest lowercased. :rtype: str """ return b'' def center(self, width, fillchar=' '): #中间对齐 """Return centered in a string of length width. :type width: numbers.Integral :type fillchar: str :rtype: str """ return b'' def count(self, sub, start=None, end=None): #计算字符在字符串中出现的次数 """Return the number of non-overlapping occurrences of substring sub in the range [start, end]. :type sub: string :type start: numbers.Integral | None :type end: numbers.Integral | None :rtype: int """ return 0 def decode(self, encoding='utf-8', errors='strict'): #把字符串转成Unicode对象 """Return a string decoded from the given bytes. :type encoding: string :type errors: string :rtype: unicode """ return '' def encode(self, encoding='utf-8', errors='strict'):#转换成指定编码的字符串对象 """Return an encoded version of the string as a bytes object. :type encoding: string :type errors: string :rtype: str """ return b'' def endswith(self, suffix, start=None, end=None):#是否已xx结尾 """Return True if the string ends with the specified suffix, otherwise return False. :type suffix: string | tuple :type start: numbers.Integral | None :type end: numbers.Integral | None :rtype: bool """ return False def find(self, sub, start=None, end=None):#字符串的查找 """Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:end]. :type sub: string :type start: numbers.Integral | None :type end: numbers.Integral | none :rtype: int """ return 0 def format(self, *args, **kwargs):#格式化字符串 """Perform a string formatting operation. :rtype: string """ return '' def index(self, sub, start=None, end=None):#查找字符串里子字符第一次出现的位置 """Like find(), but raise ValueError when the substring is not found. :type sub: string :type start: numbers.Integral | None :type end: numbers.Integral | none :rtype: int """ return 0 def isalnum(self):#是否全是字母和数字 """Return true if all characters in the string are alphanumeric and there is at least one character, false otherwise. :rtype: bool """ return False def isalpha(self):#是否全是字母 """Return true if all characters in the string are alphabetic and there is at least one character, false otherwise. :rtype: bool """ return False def isdigit(self):#是否全是数字 """Return true if all characters in the string are digits and there is at least one character, false otherwise. :rtype: bool """ return False def islower(self):#字符串中的字母是否全是小写 """Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise. :rtype: bool """ return False def isspace(self):#是否全是空白字符 """Return true if there are only whitespace characters in the string and there is at least one character, false otherwise. :rtype: bool """ return False def istitle(self):#是否首字母大写 """Return true if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. :rtype: bool """ return False def isupper(self):#字符串中的字母是都大写 """Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise. :rtype: bool """ return False def join(self, iterable):#字符串的连接 """Return a string which is the concatenation of the strings in the iterable. :type iterable: collections.Iterable[string] :rtype: string """ return '' def ljust(self, width, fillchar=' '):#输出字符左对齐 """Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). :type width: numbers.Integral :type fillchar: str :rtype: str """ return b'' def lower(self):#字符中的字母是否全是小写 """Return a copy of the string with all the cased characters converted to lowercase. :rtype: str """ return b'' def lstrip(self, chars=None):#取出空格及特殊字符 """Return a copy of the string with leading characters removed. :type chars: string | None :rtype: str """ return b'' def partition(self, sep):#字符串拆分 默认拆成三部分 """Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. :type sep: string :rtype: (str, str, str) """ return b'', b'', b'' def replace(self, old, new, count=-1):#字符串替换 """Return a copy of the string with all occurrences of substring old replaced by new. :type old: string :type new: string :type count: numbers.Integral :rtype: string """ return '' def rfind(self, sub, start=None, end=None):#右侧查找 第一次出现 """Return the highest index in the string where substring sub is found, such that sub is contained within s[start:end]. :type sub: string :type start: numbers.Integral | None :type end: numbers.Integral | none :rtype: int """ return 0 def rindex(self, sub, start=None, end=None):##右侧查找 第一次出现位置 """Like rfind(), but raise ValueError when the substring is not found. :type sub: string :type start: numbers.Integral | None :type end: numbers.Integral | none :rtype: int """ return 0 def rjust(self, width, fillchar=' '):#右对齐 """Return the string right justified in a string of length width. Padding is done using the specified fillchar (default is a space). :type width: numbers.Integral :type fillchar: string :rtype: string """ return '' def rpartition(self, sep):#从右侧拆分 """Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. :type sep: string :rtype: (str, str, str) """ return b'', b'', b'' def rsplit(self, sep=None, maxsplit=-1):#字符串的分割 """Return a list of the words in the string, using sep as the delimiter string. :type sep: string | None :type maxsplit: numbers.Integral :rtype: list[str] """ return [] def rstrip(self, chars=None):#去掉字符串的右侧空格 """Return a copy of the string with trailing characters removed. :type chars: string | None :rtype: str """ return b'' def split(self, sep=None, maxsplit=-1):#字符串的切割 """Return a list of the words in the string, using sep as the delimiter string. :type sep: string | None :type maxsplit: numbers.Integral :rtype: list[str] """ return [] def splitlines(self, keepends=False):#把字符串按照行切割成list """Return a list of the lines in the string, breaking at line boundaries. :type keepends: bool :rtype: list[str] """ return [] def startswith(self, prefix, start=None, end=None):#以xx开头 """Return True if string starts with the prefix, otherwise return False. :type prefix: string | tuple :type start: numbers.Integral | None :type end: numbers.Integral | None :rtype: bool """ return False def strip(self, chars=None):#去除左右空格 """Return a copy of the string with the leading and trailing characters removed. :type chars: string | None :rtype: str """ return b'' def swapcase(self):#大小写互换 """Return a copy of the string with uppercase characters converted to lowercase and vice versa. :rtype: str """ return b'' def title(self):#标题化字符串 """Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. :rtype: str """ return b'' def upper(self):#大写 """Return a copy of the string with all the cased characters converted to uppercase. :rtype: str """ return b'' def zfill(self, width):#变成特定长度,不足0补齐 """Return the numeric string left filled with zeros in a string of length width. :type width: numbers.Integral :rtype: str """ return b'' 以上是字符串类中的所有方法包含特殊方法。翻译不够准确,请谅解

资源下载

更多资源
优质分享App

优质分享App

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

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

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