Pseudo-random

古老的LCG(linear congruential generator)代表了最好的伪随机数产生器算法。主要原因是容易理解,容易实现,而且速度快。

如果需要高质量的伪随机数,内存充足(约2kb),Mersenne twister算法是个不错的选择。Mersenne twister产生随机数的质量几乎超过任何LCG。不过一般Mersenne twister的实现使用LCG产生种子。
Mersenne twister是Makoto Matsumoto (松本)和Takuji Nishimura (西村)于1997年开发的伪随机数产生器,基于有限二进制字段上的矩阵线性再生。可以快速产生高质量的伪随机数,修正了古老随机数产生算法的很多缺陷。 Mersenne twister这个名字来自周期长度通常取Mersenne质数这样一个事实。常见的有两个变种Mersenne Twister MT19937和Mersenne Twister MT19937-64。
Mersenne Twister有很多长处,例如:周期2^19937 - 1对于一般的应用来说,足够大了,序列关联比较小,能通过很多随机性测试。
用Mersenne twister算法实现的伪随机数版本非常多。例如boost库中的高质量快速随机数产生器就是用Mersenne twister算法原理编写的。

matlab的随机函数产生的随机数都是根据伪随机数序列获取的,在v7.7以上的版本中,有如下的伪随机数产生器:
Mersenne twister,
Multiplicative congruential generator,
Multiplicative lagged Fibonacci generator,
Combined multiple recursive generator,
Shift-register generator summed with linear congruential generator,
Modified subtract with borrow generator。

在Windows下如果用mt_rand()函数替代rand()函数的话效果也会好很多。这是由于mt_rand()用了Mersenne Twister(马其塞旋转)算法来产生随机数。PHP的文档还说:mt_rand() 可以产生随机数值的平均速度比 libc 提供的 rand() 快四倍。

Joel Spolsky的七个建议

  • 毕业前练好写作 表达能力->影响力
  • 毕业前学好C语言
    • C语言仍然是当前程序员的共同语言
    • 你能解释为什么while (*s++ = *t++);这句代码的作用是复制字符串吗?
  • 毕业前学好微观经济学 商业领域所有重要理论的基础
  • 你一定要去学微观经济学,因为你必须搞懂供给和需求,你必须明白竞争优势,你必须理解什么是净现值(NPV),什么是贴现,什么是边际效用。只有这样,你才会懂得为什么生意是现在这种做法。
    • 从经营一家公司的角度来看,比起那些不懂的程序员,一个理解基本商业规则的程序员将会更有价值。
    • 别忘了,在编程工作中也有很枯燥的东西。每一项工作都有枯燥难耐的时刻。我不想雇用那些只想干有趣事情的人。
  • 选修有大量编程实践的课程
    • 计算机科学与软件开发不是一回事。
  • 别担心所有工作都被印度人抢走
  • 找一份好的暑期实习工作

Java点点

Java语法

  • final域
    final域一旦赋值后将永远不变,因此非常适合用来定义常量。值得注意的是:如果final域是一个基本类型,那么表明改域的值是不能改变的。若final域是一个对象的引用,则仅仅表明改引用不能被改变,也就是永远指向同一个对象,但是被引用的对象自身却是可以改变的。这跟c++中的常量指针很像(不是指向常量的指针)。初始化final域有着特殊的要求:非静态final域要求在构造函数执行后必须被明确赋值,而静态final域在类初始化完成后必须要被明确赋值。

  • JAR地狱(JAR hell):JAR文件不同版本或路径带来的问题,通常是由于不懂类加载模型导致的。指类路径里JAR包太多这个问题。另外一个“JAR地狱”的解释是“反模式”中的一个概念。DLL地狱(DLL hell):不同版本带来的问题,DLL可见性和多版本问题,在微软的Windows上尤为突出

  • ThreadLocal
    A ThreadLocal can be used to avoid the creation of a new SimpleDateFormat for each call.
    It is needed in a multithread context since the SimpleDateFormat is not thread safe

Spring

Jackson Annotations

  • @JsonIgnoreProperties one of the most common annotations in Jackson – is used to mark a property or a list of properties to be ignored at the class level.如果是代理类,由于无法标记在属性或方法上,所以,可以标记在类声明上;也作用于反序列化时的字段解析。作用在类上,用来说明有些属性在序列化/反序列化时需要忽略掉,可以将它看做是@JsonIgnore的批量操作,但它的功能比@JsonIgnore要强,比如一个类是代理类,我们无法将将@JsonIgnore标记在属性或方法上,此时便可用。标注在类声明上,它还有一个重要的功能是作用在反序列化时解析字段时过滤一些未知的属性,否则通常情况下解析到我们定义的类不认识的属性便会抛出异常。
  • @JsonIgnore The @JsonIgnore annotation is used to mark a property to be ignored at the field level.一般标记在属性或方法上;作用于序列化与反序列化。作用在字段或方法上,用来完全忽略被注解的字段和方法对应的属性,即便这个字段或方法可以被自动检测到或者还有其他的注解
  • @JsonPropertyOrder,注释在类声明中
  • @JsonAutoDetect 看上面自动检测,不再重复
  • @JsonProperty 作用在字段或方法上,用来对属性的序列化/反序列化,可以用来避免遗漏属性,同时提供对属性名称重命名,比如在很多场景下Java对象的属性是按照规范的驼峰书写,但是实际展示的却是类似C-style或C++/Microsolft style
  • @JsonUnwrapped 作用在属性字段或方法上,用来将子JSON对象的属性添加到封闭的JSON对象
  • @JsonIdentityInfo 2.0+版本新注解,作用于类或属性上,被用来在序列化/反序列化时为该对象或字段添加一个对象识别码,通常是用来解决循环嵌套的问题,比如数据库中的多对多关系,通过配置属性generator来确定识别码生成的方式,有简单的,配置属性property来确定识别码的名称,识别码名称没有限制。
  • @JsonNaming jackson 2.1+版本的注解,作用于类或方法,注意这个注解是在jackson-databind包中而不是在jackson-annotations包里,它可以让你定制属性命名策略,作用和前面提到的@JsonProperty的重命名属性名称相同。

多态类型处理

jackson允许配置多态类型处理,当进行反序列话时,JSON数据匹配的对象可能有多个子类型,为了正确的读取对象的类型,我们需要添加一些类型信息。可以通过下面几个注解来实现:

  • @JsonTypeInfo 作用于类/接口,被用来开启多态类型处理,对基类/接口和子类/实现类都有效

工具

9 tools to help you with Java Performance Tuning
http://blog.idrsolutions.com/2014/06/java-performance-tuning-tools/

JWT

JWT是 Json Web Token 的缩写。它是基于 RFC 7519 标准定义的一种可以安全传输的 小巧 和 自包含 的JSON对象。由于数据是使用数字签名的,所以是可信任的和安全的。JWT可以使用HMAC算法对secret进行加密或者使用RSA的公钥私钥对来进行签名。

JWT是由三段组成的,按官方的叫法分别是header(头)、payload(负载)和signature(签名):

header.payload.signature

一个比较成熟的JWT类库,叫 jjwt ( https://github.com/jwtk/jjwt )。这个类库可以用于Java和Android的JWT token的生成和验证。

Java JWT: JSON Web Token for Java and Android
https://github.com/jwtk/jjwt

JWTs are incredibly cool for authentication because they let us implement reliable Single Sign-On (SSO) with low overhead on any platform (native, web, VR, whatever…) and across domains. JWTs are a strong alternative to pure cookie or session based auth with simple tokens or SAML, which can fail miserably in native app implementations. We can even use cookies with JWTs if we really want.

For our purposes, we just need to know how to use JWTs within our authentication workflow. When a user logs into our app, the server will check their email and password against the database. If the user exists, we’ll take their {email: , password: } combination, turn it into a lovely JWT, and send it back to the client. The client can store the JWT forever or until we set it to expire.

Whenever the client wants to ask the server for data, it’ll pass the JWT in the request’s Authorization Header (Authorization: Bearer ). The server will decode the Authorization Header before executing every request, and the decoded JWT should contain {email: , password: }. With that data, the server can retrieve the user again via the database or a cache to determine whether the user is allowed to execute the request.

The Expired Password Problem
We still have one last thing that needs modifying in our authorization setup. When a user changes their password, we issue a new JWT, but the old JWT will still pass verification! This can become a serious problem if a hacker gets ahold of a user’s password. To close the loop on this issue, we can make a clever little adjustment to our UserModel database model to include a version parameter, which will be a counter that increments with each new password for the user. We’ll incorporate version into our JWT so only the newest JWT will pass our security.

IBM developerWorks

算法

随机数生成器

使您的软件运行起来
摆弄数字
真正安全的软件需要精确的随机数生成器
https://www.ibm.com/developerworks/cn/security/playing/index.html

java

Java 编程的动态性,第 1 部分
类和类装入
研究类以及 JVM 装入类时所发生的情况
https://www.ibm.com/developerworks/cn/java/j-dyn0429/

class类文件
cafe babe 任何 Java 二进制类(甚至是文件系统中没有出现的类)都需要以这四个字节作为开始
0000 次版本 0
002e 主版本 46
001a 常量池中项的总数
后面是实际的常量池数据 常量池往往占到二进制类大小的一半或更多,但平均下来可能要少一些。

方法的可执行代码 用 JVM 的指令形式表示该代码,一般称为 字节码
构成类文件可执行部分的字节码实际上是针对特定类型的计算机 ― JVM ― 的机器码
JVM被称为 虚拟机,因为它被设计成用软件来实现,而不是用硬件来实现。每个用于运行 Java 平台应用程序的 JVM 都是围绕该机器的实现而被构建的。
JVM使用堆栈体系结构,这意味着在使用指令操作数之前要先将它们装入内部堆栈。
早期的(第一代)JVM 基本上是虚拟机字节码的解释器。这些虚拟机实际上 的确相对简单,但存在严重的性能问题 ― 解释代码的时间总是会比执行本机代码的时间长。
第二代 JVM 添加了 即时(just-in-time,JIT)转换。在第一次执行 Java 字节码之前,JIT 技术将它编译成本机代码,从而对于重复执行提供了更好的性能。
当代 JVM 的性能甚至还要好得多,因为使用了适应性技术来监控程序的执行并有选择地优化频繁使用的代码。

JAR 只是类文件的容器

增加环境变量 JAVA_OPTS -verbose 可以查看类加载过程

C 和 C++ 这些编译成本机代码的语言通常在编译完源代码之后需要链接这个步骤

使用 Java 语言,由编译器生成的类在被装入到 JVM 之前通常保持原状

链接类不是一个独立步骤,它是在 JVM 将这些类装入到内存时所执行作业的一部分

能装入独立的类集合这一灵活性是 Java 平台的一个重要特性。尽管这个特性很有用,但是它在某些情况中会产生混淆。

一个令人混淆的方面是处理 JVM 类路径这样的老问题。

使用多个类装入器还可能引起其它类型的混淆。身份危机(class identity crisis)

JDK5.0以后不需要配classpath了,只要把path配好就行

敏捷开发中高质量 Java 代码开发实践
https://www.ibm.com/developerworks/cn/java/j-lo-agile/

步骤一:统一编码规范、代码样式
步骤二:静态代码分析
步骤三:单元测试
步骤四:持续集成(Continuous Integration)
步骤五:代码评审和重构(Code Review)

使用原汁原味的 Java 语言
非 Java 原生程序员的语言流畅性
https://www.ibm.com/developerworks/cn/java/j-noaccent.html

Java 的惯例中 main()方法的参数名为 args,而不是 argv:public static void main(String[] args)

深入探讨 Java 类加载器
https://www.ibm.com/developerworks/cn/java/j-lo-classloader/

常用 Java 静态代码分析工具的分析与比较
https://www.ibm.com/developerworks/cn/java/j-lo-statictest-tools/

使用 Java 开源工具建立一个灵活的搜索引擎
揭示开源的力量
https://www.ibm.com/developerworks/cn/java/j-lo-sefrmk/

几种任务调度的 Java 实现方法与比较
https://www.ibm.com/developerworks/cn/java/j-lo-taskschedule/index.html

用 Quartz 进行作业调度
Quartz API 采用多面方式在 Java 应用程序中进行任务调度
https://www.ibm.com/developerworks/cn/java/j-quartz/

在 Web 项目中应用 Apache Shiro
https://www.ibm.com/developerworks/cn/java/j-lo-shiro/

从虚拟机视角谈 Java 应用性能优化
https://www.ibm.com/developerworks/cn/java/j-lo-jvm-perf/

使用 VisualVM 进行性能分析及调优
https://www.ibm.com/developerworks/cn/java/j-lo-visualvm/

优化 Java 垃圾收集器改进系统性能
https://www.ibm.com/developerworks/cn/java/j-lo-optimize-gc/

Java的内存泄漏
https://www.ibm.com/developerworks/cn/java/l-JavaMemoryLeak/

Java 性能优化之 String 篇
https://www.ibm.com/developerworks/cn/java/j-lo-optmizestring/

Java Web 高性能开发,第 1 部分
前端的高性能
https://www.ibm.com/developerworks/cn/java/j-lo-javawebhiperf1/

您不知道的 5 件事……
JVM 命令行标志
调优 JVM 性能和 Java 运行时
https://www.ibm.com/developerworks/cn/java/j-5things11/index.html

Java.next, Common ground in Groovy, Scala, and Clojure, Part 1
Explore how these next-generation JVM languages handle operator overloading
https://www.ibm.com/developerworks/java/library/j-jn2/index.html

Java.next, Common ground in Groovy, Scala, and Clojure, Part 3
Rethinking exceptions, expressions, and emptiness
https://www.ibm.com/developerworks/java/library/j-jn4/index.html

使用JMeter进行性能测试
https://www.ibm.com/developerworks/cn/java/l-jmeter/

使用 JMeter 完成常用的压力测试
https://www.ibm.com/developerworks/cn/opensource/os-pressiontest/

启用动态 HTTP 压缩
在各种 Web 服务器上通过动态压缩节省带宽
https://www.ibm.com/developerworks/cn/web/wa-httpiis/

最佳实践:更好的设计你的 REST API
https://www.ibm.com/developerworks/cn/web/1103_chenyan_restapi/

NIO 入门
https://www.ibm.com/developerworks/cn/education/java/j-nio/j-nio.html

Merlin 给 Java 平台带来了非阻塞 I/O
新增的功能大幅降低了线程开销
https://www.ibm.com/developerworks/cn/java/j-javaio/

深入分析 Java 中的中文编码问题
https://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/

Java SSL/TLS 安全通讯协议介绍
Java 的安全通讯
https://www.ibm.com/developerworks/cn/java/j-lo-ssltls/

Java 安全套接字编程以及 keytool 使用最佳实践
https://www.ibm.com/developerworks/cn/java/j-lo-socketkeytool/

开源规则流引擎实践
https://www.ibm.com/developerworks/cn/opensource/os-drools/index.html

使用 Drools 规则引擎实现业务逻辑

如果你的业务场景中有很多复杂的业务逻辑/业务策略,而这些业务策略又经常发生变化,那么你就可以引入规则引擎技术。

开发 Spring Redis 应用程序
使用 Redis 作为数据存储来构建基于 Spring 的应用程序
https://www.ibm.com/developerworks/cn/java/os-springredis/index.html

Java 编程中的 OAuth 2.0 客户端,第 1 部分
资源所有者密码凭据授权
https://www.ibm.com/developerworks/cn/java/se-oauthjavapt1/index.html

Java 编程中的 OAuth 2.0 客户端,第 2 部分
客户端凭据授权
https://www.ibm.com/developerworks/cn/java/se-oauthjavapt2/index.html

Java 编程中的 OAuth 2.0 客户端,第 3 部分
认证码授权
https://www.ibm.com/developerworks/cn/java/se-oauthjavapt3/index.html

Java 开发 2.0
现实世界中的 Redis
Redis 如何在包含大量读取操作的应用程序中战胜 memcached
https://www.ibm.com/developerworks/cn/java/j-javadev2-22/

全面分析 Spring 的编程式事务管理及声明式事务管理
https://www.ibm.com/developerworks/cn/education/opensource/os-cn-spring-trans/

Spring 事务管理高级应用难点剖析
第 1 部分
https://www.ibm.com/developerworks/cn/java/j-lo-spring-ts1/index.html

Spring 事务管理高级应用难点剖析
第 2 部分
https://www.ibm.com/developerworks/cn/java/j-lo-spring-ts2/

Spring 事务管理高级应用难点剖析
第 3 部分
https://www.ibm.com/developerworks/cn/java/j-lo-spring-ts3/index.html

使用 Spring 进行单元测试
https://www.ibm.com/developerworks/cn/java/j-lo-springunitest/

使用 Apache JMeter 测试基于云的应用程序
学习使用 JMeter 进行 RESTful API 测试的有效技术和最佳实践
https://www.ibm.com/developerworks/cn/cloud/library/cl-jmeter-restful/

让开发自动化
用 Eclipse 插件提高代码质量
在 Eclipse 中使用 5 个有用的插件来自动化代码质量分析
https://www.ibm.com/developerworks/cn/java/j-ap01117/

常用 Java Profiling 工具的分析与比较
https://www.ibm.com/developerworks/cn/java/j-lo-profiling/

Java Web 高性能开发,第 2 部分
前端的高性能
https://www.ibm.com/developerworks/cn/java/j-lo-javawebhiperf2/

在 Java 应用程序中使用 Elasticsearch
高性能 RESTful 搜索引擎和文档存储快速入门指南
https://www.ibm.com/developerworks/cn/java/j-use-elasticsearch-java-apps/index.html

Java 应用性能调优实践
让 Java 应用运行更快:性能调优工具及实践
https://www.ibm.com/developerworks/cn/java/j-lo-performance-tuning-practice/

通过零拷贝实现有效数据传输
零拷贝,零开销
https://www.ibm.com/developerworks/cn/java/j-zerocopy/

Java 性能分析工具 , 第 1 部分
操作系统工具
https://www.ibm.com/developerworks/cn/java/j-lo-performance-analysissy-tools/

Java 性能测试的四项原则
https://www.ibm.com/developerworks/cn/java/j-lo-java-performance-testing/

Groovy 使 Spring 更出色,第 1 部分: 集成的基础知识

Java 8 Annotation 新特性在软件质量和开发效率方面的提升

使用 Groovy 构建 DSL

Groovy:Java 程序员的 DSL

SQL

SQL 语句性能调优
初级篇 —— 简单查询语句的调优
https://www.ibm.com/developerworks/cn/data/library/techarticles/dm-1002limh/index.html

SQL 在常用报表业务中的归并、转换与信息汇总中的应用技巧
https://www.ibm.com/developerworks/cn/data/library/techarticles/dm-1008yangxy/

JavaScript

Understand memory leaks in JavaScript applications
Detect and address memory issues
https://www.ibm.com/developerworks/library/wa-jsmemory/index.html

拥抱原型面向对象编程
https://www.ibm.com/developerworks/cn/web/wa-protoop/index.html

浅谈 JavaScript 编程语言的编码规范
https://www.ibm.com/developerworks/cn/web/1008_wangdd_jscodingrule/

使用 Chrome 开发者工具进行 JavaScript 问题定位与调试
https://www.ibm.com/developerworks/cn/web/1410_wangcy_chromejs/index.html

JavaScript 中的类

用 Maven 做项目构建

POM 即 Project Object Module,项目对象模型,在 pom.xml 文件中定义了项目的基本信息、源代码、配置文件、开发者的信息和角色、问题追踪系统、组织信息、项目授权、项目的 url、以及构建项目所用的插件,依赖继承关系。

Maven 本质上是一个插件框架,它的核心并不执行任何具体的构建任务,仅仅定义了抽象的生命周期,所有这些任务都交给插件来完成的。每个插件都能完成至少一个任务,每个任务即是一个功能,将这些功能应用在构建过程的不同生命周期中。这样既能保证拿来即用,又能保证 maven 本身的繁杂和冗余。

可以用 去除这种依赖的传递

可以在当前的 POM 文件中使用 元素声明排除依赖,exclusions 可以包含一个或者多个 exclusion 子元素,因此可以排除一个或者多个传递性依赖。

Nexus是Maven仓库管理器,用来搭建一个本地仓库服务器,这样做的好处是便于管理,节省网络资源,速度快,还有一个非常有用的功能就是可以通过项目的SNAPSHOT版本管理,来进行模块间的高效依赖开发

ES6

新 JavaScript 中的变量声明等功能

React

React:创建可维护、高性能的 UI 组件
使用 React JavaScript 库创建可维护的 Web UI,超越浏览器 DOM
https://www.ibm.com/developerworks/cn/web/wa-react-intro/index.html

React 介绍及实践教程
https://www.ibm.com/developerworks/cn/web/1509_dongyue_react/

redux

Redux 简介

状态管理是软件开发的最困难方面之一,这使得状态管理错误成为了几乎所有 bug 的源头。

Redux,这是一个针对 JavaScript 应用程序的可预测的状态容器。
Redux 不仅有助于状态管理,还使得实现一些高级特性变得很简单,比如无限撤销/重做和实时编辑时间旅行 (live-editing time travel)。

尽管 Redux 来自 React 社区,但它并不依赖于 React。

Redux 是 Facebook 的 Flux 架构的一种简化实现。

Flux 在本质上采用了模型-视图-控制器 (MVC) 的结构

Redux 有 3 条原则:

  • 应用程序状态存储在单个对象中。
  • 应用程序状态不可变,只能通过描述状态更改的操作 彻底替换。
  • 缩减程序根据当前状态和某个操作来创建下一个状态。

Redux 简介

结合使用 Redux 和 React

Unix

对话 UNIX,第 4 部分
UNIX 所有权和权限管理
共享信息
https://www.ibm.com/developerworks/cn/aix/library/au-speakingunix4/index.html

UNIX 文件的权限位 表示了三类用户(您本人、您的一个组和其他用户)的某一种特定的权限
10 个字符组成的序列
每个字符都是一个开/关设置或位

起始位表示该文件是否为目录(通常,起始位 表示该文件是否为特殊文件。如果该文件是特殊文件,起始字符 d 表示目录、l 表示符号链接,等等)。这个设置是无法改变的。

接下来的三位(用蓝色表示的)分别表示您 对该文件的读、写和执行权限。您可以禁用写权限位,例如要防止删除文件。(是的,要删除一个文件,您需要写权限。)

接下来的三位(用绿色表示的)表示组 对该文件的读、写和执行权限。

最后的三位(用橙色表示的)表示所有其他 用户(即除了您自己以及您的组中的成员之外的所有用户)的权限。

您可以使用 chmod(更改模式 change mode)命令修改相应的权限(除了目录位之外)。您可以使用 chgrp(更改组 change group)命令来修改文件所属的组。(超级用户 root 也可以使用 chown 或 change owner 命令来更改文件所有权。)

find . -type f -print | sort | uniq

您可以使用符号 ~(波浪符号)引用您的 home 目录。您还可以使用 $HOME 环境变量引用您的 home 目录

许多程序可以从一个名为 .netrc(读做 net-r-c)的文件中读取您的凭据,该文件通常位于 ~/.netrc 目录中。

Linux 新用户的基本任务
Linux 安装好后,下一步该做什么?
https://www.ibm.com/developerworks/cn/linux/tutorials/l-basics/

学习 Linux,101
LPIC-1 路线图
关于 LPIC-1 考试准备的 developerWorks 文章指南
https://www.ibm.com/developerworks/cn/linux/l-lpic1-v3-map/

学习 Linux,101
创建和更改硬链接和符号链接
为同一文件使用多个名称
https://www.ibm.com/developerworks/cn/linux/l-lpic1-v3-104-6/

学习 Linux,101
管理文件权限和所有权
在您的文件上设置正确的安全性
https://www.ibm.com/developerworks/cn/linux/l-lpic1-v3-104-5/index.html

学习 Linux,101
RPM 和 YUM 包管理
添加新软件并及时更新系统
https://www.ibm.com/developerworks/cn/linux/l-lpic1-v3-102-5/

Bash 实例,第一部分
Bourne again shell (bash) 基本编程
https://www.ibm.com/developerworks/cn/linux/shell/bash/bash-1/

Bash 实例,第 2 部分
更多的 bash 基本编程
https://www.ibm.com/developerworks/cn/linux/shell/bash/bash-2/

Bash 实例,第 3 部分
探讨 ebuild 系统
https://www.ibm.com/developerworks/cn/linux/shell/bash/bash-3/

系统管理员工具包
充分利用 bash
https://www.ibm.com/developerworks/cn/aix/library/au-satbash.html

LPI 102 考试准备,主题 109
Shell、脚本、编程和编译
初级管理(LPIC-1)主题 109
https://www.ibm.com/developerworks/cn/education/linux/l-lpic1109/index.html

LPI 102 考试准备,主题 109
Shell、脚本、编程和编译
初级管理(LPIC-1)主题 109
https://www.ibm.com/developerworks/cn/education/linux/l-lpic1109/index.html

Linux 编程和系统管理新手入门
https://www.ibm.com/developerworks/cn/linux/newto/index.html

Windows 到 Linux 之旅: 系列文章概述
指引开发者走向 Linux 的路线图
https://www.ibm.com/developerworks/cn/linux/l-roadmap/index.html

Windows 到 Linux 之旅: 第 4 部分. 用户管理

Windows 到 Linux 之旅: 第 6 部分. 使用分区和文件系统

数据库

超越 MySQL
对流行数据库进行分支
https://www.ibm.com/developerworks/cn/opensource/os-beyondmysql/

LAMP 系统性能调优,第 3 部分
MySQL 服务器调优
利用服务器的几个调优技巧,让 MySQL 服务器飞速运行
https://www.ibm.com/developerworks/cn/linux/l-tune-lamp-3.html

Web

响应式 Web 设计技巧
https://www.ibm.com/developerworks/cn/web/1506_zhangqun_responsiveweb/

利用 Sass 改善 CSS 预处理

Syntactically awesome stylesheets (Sass) 是一种元语言和层叠式样式表 (CSS) 预处理程序

Sass 主要使用 Ruby 来实现

html5

使用 HTML 5 创建移动 Web 应用程序

第 1 部分: 联合使用 HTML 5、地理定位 API 和 Web 服务来创建移动混搭程序

第 2 部分: 使用 HTML 5 开启移动 Web 应用程序的本地存储

localStorage API

第 3 部分: 使用 HTML 5 支持移动 Web 应用程序离线工作

第 4 部分: 使用 Web Workers 来加速您的移动 Web 应用程序

Web Worker 规范

从 Android 2.0 开始,Android 浏览器就拥有了对 HTML 5 Web Worker 规范的全面支持。

第 5 部分: 使用 HTML 5 开发新的可视化 UI 特性

所有基于 Webkit 的浏览器都能实现 Canvas 并极大地优化其性能。

工具类

ImageMagick 魔咒
面向用户和程序员等受众的图像处理
https://www.ibm.com/developerworks/cn/opensource/os-imagemagick/index.html

其它

利用 squid 反向代理提高网站性能
https://www.ibm.com/developerworks/cn/linux/l-cn-squid/

MQ 遥测传输 (MQTT) V3.1 协议规范
https://www.ibm.com/developerworks/cn/webservices/ws-mqtt/index.html

使用 Nginx 提升网站访问速度
https://www.ibm.com/developerworks/cn/web/wa-lo-nginx/

管理移动云套接字连接
云提供商如何管理移动应用程序与云之间的连接
https://www.ibm.com/developerworks/cn/cloud/library/cl-mobilesockconnect/

配置 Tomcat 和 Wireshark 来获取并解码 SSL 通信
调试安全通信
https://www.ibm.com/developerworks/cn/web/tutorials/wa-tomcat/

使用 OpenSSL API 进行安全编程
创建基本的安全连接和非安全连接
https://www.ibm.com/developerworks/cn/linux/l-openssl.html

利用物联网 (IoT)
探索 IoT 的 7 个重要概念和开始使用它的 4 个步骤
https://www.ibm.com/developerworks/cn/iot/iot-key-concepts/index.html

了解 IT 即流程
如何自动化企业中的 IT 操作
https://www.ibm.com/developerworks/cn/websphere/techjournal/1510_brown-trs/1510_brown.html

使用访问令牌保护微服务

量子计算

量子计算入门
棘手问题的简便解法指南
https://www.ibm.com/developerworks/cn/linux/other/quant/

LLVM

使用 LLVM 框架创建一个工作编译器,第 1 部分

使用 LLVM 框架创建有效的编译器,第 2 部分

LLVM 拥有自己的前端:名为 clang 的一种工具(恰如其分)。Clang 是一种功能强大的 C/C++/Objective-C 编译器,其编译速度可以媲美甚至超过 GNU Compiler Collection (GCC) 工具(参见 参考资料 中的链接,获取更多信息)。更重要的是,clang 拥有一个可修改的代码基,可以轻松实现定制扩展。

blockchain

区块链技术基础:商业账本简介

区块链技术基础:术语和用例

Docker

Docker:带给现代开发人员的福利

Docker 就像是用于 DevOps 的一把瑞士军刀,这一点已得到充分证明。但 Docker 托管的应用程序容器的用途不仅是在云中部署服务器。Docker 容器还可以在许多常见的开发场景中帮助开发和显著提高生产力。

quotes

The gap between the best software engineering practice and the average practice is very wide—perhaps wider than in any other engineering discipline. A tool that disseminates good practice would be important. — Fred Brooks

The laws of nature are but the mathematical thoughts of God. — Euclid

“Stop being so negative, Steven!”, “Why do you always assume the worst?”, “You’re such a ‘glass half empty’ person, Steven.”

我能召唤遥远的精灵。
那又怎么样,我也可以,谁都可以,问题是你真的召唤的时候,它们会来吗? - 莎士比亚,《亨利四世》,第一部分

I can call spirits from the vasty deep.
Why, so can I, or so can any man; but will they come when you do call for them? - SHAKESPEARE, KING HENRY IV, Part I

GLENDOWER: I can call spirits from the vasty deep.
HOTSPUR: Why, so can I, or so can any man; But will they come when you do call for them?

William Shakespeare, King Henry IV, Part 1

他过去所做的许诺,是非凡的;
而他今天的执行,则什么也不是。
莎士比亚,《亨利八世》

只能根据过去判断将来。 - 帕特里克·亨利
然而永远无法根据过去规划将来。 - 埃德蒙·伯克
I know no way of judging the future but by the past. - PATRICK HENRY
You can never plan the future by the past. - EDMUND BURKE

普遍的做法是,选择一种方法,试试看;如果失败了,没关系,再试试别的。不管怎么样,重要的是先去尝试。 - 富兰克林 D. 罗斯福
It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something. - FRANKLIN D. ROOSEVELT

Donald Knuth 曾经指出,“提前优化是万恶之源”。
“premature optimization is the root of all evil,” as Donald Knuth once put it

Cliff Click expressed the same sentiment this way:
Premature optimization is the root of all evil is more true today than ever before.

Hope for the best and prepare for the worst

Fear not the future ,Weep not for the past

Men are judged by what they do

There is no time like the present

We are all slaves of opinion

Practice is the best master

The language of truth is simple

A man must take the consequence of his own deeds

Great hopes makes great men

Life is short and time is swift

Example is better than precept

Practice what you preach

Practice makes perfect

Easier said than done

It is never too late to mend

Look not too high, lest something fall into your eye.

Plain living and high thinking

A good heart conquers ill fortune

A little body often harbors a great soul

期刊摘句

你以为买到的是“知识”,其实只是“知道”。你以为买到的是“掌握”,其实只是囤积了一堆“知道”。 —— 学者方绍伟谈网络时代的“知识囤积症”

囤书如山倒,读书如抽丝,我早已经囤下后半辈子都读不完的书,但出于占有欲,我还是不断在买书。 (摘自《读者》2018年08期)

一个人好像是一个分数,他的实际才能好比分子,而他对自己的估价好比分母,分母越大则分数值愈小。(托尔斯泰《人生论》)

HALT(hungry, angry, lonely, tired)

手中事和身边人。 —— 对一个人的价值最准确的考量标准

人工智能时代对人类最大的威胁是,它让我们将虚拟社群的联系与真实事物混为一谈。 —— 哈佛大学教授桑德尔谈技术对人类社会的改变

盯住领域里最牛的那几个人,他们就是方向。— 杨振宁

Linux常用知识点

命令

最常用

man 帮助(按q退出man)
ls
pwd 输出工作目录
cd
mkdir
find 和 locate
cp
mv 改名、移动
more
kill 使用ps进程ID,kill进程
sudo
passwd 更改密码

sudo su

查看日志:tail -n 100 catalina.out

复制文件:
sudo cp kaopurServer.war /opt/apache-tomcat-8.0.24/webapps/

查看目录
ll

cat /etc/passwd

cat -n song.txt

给sh脚本增加执行权限:chmod +x yourshfile.sh

mkdir kaopurServer

cd kaopurServer

tar -zxvf ../kaopurServer.tar.gz

sudo \cp -rf kaopurServer/* /opt/apache-tomcat-8.0.24/webapps/kaopurServer

rm -f index.jsp

rm -rf WEB-INF/

如此才会覆盖:
sudo \cp -rf kaopurServer/* /opt/apache-tomcat-8.0.24/webapps/kaopurServer

sudo tar -zxf /home/hl/apache-activemq-5.9.1-bin.tar.gz

cat activemq.xml

linux下载文件:
curl -O http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.0.28/bin/apache-tomcat-8.0.28.tar.gz

curl -O -L http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

xshell中文乱码:修改Terminal的字符集

$ ps -ef|grep tfs

curl -o emqttd-centos64-0.13.0-beta-20151108.zip -L http://emqtt.io/downloads/centos

cat /etc/redhat-release

linux常用命令
在 Linux 中用的是正斜杠 (/),而不是您所熟悉的反斜杠 ()。反斜杠也用到了,但只是用来说明命令需要换行继续,这样可以提高比较长的命令的可读性。

ls -l 以长格式列出文件,包括文件大小、日期和时间、属性
ls -t 对文件以时间排序
ls -S 对文件以大小排序
ls -r 与一个排序开关组合起来使用,逆序排列。 ls -t 将最新的文件显示在列表的顶部。 ls -t 将最新的文件显示在底部。
ls -h 易读格式。使用 k、M、G 等来标识文件的大小,而不是以字节为单位。
ls -a 显示目录中所有的文件,包括隐藏文件

cp -R 递归地复制文件;当需要复制整个目录时会用到
cp -f 强制复制并覆盖已有的文件,不询问用户
cp -l 链接文件,而不是复制

使用 mv 命令来移动和重命名文件。这个命令的工作方式基本上与 DOS 中的 move 命令一样,不过它可以移动整个目录结构及所有文件。

cat
使用 cat 命令来查看文件的内容。它相当于 DOS 中的 type 命令。它将把文件的内容转储到另一个文件、屏幕或者其他命令。 cat 是concatenate 的简写,还可以将一系列的文件合并为一个大文件。

more
使用命令 more 可以以分页的方式查看文件。它基本上与 DOS 中的 more 命令相同。

less
less 命令也是用来查看文件,但是它支持上下滚屏以及在文档中进行文本搜索。

man
使用 man 命令来查看命令的文档。man 是 manual 的缩写。几乎每一个命令都有相应的文档。要深入了解 man ,请输入以下命令:

man man

info
info 命令与 man 命令类似,不过它提供了超链接文本,可以更方便地浏览文档。

curl -O -L http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

md5sum mysql-5.6.27.tar.gz

md5sum apache-tomcat-8.0.28.tar.gz

sudo tar -zxvf ~/apache-tomcat-8.0.28.tar.gz

sudo rm -r apache-tomcat-8.0.28/

/usr/apache-tomcat-8.0.28/webapps>sudo rm -r examples/

/usr>sudo rm -fr emqttd/

/home/hzg>sudo unzip emqttd-centos64-0.13.0-beta-20151108.zip -d /usr/

/usr/emqttd/bin>sudo ./emqttd console

/usr/emqttd/bin>./emqttd_ctl status

/opt/apache-tomcat-8.0.28/bin>ps -ef | grep tomcat

停止tomcat:
kill -9 2250

查看tomcat日志
/opt/apache-tomcat-8.0.28/logs>tail -n 50 catalina.out

curl -O -L http://download.redis.io/releases/redis-3.0.5.tar.gz

/home/hzg>sudo tar zxf redis-3.0.5.tar.gz -C /opt/

redis的java client
Jedis
lettuce
Redisson

/home/hzg>netstat -tnl | grep 3306

[root@instance-dqg4v0wr-3 ~]# du -sh
36K .

more /etc/passwd

lscpu

free -m

使用 su 或者 sudo -s 命令变为另一个用户
可以使用 whoami 命令来检查您当前有效的 id
可以使用 groups 命令找出您在什么组中

Linux 中的所有用户都存放于 /etc/passwd 文件中。您可以使用 more 命令来分页查看这个文件:
more /etc/passwd

who
功能:列出当前系统注册的用户
$who am i 列出当前系统使用者身份

ps
功能:显示后台进程的有关信息。单独使用ps将显示由
当前终端启动的后台进程的PID、终端号、进程已执行时间以及启动该进程的命令
语法:ps -options
参数说明:
-e:显示系统内当前运行的所有后台进程
-f:除ps所提供的信息外,还显示用户名、PPID(父进程ID)及启动时间
-l:除ps所提供的信息外,还显示 User ID, PPID 和进程优先级

kill
功能:杀死后台进程
语法:kill -num PID

find
功能:在一个或多个目录中查找符合指定条件的文件,
显示文件名或对这些文件进行特定的操作
语法:find path expression

find . –name ‘unix’ –print
find . –name ‘m*’ –exec ls –l {} ;
find . -perm 644 -mtime +4 –print

grep
功能:在文件或标准输入中搜索与指定格式相匹配的行
语法:grep [options] pattern [file1 file 2..]
grep –v mail .profile
grep “^a[0-9]z$” filename
grep a websm.log

vi

:w :保存当前文件
:x:保存当前文件并退出
:q:退出vi
:q! 放弃所做修改直接退出到shell
:q 不退出
ZZ / :x 如果需要保存则保存,之后退出到shell
:w newfile / :w!
:wq 先保存文件,再退出到shell
回车后进行命令模式
在命令模式按a(光标之后)/ A(光标所在行的最后) / i(光标处)/I(光标所在行的开头) / o / O ,进入文本输入模式
在文本输入模式下,按Esc,回到命令模式
末行模式,Ex转义模式: 在命令模式下按:进行末行模式,末行命令执行后自动回到命令模式

插入文本类命令

i :在光标前
I :在当前行首
a:光标后
r:替换当前字符

删除命令

x或X:删除一个字符,x删除光标后的,而X删除光标前的
ndd:删除当前行及其后n-1行
dd 删除当前行

搜索及替换命令

/pattern:从光标开始处向文件尾搜索pattern
?pattern:从光标开始处向文件首搜索pattern
:g/p1/s//p2/g:将文件中所有p1均用p2替换

P vs NP Problem

If it is easy to check that a solution to a problem is correct, is it also easy to solve the problem? This is the essence of the P vs NP question. Typical of the NP problems is that of the Hamiltonian Path Problem: given N cities to visit (by car), how can one do this without visiting a city twice? If you give me a solution, I can easily check that it is correct. But I cannot so easily (given the methods I know) find a solution.

Suppose that you are organizing housing accommodations for a group of four hundred university students. Space is limited and only one hundred of the students will receive places in the dormitory. To complicate matters, the Dean has provided you with a list of pairs of incompatible students, and requested that no pair from this list appear in your final choice. This is an example of what computer scientists call an NP-problem, since it is easy to check if a given choice of one hundred students proposed by a coworker is satisfactory (i.e., no pair taken from your coworker’s list also appears on the list from the Dean’s office), however the task of generating such a list from scratch seems to be so hard as to be completely impractical. Indeed, the total number of ways of choosing one hundred students from the four hundred applicants is greater than the number of atoms in the known universe! Thus no future civilization could ever hope to build a supercomputer capable of solving the problem by brute force; that is, by checking every possible combination of 100 students. However, this apparent difficulty may only reflect the lack of ingenuity of your programmer. In fact, one of the outstanding problems in computer science is determining whether questions exist whose answer can be quickly checked, but which require an impossibly long time to solve by any direct procedure. Problems like the one listed above certainly seem to be of this kind, but so far no one has managed to prove that any of them really are so hard as they appear, i.e., that there really is no feasible way to generate an answer with the help of a computer. Stephen Cook and Leonid Levin formulated the P (i.e., easy to find) versus NP (i.e., easy to check) problem independently in 1971.

Image credit: on the left, Stephen Cook by Jiří Janíček (cropped).   CC BY-SA 3.0

1
Problem Statement. Does P = NP? 

\( \mathcal{P} \) = {L | L = L(M) for some Turing machine M that runs in polynomial time}.

The notation \( \mathcal{NP} \) stands for “Nondeterministic Polynomial time”, since originally NP was defined in terms of nondeterministic machines (that is, machines that have more than one possible move from a given configuration).

To put it more briefly, \( \mathcal{P} \) is the set of easy decision problems. \( \mathcal{NP} \) is the class of decision problems for which it is easy to check the correctness of a claimed answer, with the aid of a little extra information. So we aren’t asking for a way to find a solution, but only to verify that an alleged solution really is correct.

In P are the problems where it’s easy to find a solution, and in NP are the problems where it’s easy to check a solution that may have been very tedious to find.

\(\huge \mathbf{\mathbb{P}} \subset \mathbf{\mathbb{NP}} \tt{?}\)

The crucial question related to P and NP is whether the subset relation is proper?

1
P ⊂ NP? 

很显然的是P类都属于NP类 (\( \displaystyle {\mathsf {P}}\subseteq {\mathsf {NP}} \)),这样问题就变成:是否某些NP类问题(比如旅行推销员问题)不存在多项式时间过程算法? 问题难在如何证明这一点?如何从逻辑上排除旅行推销员问题存在多项式时间过程算法的可能性?这跟黎曼假设的严格数学证明要排除临界线外有复零点的可能性一样困难。

复杂性范畴之间的包含关系:

\(\mathrm{LOGSPACE} \subseteq \mathbf{P} \subseteq \mathbf{NP} \subseteq \mathrm{PSPACE} \)
\(\mathrm{LOGSPACE} \subset \mathrm{PSPACE} \)

LOGSPACE ⊆ P ⊆ NP ⊆ PSPACE,用简单的对角化论证法能够证明 LOGSPACEPSPACE 的真子集,其余的包含关系是否为真包含关系?无人能够证明。

很多研究复杂性理论的专家都认为 P≠NP,Scott Aaronson 从哲学角度发表了他的看法:“如果P = NP,那么我们就会处于一个截然不同的世界中,创造性飞跃将失去其难能可贵的价值,解决一个问题和认识到问题有解没什么分别。任何一个能欣赏交响乐的人都能成为莫扎特,任何一个能理解数学证明的人都能成为高斯…”。(If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in “creative leaps,” no fundamental gap between solving a problem and recognizing the solution once it’s found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss…)。按 Stephen Cook 在白皮书中的说法,如果P = NP,那么机器就能给出克雷数学研究所七大难题的形式化证明,尽管证明会很繁琐很冗长。( If P = NP, …. For example, it would transform mathematics by allowing a computer to find a formal proof of any theorem that has a proof of reasonable length, since formal proofs can easily be recognized in polynomial time. Such theorems may well include all of the CMI prize problems. Although the formal proofs may not be initially intelligible to humans, the problem of finding intelligible proofs would be reduced to that of finding a recognition algorithm for intelligible proofs. Similar remarks apply to diverse creative human endeavors, such as designing airplane wings, creating physical theories, or even composing music. The question in each case is to what extent an efficient algorithm for recognizing a good result can be found. This is a fundamental problem in artificial intelligence, and one whose solution itself would be aided by the NP-solver by allowing easy testing of recognition theories. )

在克雷数学研究所的官方资料中,此问题由 Stephen Cook (创造性地提出 NP-complete 概念并证明The satisfiability problem是NP-完全问题)作出权威解读。

相关的经典论文

数学元素

  • 图灵机(Turing Machine)
  • 可计算性
  • NP-完全:如果图论中的哈密顿回路有类似欧拉回路那样的多项式判定算法,则所有其它NP类问题也都能用多项式时间过程解决

NP-hard 问题

  • 哈密顿回路判定 (Hamiltonian Circuit )
  • 旅行推销员问题 (The Traveling Salesman problem)
  • 背包问题 (The Bin Packing problem)
  • 数独(Sudoku)

专家评论

  • Richard Karp: (Berkeley, unsure, P!=NP) My intuitive belief is that P is unequal to NP,but the only supporting arguments I can offer are the failure of all efforts to place specific NP-complete problems in P by constructing polynomial-time algorithms.I believe that the traditional proof techniques will not suffice. Something entirely novel will be required. My hunch is that the problem will be solved by a young researcher who is not encumbered by too much conventional wisdom about how to attack the problem.
  • Donald Knuth: (Retired from Stanford) It will be solved by either 2048 or 4096. I am currently somewhat pessimistic. The outcome will be the truly worst case scenario: namely that someone will prove “P=NP because there are only finitely many obstructions to the opposite hypothesis”; hence there will exists a polynomial time solution to SAT but we will never know its complexity!
  • Alexander Razborov: (Institute for Advanced Study) Well, this problem is (at the moment) very unique since we seem to be missing even the most basic understanding of the nature of its difficulty. Neither we currently have any ideas of what approach might turn out to be viable and lead us to the solution (or at least to a better understanding of the problem). All approaches tried so far probably (in some cases, provably) have failed. In this sense P=NP is different from many other major mathematical problems on which a gradual progress was being constantly done (sometimes for centuries) whereupon they yielded, either completely or partially. Perhaps, although, the key word in this difference is “century”, and the P=NP problem has simply not aged enough yet (by mathematical standards).
  • Bob Tarjan: (Princeton) In my view, there is no way to even make intelligent guesses about the answer to any of these questions. If I had to bet now, I would bet that P is not equal to NP. I estimate the half-life of this problem at 25 - 50 more years, but I wouldn’t bet on it being solved before 2100. Its solution will require unforeseen new techniques.
  • Avi Wigderson: (Institute of Advanced Study) I think this project is a bit premature. I think we know too little of what is relevant to even guess answers to your questions, certainly if “we” is replaced by “I.”The only thing I can definitely say, is that it is one of the most important and interesting questions ever asked by humans, and more people and resources should participate in filling up the holes that would allow better guesses of answers to your questions.
  • Andrew Yao(姚期智): It’s hard to say when the question will be resolved. I don’t have even an educated guess. Probably the resolution is that P is not equal to NP. I think the mathematical techniques used will be beautiful.
  • Scott Aaronson: Look, this question of whether P=NP, what can I say? People like to describe it as “probably the central unsolved problem of theoretical computer science.” That’s a comical understatement. P vs. NP is one of the deepest questions that human beings have ever asked. And not only that: it’s one of the seven million-dollar prize problems of the Clay Math Institute! What an honor! Imagine: our mathematician friends have decided that P vs. NP is as important as the Hodge Conjecture, or even Navier-Stokes existence and smoothness! (Apparently they weren’t going to include it, until they asked around to make sure it was important enough.) Dude. One way to measure P vs. NP’s importance is this. If NP problems were feasible, then mathematical creativity could be automated. The ability to check a proof would entail the ability to find one. Every Apple II, every Commodore, would have the reasoning power of Archimedes or Gauss. So by just programming your computer and letting it run, presumably you could immediately solve not only P vs. NP, but also the other six Clay problems. (Or five, now that Poincaré is down.) Well, we certainly believe P≠NP. Indeed, we don’t even believe there’s a general way to solve NP problems that’s dramatically better than brute-force search through every possibility. The central challenge any P≠NP proof will have to overcome is to separate the NP problems that really are hard from the ones that merely look hard.

观点

  • P vs. NP 问题的解决可能有赖于大幅度创新的证明技术
  • 堵丁柱 & 葛可一的《计算复杂性导论》前言:
    • 人们在七十年代开始对NP-完全问题的研究主要是横向发展,也就是以许多不同的计算模型来分析难解问题的本质。这些新的计算模型包括了平行计算模型、概率计算模型、布尔线路、判断树、平均复杂性、交互证明系统以及程式长度复杂性等等。对这些新的计算模型的研究一方面使我们对难解问题有了更深一层的认识,一方面也产生了一些预想不到的应用。最显著的一个例子就是计算密码学的革命性突破:基于 NP 问题的公钥密码体系。另一个有名的例子是线性规划的多项式时间解的发现。
    • 到了八十年代中,对NP-完全问题的研究有了纵向的突破,在许多表面看来并不相关的计算模型之间发现了深刻的刻划关系。这些刻划关系不但解决了几个令人困扰多年的未解问题,同时也刺激了其它相关领域的发展。其中之一是对线路复杂性的研究发现了一些问题在某种有限制的线路模型中必有指数下界。这些结果使用了组合数学与概率方法等新的数学工具,并且解决了一个有名的有关多项式分层的未解问题。另一个更重大的结果是以概率可验证明对 NP 类的刻划。由此得出了许多组合优化问题近似解的NP-完全性,从而刺激了算法界对近似算法研究的新热潮。这个结果来自于对交互证明系统这个概念的扩展,并且使用了线性代数与编码理论等数学证明技巧。
  • 1993年 RazborovRudich 证明的一个结果表明,给定一个特定的可信的假设,在某种意义下「自然」的证明不能解决 P vs NP 问题。这表明一些现在似乎最有希望的方法不太可能成功。随着更多这类的定理得到证明,该定理的可能证明有越来越多的陷阱要规避。
  • In 1994, Alexander Razborov and Steven Rudich discovered the natural proofs barrier, which explained why previous attempts to prove P ≠ NP had failed.
  • Razborov and Rudich then proved their main result: A natural proof of P ≠ NP would require a very comprehensive understanding of how easy-to-compute and hard-to-compute functions differ, and that knowledge could also fuel a fast algorithm for spotting easy-to-compute functions even if they’re superficially complicated. If complexity theorists had succeeded in a natural proof of P ≠ NP, they would have discovered a nearly infallible way to glance at an arbitrary truth table and determine whether the corresponding function had high or low circuit complexity — a much stronger and more general result than they had set out to prove.
  • The first attempts at determining the relationship between P and NP used an elegant trick called diagonalization that had been essential for other major results in computer science. But researchers soon realized that any diagonalization-based solution to the P versus NP problem would be self-contradictory. Researchers concluded that they’d need new techniques to make progress.

Substring versus Subsequence

  • Substring : A pattern P is called a substring of Text T if the pattern appears in the Text in a continuous fashion.
  • Subsequence : A pattern P is called a subsequence of Text T if the pattern preserves the relative ordering of characters within the text T and it might not appear in a continuous fashion. e.g., the prime numbers are a subsequence of the positive integers.

  • Subsequence is a generalisation of substring, suffix, and prefix. Finding the longest string which is a subsequence of two or more strings is known as the longest common subsequence problem.

Example: The string “anna” is a subsequence of the string “banana”:

1
2
3
banana
|| ||
an na
  • Substring

A substring of a string is a prefix of a suffix of the string, and equivalently a suffix of a prefix. If one string is a substring of another, it is also a subsequence, which is a more general concept.

Example: The string “ana” is a substring (and subsequence) of banana at two different offsets:

1
2
3
4
5
banana
|||||
ana||
|||
ana

蘭亭集序

書法家王羲之所作

Main text of a Tang dynasty copy of the Lantingji xu, copied by Feng Chengsu, c. 627–650

永和九年,岁在癸(guǐ)丑。暮春之初,会于会(kuài)稽山阴之兰亭,修禊(xì)事也。群贤毕至,少长(zhǎng)咸集。此地有崇山峻岭,茂林修竹,又有清流激湍,映带左右,引以为流觞(shāng)曲水,列坐其次。虽无丝竹管弦之盛,一觞一咏,亦足以畅叙幽情。

是日也,天朗气清,惠风和畅。仰观宇宙之大,俯察品类之盛。所以游目骋(chěng)怀,足以极视听之娱,信可乐也。

夫(fú)人之相与,俯仰一世。或取诸怀抱,悟言一室之内; 或因寄所托,放浪形骸之外。虽趣(qǔ)舍万殊,静躁不同,当其欣于所遇,暂得于己,快然自足,不知老之将至; 及其所之既倦,情随事迁,感慨系之矣。向之所欣,俯仰之间,已为陈迹,犹不能不以之兴怀,况修短随化,终期于尽!古人云:“死生亦大矣”,岂不痛哉!

每览昔人兴感之由,若合一契,未尝不临文嗟悼,不能喻之于怀。固知一死生为虚诞,齐彭殇(shāng)为妄作。后之视今,亦犹今之视昔,悲夫!故列叙时人,录其所述,虽世殊事异,所以兴怀,其致一也。后之览者,亦将有感于斯文。


由林语堂翻译的英文版

Preface to the Poems Collected from the Orchid Pavilion

by Lin Yutang

It is the ninth year of Yonghe (A.C.353), also known as the year of Guichou in terms of the Chinese lunar calendar.

On one of those late spring days, we gather at the Orchid Pavilion, which is located in Shanyin County, Kuaiji Prefecture, for dispelling bad luck and praying for good fortune.

The attendees of the gathering are all virtuous intellectuals, varying from young to old.

Endowed with great mountains and lofty peaks, Orchid Pavilion has flourishing branches and high bamboo bushes all around, together with a clear winding brook engirdled, which can thereby serve the guests by floating the wine glasses on top for their drinking.

Seated by the bank of brook, people will still regale themselves right by poetizing their mixed feelings and emotions with wine and songs, never mind the absence of melody from string and wind instruments.

It is such a wonderful day, with fresh air and mild breeze. Facing upwards to the blue sky, we behold the vast immensity of the universe; when bowing our heads towards the ground, we again satisfy ourselves with the diversity of species.

Thereby we can refresh our views and let free our souls, with luxuriant satisfaction done to both ears and eyes. How infinite the cheer is!

People keep coming and going, and life soon rushes to its end. Some people prefer to share their proud aspiration and lofty goals with close friends indoors, while some others choose to follow their interest and free their minds wherever and whenever they like.

May characters vary from person to person, or some would rather stay peaceful while others like to live restlessly, they will all become delighted and satisfied once they meet something pleasant, so cheerful that they get unaware of their imminent old age.

However, when they get tired of their old fancies that they’ve already experienced, and sentiment correspondingly accompanies the change of situation, all sorts of complicated feelings will well up in the heart, too.

Isn’t it thought-provoking that the happiness we used to enjoy passes by without leaving a single trace, let alone that the length of life is subject to the fate, and death is inevitable for anybody in the end?

Just as some ancient man once put it, “Death also deserves our attention, like what life does.”, so how can we restrain ourselves from grieving?

Every time I ponder about the reasons why our predecessors would produce works with such inenarrable emotions, I find there seem some similarities between our minds.

Yet I cannot help lamenting their literary masterpieces while I am struggling for the very cause in my innermost world. Now I come to realize that it has been ridiculous for me to equate death with life, long life with short life.

The descendents view us just the way we look at our predecessors, and how woeful it is! Hence I write down all the names of the attendees and put their poetry into record.

Conditions may go with the changes of time, but people’s emotions shall stay the same. I believe the following readers will still have much to mediate about life and death when appreciating this poetry anthology.