-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.json
1 lines (1 loc) · 321 KB
/
index.json
1
[{"categories":["技术"],"content":"提示 : 本文翻译了LLVM官方文档中的The LLVM Target-Independent Code Generator一文,主要为个人学习之用。根据个人的理解,删繁就简,所以有些地方跟原文有所出入,幸勿见怪。如果需要更准确的信息,请参照原文。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:0:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 机器无关代码生成算法本节描述代码生成器的各个阶段,描述它们是如何工作的,以及如此设计的背后原理。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 指令选择指令选择是将LLVM IR转换为特定机器指令的过程。学术界有多种指令选择算法,而LLVM使用了基于SelectionDAG的指令选择器。 目前,DAG指令选择器的一部分是由.td文件生成的,另一部分还是需要用C++代码实现。 GlobalISel是另一个指令选择框架,目前还是实验版本。 SelectionDAG简介SelectionDAG提供了一种代码表示方式,对于用自动化的指令选择比较友好。另外,对于指令调度也比较友好。而且在这种表示上还可以做一些很低级的机器无关优化。 SelectionDAG是一种有向无环图,其结点是SDNode实例。SDNode主要包含了操作码和操作数。include/llvm/ISDOpcodes.h文件中描述各种操作节点类型。 实际中大多结点只是定义一个值,但每个结点都有可能定义多个值。比如,一个div/rem操作同时定义了商和余数。很多其他情形也需要多个值。每个结点还有若干操作数,表示为指向定义这些操作数的结点的边。因为结点可能定义多个值,这些边要表示为SDValue实例,即\u003cSDNode, unsigned\u003e序对,SDNode表示来自哪个结点,unsigned表示来自其哪个结果。SDNode产生的每个值都有关联的MVT (Machine Value Type),表示该值的类型。 SelectionDAG包含两种类型的值:表示数据依赖的,表示控制依赖的。数据值就是整数或浮点数类型的边,控制依赖边就是MVT::Other类型的chain边。这些边为有副作用的结点(load/store/call/return)提供了顺序。根据约定,chain输入总是0号操作数,chain输出总是该操作产生的最后一个值。然而,经过指令选择,机器结点也会有在指令操作数后面的chain输入,而且后面可能跟着glue结点。 SelectionDAG指定有Entry和Root结点,Entry结点是一个标记结点,其操作数总是ISD::EntryToken。Root结点是产生最终结果的结点。 对于SelectionDAG,一个重要的概念是合法或非法。合法DAG只使用目标机支持的操作和类型。类型合法化和操作合法化负责将非法DAG转换为合法DAG。 SelectionDAG指令选择过程包含以下步骤: 构建初始DAG:从LLVM IR到非法DAG做一个简单的转换。 优化SelectionDAG:在DAG上做一些简单优化,并识别出目标机上支持的元操作,从而使得后面的转换更简单些。 类型合法化:清除目标机器上不支持的类型。 优化SelectionDAG:消除类型合法化引入的冗余。 操作合法化:清除目标机器上不支持的操作。 优化SelectionDAG:消除操作合法化引入的冗余。 从DAG上做指令选择:将机器无关的DAG输入转换为目标机指令的DAG。 SelectionDAG调度和指令序列化:给DAG中的指令指定一个线性顺序,并输出为MachineFunction。这一步使用了传统的调度技术。 上述步骤完毕后,SelectionDAG被销毁,再运行的其他的代码生成pass。 为方便查看这些步骤发生的事情,可以利用LLC工具的一些选项。 -view-dag-combine1-dags 显示初构建好的DAG。 -view-legalize-dags 显示合法化前的DAG。 -view-dag-combine2-dags 显示在第二步优化前的DAG。 -view-isel-dags 显示在指令选择前的DAG。 -view-sched-dags 显示在调度前的DAG。 -view-sunit-dags 显示调度器的依赖图,该图基于最终SelectionDAG。 -filter-view-dags 可以选择要查看的基本块的名称,并配合上面几个选项一起使用。 初始DAG构建SelectionDAGBuilder类负责从LLVM IR构建SelectionDAG,这个Pass大部分都是硬编码的(LLVM add -\u003e SDNode add, getelementptr -\u003e 显式的算术运算),过程中需要用到机器特定hooks来lower calls, returns, varargs等。 SelectionDAG类型合法化使DAG只使用目标机支持的类型。 将不支持的标量类型转化为支持的类型有两种方式:一种叫promoting,将小类型转为大类型,另一种叫expanding,将大整型分解为几个小整型。 将不支持的vector类型转换为支持的类型也有两种方式:一种是将vector分割,直到找到合法的类型,另一种是通过在末尾添加元素的方式扩展vector,叫expanding。如果一个vector一路到底分割为了单个元素,还没有找到支持的vector类型,那么这些元素就会被转化为标量,叫scalarizing。 目标机实现通过调用TargetLowering中的addRegisterClass方法来告知合法化器它支持哪些类型,对应的寄存器类是什么。 SelectionDAG操作合法化使DAG只使用目标机支持的操作。 目标机通常有古怪的约束,比如不支持某些操作。操作合法化通过用一系列操作来模拟某个不支持的操作(expansion),或者通过将类型提升为更大类型来支持该操作(promotion),或者通过目标特定的hook来实现合法化(custom)。 目标机实现通过调用TargetLowering中的setOperationAction方法来告知合法化器它不支持哪些操作,还有采用以上哪种方式来处理这种情况。 如果目标机有合法的vector类型,肯定希望用这些类型为shufflevector IR指令生成高效机器码,这就需要为shufflevector定制合法化操作。需要处理的形式包括以下几种: vector select: 就两个输入vector中挑选元素组成新的vector,这也叫做blend或者bitwise select。 Insert subvector:vector要放入从index 0开始的一个更长的vector中。 Extract subvector: 从一个长的vector的index 0处拉出子向量。 Splat: vector的所有元素都是同样的标量元素。也叫broadcast或者duplicate。 合法化阶段的引入提供了一种SelectionDAG的标准化形式,并且可以在这种形式上做一些通用优化。 SelectionDAG优化阶段:DAG合并器在代码生成中,SelectionDAG优化会多次运行,包括DAG刚刚构建好,以及每次合法化pass之后。该pass主要是做一些清理工作。一项重要的工作就是优化插入的符号扩展和零扩展指令。目前是使用ad-hoc技术,未来可能会转为使用更严格的技术。 SelectionDAG指令选择阶段这是指令选择过程的与机器有关的主要阶段。该阶段以合法的SelectionDAG为输入,通过模式匹配选择目标机上支持的指令,并输出新的DAG。考虑如下LLVM IR: %t1 = fadd float %W, %X %t2 = fmul float %t1, %Y %t3 = fadd float %t2, %Z 对应的SelectionDAG大致如下: (fadd:f32 (fmul:f32 (fadd:f32 W, X), Y), Z) 如果目标机支持浮点乘累加操作,那么乘和加就可以合并。在PowerPC上,指令选择器的输出大致如下: (FMADDS (FADDS W, X), Y, Z) PowerPC的后端会包含以下指令定义: def FMADDS : AForm_1\u003c59, 29, (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB), \"fmadds $FRT, $FRA, $FRC, $FRB\", [(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC), F4RC:$FRB))]\u003e; def FADDS : AForm_2\u003c59, 21, (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB), \"fadds $FRT, $FRA, $FRB\", [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]\u003e; TableGen DAG指令选择器从.td文件中读取指令模式,并自动构建模式匹配代码。它具有以下优势: 在编译器自身的编译阶段,可以分析指令模式并告诉你该模式是否有意义。 在模式匹配时处理操作数约束。比如,很方便表达\"匹配一个13 bit的符号扩展立即数\"。 知悉关于模式一些重要性质。比如,知悉加法符合交换律。 具有功能齐全的类型推理系统。基本上不需要显式说明模式的每个部分是什么类型的。 目标机可以定义它们自己的模式片段。模式片段就是命名并可重用的模式。 除了指令,目标机还可以利用Pat类指定可以映射到单个或多个指令模式。比如,PowerPC不具有在一条指令中奖任意整型立即数搬到寄存器的方式,那么就可以在tblgen中做如下定义: // Arbitrary immediate support. Implement in terms of LIS/ORI. def : Pat\u003c(i32 imm:$imm), (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))\u003e; 当使用Pat类将一个模式映射为一条具有单个或多个操作数的指令时,该模式要么用C","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 基于SSA的机器码优化TODO ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 活跃区间活跃区间表示一个变量在哪个范围内是活跃的(live)。某些寄存器分配器会根据该信息确定需要相同物理寄存器的几个虚拟寄存器是否在某些程序点上同时活跃,即它们产生了冲突。如果产生了冲突,就要把某个虚拟寄存器溢出(spill)。 活跃变量分析确定变量活跃区间的第一步就是计算指令执行后立即失效的寄存器集合(即指令计算了值,但后续不再使用),和本条指令中使用但后续不再使用的寄存器集合(即被杀死)。需要对每个虚拟寄存器和可分配的物理寄存器计算活跃变量信息,由于可以使用SSA对虚拟寄存器进行稀疏生命期分析,而且只需要跟踪一个基本块内的物理寄存器,这项任务可以很高效地完成。在寄存器分配之前,LLVM假设物理寄存器只在单个基本块活跃,这就使得通过局部分析就可以解析出物理寄存器的生命期。而如果一个物理寄存器不是可分配的(比如栈指针或条件码),就不需要跟踪它。 物理寄存器可能以活跃的状态流入或流出一个函数。流入的值常常是寄存器传递的参数,流出的值常常是寄存器传递的返回值。这些值在活跃区间分析中要打上特殊的标记。 PHI结点需要特殊处理,主要是因为在计算活跃变量信息时,对CFG的DFS遍历无法保证PHI结点使用的虚拟寄存器在使用前定义。当遇到PHI结点时,只处理定义,这是因为其使用会在其他基本块中处理。 对于当前基本块的每个PHI结点,要在当前基本块末尾模拟一个赋值语句并遍历后继基本块。如果后继基本块有PHI结点,且PHI结点的操作数来自于当前基本块,那么该变量就标记为在当前基本块中以及所有的前驱基本块中都是活跃的,直到碰到定义该变量的那个基本块。 活跃区间分析现在有了足够的信息来做活跃区间分析。从给基本块和机器指令编号开始,接着处理流入的活跃值,这些值都是在物理寄存器中,所以在基本块末尾可以认为这些寄存器都死亡了。而对于虚拟寄存器,会计算出一个[i, j)形式的活跃区间,其中i, j都是指令编号。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 寄存器分配寄存器分配问题就是将一个使用无限虚拟寄存器的程序,映射为只使用有限物理寄存器的程序。每个机器架构都有不同数量的物理寄存器,如果物理寄存器不够容纳所有的虚拟寄存器,一些虚拟寄存器就会被映射到内存,这叫spilled virtuals。 LLVM中寄存器如何表示LLVM中物理寄存器用1~1023范围的整数来表示,可以阅读GenRegisterNames.inc文件来查看具体某个架构是怎么编号的,比如查阅lib/Target/X86/X86GenRegisterInfo.inc就可以直到EAX寄存器编号为43,MMX寄存器MM0编号为65。 一些架构含有物理位置相同的寄存器,如X86架构的EAX, AX, AL共享了前8bit。这些物理寄存器在LLVM中标记为别名。可以查阅RegisterInfo.td文件来检查某个架构的哪些寄存器是别名。而且,MCRegAliasIterator类可以枚举出跟某一个寄存器别名的所有物理寄存器。 物理寄存器在LLVM中被分组为寄存器类。同一个寄存器类中的寄存器是功能等价的,可以互换使用。每个虚拟寄存器只能被映射到某个寄存器类中的物理寄存器。例如,X86上,一些虚拟寄存器只能分配到8bit寄存器中。寄存器类用TargetRegisterClass对象描述,要想检查一个虚拟寄存器跟物理寄存器是否兼容,可以使用以下代码: bool RegMapping_Fer::compatible_class(MachineFunction \u0026mf, unsigned v_reg, unsigned p_reg) { assert(TargetRegisterInfo::isPhysicalRegister(p_reg) \u0026\u0026 \"Target register must be physical\"); const TargetRegisterClass *trc = mf.getRegInfo().getRegClass(v_reg); return trc-\u003econtains(p_reg); } 有时为了调试需求,需要改变目标机可用的物理寄存器数量。这项任务必须在TargetRegisterInfo.td中静态完成,RegisterClass的最后一个参数就是寄存器列表,如果需要避免使用某些寄存器,就从这里注释掉。 虚拟寄存器也是用整数表示的。与物理寄存器不同,不同的虚拟寄存器从来不会共享编号。物理寄存器是在TargetRegisterInfo.td中事先定义好的,不能由应用开发者创建,而虚拟寄存器不是这样。为了创建新的虚拟寄存器,可以使用MachineRegisterInfo::createVirtualRegister()方法,它会返回一个新的虚拟寄存器。用IndexedMap\u003cFoo, VirtReg2IndexFunctor\u003e来容纳每个虚拟寄存器的信息。如果需要枚举所有的虚拟寄存器,就使用TargetRegisterInfo::index2VirtReg()方法来找到虚拟寄存器编号: for (unsigned i = 0, e = MRI-\u003egetNumVirtRegs(); i != e; ++i) { unsigned VirtReg = TargetRegisterInfo::index2VirtReg(i); stuff(VirtReg); } 在寄存器分配之前,虽然物理寄存器也有使用,不过指令操作数大部分都是虚拟寄存器。为了检查给定的操作数是否是寄存器,可以用MachineOperand::isRegister()方法。为了获得寄存器的整数编号,使用MachineOperand::getReg()。指令可能定义或使用寄存器。比如ADD reg:1026 := reg:1025 reg:1024使用了寄存器1024和1025,而定义了1026。给定寄存器操作数,方法MachineOperand::isUse()返回该寄存器是否被使用,而MachineOperand::isDef()返回该寄存器是否被定义。 我们将寄存器分配之前存在于LLVM IR中的物理寄存器叫做pre-colored寄存器。这类寄存器用于很多场景,比如,函数调用的参数传递,存储特殊指令的结果。有两类pre-colored寄存器:隐式定义的,显式定义的。后者就是正常的操作数,可以通过MachineInstr::getOperand(int)::getReg()来访问。而要想访问前者,就用TargetInstrInfo::get(opcode)::ImplicitDefs,其中opcode就是该指令的操作码。显式和隐式物理寄存器的重要区别就是后者是每条指令静态定义的,而前者会依赖具体被编译的程序而变化。例如,函数调用总是隐式定义或使用相同的物理寄存器集合。Pre-colored寄存器会给寄存器分配算法施加约束,寄存器分配器必须确保它们在活跃期间都不能被虚拟寄存器中的值所覆盖。 把虚拟寄存器映射为物理寄存器映射有两种方式:一是直接映射,使用TargetRegisterInfo和MachineOperand类中的方法;二是间接影射,依赖VirtRegMap类来插入load/store指令。 直接映射给寄存器分配器的开发者提供了更多灵活性,但是,也更容易出错,并且需要更多的实现工作。程序员需要指明在哪里插入laod和store指令。为了将某个物理寄存器指派给某个虚拟寄存器,用MachineOperand::setReg(p_reg),插入store指令用TargetInstrInfo::storeRegToStackSlot(…),插入load指令用TargetInstrInfo::loadRegFromStackSlot。 间接映射使开发者免于插入load/store指令的复杂性。用VirtRegMap::assignVirt2Phys(vreg, preg)将虚拟寄存器映射为物理寄存器,用VirtRegMap::assignVirt2StackSlot(vreg)将虚拟寄存器映射到内存,并返回映射的那个stack slot位置。如果需要将另一个虚拟寄存器映射到相同的stack slot,要用VirtRegMap::assignVirt2StackSlot(vreg, stack_location)。需要注意的一点是,当使用间接映射时,即便虚拟寄存器映射到了内存,仍然需要将它映射到物理寄存器,在对应值store之前,或reload之后,这个物理寄存器就是保存该值的位置。 如果使用间接映射,在虚拟寄存器映射到物理寄存器或栈槽之后,还需要使用spiller对象防止load/store指令。每个被映射到栈槽的虚拟寄存器在被定义之后都需要store到栈槽中,并在使用之前load回来。spiller的实现会尝试回收利用load/store指令,从而避免冗余。 处理二地址指令LLVM机器码指令一般都是三地址指令,也就是说,最多定义一个寄存器,使用两个寄存器。但是有些架构使用二地址指令,被定义的寄存器同时也是被使用的寄存器中的一个,例如,X86中的ADD %EAX, %EBX表示%EAX = %EAX + %EBX.。 为了生成正确代码,LLVM必须将这类指令转化为二地址指令。LLVM提供了TwoAddressInstructionPass 来处理这种情况,且需要在寄存器分配前调用。调用之后生成的代码不再是SSA形式了,比如,%a = ADD %b %c会被转化为如下代码: %a = MOVE %b %a = ADD %a %c 注意,在LLVM内部,第二条指令被表示为 ADD %a[def/use] %c。 SSA销毁过程在寄存器分配过程中发生的一个重要转换是SSA的销毁。SSA形式简化了CFG上执行的很多分析,但是传统指令集是不实现PHI指令的,因此,为了生成可执行代码,编译器必须将PHI指令替换为等价的其他指令。 消除PHI指令有多种方式,最传统的一种就是用copy指令替换PHI,这也是LLVM采取的策略。SSA销毁算法实现在lib/CodeGen/PHIElimination.cpp中。为了调用该Pass,需要打上PHIEliminationID标识符作为标记,因为寄存器分配器需要它。 指令折叠指令折叠是在寄存器分配期间删除冗余copy指令的优化。比如,以下指令: %EBX = LOAD %mem_address %EAX = COPY %EBX 可以被安全替换为如下单条指令: %EAX = LOAD %mem_address 通过TargetRegisterInfo::foldMemoryOperand(...)方法可以将指令折叠。不过指令折叠时需要小心,折叠后的指令可能跟原始指令有相当大的差别。 内置寄存器分配器LLVM基础设施提供了四种不同的寄存器分配器: Fast — 是debug构建中默认使用的分配器。在基本块级别分配寄存器,尽量将值保存在寄存器中。 Basic — 一种增量的寄存器分配方法。通过启发式算法给寄存器指派活跃范围,每次一个。由于分配期间代码可能被改写,该框架允许分配器作为扩展实现。这并不是一个生产级别的分配器,但是在修复bug时很有用,而且可以作为性能基准。 Greedy — 默认的分配器。在Basic分配器基础上做了高度调优,引入了全局活跃范围分割。该分配器致力于使溢出代码的代价最小化。 PBQP — 基于PBQP的分配器。该分配器将寄存器分配问题建模为PBQP问题,然后使用PBQP求解器解决它,再把答案映射为寄存器的指派方案。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:4","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" Prolog/Epilog代码插入TODO ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:5","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" Compact UnwindTODO: ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:6","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 晚期机器码优化TODO ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:7","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 代码输出代码输出负责将代码生成器中的抽象表示(MachineFunction, MachineInstr等)lower到MC层使用的抽象表示(MCInst, MCStreamer等)。几个不同类合作完成这项任务:机器无关的AsmPrinter类,机器相关的AsmPrinter的子类,以及TargetLoweringObjectFile类。 MC层属于obj文件的抽象,不再有函数、全局变量等概念。相反,它会考虑标号,directive,指令等概念。此时使用的关键类是MCStreamer,它是可以用多种方式实现(输出.s或.o)的抽象API。MCStreamer针对每个directive有一个方法,比如EmitLabel, EmitSymbolAttribute, switchSection等,这都跟汇编级的directive是对应的。 如果对为某个机器实现代码生成器感兴趣,那么徐璈实现三件事情: 首先,需要继承AsmPrinter。该类将MachineFunction向下转换为MC标号。AsmPrinter基类提供了一系列有用的方法和例程,并允许覆盖其向下转换过程。如果想实现ELF,COFF,或者MachO格式的机器,可以复用很多已实现的代码,因为TargetLoweringObjectFile类已经实现了大部分公共逻辑。 其次,需要为你的目标机实现指令打印器。指令打印器以MCInst为输入,将其渲染成文本输出到raw_ostream。这里大部分都可以从.td文件中自动生成,但是仍然需要实现打印操作数的例程。 再次,需要实现从MachineInstr到MCInst的向下转换,常常实现在\u003ctarget\u003eMCInstLower.cpp文件中。这个向下转换过程经常是目标机相关的,负责将跳转表条目、常量池索引、全局变量地址转换为MCLabels。该转换层负责将代码生成器使用的微操作扩展为对应的实际机器指令,生成的MCInsts会交给指令打印器或者编码器。 最后,根据你的选择,你也可以为MCCodeEmitter实现一个子类,将MCInst向下转换为机器码字节和重定位。如果你想要支持.o文件输出,或者想实现一个汇编器,这一步就很重要。 输出函数栈大小信息当TargetLoweringObjectFile::StackSizesSection非空,且设置了TargetOptions::EmitStackSizeSection (-stack-size-section)时,包含函数栈大小元信息的section就会输出。该section包含一个数组,其元素是函数符号值和栈大小组成的有序对。当然栈大小仅包含在函数prologue中申请的栈空间,不包括动态栈申请。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:8","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" VLIW打包器在超长指令字架构上,编译器负责将指令映射到硬件功能单元上。为此,编译器会创建叫做packets或bundles的指令组。LLVM中的VLIW打包器就是完成机器指令打包的机器无关机制。 从指令映射到功能单元典型的VLIW机器指令会映射到多个功能单元。在打包过程中,编译器必须能够推理出一条指令是否能添加到指令包中。由于编译器需要检查所有可能的映射,这个决策过程可能会很复杂。因此,为了缓解这种复杂性,VLIW打包器会解析目标机的指令类,并在编译器构建期间生成表。可以通过机器无关的API查询这些表,来决定一条指令是否要容纳进一个指令包中。 打包表如何生成和使用打包器从目标机的itinerary描述中读取指令类,构建一个DFA来表示指令包的状态。一个DFA包含三个主要元素:输入、状态、转换。DFA的输入集合表示正在被添加到指令包中的指令,状态表示指令所消耗的可能的功能单元。在DFA中,从一个状态到另一个状态的转换发生在给已存在的指令包添加指令时。如果从功能单元到指令的合法映射存在,那么DFA就包含相应的转换。如果转换不存在,就意味着合法的映射不存在,指令不能添加到指令包中。 为了给VLIW机器生成表,需要在Makefile中将TargetGenDFAPacketizer.inc添加为目标。导出的API提供了三个函数:DFAPacketizer::clearResources(), DFAPacketizer::reserveResources(MachineInstr *MI), 和 DFAPacketizer::canReserveResources(MachineInstr *MI).。这些函数允许打包器将一条指令添加到已存在的指令包中,以及检查指令是否能被添加到指令包中。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:1:9","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 实现独立汇编器LLVM支持实现完整的独立汇编器。其大部分代码都是从td文件中生成的。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:2:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 指令解析","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:2:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 指令别名处理指令解析一旦完成,就会进入MatchInstructionImpl函数。该函数做别名处理然后做实际的匹配。 别名处理是将相同指令的不同文本形式处理为一种标准形式。可能实现的别名有多种,下面按照它们被处理的顺序列出来了。通常情况下,你会想用第一种别名机制来满足实际需要,因为它允许更简洁的描述。 助记符别名别名处理的第一步是简单的指令助记符重映射,它就是一种简单的从一种输入助记符到输出助记符的无条件重映射。这种别名不会去看操作数,所以这种重映射必须对给定的助记符的所有形式都适用。助记符别名的定义是很简单的,比如X86如下: def : MnemonicAlias\u003c\"cbw\", \"cbtw\"\u003e; def : MnemonicAlias\u003c\"smovq\", \"movsq\"\u003e; def : MnemonicAlias\u003c\"fldcww\", \"fldcw\"\u003e; def : MnemonicAlias\u003c\"fucompi\", \"fucomip\"\u003e; def : MnemonicAlias\u003c\"ud2a\", \"ud2\"\u003e; 有了这类定义,助记符就可以简单直接地重映射。虽然助记符别名不会看指令内部信息,但是它们会通过Requires子句依赖于全局模式: def : MnemonicAlias\u003c\"pushf\", \"pushfq\"\u003e, Requires\u003c[In64BitMode]\u003e; def : MnemonicAlias\u003c\"pushf\", \"pushfl\"\u003e, Requires\u003c[In32BitMode]\u003e; 该例子中,根据当前指令集,助记符被映射到不同的指令。 指令别名别名处理的最一般步骤发生在匹配时:它提供了匹配器的新形式来匹配特定的指令生成。指令别名有两部分:要匹配的字符串和要生成的指令。例如: def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX16rr8W GR16:$dst, GR8 :$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX16rm8W GR16:$dst, i8mem:$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX32rr8 GR32:$dst, GR8 :$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX32rr16 GR32:$dst, GR16 :$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX64rr8 GR64:$dst, GR8 :$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX64rr16 GR64:$dst, GR16 :$src)\u003e; def : InstAlias\u003c\"movsx $src, $dst\", (MOVSX64rr32 GR64:$dst, GR32 :$src)\u003e; 这展示了一个强大的指令别名例子,根据汇编中存在哪些操作数,以多种不同的方式匹配相同的助记符。指令别名的结果可以包含以不同于目标指令的顺序排列的操作数,并且可以多次使用同一个输入,例如: def : InstAlias\u003c\"clrb $reg\", (XOR8rr GR8 :$reg, GR8 :$reg)\u003e; def : InstAlias\u003c\"clrw $reg\", (XOR16rr GR16:$reg, GR16:$reg)\u003e; def : InstAlias\u003c\"clrl $reg\", (XOR32rr GR32:$reg, GR32:$reg)\u003e; def : InstAlias\u003c\"clrq $reg\", (XOR64rr GR64:$reg, GR64:$reg)\u003e; 这个例子也展示了绑定的操作数只列出一次。在X86后端,XOR8rr有两个输入GR8和一个输出GR8(其中一个输入与输出绑定)。InstAliases 获取一个简化的不重复的操作数列表,指令别名的结果也可以使用立即数和固定的物理寄存器,它们在结果中会被添加为简单的立即数操作数,例如: // Fixed Immediate operand. def : InstAlias\u003c\"aad\", (AAD8i8 10)\u003e; // Fixed register operand. def : InstAlias\u003c\"fcomi\", (COM_FIr ST1)\u003e; // Simple alias. def : InstAlias\u003c\"fcomi $reg\", (COM_FIr RST:$reg)\u003e; 指令别名也可以使用Requires子句来使它们特定于具体的子目标机器。 如果后端支持,指令打印器还可以自动输出别名,而不是被别名的指令。通常这会导致代码更好更易读。如果确实需要被别名的指令,就在InstAlias定义时将0传入作为第三个参数。 ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:2:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":" 指令匹配TODO ","date":"2024-02-06","objectID":"/posts/2024/02/llvm-code-generator-1/:2:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(下)(译)","uri":"/posts/2024/02/llvm-code-generator-1/"},{"categories":["技术"],"content":"提示:本文翻译了LLVM官方文档中的The LLVM Target-Independent Code Generator一文,主要为个人学习之用。根据个人的理解,删繁就简,所以有些地方跟原文有所出入,幸勿见怪。如果需要更准确的信息,请参照原文。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:0:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 简介LLVM的代码生成器是一个框架,提供了一系列可重用组件,将LLVM IR翻译为特定目标机器的汇编指令。包含以下六个组件: 抽象目标机描述接口:关于目标机器的重要属性(不包括这些属性是如何使用的)。位于include/llvm/Target。 用于表示目标机器代码的类:使之足够抽象以便能表达任意目标机的机器代码。位于include/llvm/CodeGen。例如,可以表达\"常量池条目\"和\"跳转表\"的概念。 用于在目标文件(MC层)表示代码的类和算法:可以表达汇编级的概念如:label, section, instruction. 而\"常量池条目\"和\"跳转表\"的概念不在这层表达。 目标无关算法。用于实现不同阶段的本地代码生成,如:寄存器分配、指令调度、栈帧表示。位于lib/CodeGen 对应于抽象机器描述接口的特定机器实现。这些机器描述利用LLVM提供的组件,以及为特定目标机定制的pass,为特定机器构件一个完整的目标生成器。位于lib/Target。 目标无关的JIT组件。该组件本身是目标无关的,但它会利用TargetJITInfo接口来处理目标相关的问题。位于lib/ExecutionEngine/JIT。 后端开发人员需要熟悉目标机描述以及机器代码表示相关的类。若要为新机器添加后端,需要为该机器实现抽象机器描述接口,并理解LLVM IR。若要实现新的代码生成算法,为了其可移植性,必须只依靠来目标机描述和机器代码表示来做。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:1:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 代码生成器中的必需组件要在LLVM框架中增加后端,需要实现的必不可少的接口只有两个:TargetMachine, DataLayout。 这意味着:一方面LLVM能够支持非传统的目标机,比如以C语言为后端,就不需要寄存器分配、指令选择等阶段;另一方面可以设计实现出完全不同的不需要用LLVM内置组件的代码生成器,比如针对FPGA。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:1:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 代码生成器的高层设计设计代码生成器是为了支持寄存器微处理器的高效高质量代码生成。代码生成包含以下阶段: 指令选择:将LLVM IR转换为目标指令DAG。该DAG使用SSA形式的虚拟寄存器,以及与目标约束或调用约定相关的特定物理寄存器。 调度和生成序列化指令:以SelectionDAG为输入,决定指令顺序,并输出MachineInstr机器指令。 基于SSA的机器代码优化:比如modulo-scheduling和窥孔优化。 寄存器分配:将无限的虚拟寄存器映射到具体的物理寄存器,在必要时生成spill code。 插入prolog/epilog:一旦机器码生成完毕,栈空间需求量确定,就可以插入prolog/epilog。帧指针消除和stack packing也是在这阶段做的。 晚期机器码优化:比如spill code scheduling和窥孔优化。 代码输出:可以是汇编格式或二进制格式。 指令选择是基于最优化的模式匹配选择器做的。 具体后端的实现可以在这些阶段中任意插入自己特定的Pass。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:1:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 用TableGen描述目标机器机器描述类需要关于目标架构的详细描述。为了提取出关于机器描述的公共部分,LLVM使用TableGen语言来描述目标机器,来减少重复。 随着LLVM继续发展,会将越来越多机器描述移到td文件中。这样可以使移植后端更容易。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:1:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 目标机描述类(include/llvm/Target)提供了目标机器的抽象描述。例如:指令、寄存器 所有的机器描述类(除了DataLayout)都是要被具体机器的实现继承的。TargetMachine类提供了需要被目标机实现的访问器。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetMachine类提供了用于访问不同机器描述类的虚函数(getInstrInfo, getRegisterInfo, getFrameInfo)。具体机器(X86TargetMachine)实现这些虚函数。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" DataLayout类该类是唯一必需的机器描述类,且不可被继承。该类用来说明目标机针对不同数据类型的内存布局、对齐要求、指针size、大小端等信息。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetLowering类给指令选择使用,主要用于描述LLVM IR代码是如何lower到SelectionDAG。此外还用来指定: 针对不同数据类型的register class 目标机器支持的操作 setcc操作的返回类型 用于表示Shfit amount的类型 一些高层特性,如将常量除法替换为乘法序列是否有收益 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetRegisterInfo类该类描述目标机的寄存器集合以及这些寄存器之间的相互作用。 寄存器是用无符号整数表示的。需注意寄存器0保留为flag值。 处理器描述中的每个寄存器都有一个关联的TargetRegisterDesc条目,该条目提供了寄存器的文本名字以及一系列别名。 TargetRegisterInfo类还暴露了处理器特定的寄存器类,每个寄存器类都有相同属性。指令选择器创建的每个SSA虚拟寄存器都有一个关联的寄存器类。寄存器分配时,虚拟寄存器被相关联的寄存器类中的一个物理寄存器所替代。这些寄存器类都是通过TableGen自动生成的。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:4","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetInstrInfo类该类描述目标机支持的指令。定义了opcode对应的助记符、操作数数量、隐式使用和定义的寄存器、是否具有一些机器无关的属性(访问内存、满足交换律等)和机器相关的flag。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:5","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetFrameLowering类提供关于目标机器堆栈布局的信息。包含堆栈的增长方向,每个函数的堆栈对齐要求,局部变量区域的偏移位置。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:6","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetSubtarget类提供目标机器的特定子芯片的信息。包括该子芯片支持的指令、指令延迟、指令指令itinerary(使用的的处理单元、顺序以及时长)。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:7","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" TargetJITInfo类定义了给JIT代码生成器的抽象接口,来处理机器相关的活动,如发射stub。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:2:8","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 机器码描述类llvm使用MachineFunction, MachineBasicBlock, MachineInstr (include/llvm/CodeGen) 几个类来表示机器码,这几个类本身是机器无关的,将代码表示成抽象形式的指令:一个操作码加几个操作数。这种表示既支持SSA形式,也支持寄存器分配后的非SSA形式。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:3:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MachineInstr类将机器指令表示为MachineInstr的实例。MachineInstr表达指令的方式相当抽象,只记录操作码和一系列操作数。 操作码就是一个简单的无符号整数。目标机的所有指令都应该定义在InstrInfo.td中。操作码的枚举值就是从这些定义中生成的。MachineInstr类并不包含对应指令的语义信息(这些信息在TargetInstrInfo类中)。 操作数可以有几种类型:寄存器引用、常量整数、基本块引用等。另外,还需要将操作数标记为def或use。根据约定,操作数中寄存器def必须出现在use之前(不管最终的汇编码是否如此)。 使用MachineInstrBuilder.h中的函数可以使用BuildMI (include/llvm/CodeGen/MachineInstrBuilder.h)来创建机器指令。用法如下: // Create a 'DestReg = mov 42' (rendered in X86 assembly as 'mov DestReg, 42') // instruction and insert it at the end of the given MachineBasicBlock. const TargetInstrInfo \u0026TII = ... MachineBasicBlock \u0026MBB = ... DebugLoc DL; MachineInstr *MI = BuildMI(MBB, DL, TII.get(X86::MOV32ri), DestReg).addImm(42); // Create the same instr, but insert it before a specified iterator point. MachineBasicBlock::iterator MBBI = ... BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), DestReg).addImm(42); // Create a 'cmp Reg, 0' instruction, no destination reg. MI = BuildMI(MBB, DL, TII.get(X86::CMP32ri8)).addReg(Reg).addImm(42); // Create an 'sahf' instruction which takes no operands and stores nothing. MI = BuildMI(MBB, DL, TII.get(X86::SAHF)); // Create a self looping branch instruction. BuildMI(MBB, DL, TII.get(X86::JNE)).addMBB(\u0026MBB); 若要增加额外的def操作数,必须要显式标记出来。 MI.addReg(Reg, RegState::Define); 固定用途寄存器代码生成器需要知道哪些寄存器是有固定用途的。指令流里面常常需要把特殊值安排在特殊寄存器中,比如由于指令集的限制,X86需要用EAX/EDX来做32位除法,再比如调用约定产生的特殊约束。在这些情况下,指令选择器会生成代码将虚拟寄存器拷入或拷出到物理寄存器。比如以下LLVM代码: define i32 @test(i32 %X, i32 %Y) { %Z = sdiv i32 %X, %Y ret i32 %Z } 会被转换为如下的机器码: ;; Start of div %EAX = mov %reg1024 ;; Copy X (in reg1024) into EAX %reg1027 = sar %reg1024, 31 %EDX = mov %reg1027 ;; Sign extend X into EDX idiv %reg1025 ;; Divide by Y (in reg1025) %reg1026 = mov %EAX ;; Read the result (Z) out of EAX ;; Start of ret %EAX = mov %reg1026 ;; 32-bit return value goes in EAX ret 不过在最后,寄存器分配器会将冗余的寄存器拷贝操作删除,生成如下代码: ;; X is in EAX, Y is in ECX mov %EAX, %EDX sar %EDX, 31 idiv %ECX ret 这种方法对任何目标机都适用。需要注意的是,为了高质量的代码生成,物理寄存器的生命周期要短,而且所有的物理寄存器在进入基本块和离开基本块时是dead的(在寄存器分配之前如此)。因此,如果需要一个值的活跃期跨越基本块,必须活跃于虚拟寄存器中。 函数调用会破坏的寄存器一些机器指令会破坏大量的物理寄存器,,比如函数调用。这时就需要用MO_RegisterMask来将它们标记出来,MO_RegisterMask能够标记出哪些寄存器是在函数调用中被保护的,而除此之外的其他寄存器就默认是被破坏了。 SSA形式的机器码MachineInstr在寄存器分配之前都保持着SSA形式。LLVM PHI结点变成了机器码PHI结点,而虚拟寄存器只允许有一个def。在寄存器分配之后,代码中就不存在虚拟寄存器了,机器码也不再是SSA形式了。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:3:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MachineBasicBlock类包含一个机器指令(MachineInstr)列表。大致跟LLVM IR中的基本块是对应的,不过也有可能一个LLVM IR基本块对应多个MachineBasicBlock。其中有一个getBasicBLock方法,可以返回对应的LLVM IR基本块。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:3:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MachineFunction类包含一个MachineBasicBlock列表。跟LLVM IR中的函数是对应的。除了MachineBasicBlock列表之外,每个MachineFunction还包含一个MachineConstantPool, 一个MachineFrameInfo, 一个MachineFunctionInfo, 一个MachineRegisterInfo。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:3:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MachineInstr指令包可以将一个指令序列视为MachineInstr指令包。这种指令包可以建模包含任意数量并行指令的VLIW指令,也可以建模无法分割的一个执行序列,如ARM Thumb2 IT block。 在概念上,一个MI指令包就是一个MI内部嵌套了几个其他MI。 -------------- | Bundle | --------- -------------- \\ | ---------------- | | MI | | ---------------- | | | ---------------- | | MI | | ---------------- | | | ---------------- | | MI | | ---------------- | -------------- | Bundle | -------- -------------- \\ | ---------------- | | MI | | ---------------- | | | ---------------- | | MI | | ---------------- | | | ... | -------------- | Bundle | -------- -------------- \\ | ... 内部的MI会打上InsideBundle标志。具有特殊BUNDLE操作码的顶层MI用来表示指令包的开头。 关于MachineInstr的Pass是将MI指令包作为基本单元来操作的。MachineBasicBlock的迭代器就是如此。正因如此,MachineBasicBlock还提供了另外一个迭代器instr_iterator,可以遍历基本块的所有MI指令。顶层BUNDLE指令必须具有正确的寄存器 MachineOperand 集合,这些寄存器表示捆绑指令(bundled MIs)的累积输入和输出。 对于VLIW架构,MachineInstr的打包是寄存器分配的一部分。具体说,决定哪些指令打包在一起的pass应该在代码从SSA形式退出之后做,需要在虚拟寄存器改写为物理寄存器之后完成。这就不再需要将虚拟寄存器操作数添加到BUNDLE指令中。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:3:4","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MC层MC层用来表示和处理原始机器码级别的代码,已经不再存在诸如常量池、跳转表、全局变量等高层次的概念。在MC层,LLVM处理诸如label名称,机器指令,目标文件中section等。这层的代码有几个重要目的:代码生成器用它生成.s或.o文件,llvm-mc工具用它实现独立的机器码汇编器和反汇编器。 以下讲述几个重要的相关类: ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:0","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MCStreamer API最好将MCStreamer看做是汇编器API,它是抽象的,可以用不同方式实现,比如生成.s、生成.o就是不同的方式。MCStreamer对于每种directive都有一个方法,比如EmitLable, EmitSymbolAttribute, switchSection, emitValue等,这些都对应着汇编级别的概念。还有一个EmitInstruction方法,用来输出MCInst。 这套API有两个重要的客户:llvm-mc独立汇编器和代码生成器的代码发射阶段。 MCStreamer有两个主要的实现:一个用来输出.s文件,另一个用来输出.o文件。输出.o文件的MCObjectStreamer实现了一个完整的汇编器。 对于目标机器特定的directive,MCStreamer有一个MCTargetStreamer实例,一个目标机如果需要实现特定的directive,那么就需要从该类继承。这个自定义的子类需要对每个directive定义一个方法,同时还需要定义两个子类,分别生成asm和obj。 目标机的初始化代码还需要调用TargetRegistry::RegisterAsmStreamer和TargetRegistry::RegisterMCObjectStreamer将对应的streamer进行注册。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:1","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MCContext类该类是MC层各种数据结构的所有者,包括symbols, sections等。若要创建symbol和section,就要与该类交互。该类不可被继承。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:2","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MCSymbol类该类代表汇编文件中的一个symbol (aka label)。symbol有两种:汇编器临时symbol、正常symbol。汇编器临时symbol是被汇编器使用并处理的,并在生成obj文件时被丢弃。常见的做法是在label名前加前缀以示区别。 MCSymbol是被MCContext创建的,并保证唯一性。这意味着两个MCSymbol可以通过比较指针是否相等来判断同一性。但是指针不相等却不能保证它们最终映射到不同的地址。如下的输出在.s文件中是合法的: foo: bar: .byte 4 这种情况下,foo和bar具有相同的地址。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:3","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MCSection类该类代表一个obj文件的section。可以被继承以实现各种不同格式的obj文件,如ELF。它是被MCContext创建的并保证唯一性。MCStreamer中有当前section的概念,可以通过SwitchToSection来改变当前section(这个概念与.s文件中的.section directive相当)。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:4","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" MCInst类该类是一条指令的机器无关表示。这是一个很简单的类(相对于MachineInstr来说),只包含了特定机器的操作码和一系列MCOperands。而MCOperand只是一个包含了三种情况的union:1) 简单立即数 2)寄存器ID 3) 符号表达式MCExpr(如Lfoo-Lbar+42) ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:5","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":" 目标文件格式MC层的obj文件输出器支持多种obj格式。实际上每个目标机支持的格式仅仅是MC层提供的子集。大部分机器支持ELF格式,而其他机器可能还有它们自己定义的格式。 ","date":"2024-02-05","objectID":"/posts/2024/02/llvm-code-generator-0/:4:6","tags":["LLVM","编译器","后端","代码生成"],"title":"LLVM目标无关代码生成器(上)(译)","uri":"/posts/2024/02/llvm-code-generator-0/"},{"categories":["技术"],"content":"LLVM IR中有两个特殊的关键字:undef和poison,它们分别代表两种特殊的常量,是常见的编程语言中没有的概念。 undef用来表示该常量有可能取任意值,这有利于编译器做优化,因为编译器可以用任意值来替代undef。 需要注意的是,undef的取值可以在其活跃范围内随时变化,这会带来一些违反直觉的结果。比如: %A = undef %B = xor %A, %A 与之等价的是 %B = undef ,而不是直观上的 %B = 0 。 poison用来表示错误操作的结果。 典型的例子是,带有nsw/nuw flag的add指令,如果结果溢出,就会产生poison结果。 对于大多数指令(除了select),如果有一个操作数是poison,那么其结果也是poison。 与undef和poison密切相关的一条指令是freeze,它是用来停止undef/poison的传播的。 如果其操作数是undef/poison,那么其结果就变成了固定值(具体是多少是任意取的);如果是其他操作数,则相当于一条nop。比如: %A = undef %B = freeze %A %C = xor %B, %B 这段代码的执行结果会是: %C = 0 。 从语义角度看,poison是比undef更「强」的概念。 在能使用poison的地方,用undef来替代是安全的,反之则不然。 而从有利于优化的角度来看,应该尽可能使用poison,因为这相当于让编译器看到了更「具体」的信息,可以做更激进的优化。 ","date":"2024-02-01","objectID":"/posts/2024/02/llvm-undef-poison/:0:0","tags":["LLVM","编译器","undef","poison"],"title":"笔记-LLVM IR中的undef和poison","uri":"/posts/2024/02/llvm-undef-poison/"},{"categories":["技术"],"content":" refs https://llvm.org/docs/LangRef.html#undefined-values ","date":"2024-02-01","objectID":"/posts/2024/02/llvm-undef-poison/:1:0","tags":["LLVM","编译器","undef","poison"],"title":"笔记-LLVM IR中的undef和poison","uri":"/posts/2024/02/llvm-undef-poison/"},{"categories":["读书"],"content":"人是社会性动物,要在这个社会上生存,显然无法避开人际关系这个课题。而要创造良好的人际关系,就必须学会沟通。 不管是日常生活中的交朋友、谈恋爱,还是工作中的合作共赢,抑或是读书写作,只要需要与人打交道,就需要沟通。 可以说,沟通涉及到生活的方方面面,沟通能力的高低,直接或间接影响着我们的生活质量和幸福感,其重要性不言而喻。 《沟通的艺术》是一本专门讨论「沟通」的心理学书籍,它被多次再版(目前最新版是第15版),足见其受到的认可程度。 沟通能力,尽管受到许多先天因素的影响,但是其中仍然有不少技巧是可以通过学习而掌握的。如果你想提高沟通能力,不妨看看这本书。 ","date":"2024-01-30","objectID":"/posts/2024/01/reading-art-of-communication/:0:0","tags":["沟通","方法论","人际关系"],"title":"读《沟通的艺术》","uri":"/posts/2024/01/reading-art-of-communication/"},{"categories":["读书"],"content":" 为什么要沟通该书第一章对「为什么要沟通」有更详尽的描述,从更科学的角度说明了沟通的重要性。 生理需求 沟通质量会直接影响我们的身体健康。 认同需求 我们在人际沟通中认识自己,知道「我是谁」。 社交需求 积极的关系是我们生活满足感和情绪幸福感的重要来源。 实际目标 沟通是我们完成具体任务(如工作)所需要的,良好的沟通能够使我们更有效率达到目标。 马斯洛把人的需求划分为五个层次:生理需求、安全需求、社交需求、自尊需求、自我实现需求。显然,沟通能力对于实现各个层次的需求都是必要的。 ","date":"2024-01-30","objectID":"/posts/2024/01/reading-art-of-communication/:1:0","tags":["沟通","方法论","人际关系"],"title":"读《沟通的艺术》","uri":"/posts/2024/01/reading-art-of-communication/"},{"categories":["读书"],"content":" 沟通高手是什么样的要想成为沟通高手,首先要看看沟通高手有哪些突出的特质,以便在我们自己练习时明确努力的方向。 以下列举了沟通高手具有的一些特质,以及对于每项特质的提高,我们需要在哪些方向上努力。我们可以反省一下自己在这些方面是否有不足,然后针对自己的不足,在实践中刻意练习。 拥有多样化的行为资料库 用心观察,归纳总结 挑选恰当行为的能力 考虑三个因素:当时的具体情境/自己的目的/对对方的认知 表现行为的技巧 刻意练习,孰能生巧 认知复杂度 知觉核验 描述对方的行为,列出关于此行为的至少两种可能的诠释,请求对方对行为诠释作澄清 枕头法 从多个角度看问题:我对你错,你对我错,双方都有对有错,这个议题不重要,前面几个立场都有道理 同理心 倾听技巧 重在搜集信息和提供支持:借力使力/问话/释义/支持 重在提供指示和评断:分析/忠告/评断 倾听应考虑的因素:性别/情境/对方和自己的反应风格 自我监控:以超然的眼光看待自己的所作所为 承诺:对沟通的重视意愿 以上是我的摘录,也是我认为该书的精华所在。如果你想了解更多,请直接读原书,很值得一读。 ","date":"2024-01-30","objectID":"/posts/2024/01/reading-art-of-communication/:2:0","tags":["沟通","方法论","人际关系"],"title":"读《沟通的艺术》","uri":"/posts/2024/01/reading-art-of-communication/"},{"categories":["工具"],"content":"软件开发工作中,用ssh登录后在远程机器上操作,常常需要从远程机器上往本地复制文本。如果是小段的文本,一般在终端选中即可在本地粘贴;但是如果是大段的文本(超过一个屏幕),就没法一次性选中,复制操作变得很麻烦。这里提供一种方法,利用ssh reverse tunnel,可以很方便地将远程大段文本拷贝到本地。 基本思路是:在本地开启一个服务,其监听端口为5689,这个服务持续地将接收到的文本拷贝到剪贴板;利用ssh reverse tunnel将远程机器上的5689端口与本地的5689端口连接起来;在远程机器上,将需要复制的大段文本发送到其5689端口,这段文本就会出现在本地机器的剪贴板里。 ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:0:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["工具"],"content":" 本地开启服务命令行中执行以下代码: while (true); do nc -l -p 5689 | xclip -selection c; done 启动netcat监听5689端口,将接收到的任何数据拷贝到剪贴板,然后继续监听。 现在,可以在本地测试一下效果: echo \"send me to local clipboard\" | nc -q0 localhost 5689 # -q0 是为了去除文本末尾的eof ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:1:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["工具"],"content":" 将服务暴露给远程机器ssh reverse tunnel 可以在远程机器和本地机器之间建立一个通道,在远程机器和本地机器各指定一个端口,并将它们连接在一起,这是通过-R参数实现的。 ssh user@remote-server.com -R 5689:localhost:5689 也可以将此配置写入.ssh/config,在对应的host条目里添加下面这行,以后登录ssh都会自动建立这个通道。 RemoteForward 5689 localhost:5689 现在,可以在远程机器上执行以下命令测试一下效果: echo \"send me to local clipboard\" | nc -q0 localhost 5689 ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:2:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["工具"],"content":" 从远程机器发送文本经过以上步骤,只要在远程机器上将数据发往其5689端口,数据就会出现在本地剪贴板了。不过我最常用的场景是在vim中复制文本,把这部分操作进一步简化就很有必要了。为此,我在.vimrc中添加如下代码: \" :CL copy from remote ssh to local command! -range CL execute '\u003cline1\u003e,\u003cline2\u003ew !nc -N localhost 5689' 添加了一个自定义命令CL,执行这个命令时,被选中的文本就会发送到5689端口,进而传回到本机的剪贴板。 如此,当我在远程机器上的vim中想要复制文本时,我就先选中这段文本,然后执行命令:CL,接下来就可以从本地机器的剪贴板粘贴了。 ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:3:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["工具"],"content":" 更进一步在远程机器的.bashrc中设置以下命令: ncp() { nc -N localhost 5689 } cp2l() { base64 $1 | ncp } 在本地机器的.bashrc中设置以下命令: function cp2l { xclip -selection c -o | base64 -d \u003e $1 } 这样,分别在远程和本地机器上执行以下命令(会利用base64工具的编码和解码功能): cp2l file 就可以将远程机器上的file文件复制到本地了。 ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:4:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["工具"],"content":" 参考 https://gist.github.com/dergachev/8259104 https://qbee.io/misc/reverse-ssh-tunneling-the-ultimate-guide/ ","date":"2024-01-26","objectID":"/posts/2024/01/copy-remote-text-to-local/:5:0","tags":["问题记录"],"title":"利用ssh reverse tunnel从远程向本机复制文本","uri":"/posts/2024/01/copy-remote-text-to-local/"},{"categories":["生活"],"content":"时光易逝,伟业难成。写此总结,回顾2023,以挥别过去,喜迎将来。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:0:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 健康 饮食。多数时候能够做到食不过饱,饮不过量,会有意识地多吃蔬菜,平时常备坚果、维生素片、鱼油等补充,注重营养均衡。偶尔比较放纵,不过尚不影响大局。体重近期有反弹倾向,需要注意控制。尤其需要注意少油少盐少糖。 运动。运动保持在还可以的状态,在条件允许时,坚持推进了长征计划。美中不足的是,天冷之后户外跑步不太方便。相比于围着园区慢跑,我还是更喜欢换上运动装,出去大汗淋漓一场。近期重新捡起了八段锦,但时有时无,应加大频率。无氧运动中断了,需要捡起来,卷腹、俯卧撑、深蹲均可,这些活动室内就可以做。平时精力都还不错。上班期间常常一坐就是很久,对颈椎、腰椎、视力都不好,应该隔半小时站起来活动一下,养成习惯。 睡眠。熬夜还是比较严重,多数时候要到1点才睡着。早上一般8点多起,天冷之后有赖床倾向。总的睡眠时间还算够,整体睡眠质量也还不错,白天基本不困。睡眠是典型的越想控制越做不好的事情,怎么办?顺其自然吧。慢慢把入睡时间往前提一点。 打坐。今年打坐的次数很少,屈指可数。作为最好的大脑保健项目,我觉得还是需要捡起来。两点需注意,一是心要静,二是不需要追求时间多长,三五分钟即可,太高的目标难以坚持,失败了打击积极性,于长远是不利的。 心态。论对健康的影响,还是心态最大。这些年经过自己的摸索,以及周老师的指导熏陶,我对治心方法还算有些心得。去年总体上保持心态良好,在最困难的日子里,也保证自己不至于崩溃。有时还是会有焦虑,但总体可控,也能很快调节。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:1:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 工作五月份跟同事朋友约饭告别,离开前公司。七月份开始到南京上班,做NPU编译器方面的工作。摆脱了上一段工作的束缚,颇有点「海阔凭鱼跃,天高任鸟飞」的感觉。 入职后的半年,工作内容主要集中在LLVM,也看了几本LLVM相关书籍,现在基本上对LLVM后端比较熟悉了,遇到问题能够很快解决了。另外还学习了陈天奇的MLC课程,在工作中也看了一部分TVM源码,对深度学习工具链有了一定的认识。今后会在这一领域深耕。 这个过程中,对于职业生涯有了更多的思考,期间看了几本书,远见、权力与领导力、软技能给了我很大的启发。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:2:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 家庭 入职前待在家的一个多月,学会了一些家常菜的做法。今后不怕会饿死了\\^o^/。另外,亲手做饭给亲爱的人品尝,并得到认可,真的是一件超有幸福感的事! 入职前回了趟老家,刚好老爸生病了,在医院陪着照顾几天。父母年纪渐渐大了,身体难免会出问题,希望趁着有机会多为他们做些事情,少留遗憾。 十一月份办了婚礼。现在想来,婚礼前和老婆一起准备的场景,婚礼中各个环节的身心参与,都宛如发生在昨日。婚礼时各路亲朋好友咸来祝贺,希望他们玩得开心。当时无比认真地写了誓言卡,读了誓言卡,尽管已经无数次预想过婚礼上的各种场景,在实际参与的时候,仍然体会到了诸多感动。从此,木棉和橡树,根紧握在地下,叶相触在云里。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:3:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 技能 C++。C++是开发LLVM时使用的主要语言,另外还读了两本书《C++程序设计语言(第 1 - 3 部分)》《C++ 程序设计语言(第 4 部分:标准库)》,是C++作者写的,相当不错。 Python。在给TVM写测试时用了Python,读了懒猫推荐的这本《Python核心编程》。 Vim。在服务器上写代码,我都是用Vim作为编辑器。像LLVM这样的大型项目,使用Vim加上一些插件,完全可以胜任,操作起来特别方便。 tmux。也是在服务器上做软件开发的神器。 chatgpt。AI时代来临,在工作中开始越来越多地使用chatgpt。以前需要使用搜索引擎的地方,很多都可以用chatgpt更快速更准确的得到答案,效率提高了一大截。 笔记。更多地使用flomo做各种笔记,看了少楠写的《笔记的方法》,对自己的笔记系统做了一些调整。另外也在用纸笔做子弹笔记。 写作。看了两本小书《文心》《文章作法》。平时看文章开始留意他们的写作技巧。开始学习《古代汉语》。 治心。全年参与了「节气生活修行」。虽然参与时没有特别认真,但是有个长者经常在耳边提醒着「生活不止眼前的苟且,还有诗和远方」,对我也是挺有帮助的。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:4:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 旅行 一月份,到良渚遗址公园玩,参观了良渚博物馆。 四月份,乘船游西湖,上岸后去了太子湾公园,赶上了末班郁金香的盛开。四月底在亚运会体育馆现场看了张信哲演唱会,是平生看的第一场演唱会。 五月份,去新疆伊犁自驾游,驰骋于辽阔的大西北,看到了绝美的赛里木湖,邂逅了五月的大雪纷飞。 六月份,去了绍兴,看了周恩来祖居和王阳明故居;去了湘湖,游船赏荷,然后参观了跨湖桥遗址博物馆;回了趟老家,在陪在医院的老爸的间隙,骑着电动车把小县城足足转了几圈,看了西平宝岩寺塔、小洪河公园、嫘祖文华苑。 八月份,一个闲适的下午,散步于位于西溪湿地的太极禅苑。 十月份,在杭州半山上远眺。十月末,趁着去成都出差的机会,独自去了乐山、峨眉山(乐山峨眉山之旅),看到了壮丽的峨眉日出。 十一月份,趁着在宜兴办婚宴的机会,游玩了龙背山公园,看到了壁画上那些风光一时的佳人才子们,他们也消失在历史的长河中,很难不有所感慨。带父母逛了玉泉校区,看到了曾经的宿舍、曾经的食堂、曾经的教室。 十二月份,参观了南京博物院。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:5:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 读书观影 读书。读了65本书,其中20本专业书,其他涉及佛学、心理学、语文、传记、理财、思维方法等各若干。就不一一列举了。 观影。看了18个影视作品,大多是电影,少量纪录片、电视剧。 ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:6:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["生活"],"content":" 2024展望给自己的最大祝愿是:不要怕犯错。培养勇气的唯一途径是直面挑战,直面恐惧。 引用作家尼尔.盖曼在2011年的新年祝福: 希望在新的一年里,你可以多多犯错。 因为当你犯错时,意味着你正在创造崭新的事物,尝试崭新的可能,你在汲取,跃动,让自己前行,也让自己改变,甚至也把自己所生活的世界撬动。你在尝试一些此前从未做过的事情,更重要的是,你在做一些事情。 所以这是我对你的新年祝福,也是对我们所有人的祝福:犯一些崭新的错误,犯一些灼目耀眼的错误,一些令人瞠目结舌的错误,一些别人还未曾犯过的错误。不要望而却步,不要就此打住,不要担心它不够好,不够完美无缺,无论这错误是什么:艺术,爱,工作,家庭还是生活。 无论它是你恐惧的任何事,迎头直上。 祝福你在新的一年,勇于犯错,接下来每一年也是如此。 愿所有人都能被温柔以待~ ","date":"2024-01-18","objectID":"/posts/2024/01/summary-2023/:7:0","tags":["总结"],"title":"2023总结","uri":"/posts/2024/01/summary-2023/"},{"categories":["思维"],"content":"关于人生的意义,《活出生命的意义》一书中说:“人不应该问他的生命之意义是什么,而必须承认是生命向他提出了问题。简单地说,生命对每个人都提出了问题,他必须通过对自己生命的理解来回答生命的提问。”你会如何回答这个问题呢? 于我而言,人生中最重要的是体验,体验到一种成就感、意义感、幸福感。回顾我自己的人生经历,结合对历史上我所敬佩的那些人的观察,我发现我长久以来孜孜以求的,就是这几种感觉。当我通过运用自己的能力,做好一件事,或者完成一件作品,我会体验到一种成就感,这种成就感会给我长久的满足。当我知道我为什么做一件事,知道我做的事情会对他人产生正面影响,我会感到这件事是有意义的,这种意义感也会给我长久的满足。这些都是幸福感的重要来源。相反,如果做事时常常挫败,或者不知道自己做的事是为了什么,就很容易陷入沮丧和消沉。 那么怎么更多获得这样的正面体验呢?根据著名的马斯洛需求层次理论,越高层次需求的满足,特别是自我实现,越能给我们带来成就感、意义感和幸福感。而自我决定论指出,人的三种内在动机包括自主感、胜任感和归属感,当我们在做一件事的过程中,感到这件事不是被迫做的,感到自己有足够的能力做好这件事,感到做好这件事能给他人带来正面影响,我们就会由衷地感到满足。我们应该尽可能多做这样的事情。 《象与骑象人》指出,幸福的两大原则是:进展原则和适应原则。进展原则是说,达到目标后的幸福是短暂的,朝着目标不断前进比达到目标更幸福。适应原则是说,从长远来看,我们总会适应所遇到的“顺境”或“逆境”。因此不可能存在一个能永保幸福的标准,不可能说得到了某件事物,做成了某件事情,就保证幸福了。在我们的一生中,我们必须不停地做事情,制定目标,全力以赴去实现目标。但是须谨记,应该在这整个过程中去体验幸福感,而不是寄希望于达成目标的那一刹那。 如何看待世俗所追求的名和利呢?最好的态度是把名利视为做事的工具,而不是最终目的。名利显然不等于幸福,也未必带来幸福,利欲熏心者最终只能成为名利的奴隶。但也不必排斥名利,首先,作为凡夫俗子,多多少少会有名利心,这是很正常的;其次,如果出发点是善的,更多的财富,更好的名声,可以使我们更加便利地做事,给他人带来更多的帮助;再次,在做事的过程中,当我们为社会解决了更多的问题,名声和财富常常会随之自然而来,强行拒之门外反而是不自然的,佛家说莫执着,沉湎于名利是执着,而避之唯恐不及恐怕也是一种执着。 人终究走向死亡,正如佛陀所说,“如梦幻泡影,如露亦如电”。 在死亡面前,一切都如过眼云烟,微不足道。如果说人生是个梦,我依然希望是精彩的梦,梦中全心全意去体验。 我相信,到这个世界上我们是带着使命来的,我们每个人都有独一无二的天赋。我们需要相信天道,充分发挥天赋,不断超越自己,去做事,去解决问题,去创造属于自己的作品,给这个世界增添一些属于自己的色彩,就不枉来这世上走一遭了。 PS: 翻看自己的日志,发现自己多年前写过一篇小文明吾志,原来自己那时就已经在思考这些问题了。能够看出,今天的很多看法在当时已有萌芽,可以说是一脉相承的。只是,当时思考比较简单,不够深入,不成体系,在随后的这些年里也并未踏实践行,在遇到挫折时常常会怀疑自己,踌躇不定,这也导致这些年走了不少弯路。不过,随着人生经历的增加,读了一些书,行了一些路,识了一些人,自己对这些问题的认识和体会也更加深刻。虽然看似又回到了原点,但其实深度不可同日而语。马克思说事物的发展是螺旋上升的,我想我的思想认识也是如此。对自己是谁更加清晰,对自己要去哪儿更加坚定,我想这也是那些弯路的价值。人生没有白走的路,那些杀不死我的,必将使我更强大。 ","date":"2024-01-12","objectID":"/posts/2024/01/what-to-do/:0:0","tags":["感悟"],"title":"人生要做什么","uri":"/posts/2024/01/what-to-do/"},{"categories":["生活"],"content":"去成都出差,趁着周末去了趟乐山和峨眉山。 ","date":"2023-12-27","objectID":"/posts/2023/12/travel-mount-emei/:0:0","tags":["旅行"],"title":"乐山峨眉山之旅","uri":"/posts/2023/12/travel-mount-emei/"},{"categories":["生活"],"content":" 2023年10月28日早上6:30从酒店出发,7:20的成都东站高铁,8:10到乐山,出租车到重百吃早餐,随后打车去乐山大佛景点,佛脚平台因修整而不开放,无法到佛脚平台仰观,只能在佛头顶平台俯瞰。佛倚壁而坐,面前即是南流的岷江,体积巨大,“佛即一座山,山是一尊佛”,诚非虚言。然后在凌云寺上了香,便出东门打车,到高铁站去峨眉山。 下高铁后,稍微规划了一下路线。打车到报国寺附近,此处有秀甲瀑布、儒释道文化长廊,流连片刻,吃了点特色美食,便到游客中心买票,坐大巴进山了。 一路雾气缭绕,行了近两个小时到达雷洞坪,一下车冷气即扑面而来,打听得知预订的旅馆还在前面四公里处,于是租个大衣继续前行。不多时便遇到了几个河南老乡,于是相约结伴登山。到旅馆时天已近黑,我放了行李,跟他们继续往上登。又爬了半个多小时达到金顶,雾气很浓,我们随意逛逛,找到一处次日早晨观日出的绝佳地点,随意拍了几张照片。其中一位同行者带了帐篷,就地住下,我们其他几位便下山,回旅店休息。在旅店用携带的甜皮鸭垫垫肚子,跟同行的两位女生约定好次日早上5点半出发,之后便休息了。 ","date":"2023-12-27","objectID":"/posts/2023/12/travel-mount-emei/:1:0","tags":["旅行"],"title":"乐山峨眉山之旅","uri":"/posts/2023/12/travel-mount-emei/"},{"categories":["生活"],"content":" 2023年10月29日早上五点半准时出发,雾气早已散了,仰望天空,繁星点点,圆月西斜,山林寂静,唯闻登山者步履声。大约半个小时,到达金顶,先虔诚敬拜普贤菩萨,后至观日出地点,抢占有利地形,一边欣赏挂满繁星的天空和仙气飘飘的云海,一边满怀期待地等待日出。 大概7点10分,随着众人的欢呼声,太阳终于把第一缕光洒向人间。我用手机视频记录了日出全过程。结束后在金顶烧香拜佛,虔诚许愿。拍完合照后一起下山。 到达雷洞坪,坐大巴去零公里停车场,然后坐老乡的车下去,一同吃了午饭,徒步到万年寺。在万年寺的前面,亲眼见到了猴子打劫行人,直接翻查行人的包裹找吃的。 然后原路返回停车场,路上喝喝茶,跟老乡聊聊天,诉说诉说平日的烦恼,分享分享对生活的看法,由于是萍水相逢,也就无所顾忌。 在离开峨眉山之前,我让老乡带我去周一甜皮鸭,买了一只甜皮鸭给辉辉寄回去,然后我们就驱车返回成都。 热情的老乡直把我送到酒店门口,峨眉之旅遂结束。 ","date":"2023-12-27","objectID":"/posts/2023/12/travel-mount-emei/:2:0","tags":["旅行"],"title":"乐山峨眉山之旅","uri":"/posts/2023/12/travel-mount-emei/"},{"categories":["生活"],"content":" 照片 ","date":"2023-12-27","objectID":"/posts/2023/12/travel-mount-emei/:3:0","tags":["旅行"],"title":"乐山峨眉山之旅","uri":"/posts/2023/12/travel-mount-emei/"},{"categories":["生活"],"content":" 生活修行准则 精进,以持戒为首要;疾病,以减食为汤药; 烦恼,以忍辱为妙解;是非,以不辩为解脱; 待人,以诚实为真情;执事,以尽心为有功; 语言,以减少为直截;上下,以慈和为进德; 学问,以勤习为入门;因果,以明白为无过; 老病,以无常为警策;修行,以精虔为切要; 敬客,以谦益为供养;居室,以朴实为庄严; 凡事,以预办为不牢;处众,以慎言为常礼; 遇险,以不乱为章程;济物,以慈悲为根本。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:1:0","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 各节气修行主题","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:0","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 冬至 原学篇 (明)许孚远 天然自有之谓性,效性而动之谓学。性者万物之一原,学者在人之能事。故曰天地之性人为贵,为其能学也。学然后可以尽性,尽己性以尽人物之性,则可以赞天地之化育,而与天地参而为三才,故学之系于人者大也。 天聪天明,非学不固;威仪动止,非学不端;刚柔善恶之质,非学不化;仁义礼智信之德,非学不完;君臣、父子、夫妇、昆弟、朋友之伦,非学不尽;富贵贫贱之遇,非学不达。学则智,不学则愚;学则治,不学则乱。自古圣贤盛德大业,未有不由学而成者也。故先师孔子特揭学之一言以诏来世,而其自名,惟曰学而不厌而已。性之理无穷,故学之道无尽,学而不厌,孔子之所以为孔子也。 然而三代以上,道明而学醇;三代以下,道丧而学杂,高之沦于空虚,卑之局于器数,浸淫于声利,靡滥于词章。呜呼!学其所学,而非孔子之所谓学也。其卓然志于孔子之学,不为他道所惑者,寥寥数千载之间,几人而已。乃其见有偏全,言有离合,行有至不至,择而取之,则又存乎其人焉。故学以尽性为极,以孔子为宗。若射之有的,发而必中,若川之归海,不至于已矣,夫然后可以语学。学之义大矣哉! 学者既有志于孔子之学,则必知夫求端用力之地。孔子之学,自虞廷精一执中而来,其大旨在为仁,其告颜子以克己复礼,最为深切著明者也。人心本来具此生理,名之曰仁。此理不属血气,不落形骸,故直云克己。己私一克,天理具存,视听言动,各有当然之则,故云复礼。一日克己复礼,则无我无人,平平荡荡,万物一体,故曰天下归仁。 己最难克,仁最难言,因循牵系,终身陷溺;刚毅深潜,一日可至,故曰为仁由己而不由人。出此入彼,即在身心之间,其机至严,其用至博,故曰非礼勿视听言动。此孔门学脉也。他如言敬,言恕,言忠信,言闲邪存诚,言洗心藏密,言格物致知、诚意正心,无非此理,无非此学,神而明之,存乎其人焉尔矣。 是故舍仁而不求者,昧其本心,不可立人道于天地之间;不由克己复礼而言仁者,道不胜欲,公不胜私,而徒以闻见凑泊气魄承当,无强至于仁之理。知克己者,一私不容,气质浑化,故功利权谋之说,非所可入。知复礼者,体用俱全,万理森著,故虚无寂灭之教,非所可同。修此之谓天德,达此之谓王道,此孔子之学,自精一执中而来,为万世立人极者也。学者于斯笃信不惑,而行之不惰,其庶几乎可以语学也夫! 学不贵谈说,而贵躬行;不尚知解,而尚体验。《易》曰:“默而成之,不言而信,存乎德行。”孟子曰:“君子所性,仁义礼智根于心,其生色也,睟然见于面,盎于背,施于四体,四体不言而喻。”此其说也。是故性定者,其言安以舒;养深者,其容静以肃;内直者,其动简;德盛者,其心下。反之,而躁妄、轻浮、繁扰、骄泰生焉。盖理欲消长之机,志气清浊之辨,见于动静,微于应感,如影随形,不可掩也。 昔者虞舜,夔夔齐栗,以格其亲,而好问好察,善与人同,乃见其精一之学。文王在宫在庙,雝雝肃肃,而无然畔援,无然歆羨,乃见其敬止之功。孔子温良恭俭让,萃至德于其躬,而意必固我,至于尽忘,乃其学而不厌之实。凡古今圣贤所为师表人伦信今传后者,必以躬修道德而致之,断非声音笑貌之所能为也。故学者之学,务实修而已矣。 珠藏而渊媚,玉韫而山辉,德聚于其中而发见于其外。有不修,修之未有无其验者也。不修而伪为于外,与夫修之未至,而欲速助长操上人之心者,皆孟子所谓无源之水,易盈易涸,不可长久矣。 故曰:“君子之道闇然而日章,小人之道的然而日亡。”言忠信,行笃敬,虽蛮貊之邦行矣。言不忠信,行不笃敬,虽州里行乎哉?诚伪虚实,判若霄壤,其理甚明。内辨诸身心,外证诸家国,学之终身,不至不已,斯学之道也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:1","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 小寒 颜子所好何学论 (宋)程颐 圣人之门,其徒三千,独称颜子为好学。夫《诗》、《书》、六艺,三千子非不习而通也,然则颜子所独好者,何学也﹖学以至圣人之道也。圣人可学而至与﹖曰:然。学之道如何﹖曰:天地储精,得五行之秀者为人。其本也真而静,其未发也五性具焉,曰仁义礼智信 。形既生矣,外物触其形而于中矣,其中动而七情出焉,曰喜怒哀惧爱恶欲。情既炽而益荡,其性凿矣。是故觉者约其情使合于中,正其心,养其性,故曰「性其情」。愚者则不知制之,纵其情而至于邪僻,牿其性而亡之,故曰「情其性」。凡学之道,正其心,养其性而已。中正而诚,则圣矣。君子之学,必先明诸心,知所养,然后力行以求至,所谓「自明而诚」也。故学必尽其心,尽其心则知其性。知其性,反而诚之,圣人也。故《洪范》曰:「思曰睿,睿作圣。」诚之之道,在乎信道笃。信道笃则行之果,行之果则守之固,仁义忠信不离乎心,造次必于是,颠沛必于是,出处语默必于是。久而弗失,则居之安,动容周旋中礼,而邪僻之心无自生矣。故颜子所事,则曰「非礼勿视,非礼勿听,非礼勿言,非礼勿动」。仲尼称之,则曰「得一善则拳拳服膺,而弗失之矣」,又曰「不迁怒,不贰过」,「有不善未尝不知,知之未尝复行也」。此其好之笃,学之之道也。视听言动皆礼矣,所异于圣人者;圣人则不思而得,不勉而中,从容中道;。颜子则必思而后得,必勉而后中。故曰:颜子之与圣人,相去一息。孟子曰:「充实而有光辉之谓大,大而化之之谓圣,圣而不可知之谓神。」颜子之德,可谓充实而有光辉矣;所未至者,守之也,非化之也。以其好学之心,假之以年,则不日而化矣。故仲尼曰:「不幸短命死矣!」盖伤其不得至于圣人也。所谓化之者,入于神而自然,不思而得,不勉而中之谓也,孔子曰「七十而从心所欲,不踰矩」是也。或曰:「圣人,生而知之者也。今谓可学而至,其有稽乎﹖」曰:「然。孟子曰:『尧、舜,性之也;汤、武,反之也。』性之者,生而知之者也;反之者,学而知之者也。」又曰:「孔子则生而知也,孟子则学而知也。后人不达,以谓『圣本生知,非学可至』,而为学之道遂失。不求诸己而求诸外,以博文强记、巧文丽辞为工,荣华其言,鲜有至于道者,则今之学与颜子所好异也。」 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:2","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 大寒 求放心说 (明)刘宗周 程子曰:“心要在腔子里”,此本孟子求放心而言,然则人心果时放外耶?即放外,果在何处?因读《孟子》上文云:“仁,人心也。”乃知心有不仁时,便是放。所谓“旷安宅而弗居也。”故阳明先生曰:“程子所谓腔子,亦即是天理。”至哉言乎!程子又曰:“吾学虽有所授,然天理二字,却是自家体认出来。”夫既从自家体认而出,则非由名象凑泊可知。凡仁与义,皆天理之名象,而不可即以名象为天理,谓其不属自家故也。试问学者,何处是自家一路?须切己反观,推究到至隐至微处,方有着落。此中无一切名象,亦并无声臭可窥,只是个维玄维默而已。虽维玄维默,而实无一物不体备其中,所谓天也。故理曰天理,才着人分,便落他家。一属他家,便无归宿。仔细检点,或以思维放,或以卜度放,或以安排放,或以智故放,或以虚空放,只此心动一下,便是放。所放甚微,而人欲从此而横流,其究甚大。盖此心既离自家,便有无所不至者。心斋云:“凡有所向,有所见,皆是妄。”既无所向,又无所见,便是无极而太极。无极而太极,即自家真底蕴处。学者只向自家寻底蕴,常做个体认工夫,放亦只放在这里,求亦只求在这里,岂不至易?岂不至简?故求放心三字,是学人单提口诀,下士得之为入道之门,上根得之即达天之路。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:3","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 立春 应事说 (明)刘宗周 学者静中既得力,又有一段读书之功,自然遇事能应。若静中不得力,所读之书,又只是章句而已,则且教之就事上磨练去。自寻常衣食以外,感应酬酢,莫非事也。其间千万变化,不可端倪,而一一取裁于心,如权度之待物然。权度虽在我,而轻重长短之形,仍听之于物,我无与焉,所以情顺万事而无情也。故事无大小,皆有理存,劈头判箇是与非。见得是处,断然如此,虽鬼神不避;见得非处,断然不如此,虽千驷万锺不回。又于其中条分缕析,铢铢两两,辨箇是中之非,非中之是,似是之非,似非之是。从此下手,沛然不疑,所行动有成绩。又凡事有先着,当图难于易,为大于细。有要着,一着胜人千万着;失此不着,满盘败局。又有先后着,如低棋以后着为先着,多是见小欲速之病。又有了着,恐事至八九分,便放手,终成决裂也。盖见得是非后,又当计成败,如此方是有用学问。世有学人,居恒谈道理井井,才与言世务便疏。试之以事,或一筹莫展。这疏与拙,正是此心受病处,非关才具。谚云:“经一跌,长一识。”且须熟察此心受病之原,果在何处,因痛与之克治去,从此再不犯跌,庶有长进。学者遇事不能应,只有练心法,更无练事法。练心之法,大要只是胸中无一事而已。无一事乃能事事,便是主静工夫得力处。又曰:“多事不如少事,省事不如无事。” ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:4","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 雨水 定性书 (宋)程颢 所谓定者,动亦定,静亦定,无将迎,无内外。苟以外物为外,牵己而从之,是以己性为有内外也。且以己性为随物于外,则当其在外时,何者为在内?是有意于绝外诱,而不知性之无内外也。既以内外为二本,则又乌可遽语定哉! 夫天地之常,以其心普万物而无心;圣人之常,以其情顺万物而无情。故君子之学,莫若廓然而大公,物来而顺应。《易》曰:“贞吉悔亡。憧憧往来,朋从尔思。”苟规规于外诱之除,将见灭于东而生于西也,非惟日之不足,顾其端无穷,不可得而除也。 人之情各有所蔽,故不能适道,大率患在于自私而用智。自私则不能以有为为应迹,用智则不能以明觉为自然。今以恶外物之心,而求照无物之地,是反鉴而索照也。《易》曰:“艮其背,不获其身。行其庭,不见其人。”孟氏亦曰:“所恶于智者,为其凿也。”与其非外而是内,不若内外之两忘也。两忘则澄然无事矣。无事则定,定则明,明则尚何应物之为累哉! 圣人之喜,以物之当喜;圣人之怒,以物之当怒。是圣人之喜怒,不系于心而系于物也。是则圣人岂不应于物哉?乌得以从外者为非,而更求在内者为是也?今以自私用智之喜怒,而视圣人喜怒之正为何如哉?夫人之情易发而难制者,唯怒为甚。第能于怒时遽忘其怒,而观理之是非,亦可见外诱之不足恶,而于道亦思过半矣。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:5","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 惊蛰 寡欲论 (《答林子仁》) (明)黄宗明 (林子仁)来谕谓:“此心之中,无欲即静,遇事时不觉交战,便是得力。”所言甚善,尚有不得不论者。盖无欲即静,与周子《图说》内自註无欲故静之说,亦略相似。其谓遇事时不觉交战,便是得力,亦谓心中有主,不为事物所胜云耳。然尝闻之,程子曰:“为学不可不知用力处,既学不可不知得力处。”周子曰:“养心莫善於寡欲,寡之又寡,以至於无。”正不在得力,而在於知所以用力;不在无欲,而在寡欲耳。学必寡欲而后无欲,知用力而后知得力,此其工夫渐次,有不可猎而进者。若执事所言,恐不免失之太早。如贫人说富,如学子论大贤,功效体当,自家终无受用时也。仆之所谓主静者,正在寡欲,正在求所以用力处,亦不过求之於心,体之於心,验之於心。盖心为事胜,与物交战,旨欲为之累。仆之所谓主静者,正以寻欲所从生之根而拔去之,如逐贼者,必求贼所潜入之处而驱逐之也。是故善学者莫善於求静,能求静然后气得休息,而良知发见。凡其思虑之烦杂,私欲之隐藏,自能觉察,自能拔去,是故无欲者本然之体也,寡欲者学问之要也,求静者寡欲之方也,戒惧者求静之功也。知用力而后得力处,可得而言无欲,真体常存常见矣。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:6","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 春分 改过说 (明)刘宗周 天命流行,物与无妄,人得之以为心。是谓本心。人心无一妄而已。忽焉有妄,希乎微乎?其不得而端倪乎?是谓微过,独知主之;有微过,是以有隐过,七情主之;有隐过,是以有显过,九容主之;有显过,是以有大过,五伦主之;有大过,是以有丛过,百行主之。总之妄也。譬之木自本而根、而干、而标,水自源而后及于流,盈科而至於放海,故曰:“涓涓不息,将成江河;绵绵不绝,将寻斧柯。”是以君子贵防之早也。其惟慎独乎?慎独则时时知改。俄而授之隐过矣,当念过,便从当念改;又授之显过矣,当身过,便从当身改;又授之大过矣,当境过,当境改;又授之丛过矣,随事过,随事改。改之则复於无过,可喜也;不改成过,且得无改乎?总之皆祛妄还真之学,而工夫次第如此。譬之擒贼者,擒之於室甚善,不於室而於堂,不於堂而於外门,於衢,於境上,必成擒而后已。子绝四:毋意,毋必,毋固,毋我。真能慎独者也。其次则“克伐怨欲不行焉尔。”宋人之言曰:“独行不愧影,独行不愧衾。”独而显矣;司马温公则云:“某平生无甚过人处,但无一事不可对人言者。”庶几免於大过乎?若邢恕之一日三检点,则丛过对治法也。真能慎独者,无之非独,即邢恕学问,孔子亦用得着,故曰“不为酒困。”不然自原宪而下,总是个闲居小人,为不善而已。善学者须学孔子之学,只於意根上止截一下,便千了百当。若到必固我,已渐成决裂,幸於我处止截得,犹不失为颜子,克己过,此无可商量矣。落一格,粗一格,工夫转愈难一格,故曰:“可为难矣。”学者须是学孔子之学。 人之言曰:“有心为恶,无心为过。”则过容有不及知者,因有不及改,是大不然。夫心不爱过者也,才有一点过,便属碍膺之物,必一决之而后快。故人未有有过而不自知者,只不肯自认为知尔。然则过又安从生?曰只不肯自认为知处,其受蔽处良多,以此造过遂多,仍做过不知而已。孟子言:“君子之过,如日月之食。”可见人心只是一团灵明,而不能不受暗於过。明处是心,暗处是过。明中有暗,暗中有明。明中之暗,即是过;暗中之明,即是改,手势如此亲切。但常人之心,忽明忽暗,展转出没,终不能还得明明之体,不归薄蚀何疑?君子则以暗中之明,用箇致曲工夫,渐次与它恢扩去,在《论语》则曰“讼过”,如两造当庭,抵死仇对,不至十分明白不已。才明白,便无事。如一事有过,直勘到事前之心,果是如何?一念有过,直勘到念后之事,更当如何?如此反覆推勘,更无躲闪,虽一尘亦驻足不得,此所谓致曲工夫也。《大易》则言“补过”,谓此心一经缺陷,便立刻与之圆满那灵明尔。若只是小小补缀,头痛救头,脚痛救脚,败缺难掩,而弥缝日甚,谓之文过而已。虽然,人犹有有过而不自知者。“子路,人告之以有过则喜。”子曰:“丘也幸,苟有过,人必知之。”然则学者虚心,逊志时务,察言观色,以辅所不逮,有不容缓者。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:7","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 清明 克己箴 (明)赵贞吉 天地万物,本吾一体也,而吾何以知天地万物之然哉?天地非仁将恐折,万物非仁将恐歇,吾心非仁吾身将恐蹶。吾何以知吾身之然哉?吾视非仁,盲从目生,吾听非仁,聋从耳腾,吾言非仁,吾过瞢瞢,吾动非仁,身过殷殷。呜乎!微翳眯睛,则八方易位,一念颠倒,而人己成敌。执迷为真,贼以代子,四窍尘投,一妙觉死。乐出於虚,蒸则成菌,既死之心,不可复振。蜗窟蚓穴,去仁几何!鸢飞鱼跃,於仁何若!古之有道,去彼取此,三才归根,一日克己。吾何以知有道之然哉?以其无己也,故能成其己。呜乎!吾有大己,俯万物而观天地者也。大己不浃,小己揭揭,小己既克,大己泼泼。古之善克者,视於无形,听於无声,动无轨辙,言非述称,四用反一,一真流行,无体无方,礼嘉而亨。少有意必固我作累,妙用齐滞,具为痿痺,此为不仁,而株橛小己。是故无己为克,真己为大,至大为仁。体无对待,不见大小,正知内外?性此曰圣,复此曰贤,小子至愚,择焉执焉。昔者吾友从事於此,敢告非狂,为仁由己。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:8","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 谷雨 读书说 (明)刘宗周 朱夫子尝言:“学者半日静坐,半日读书,如此三年,必有进步可观。”今当取以为法,然除却静坐工夫,亦无以为读书地,则其实亦非有两程候也。学者诚于静坐得力时,徐取古人书读之,便觉古人真在目前,一切引翼提撕,匡救之法,皆能一一得之于我,而其为读书之益,有不可待言者矣。昔贤诗云:“万径千蹊吾道害,四书六籍圣贤心。”学者欲窥圣贤之心,遵吾道之正,舍四书六籍,无由而入矣。盖圣贤之心,即吾心也,善读书者,第求之吾心而已矣。舍吾心而求圣贤之心,即千言万语,无有是处。阳明先生不喜人读书,令学者直证本心,正为不善读书者,舍吾心而求圣贤之心,一似沿门持钵,无益贫儿,非谓读书果可废也。先生又谓“博学只是学此理,审问只是问此理,慎思只是思此理,明辨只是辨此理,笃行只是行此理”,而曰“心即理也”,若是乎此心此理之难明,而必假途於学问思辨,则又将何以学之、问之、思之、辨之,而且行之乎?曰:“古人诏我矣,读书一事,非其导师乎?即世有不善读书者,舍吾心而求圣贤之心,一似沿门持钵而有得也,亦何惜不为贫儿?”昔人云士大夫:“三日不读书,即觉面目可憎,语言无味。”彼求之闻见者犹然,况有进于此者乎?惟为举业而读书,不免病道,然有志之士,卒不能舍此以用世,何可废也?吾更恶夫业举子而不读书者! ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:9","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 立夏 论讲学书 (《答李赞宇》) (明)曹于汴 夫道无之是非,无人弗足,讲学以明道,士农工贾,皆学道之人,渔牧耕读,皆学道之事。隆古无讲学之名,其人皆学,故无名也。国家以文学取士,天下学校,无虑千百,章缝之士,无虑万亿,盖令其日讲所谓时习、所谓孝弟、所谓性命仁义,而以淑其身,待天下之用也。乃人心不古,遂有口耳活套,掇拾粉饰,以为出身之媒,师以是教,上以是取,恬不为异,非其质矣。而於立身行政,毫无干涉。於是君子厌薄其所为,而聚徒讲道,人遂以道学目之。若以为另是一种,岂不惑哉?然讲学之中,亦或有言然而行不然,而藉是以干贵人、捷仕径者,而其名为道学也,是有口耳活套之实,而更美其名,人谁甘之?则群起而相攻,而讲者益寡,道益晦矣。太抵所学出於实,则必闇然自修,不论大节细行,一一不肯放过,虽力量不同,未必尽无疵,而不自文以误人也。所学出於名,则有张大其门面,而於其生平未纯处,亦曲为言说,而谓其为道。夫夷之隘,不害其清;惠之不恭,不害其和,然亦何必曰此隘,此不恭正道之所在,而陋孔子於下风乎?罗近溪逢人问道,透彻心体,岂不可尚?而阔略处,亦诚其病,乃学者得其阔略以为可,便其私也。而或多不羁,诚有如止菴疏所谓贿赂干请、任情执见等说,是其坐女子於怀而乱之,而犹侈然薄鲁男子不为也,而可乎?但今因止菴之疏而遂禁其讲,是因噎废食。夫此学乃乾坤所由不毁,何可一日废也?似更当推广,而俾千百学校,亿万章缝无不讲,以及农工商贾无不讲才是。而其机则自上鼓之,若得复辟召之典,罗致四方道学,仿程子学校之议,布之天下,以主道教,於一切乡学社学之众,渐次开发,而申饬有位之士,以兴学明道为先图。其学则以躬行实践为主,随其人之根基,引之入道,或直与天通,或以人合天,或真臻悟境,或以修求悟。夫天人合一,修悟非二,舍天而言人,舍悟而言修,则浅矣。近时学者,知皆及此,然言天矣,而人尚未尽;言悟矣,而修且未能。世岂有能致中而不能致和,能正心而不修身者哉?则不可不戒也。大抵果能合天,则必益尽其人事,果能真悟,则必益尽其真修。尧、舜、文王、孔子,何人也,而兢兢业业,望道未见,徙义改过,没齿以之也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:10","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 小满 格物论 (明)黄佐 物理曷谓之天理也?本於赋予禀受,自然明觉,莫之为而为者也。如恻隐之心,非纳交要誉,恶其声而然是也。物欲曷谓之人欲也?不安於品节限制,而凿以私智,非天之所以与我者也。如子贡貸殖,而必先言其不受命是也。去其所本无,而复其所固有,则万物皆备於我矣。夫理虽可以触类而长,而其出於天者,物物各有当然不易之则,自私用智,则违天而自贼,故《诗》曰“不识不知,顺帝之则”,又曰“不僭不贼,鲜不为则”,《周礼》曰“则以观德,毁则为贼”是也。则者,法也。自貌言视听而达诸人伦,无非物也,而莫不有法焉,如恭从明聪,以及亲义序别信之类是也。推之,盈天地间无一物而无理可法者,违其理则非天之法矣。《易》所谓“天则”,正以其出於天,当然不易者也。孟子亦曰:“君子行法以俟命而已矣。”岂敢毁之而自贼哉?将欲行之,必自致知始,致虽有推极之义,而《说文》原训则曰:“送,诣也。”其文为久,至触类而推极之久,则天牖帝迪,送诣而至。性之本善,吾所固有者,明而通於心中矣。是故格物所以明善也,诚意所以诚身也。身主於心,心发於意,意萌於知,知起於物,曰“致知在格物”,不言先者,知与意虽有先后,其实非二事也。知之不至,则意不诚而无物。《记》曰:“物至知知,而后好恶形焉。”何者?好善恶恶,感於物理者也,好妍恶媸,好富恶贫,感於物欲者也。道不离物,物不离事,盈天地间,物物各有一理存焉,去欲求理,岂以空谈悟哉?不曰理,而曰物者,践其实耳。郑玄曰:“格,来也。物,犹事也。”程子因言:“物来知起。”象山曰:“格至也,研磨考索,以求其至。”朱子因言:“穷至事物之理。”温公曰:“扞格外物,以物至为外,非合内外之道。”黄润玉曰:“格,正也,义取格其非心,心正矣,奚用诚意致知为哉?”是数说,皆因《记》而亿者也。惟《说文》曰:“格,木长貌,从木各声,取义於木,声以谐之。”其训精矣。今夫五行之各一其性也,水土金火汇萃鎔合,皆可为一。惟木不然,挨接暂同,终则必异。理欲同行而异情,正如桃李荆棘共陌连根,始若相似,及至条长之时,形色别矣。荆棘必剪,犹恶之菑逮夫身者也,桃李必培,犹善之欲有诸己也。培其根而达其枝,则本各滋息而长矣,修其本而达其末,则物各触类而长矣。是故耳目口体物也,心为本,而视听食息其末也。喜怒忧惧无节於内,胡为物交物引之而去乎?必使心能为身之本,明於庶物而后已。父子兄弟物也,自孝弟慈推之,则身为本而絜矩其末也,好恶胡为而偏乎?必使身能为家国之本,至诚动物而后已。天下大矣,始乎格物,先事者也。理自理,欲自欲,则本根各异,物既格矣,至於天下平,后得者也。人人亲其亲,长其长,物各付物,则枝叶亦各不同焉。惟明也,辨物之理欲而至善存;惟诚也,成物之始终而大道得。孔子之诚身,不过乎物,孟子之万物皆备,反身而诚,皆反本之谓也。或曰:“礼乐刑政之道,鸟兽草木之名,莫非物也,汎而格诸?”曰:“否,否!本则身,厚则伦,经不云乎?其本乱而末治者否矣,其所厚者薄,而其所薄者厚,未之有也。” ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:11","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 芒种 太极图说 (宋)周敦颐 无极而太极。太极动而生阳,动极而静,静而生阴,静极复动。一动一静,互为其根;分阴分阳,两仪立焉。阳变阴合而生水火木金土,五气顺布,四时行焉。五行一阴阳也,阴阳一太极也,太极本无极也。五行之生也,各一其性。无极之真,二五之精,妙合而凝。“乾道成男,坤道成女。”二气交感,化生万物,万物生生而变化无穷焉。 唯人也得其秀而最灵。形既生矣,神发知矣,五性感动而善恶分,万事出矣。圣人定之以中正仁义[自注:圣人之道,仁义中正而已矣]而主静[自注:无欲故静],立人极焉。 故圣人“与天地合其德,日月合其明,四时合其序,鬼神合其吉凶”,君子修之吉,小人悖之凶。故曰:“立天之道,曰阴与阳。立地之道,曰柔与刚。立人之道,曰仁与义。”又曰:“原始反终,故知死生之说。”大哉易也,斯其至矣! ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:12","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 夏至 静坐说 (明)刘宗周 人生终日扰扰也,一着归根复命处,乃在向晦时,即天地万物,不外此理。于此可悟学问宗旨,只是主静也。此处工夫最难下手,姑为学者设方便法,且教之静坐。日用之间,除应事接物外,苟有余刻,且静坐。坐间本无一切事,即以无事付之,即无一切事,亦无一切心,无心之心,正是本心。瞥起则放下,沾滞则扫除,只与之常惺惺可也。此时伎俩,不合眼,不掩耳,不趺跏,不数息,不参话头,只在寻常日用中。有时倦则起,有时感则应,行住坐卧,都在静观,食息起居,都作静会。昔人所谓勿忘勿助间,未尝致纤毫之力,此其真消息也。故程子每见人静坐,便叹其善学,善学云者,只此是求放心亲切工夫。从此入门,即从此究竟,非徒小小方便而已。会得时立地圣域,不会得时终身只是狂驰了,更无别法可入。不会静坐,且学坐而已。学坐不成,更论恁学?坐如尸,坐时习学者且从整齐严肃入,渐进于自然。《诗》云:“相在尔室,尚不愧于屋漏。”又曰:“神之格思,不可度思,矧可射思。” ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:13","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 小暑 正心原 (明)李经纶 心也者,神明之舍,心不可以专神,而神则寓宅於心者也。神贵静,静则性全而仁义之体立,神贵明,明则思睿而仁义之用行。曰寂,曰明,而心之本体正矣。欲多则荡,动极则昏,事物无形,虚静以养中可也。而常情有无故之感,事为之著安而和行可也;而常情有物胜之动,於是乎昏荡生,而寂明者失矣,此固无主之心,而心失其正者也。若夫意存於天理,而私妄难以绝其根,意存乎王道,而利害得以冲其志,其为昏荡一也。邪妄绝矣,而可为之事,不免生心以系事;利害妄矣、而欲为之事,不免持心以必为。非邪妄利害之私,而终留喜怒之形声,亦不可得而寂明也。然则寂明无累者,其惟圣人之心正乎?方其静也,物之未感,我之无情,至虚独觉,而影响俱无也;及其动也,妍媸在物,精凝在我,至灵常止,而好恶不作也;其复而之静也,与化俱往,宾去主存,而又影响之俱无也,是正心之义也。或曰:“何思何虑,圣人无故而不感,忘食以思,岂有故之感乎?寂然不动,圣人有心而无为,不思则罔,岂无为之心乎?”圣人之心,所不累者身之情,所欲察者天之理,无思无为者洗心以神德,思睿作圣者精义以穷神。累情之心,为意必,意必则私,私则动;精义之心,为性命,性命则公,公则平,何动之有哉?朱子曰:“静而常觉,动而常止,此人心之妙。”明道曰:“所谓定者,动亦定,无将迎,无内外,正心之谓也。”心与意,诚与正,相似而难辨也,作《正心原》。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:14","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 大暑 敬斋箴 (宋)朱熹 正其衣冠,尊其瞻视。潜心以居,对越上帝。足容必重,手容必恭。择地而蹈,折旋蚁封。出门如宾,承事如祭。战战兢兢,罔敢或易。守口如甁,防意如城。洞洞属属,罔敢或轻。不东以西,不南以北。当事而存,靡他其适。弗贰以二,弗参以三。惟心惟一,万变是监。从事于斯,是曰持敬。动静弗违,表里交正。须臾有间,私欲万端。不火而热,不冰而寒。毫厘有差,天壤易处。三纲既沦,九法亦斁。于乎小子,念哉敬哉!墨卿司戒,敢告灵台。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:15","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 立秋 慎独论 (明)黄佐 道也者,无有精粗、大小、远迩、微显,格天地,济民物,日费而用之,不可得而尽也。正万目以视之,而莫知其所繇也,故曰“君子之道,费而隐”。得之者,盖或寡矣,必也敬乎?《易》以衣袽言戒,履霜言慎,目睹者也;以荐雷言恐惧,耳闻者也。不睹而亦戒慎焉,不闻而亦恐惧焉,虽青天白日之下,稠人广坐之中,其暗处细事,必自知之。及其微有迹也,诗云“无”曰“不显”,“莫予”云“觏”。韩婴曰:“匹夫匹妇,会於墙阴,而明日有传之者矣。男女大欲不正,则放辟邪侈,将靡不为焉,天命不能须臾存矣。”是故君子慎独,必造端乎夫妇,正其源也。朱子曰:“有天地后此气常运,有此身后此心常发,要於常运中见太极,常发中见本性。”岂非顾諟之功邪?欲既遏矣,惟理是安,日用常行,念念精察,则此心全体虚明洞彻,天何言哉?昭昭於此。已发者往,未发者来,逝者如斯,澄渟於此。充满流动,如川之不息,天之不穷,内外本末,体用动静,洞然无一毫之间,而鸢飞鱼跃,触处朗然也。存者存此而已,养者养此而已。必有事焉而勿正,心勿忘,勿助长也,至此则从容中道,浩然之气其生於性矣乎?及其成功也,自其灿然时出者言,则谓之圣。圣则知命以尽性,故曰“如天如渊”。自其浑然真切者言,则谓之仁。仁则尽性以至命,故曰“其渊其天”。敬以达诚,斯其至矣。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:16","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 处暑 观心说 朱熹 心则一也,以正不正而异其名耳。惟精唯一,则居其正而审其差者也,拙其异而反其同者也。能如是,则信执其中而无过不及之骗矣:非以道为一心,人为一心,而又有一心以精一之也。夫谓操而存者,非彼操此而存之也;舍而亡者,非以彼舍此而亡之也;心而自操,则亡者存;舍而不操,则存者亡耳。然其操之也,亦曰不使旦昼之所为得以捁亡其仁义之良心云尔,非块然兀坐以守其迥然不用之知觉,而谓之操存也。若尽心云者,则格物穷理,廓然贯通,而有以极夫心之所具之理也;存心云者,则“敬以直内,义以方外”,若前所谓精一操存之道也。故尽其心而可以知性知天,以其体之不蔽而有以究夫理之自然也;存心而可以养性事天,以其体之不失而有以顺夫理之自然也。是岂以心尽心,以心存心,如两物之相持而不相舍。若参前倚衡之云者,则为忠信笃敬而发也;盖曰忠信笃敬不忘乎心,则无所适而不见其在是云尔,亦非有以见夫心之谓也。且身在舆而心倚衡,是果何理也耶。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:17","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 白露 识仁篇 程颢 学者须先识仁。仁者,浑然与物同体,义、礼、智、信皆仁也。识得此理,以诚敬存之而已,不须防检,不须穷索。若心懈,则有防;心苟不懈,何防之有!理有未得,故须穷索;存久自明,安待穷索!此道与物无对,「大」不足以明之。天地之用,皆我之用。孟子言「万物皆备于我」,须「反身而诚」,乃为大乐。若反身未诚,则犹是二物有对,以己合彼,终未有之,又安得乐!《订顽》意思,(横渠西铭,旧名《订顽》。)乃备言此体,以此意存之,更有何事。「必有事焉而勿正,心勿忘,勿助长」,未尝致纤毫之力,此其存之之道。若存得,便合有得。盖良知良能,元不丧失。以昔日习心未除,却须存习此心,久则可夺旧习。此理至约,惟患不能守。既能体之而乐,亦不患不能守也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:18","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 秋分 为善说 (明)高攀龙 为善必须明善,善者性也,性者人生而静是也。人生而静时,胸中何曾有一物来?其营营扰扰者,皆有知识以后,日添出来,非其本然也。即是添来,今宜减去,减之又减,以至于减无可减,方始是性,方始是善。何者?人心湛然无一物时,乃是仁义礼智也。为善者,乃是仁义礼智之事也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:19","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 寒露 诚意原 (明)李经纶 意非心之发也,心之发则情也。意从心从曰从心。心立欲为之意,而非为之意,而必为之主宰乎知觉之中也。寂者心之体,而主忠以为之根。知天之德,即我之德,而意专主乎天德,立心以的之,闲邪以存之,是宁静之中,而精神之有所注者也。感者心之用,则主信以为之干。知人之道,即我之道,而意专主乎人道,定其向,决其趋,盖攻取之中,而精神之有所守者也。无事而灵根植焉,画一无二而好色恶臭之几明,有事而美干达焉,致命遂志,而好色恶臭之几决,故不知意为身心之干,则视之也轻,不知几为万事之本,则其功也略,我图圣功,莫先诚意,作《诚意原》。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:20","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 霜降 心性图说 (明)湛若水 性者,天地万物一体者也;浑然宇宙,其气同也;心也者,体天地万物而不遗者也。性也者,心之生理也,心性非二也。譬之谷焉,具生意而未发,未发故浑然而不可见。及其发也,恻隐、羞恶、辞让、是非萌焉,仁义礼智自此焉始分矣,故谓之四端。端也者,始也,良心发见之始也。是故始之敬者,戒惧慎独以养其中也,中立而和发焉,万事万化自此焉达,而位育不外是矣。故位育非有加也,全而归之者耳。终之敬者,即始之敬而不息焉者也。曰:“何以小圈?”曰:“心无所不贯也。”“何以大圈?”曰:“心无所不包也。包与贯实非二也,故心也者,包乎天地万物之外,而贯乎天地万物之中者也。中外非二也,天地无内外,心亦无内外,极言之耳矣。故谓内为本心,而外天地万事以为心者,小之为心也甚矣。” ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:21","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 立冬 命说 (明)孙慎行 《易》云“利贞”者,性情也。又云:“各正性命”。夫性其命者,所以合天,性其情者,所以坊人。其本则所谓刚健中正,纯粹精也。而世说天命者,若除理义外,别有一种气运之命,杂糅不齐者。然因是则有理义之性,气质之性。又因是则有理义之心,形气之心。三者异名而同病。总之不过为为不善者作推解说。夫世之为善者少,而不为善者多,则是天之生善人也少,而生不善人也多,人之得性情之善于天也少,而得性情之不善於天也多。诬天诬人,莫此为甚,以是有变化气质之说。夫气质善,而人顺之使善,是以人合天,何极易简?若气质本有不善,而人欲变化之使善,是以人胜天,何极艰难?且使天而可胜,即荀子矫性为善,其言不异,而世非之何哉?孟子曰:“天之高也,星辰之远也,苟求其故,千岁之日至,可坐而致也。”是天之气运之行,无不齐也。而独命人于气运之际,顾有不齐乎哉?《中庸》曰:“文王之所以为文也,纯亦不已。”夫使天果不齐,是纯独文之所有,而举世性情之所无也。又非独举世性情之所无,而亦天命之所本无也。将所谓纯粹精者,何在乎? ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:22","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 小雪 辨学录(善利辨) (明)冯从吾 吾儒曰:“喻利之心不可有。”异端曰:“喻义之心不可有。”吾儒曰:“为恶之心不可有。”异端曰:“为善之心不可有。”或诘之曰:“喻义之心不可有,喻利之心可有乎?为善之心不可有,为恶之心可有乎?”彼则曰:“喻义之心且不可有,况喻利乎?为善之心且不可有,况为恶乎?”如此为言,虽中人亦知其非。彼又恐人之非之也,复倡为一切总归於无心之说,以为人之心体本空,无利、无义、无善、无恶者,其本体也。必也无喻利心,并无喻义心,并无无喻义心;无为恶心,并无为善心,并无无为善心。一切总归於无心,方合本体耳。说至此,虽高明莫知其非矣。不知正是发明喻义之心不可有,为善之心不可有处,奈何不察而误信之耶?且义原非外,性原是善,心之本体原是有善无恶的,可见必有喻义为善之心,而后为合本体也。今欲一切总归於无心,安在其为合本体耶?况人心易放而难收,尽去喻义,犹恐喻利;尽去为善,犹恐为恶。今欲一切总归於无心,窃恐义无而利未必无,善无而恶未必无,反为本体之累不小也。又况义利只有两途,人心原无二用,出於义即入於利,出於善即入於恶,岂有无义无利,无善无恶,一切总归於无心之理乎?太抵义原非外,特自有其义之心不可有,而喻义之心必不可无;性原是善,特自有其善之心不可有,而为善之心必不可无。总是喻之又喻,以至於化,为之又为,以至於忘,造到上天之载,无声无臭处,只好说有喻义之心而至於化,有为善之心而至于忘,有喻义为善之心,而无声臭之可儗。亦说不得喻义之心不可有,为善之心不可有。今云云者,所谓小人而无忌惮者也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:23","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["生活"],"content":" 大雪 仁心说 朱熹 天地以生物为心者也,而人物之生,又各得夫天地之心以为心者也。故语心之德,虽其总摄贯通,无所不备,然一言以蔽之,则曰仁而已矣。请试详之。盖天地之心,其德有四,曰元、亨、利、贞,而元无不统。其运行焉,则为春、夏、秋、冬之序,而春生之气无所不通。故人之为心,其德亦有四,曰仁、义、礼、智,而仁无不包。其发用焉,则爱恭宜别之情,而恻隐之心无所不贯。故论天地之心者,则曰乾元、坤元,则四德之体用亦不待遍举而该。盖仁之为道,乃天地生物之心,即物而在。情之未发,而此体已具;情之既发,而其用不穷。诚能体而存之,则众善之源、百行之本莫不在是。此孔门之教所以必使学者汲汲于求仁也。其言有曰:“克己复礼为仁。”言能克去己私,复乎天理,则此心之体无不在,而此心之用无不行也。又曰:“居处恭,执事敬,与人忠”,则亦所以行此心也。又曰:“求仁得仁”,则以让国而逃,谏伐而饿为能不失乎此心也。又曰:“杀身成仁”,则以欲甚于生、恶甚于死为能不害乎此心也。此心何也也?在天地则共坱然生物之心,在人则温然爱人利物之心,包四德而贯四端者也。 ","date":"2023-12-07","objectID":"/posts/2023/12/solar-terms-life-practice/:2:24","tags":["修行"],"title":"节气生活修行","uri":"/posts/2023/12/solar-terms-life-practice/"},{"categories":["读书"],"content":"最近读了Austin Kleon的Show your work,我读的是英文版,书中的观点和方法很值得借鉴。在这个互联网时代,如果你想扩大自己的影响力,或者单纯想在网上分享自己的知识和见解,但不得其法,可以看一下这本小书,会很有帮助。下面是我读这本书时所做的一些摘录笔记: In order to be found, you have to be findable. The best way to get started on the path to sharing your work is to think about what you want to learn, and make a commitment to learning it in front of others. Find a scenius, pay attention to what others are sharing, and then start taking note of what they’re not sharing. Be on the lookout for voids that you can fill with your own efforts, no matter how bad they are at first. Share what you love, and the people who love the same things will find you. “Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything—all external expectations, all pride, all fear of embarrassment or failure—these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked.” —Steve Jobs But today, by taking advantage of the Internet and social media, an artist can share whatever she wants, whenever she wants, at almost no cost. But human beings are interested in other human beings and what other human beings do. By letting go of our egos and sharing our process, we allow for the possibility of people having an ongoing connection with us and our work, which helps us move more of our product. How can you show your work even when you have nothing to show? The first step is to scoop up the scraps and the residue of your process and shape them into some interesting bit of media that you can share. You have to turn the invisible into something other people can see. Become a documentarian of what you do. Start a work journal: Write your thoughts down in a notebook, or speak them into an audio recorder. Keep a scrapbook. Once a day, after you’ve done your day’s work, go back to your documentation and find one little piece of your process that you can share. Where you are in your process will determine what that piece is. If you’re in the very early stages, share your influences and what’s inspiring you. If you’re in the middle of executing a project, write about your methods or share works in progress. If you’ve just completed a project, show the final product, share scraps from the cutting-room floor, or write about what you learned. Social media sites are the perfect place to share daily updates. Don’t show your lunch or your latte; show your work. Of course, don’t let sharing your work take precedence over actually doing your work. If you’re having a hard time balancing the two, just set a timer for 30 minutes. Once the timer goes off, kick yourself off the Internet and get back to work. you want the work you post online to be copied and spread to every corner of the Internet, so don’t post things online that you’re not ready for everyone in the world to see. Be open, share imperfect and unfinished work that you want feedback on, but don’t share absolutely everything. The act of sharing is one of generosity—you’re putting something out there because you think it might be helpful or entertaining to someone on the other side of the screen. If you’re unsure about whether to share something, let it sit for 24 hours. Put it in a drawer and walk out the door. The next day, take it out and look at it with fresh eyes. Ask yourself, “Is this helpful? Is it entertaining? Is it something I’d be comfortable with my boss or my mother seeing?” A blog is the ideal machine for turning flow into stock: One little blog post is nothing on its own, but publish a thousand blog posts over a decade, and it turns into your life’s work. Don’t think of your website as a self-promotion machine, think of it as a self-invention machine. Online, you can become the person you really want to be. Fill your website with your work and your ideas and the stuff ","date":"2023-12-06","objectID":"/posts/2023/12/reading-show-your-work/:0:0","tags":["方法论"],"title":"读 Show Your Work","uri":"/posts/2023/12/reading-show-your-work/"},{"categories":["生活"],"content":"不知不觉已经跑了一千多公里了。 上半年在云谷园区,每天晚饭前围着北边的小球场跑上几圈。下半年来到了南京,最开始是围着百家湖跑,后来去秦淮河对岸的那条宽敞跑道跑。最近天冷了,计划每天晚上围着单位园区跑几圈。 这一年,跑步慢慢变成了生活中的一个习惯,如果一段时间没跑,就会觉得生活好像少了点什么。 这一年,比较少追求跑步速度了,更多的是随心所欲,跑累了就走一段,看看路边的风景,听听路上的行人在聊些什么,走一会儿再接着跑。 有时,看着跑步记录里不断增长的数字,还是很有些成就感的。也会感觉到更多的安心、踏实,那些跑过的路,都成为了自己人生之路的一部分。 ","date":"2023-11-16","objectID":"/posts/2023/11/long-march-plan2/:0:0","tags":["习惯"],"title":"“长征”计划-第二个500公里","uri":"/posts/2023/11/long-march-plan2/"},{"categories":["思维"],"content":" 想清楚为什么学 学习新技能并不是件很容易的事情,知道为什么而学,才会有强大的学习动力。另一方面,弄清楚学习的目的,才能有的放矢,在学习中抓住重点,分清主次,更合理地分配时间和精力。 了解习得该技能的具体途径 每种技能都有它的特殊性,学习的方法也需要具体情况具体分析。在初始阶段,要设法了解习得目标技能的具体途径,可以向专家请教,或者读相关书籍、看相关视频、网络上搜索等多种方法并用。 了解了前人是怎样习得这项技能的,再结合自己的具体情况,就可以制定出适合自己的学习方法。 不过这个过程中要注意,技能的实践性一般都很强,譬如游泳,学很多游泳理论知识也不如早点下水来得有用,所以不要犯过度搜集信息的错误,要把握住这个度,尽早行动起来。 分而治之 一项技能通常可以分为多个子技能,子技能还能递归地分为更多子技能,如英语包含听说读写多个方面,单说写,又有词汇、语法、段落结构、谋篇布局等方面。 划分子技能可以降低学习的复杂度,在一个时间段只关注一个子技能,各个击破。另外也能更容易发现薄弱环节,哪里不会学哪里。 寻求反馈 我们常常对自己产生认知偏差,评价自己的水平时要么过于乐观,要么过于悲观。 接受反馈可以使我们更准确地评价自己,知道自己的差距有多少,知道自己的薄弱环节在哪里,从而更有针对性地刻意练习。 寻求反馈有多种方式,比如请专家指导纠正、主动测试、讲给别人等等,可根据自己的情况选用。 ","date":"2023-10-06","objectID":"/posts/2023/10/learning-skills/:0:0","tags":["方法论"],"title":"学习新技能的tips","uri":"/posts/2023/10/learning-skills/"},{"categories":["工具"],"content":"我在windows上喜欢用onenote做表格化的笔记,遇到的一个小问题是在表格内添加另一个表格的操作有点繁琐,没有快捷键。不过,利用本文的方法,可以自己添加快捷键,达到一键添加表格的效果。 Onenote中在表格内添加表格,如果用鼠标点,需要:插入-表格-插入表格-填入行数和列数-确定,挺麻烦的。 简化的思路是:第一步将这些鼠标点击转换为一系列键盘按键,第二步再用ahk脚本将这些按键一键化。 第一步:首先要依次按:插入-表格,然后在“插入表格”这个按钮上右键,将该按钮添加到“快速访问工具栏”。此后便可以用“Alt+数字”访问该按钮。 这里数字代表的是该按钮在快速访问工具栏中的位置,比如,我把它放在第一个,我就可以用Alt+1来访问它。 完成第一步后,按下Alt+1,然后在弹出的对话框中填入行数和列数,再按确定,即可插入表格。 第二步:利用ahk脚本,将这一系列操作一键化。 脚本如下(需要先安装autohotkey软件v1.1): !i:: Send {Alt down}1{Alt up} ; 按下Alt+1组合键 Sleep 10 ; 暂停10毫秒 Send 1 ; 按下1 Sleep 10 Send {Tab} ; 按下Tab Sleep 10 Send 1 ; 按下1 Sleep 10 Send {Enter} ; 按下Enter Return 大功告成,此后即想要插入表格时,只需按Alt+i就可以了! ","date":"2023-10-04","objectID":"/posts/2023/10/onenote-insert-table/:0:0","tags":["问题记录","onenote"],"title":"onenote为插入表格添加快捷键","uri":"/posts/2023/10/onenote-insert-table/"},{"categories":["技术"],"content":"编程本质上是在对目标系统做抽象,不同的编程范式对目标系统做抽象的视角不同。 对于一个系统,命令式将之描述为一系列系统状态随时间演进的步骤;函数式将之描述为输出值和输入值之间的数学关系;声明式将之描述为系统各个组成部分应该满足怎样的约束条件;而面向对象则将之描述为系统内各组件之间的交互过程。 从功能性来说,一个系统可以用不同范式来描述,但特定的系统有其比较适合的描述方法,选择了适合的编程范式往往能达到事半功倍的效果;甚至对于一个系统的各个部分,所适合的描述方法也不同,这时应该对它们分开思考。 注意,编程范式不完全跟特定的编程语言绑定,更多强调的是一种思维方式,是看待目标系统的视角。 ","date":"2023-10-04","objectID":"/posts/2023/10/programming-paradigm/:0:0","tags":["软件设计"],"title":"关于编程范式","uri":"/posts/2023/10/programming-paradigm/"},{"categories":["思维"],"content":"知识、能力和智慧三者彼此不同,但又相互联系,本文旨在理清三者的概念,从而使自我成长的道路更加明晰。 ","date":"2022-12-08","objectID":"/posts/2022/12/knowledge-ability-wisdom/:0:0","tags":["感悟"],"title":"知识、能力和智慧","uri":"/posts/2022/12/knowledge-ability-wisdom/"},{"categories":["思维"],"content":" 什么是知识知识跟具体的事物有关,是关于某些事物的事实、道理,或有关问题的解决方法。通常,一个领域的知识由一些核心概念和其他非核心概念组成,这些概念形成一个知识结构。重在记忆和理解。 ","date":"2022-12-08","objectID":"/posts/2022/12/knowledge-ability-wisdom/:1:0","tags":["感悟"],"title":"知识、能力和智慧","uri":"/posts/2022/12/knowledge-ability-wisdom/"},{"categories":["思维"],"content":" 什么是能力能力是在实践中解决问题的本领,也跟具体的问题密切相关。需要问题相关的领域知识加上行动力。重在练习和行动。 ","date":"2022-12-08","objectID":"/posts/2022/12/knowledge-ability-wisdom/:2:0","tags":["感悟"],"title":"知识、能力和智慧","uri":"/posts/2022/12/knowledge-ability-wisdom/"},{"categories":["思维"],"content":" 什么是智慧智慧主要指为人处世的一些普遍原则,如:善良、真诚、谦逊、减法、耐心、平和、积极、勤奋、勇敢。这些原则会在生活的各个方面、各个时间段都适用。智慧来自于对长期因果的洞见和觉悟。 ","date":"2022-12-08","objectID":"/posts/2022/12/knowledge-ability-wisdom/:3:0","tags":["感悟"],"title":"知识、能力和智慧","uri":"/posts/2022/12/knowledge-ability-wisdom/"},{"categories":["技术"],"content":"Type system的基本目标是保证程序中不会出现某些错误,本文先谈什么叫错误,错误都有哪些种类,然后再谈类型系统的一些基础概念。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:0:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" execution error需要区分两种情况:trapped errors和untrapped errors,前者发生时会导致程序立即终止,而后者发生时不会导致立即终止,而是继续执行但后续行为不可预知。典型的untrapped error如C语言里面的数据越界读写。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:1:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" language safety如果一段程序不会发生untrapped error,就称这段程序是safe的。如果一个语言写成的程序都是safe的,那么就称该语言为safe language;否则就是unsafe language。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:2:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" Well-behaved vs. ill-behaved设计语言时会指定所有可能发生的execution error的一个子集,为forbidden error。这个子集必须包含所有的untrapped error和一部分trapped error。如果一段程序不会出现forbidden error,就称之为well-behaved,否则称为ill-behaved。 由此定义可知,well behavior比safety要求更严格。一段safe的程序并不一定是well-behaved,因为还可能发生trapped error。但是如果是well-behaved,那么一定safe。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:3:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" type system排除程序中错误的手段有多种,type system只是其中一种。TAPL中对type system的定义如下: A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute. 根据以上定义,做三点说明: 是用来对系统进行推理的一种工具 其目标是排除程序中某些特定类型的错误,而排除哪些错误与与具体类型系统的具体目标有关 其手段是对程序中变量的取值集合进行分类,相当于对程序动态行为的一种静态近似 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:4:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" typetype定义了变量可能的取值集合以及允许在其上执行的操作集合。如:整数类型,浮点数类型,布尔类型。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:5:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" typed languages vs. untyped languages配备type system的语言叫typed language,没有配备type system的语言叫untyped language。Pure lambda calculus就是典型的untyped language。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:6:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" type checking一般来说,type system的基本目标是要保证safety,进阶目标是要保证well behaviour,这因语言的具体设计而异。保证type system实现其目标的手段type checking,这是在运行前对程序进行检查,由于是在运行前检查,也叫static checking,执行检查的工具是type checker。如果一个程序经受住了type checker的检查,则称之为well typed,否则称为ill typed。 保证程序不发生错误的手段不是只有type checking,比如untyped language(如LISP)根本没有类型系统,但它可以使用运行时检查来排除掉所有的forbidden error。由于是在运行时检查的,所以叫dynamic checking。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:7:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["技术"],"content":" Strongly checked vs. weakly checked现实中一些语言并不保证safety或well behaviour,也就是说它们并不保证检查出所有的untrapped error,我们称这类语言为weakly checked,而称提供了这种保证的语言为strongly checked。 ","date":"2022-11-04","objectID":"/posts/2022/11/type-system/:8:0","tags":["程序分析"],"title":"类型系统的基本概念","uri":"/posts/2022/11/type-system/"},{"categories":["思维"],"content":" 为什么写博客 书写帮助自己思考 把自己有价值的思考/知识分享给别人 提高表达能力 交志同道合的朋友 通过接受反馈认识和改善自己 ","date":"2022-10-23","objectID":"/posts/2022/10/blogging/:1:0","tags":["习惯"],"title":"关于写博客","uri":"/posts/2022/10/blogging/"},{"categories":["思维"],"content":" 以什么原则写 要真诚,不写违心的话 要追求质量,为读者增加价值 忽略非建设性的批评 保持简洁 ","date":"2022-10-23","objectID":"/posts/2022/10/blogging/:2:0","tags":["习惯"],"title":"关于写博客","uri":"/posts/2022/10/blogging/"},{"categories":["思维"],"content":" 写什么 对某个问题的有价值的思考 专业领域的知识 读书笔记 某个实际问题的解决方案 生活中有重要意义的事件 生活理念、价值观、感悟 ","date":"2022-10-23","objectID":"/posts/2022/10/blogging/:3:0","tags":["习惯"],"title":"关于写博客","uri":"/posts/2022/10/blogging/"},{"categories":["思维"],"content":" 不写什么 心情碎碎念 流水账 ","date":"2022-10-23","objectID":"/posts/2022/10/blogging/:4:0","tags":["习惯"],"title":"关于写博客","uri":"/posts/2022/10/blogging/"},{"categories":["思维"],"content":"最近刚换了新电脑。趁此辞旧迎新之际,我做了一次数字大扫除。 笔记。之前的笔记散落各处:onenote,有道云,语雀,obsidian,org-roam,flomo,手机便笺…… 这次做了一次系统性的整理,全部收归到onenote来。删除了一部分,合并了一部分,还根据已有的笔记内容重新分了类,清爽了许多。今后打算以onenote为核心做知识管理,其他分散的笔记会定期(比如每周)整理到onenote中来。需要记忆的导入到anki中去。 照片。删了许多没用的照片,值得留下来的照片也分类存放,分类的主要标准是时间,其次是主题,照片备份到nas。有价值的截图直接贴到onenote统一管理。 电子书。之前用来管理电子书的calibre有个很大的缺点:无法对电子书用层级分类。于是决定回归最原始的方法——电脑文件夹。我把所有电子书导出,去重,删除了许多没用的,然后重新分类。然后备份到nas。 影视资源。包括电影电视剧还有很多视频教程,删了大部分,只留下很小一部分真正有用的。 邮件订阅。很多从来不看的邮件直接unsubscribe了。 RSS。价值不高的RSS源直接取消关注了。 浏览器书签。删。 手机app。消息通知全部禁止。 网盘。减少网盘的使用,删除了网盘里大量现在用不到的资源。 知乎、b站、油管收藏夹。重温收藏夹的内容,发现大部分已经没有收藏的价值了,删除。有价值的我会整理到onenote中。还在进行中。 在这个信息泛滥的时代,很多人都有信息松鼠病(我也是其中一员),囤积了很多数字资源,觉得以后会用到,然而大多数资源都静静地躺在硬盘里从未打开过。数字大扫除是一个费力劳神的事情,过程中需要重温自己想要什么,需要思考东西的分类,需要判断东西是去还是留,要留在哪里。在大扫除过程中,面对许多文件,我常常觉得“这个以后会用到吧”而不舍得,最后还是狠心删了,也有一些文件,犹豫了几下还是没舍得删。 就像家里需要定期打扫卫生以维持整洁一样,数字空间其实也需要定期做一下整理,尤其是对于需要长期使用电脑工作的人来说。我打算每周都花一小时来整理自己的数字空间,用”断舍离“为自己创造一个干净清晰有秩序的工作环境。 ","date":"2022-10-05","objectID":"/posts/2022/10/digital-clean/:0:0","tags":["习惯"],"title":"数字大扫除","uri":"/posts/2022/10/digital-clean/"},{"categories":["思维"],"content":" 目的是极简生活,而不是极简物质。 思想上的极简是核心,认清自己的欲望与贪婪,找到生活的主线,愿意拿掉越来越多的东西,专注在自己真正在乎的事物上 面对自己的真实需求,思考物品和自己之间的关系 不仅仅是数量上的减少,还包括流程上的简化 需要提前花时间做好设计、善用收纳 应该注重对选择的简化 信息分类 主动选择信息 善用工具 主动远离诱惑源。注意力和意志力都是极其珍贵的稀缺资源,应该减少诱惑对它们的损耗 他咋恁能自控? 少做事。生命有限,选择了自己心中所爱,就必然意味着要放弃很多东西,很多可做可不做的事情就不要做了 ","date":"2022-10-03","objectID":"/posts/2022/10/minimalism-self-control/:0:0","tags":["极简主义","自控力"],"title":"我对极简主义的理解","uri":"/posts/2022/10/minimalism-self-control/"},{"categories":["思维"],"content":" 读完所有书 知道所有知识 后悔昨天 担心明天 赢得辩论 他人对你的看法 取悦所有人 所有事情都想正确 社交媒体 新闻八卦 b站, youtube, 知乎… 抽烟喝酒 Porn 所用物品的品牌 抱怨 妒忌 自责 购物 买东西花过多时间挑选 过度整理 最新的软件 与目标无关的技能 电视剧,电影,纪录片,综艺 ","date":"2022-08-20","objectID":"/posts/2022/08/unimportant-things/:0:0","tags":["感悟"],"title":"生活中不重要的事情","uri":"/posts/2022/08/unimportant-things/"},{"categories":["生活"],"content":"实际上是我的跑步计划。之所以名为“长征”,是因为我目标跑步距离是25000里,刚好是红军长征的距离。 我给实现这个目标的时限是30年。这个时间足够长,一方面是为了将跑步作为此后生活中重要的一部分,保证我身体健康,精力充沛;另一方面,生活中总会有各种意外,一小段时间没跑也不至于影响大局,有足够的余地灵活安排,不会给自己带来额外的心理压力。 至于距离设置为25000里,是为了向红军长征致敬。前几年看《长征》电视剧,就萌生了重走长征路的想法,但至今尚未有合适的机会。以后能不能实现重走长征路先放一边,我这跑个长征的距离,也算是以另一种形式在实现这个愿望了。 25000里是12500公里。如果我每年跑500公里,那么25年就可以完成这个目标,30年时间绰绰有余了。所以我每年给自己的目标也不是硬性的500公里,多一点少一点都可以,可能年轻时多跑一点,年老时少跑一点。 今天,刚刚完成了第一个500公里,第一次跑步是去年的9月5日,今天是8月20日,略少于一年。很开心,特发此文以纪念! ","date":"2022-08-20","objectID":"/posts/2022/08/long-march-plan/:0:0","tags":["习惯"],"title":"\"长征\"计划-第一个500公里","uri":"/posts/2022/08/long-march-plan/"},{"categories":["读书"],"content":"最近从信阅上借了两本书:《编程珠玑》和《代码大全》,这两本书以前都看过的,只是那时经验尚浅,这次阅读属于温故而知新,这里记录《编程珠玑》中一些我觉得比较重要的内容。 ","date":"2022-06-08","objectID":"/posts/2022/06/reading-programming-pearls/:0:0","tags":["算法"],"title":"读《编程珠玑》","uri":"/posts/2022/06/reading-programming-pearls/"},{"categories":["读书"],"content":" 第1章 开篇 正确的问题。编程活动中,如果能够正确理解并定义了问题,这场战役就成功了90%。什么是问题?问题就是想要的目标状态和目前的实际状态之间的差异,所以要从这几个角度来思考:目标是什么?现状是什么?有哪些约束条件? 时间-空间折中与双赢。通常我们会认为时间和空间效率不可兼得,需要做trade-off。但是有时这个假设是不正确的,在某些情况下,减少程序的空间需求也会减少其运行时间。这可能是因为:需要处理的数据变少了,意味着处理这些数据所需的时间也减少了;同时将这些数据保存在内存中而不是磁盘上,进一步避免了磁盘访问的时间。所以,应尽可能寻找时空双赢的方案。 简单的设计。Antoine de Saint-Exupéry是法国作家(《小王子》的作者)兼飞机设计师,曾说:“设计者确定其设计已经达到了完美的标准不是不能再增加任何东西,而是不能再减少任何东西”。程序设计亦然。 ","date":"2022-06-08","objectID":"/posts/2022/06/reading-programming-pearls/:1:0","tags":["算法"],"title":"读《编程珠玑》","uri":"/posts/2022/06/reading-programming-pearls/"},{"categories":["读书"],"content":" 什么是整体性学习整体性学习需要采取多种途径综合学习,在于创造信息的网络,一个知识与另一个知识相互关联,那些相互关联的知识网络使你真正做到对知识的完全理解,从而轻松地驾驭知识。 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:1:0","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 核心目的建立知识间的联系,形成结构/模型和高速公路. ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:1:1","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 核心概念 结构: 某一块紧密联系的知识. 模型: 对结构进行抽象,进行压缩编码.随着理解深入,需要对模型进行更新 高速公路: 将结构与结构联系起来.有一些成熟结构(感知结构,关系结构,基础数学结构)可资利用. ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:1:2","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 信息的类型","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:2:0","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 信息的分类及应对 随意信息 一系列缺少逻辑分类的事实,日期,定义和规则.用联想法,挂钩法,压缩法去记忆 观点信息 存在争论的信息.需要速读来收集信息,并用图表法列出. 过程信息 教导如何行动的信息.先建立正确的背景观念,不断练习,并在练习中归纳出模型.这类信息必须投入大量的时间联系. 具体信息 那些在实际中可以被感官接收的信息.内在化有助于将信息与多个感官相联系. 抽象信息 缺少与感官直接联系的信息,如数学,计算机.内在化和比喻法对于将复杂知识简化至关重要;随时进行模型纠错. 学习一个新问题时,首先要判断信息主要属于哪一类?确定信息的类型可以帮助我们决定学习时采用什么技术,以及估计记忆时可能会遇到的困难。 信息结构的强弱随意信息结构最弱,具体信息和过程信息结构最强.应该尽量将弱信息结构转变为强信息结构. ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:2:1","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 整体性学习的具体策略以实际应用为目的进行学习. ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:0","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 获取知识 快速阅读 积极阅读 带着问题阅读 笔记流 步骤 首先写下最主要的观点,尽量用很短的单词来替换完整的句子 一旦你写下了一个观点,下一步就是在这个观点和其他观点之间画上一些箭头,观点不是建立成金字塔式的结构,而是呈现出相互关联的关系,这个过程与实际的整体性学习策略类似,观点连在一张网中。 不需要画得好看 识别重点以及知识间的联系 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:1","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 联系观点 比喻法 不熟悉的知识和熟悉的知识,建立桥梁. 找到比喻要保证让10岁孩子听懂. 内在化 想象一副图像,并把其他感觉也加入图像中,还可以加入情感. 比喻内在化 理解抽象概念时,可以将比喻法和内在化结合起来 图表法 流程图 绘制一系列的步骤 绘制历史事件 绘制一个系统 概念图 核心概念/衍生概念以及它们之间的关系 从最重要的观点出发,不断发出分支细化知识及分解观点 图像 简单的涂鸦 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:2","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 随意信息的处理 联想法 创造顺序清单 给清单中的每一项设一个有关联的符号 创建属于自己的联想(尽量夸张,奇特) 挂钩法 记忆事件的日期 创造与事件相关的图像 与数字挂钩 将事件与数字的特殊含义(事先自己编造)建立联系 信息压缩技术 记忆术 每句话抽出一个字或一个词,组成新的词或新的句子 图像联系 将几个信息联系起来,放在图表里. 笔记压缩法 将大量只是减少到几页笔记,从整体上审视之. 拿几张空白纸 用最小的字,写下笔记中的主要观点. 接着写下与之相联系的观点/公式/概念或定义. 持续上述自由写下观点的过程,直至将笔记中每一个主要观点都写下来为止. 有时候可以更进一步,将压缩后的信息整理得更有条理. ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:3","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 知识的延伸 用于实际 用编程思想解决生活中的问题 用会计学管理个人财务 模型纠错 在实践中发现问题,改进自己的模型. 散弹枪策略 每种类型的问题都做一做,同一类的问题不要重复 把练习时间分配到每一天 以项目为基础的学习设定一个需要1~3个月达成的目标,围绕着目标去学习. 从小项目开始 将完成项目的过程记录下来 最好项目本身也有意义 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:4","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 费曼技巧 选择要学习的概念 设想你是老师,正在试图教会一名新生这个知识点,把自己的解释记录下来 当你感到疑惑时,返回去重新解释 简单化和比喻 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:3:5","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 提高效率的好习惯","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:0","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 能量管理 增加能量储备 每周运动3~5次 良好的睡眠 健康的饮食 足量的饮水 日程表由线性改为循环 一周休息一天 晚上不干活儿 90分钟为一个学习周期 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:1","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 决不拖延 每周周末,列一个清单,包括所有的任务/作业以及你想在下周完成的读书和学习活动 每天晚上,检查周计划,列出每日目标清单 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:2","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 批处理类似的零散工作要集中起来一次性处理完. 耗时不太长(\u003c3h)的那些适合用批处理,如看邮件 能一次性完成的工作就一次性完成 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:3","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 有组织 所有的物品都放在固定的位置 随身携带一个记事本 坚持日历和做事清单 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:4","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 自我教育 每日阅读 每日练习 每日目标 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:5","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 克服挫折 遇到任何障碍可以写下来 使用网络 找一本\"怎么做\"的工具书 换一个角度试试 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:6","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["读书"],"content":" 设置学习目标目标要吸引自己. 所有的目标都要写下来 让目标客观化,可衡量 设定有些困难,但是努把力也可以达到的截止期限 将目标的完成转化为每日和每周的具体行动 经常看看自己的目标 ","date":"2022-05-18","objectID":"/posts/2022/05/reading-how-to-learn/:4:7","tags":["方法论"],"title":"读《如何高效学习》","uri":"/posts/2022/05/reading-how-to-learn/"},{"categories":["生活"],"content":" 1021年,生于江西抚州临川 1030年,十岁,父王益知韶州,安石随之 1033年,十三岁,祖父去世,随父归临川 1036年,十六岁,随父进京 1037年,十七岁,随父至江宁,立志,用功读书 1039年,十九岁,父去世,居丧江宁,读书 1041年,二十一岁,科举礼部考试 1042年,二十二岁,进士及第,签书淮南判官,至扬州 1045年,二十五岁,任满归京师 1047年,二十七岁,知鄞县,开始尝试青苗法 1050年,三十岁,任满离开鄞县,回京师听调 1051年,三十一岁,通判舒州 1054年,三十四岁,舒州任满还京师,作“游褒禅山记”,然后任群牧判官 1057年,三十七岁,离京赴任知常州 1058年,三十八岁,自常州移提点江南东路刑狱,赴饶州 1059年,三十九岁,为三司度支判官 1061年,四十一岁,以三司度支判官知制诰,纠察在京刑狱 1063年,四十三岁,英宗立,安石丁母忧,解官归江宁 1064年,四十四岁,居丧江宁讲学 1067年,四十七岁,英宗卒,神宗立,安石以知制诰出知江宁府 1068年,四十八岁,奉诏越次入对 1069年,四十九岁,任参知政事,开始推行新法 1073年,五十三岁,王韶击败吐蕃木征等,收复洮、岷诸州,神宗以所服玉带赐安石 1074年,五十四岁,安石请求罢相,以吏部尚书、观文殿大学士出知江宁府 1075年,五十五岁,安石复相,颁《三经新义》 1076年,五十六岁,再度罢相,为镇南军节度使、同平章事、判江宁府 1079年,五十九岁,营建半山园;发生乌台诗案 1085年,六十五岁,神宗崩,新法遭全面否定 1086年,六十六岁,安石病死于金陵 ","date":"2022-04-19","objectID":"/posts/2022/04/life-of-wanganshi/:0:0","tags":["人物"],"title":"王安石生平","uri":"/posts/2022/04/life-of-wanganshi/"},{"categories":["技术"],"content":" 程序分析的目的是什么对计算机程序进行自动化的处理,以确认或发现其特性,比如性能、正确性、安全性等. 其结果可用于编译优化、提供警告信息等,比如被分析程序在某处可能出现指针为空、数组下标越界的情形等. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:1:0","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 被分析的对象被分析的程序可以是源代码(各种语言),也可以是是二进制可执行代码(各种指令集),也可以是中间代码(LLVM IR, VEX IR). ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:1:1","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 欲获取的程序性质根据分析目的不同,非常多样.大致可分为性能/正确性/安全性. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:1:2","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 如何评价程序分析技术不仅要看其分析对象的规模、复杂度,分析过程的效率,还要看其对用户的要求,发现缺陷的严重程度,以及误报率、漏报率等. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:2:0","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 有哪些程序分析技术总体上分为动态和静态.所谓的静态分析,是指对程序代码进行自动化的扫描、分析,而不必运行程序;与静态分析相对应的是动态分析技术,其利用程序运行过程中的动态信息,分析其行为和特性. 以下几种都是静态分析技术. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:0","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 抽象解释基于抽象解释来设计程序分析,本质上是通过对程序语义进行不同程度的抽象,以在分析精度和计算效率之间取得权衡.由于分析过程赋予了源程序一种抽象语义,所以分析器就变成了一种在抽象语义上的解释器,这也是名称\"抽象解释\"的由来. 抽象解释的典型应用案例是,Astrée 成功应用于空客 A340(约 13.2 万行 C 代码)、 A380(约 35 万行 C 代码)等系列飞机飞行控制软件的自动分析并实现了分析的零误报. 数据流分析通过分析程序状态信息在控制流图中的传播来计算每个静态程序点(语句)在运行时可能出现的状态.可视为抽象解释的一个特例,其计算的状态信息(抽象域)局限于有限高度的格. 主要应用在编译器中,其分析结果可用于编译优化. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:1","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 符号执行使用符号化输入代替实际输入以模拟执行(不实际执行)被分析程序,程序中的操作被转化为相应的符号表达式操作.在遇到条件语句时,程序的执行也相应地分叉以探索每个分支,分支条件则被加入到当前路径的路径条件(path condition)中.通过调用 SAT/ SMT 求解器,对路径条件的可满足性进行求解来加以判断. 典型的应用案例是微软公司把自己开发的二进制动态符号执行工具 SAGE 用于 Win 7 的测试,发现了文件模糊测试中 1/3 的 缺陷;2016 年 8 月,在美国 DARPA 举办的网络空间安全竞赛(CGC)中,最终排名前三的参赛队伍全 部使用了符号执行技术,用于自动发现并利用二进制程序中的漏洞. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:2","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 基于机器学习的程序分析随着近年来通用计算设备能力的提高,海量的程序执行数据被存储和管理;研究者采用机器学习、统计分析等系列技术提升现有的程序分析能力. ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:3","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" 待补充…","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:4","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["技术"],"content":" Reference 张健 等:程序分析研究进展 ","date":"2022-04-19","objectID":"/posts/2022/04/program-analysis-intro/:3:5","tags":["程序分析"],"title":"程序分析简介","uri":"/posts/2022/04/program-analysis-intro/"},{"categories":["思维"],"content":"就像吃饭一样,我们吃的东西会影响我们的身体健康状态.信息就好像是我们的精神食粮,我们每天都在接收处理信息,它会深刻影响我们的精神健康状态. 有人说,我有分辨甄别能力,我不会受到那些负面影响.其实不然,很多人低估了负面信息的影响,我们看到的听到的信息,其实都会潜移默化地对我们的精神产生影响,很多是潜意识层面的,反思能力不强的人根本觉察不到. 即便是有甄别信息的能力,难道接收处理那些信息不需要成本吗?需要我们付出极大的时间和精力成本,而这些时间和精力本来可以用来做更有价值的事情. 有人说,我如果不关注这些信息,我就跟世界脱节了,就没法跟身边的小伙伴愉快的聊天了.诚然,这话有一定的道理.我们都害怕孤独,希望融入到集体中,在聊天的时候能够接得上话,不至于显得特别无知.这是可以理解的.可是害怕孤独更多的是因为我们内心不够强大,修炼自己的内心才是更好的解决之道.我们期望能够在集体聊天时接得上话,这是合理的,也是应该的,但这个只需要我们对时事新闻保持一点点的关注就够了,知道他们说什么就可以了,能够在小伙伴说的时候问出正确的问题就行了.这些都是时效性很短的东西,不需要在这些事情上寻找优越感,不用在这些事情上懂得很多. 另一方面,在聊天时要克制自己显摆的欲望,要更多的给别人说话的机会,那么适当的发问就很重要.甚至,我们可以把这个聊天也当作一个信息源,这就更加节约了自己获取信息的成本.利己利人,何乐而不为? 强调一下,当然不是要完全不关心时事,否则,大家在讨论什么,你一点也不知道,一问三不知.时间久了确实会脱节的.所以说,要关注,只是关注的程度要足够低罢了. ","date":"2022-03-16","objectID":"/posts/2022/03/information-source-control/:0:0","tags":["方法论"],"title":"为什么要控制信息源","uri":"/posts/2022/03/information-source-control/"},{"categories":["思维"],"content":"有这三种笔记本就够了:学习笔记本,任务管理笔记本和解决问题笔记本。其中学习笔记本侧重于知识输入,帮助知识内化在自己的头脑中,并形成一个知识库,作为自己的外脑供检索。而任务管理笔记本和解决问题笔记本侧重于输出,都是为了指导自己的行动。任务管理笔记本着眼在宏观,提供一个整体的蓝图,用于计划我要做哪些事情;而解决问题笔记本着眼在微观,针对一个个具体的任务和问题,用于引导自己思考我要怎么解决这个问题。 ","date":"2022-02-08","objectID":"/posts/2022/02/my-note-taking-system/:0:0","tags":["方法论"],"title":"你需要的三种笔记本","uri":"/posts/2022/02/my-note-taking-system/"},{"categories":["思维"],"content":"道理与解数学题是类似的。 ","date":"2022-02-08","objectID":"/posts/2022/02/how-to-solve-problems/:0:0","tags":["方法论"],"title":"你会解决问题吗","uri":"/posts/2022/02/how-to-solve-problems/"},{"categories":["思维"],"content":"有的人对很多领域都有所涉猎,博闻强识,兴趣广泛,却没有一件事情能做到顶尖水平;有的人只在一个领域深耕,兴趣单一,但对深耕的领域极为精通。 我们称前者为通才,后者为专才。当然,有一些天才能做到既通又专,在很多领域都能做到顶尖水平,但天才毕竟极少,是我们羡慕但学不来的。 那么,对于我们这些不甘于平庸的平凡人来说,努力的方向是成为通才呢,还是成为专才呢? 我的答案是,单单考虑社会价值的话,应该以成为专才为首要目标。 理由如下: 我们是平凡人,不是天赋型选手 现代社会是一个高度分工和专业化的社会 我们时间和精力有限 我们虽然是平凡人,但却往往对某一领域比较擅长或比较感兴趣 有人会拿「木桶理论」说事,说应该补足个人能力的短板,否则个人的发展就会受到那块短板的制约。这话有一定的道理,但是却很容易误导人,原因在于我们并不清楚短板应该补足到何种程度。 我们去接触学习各种领域的知识,美其名曰「补足短板」「兴趣广泛」,其实有时只是满足自己的猎奇心理,有时只是为了造成在努力学习的假象,缓解自己的知识焦虑,有时二者兼而有之。 所以,不要被「木桶理论」所迷惑,要先以做一个专才为目标,深耕一个领域,刻意练习,投入时间来积累,做到专家的水准。 或者更准确的说法,如做出好选择 (豆瓣)所说,做一个「一专多能零缺陷」的人。 这个词语本来是说产品设计的,但是对个人成长也同样适用。一个人的社会价值,跟一个产品的社会价值,道理是一样的。当我们把人当作社会中的产品来思考,「一专多能零缺陷」的道理就很明白了。 又有人会说,把一个人的价值等同于其社会价值,太狭隘了,我们应该跟随内心的兴趣,不要在乎外部评价。 这话也有道理,一个人的价值不能等同于外部评价。但是对于普通人,外部评价却对我们对自我的看法有很大的影响(除非是像庄子那样的圣人),我们对自我的看法又决定了我们的自尊、自信和幸福感,试想一个不停遭受打击和嘲讽的人,很难拥有自信健康的心理。 另外,我所说的社会价值也不全是外部评价,为社会做点贡献,为社会做更多的贡献,也是我心向往之的一种活法,这是应该在意的。至于后续的评价,更多的只是自然而然的结果罢了,这种结果有时不公,有时迟到,这才是不要过分在意的对象。 总之,要记住少即是多,「一专多能零缺陷」。专业领域踏实积累,刻意练习;其他领域有需要则了解,不需要则不需要去了解,牢记二八定律;至于缺陷,将之弥补到不会成为瓶颈的程度即可。 ","date":"2022-02-08","objectID":"/posts/2022/02/generalist-or-specialist/:0:0","tags":["方法论"],"title":"做通才还是专才","uri":"/posts/2022/02/generalist-or-specialist/"},{"categories":["思维"],"content":" 引子著名的任务管理四象限法,将任务按照重要性和紧急性两个维度来考量。紧急性主要与deadline有关,是比较容易判断的。但是任务的重要性,却不像表面上看起来那么容易判断。 那么有没有比较科学又容易执行的判断方法呢? 采铜在知乎上的一个回答中,提到的两个概念:收益值与半衰期,为回答这个问题提供了一些启发。 他是这么说的: 当我们评价一个事情值不值得去做、应该花多少精力去做的时候,应该抛弃单一的视角,而是分从两个不同的维度来看,一是该事件将给我带来的收益大小(认知、情感、物质、身体方面的收益皆可计入),即「收益值」;二是该收益随时间衰减的速度,我称为「收益半衰期」,半衰期长的事件,对我们的影响会持续地较久较长。 如此,收益值和半衰期正交一下就构成了一个四象限图,所有的任务都可以放到这个图的某个象限里。文中举了一些例子: 高收益值、长半衰期事件:找到自己的真爱、学会一种有效的思维方法、完成一次印象深刻的旅行、与大牛进行一场意味深长的谈话; 高收益值、短半衰期事件:买一件时髦的衣服、玩一下午手游、吃一顿大餐、看AV撸管; 低收益值、长半衰期事件:练一小时书法、背诵一首诗、背牢十个单词、看一本经典小说、读懂哲学著作的一个章节、多重复一次技能练习、认真地回复一封友人的邮件; 低收益值、短半衰期事件:挑起或参与一次网络掐架、漫无目的地网上闲逛刷微博、使用微信陌陌知乎等进行成功率很低的勾搭。 ","date":"2022-02-07","objectID":"/posts/2022/02/importance-estimation/:1:0","tags":["方法论"],"title":"如何确定事情的重要性","uri":"/posts/2022/02/importance-estimation/"},{"categories":["思维"],"content":" 用收益值和半衰期来确定重要性借鉴这个思路,我们需要确定事情的重要性时,就按照这两个维度进行思考,第一个维度要考虑做了这个事情收益有多大,第二个维度要考虑这个收益是否能对未来影响深远。 如此,思考更加系统,而且更加细化。 对于一件事情,完成之后收益越大,能够影响未来的时间越长,那么相应地也就越重要。 ","date":"2022-02-07","objectID":"/posts/2022/02/importance-estimation/:2:0","tags":["方法论"],"title":"如何确定事情的重要性","uri":"/posts/2022/02/importance-estimation/"},{"categories":["思维"],"content":" 收益的衡量这里还有一个问题:如何判断一件事情的收益呢? 这与个人的价值观关系很大。一个人认为价值很大的事情对另一个人价值可能很小,比如有的人就喜欢时髦的衣服,有的人却喜欢穿得仆仆素素。 所以我们要先问自己一个问题:我到底需要什么?之前的文章如何做更好的决定也探讨了这个问题。 只有知道自己需要什么,才好确定做成这件事的结果是不是自己期待的,以及到底有多期待。 然后确定事情的收益值就成了水到渠成的事情。 ","date":"2022-02-07","objectID":"/posts/2022/02/importance-estimation/:3:0","tags":["方法论"],"title":"如何确定事情的重要性","uri":"/posts/2022/02/importance-estimation/"},{"categories":["思维"],"content":" 总结要确定一件事情的重要性的时候,要问自己三个问题: 我需要什么?我的价值观排序是怎样的? 做成这个事情的收益是大还是小? 这个收益对未来的影响是否深远? ","date":"2022-02-07","objectID":"/posts/2022/02/importance-estimation/:4:0","tags":["方法论"],"title":"如何确定事情的重要性","uri":"/posts/2022/02/importance-estimation/"},{"categories":["思维"],"content":" 参考 收益值与半衰期 | Notes ","date":"2022-02-07","objectID":"/posts/2022/02/importance-estimation/:5:0","tags":["方法论"],"title":"如何确定事情的重要性","uri":"/posts/2022/02/importance-estimation/"},{"categories":["读书"],"content":" 职责链模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:1:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景有多个对象可以处理同一个请求,具体是哪个对象由运行时刻自动确定 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:1:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案能够处理请求的对象继承自同一个抽象类,运行时刻组成链状结构。 客户发请求给这条链的第一个对象,如果这个对象能处理则处理,不能处理则交给这条链的下一个对象。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:1:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:1:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 命令模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:2:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景有时必须向某对象提交请求,但并不知道关于被请求的操作或请求的接受者的任何信息。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:2:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案将一个请求封装为一个对象,从而使我们可用不同的请求对客户进行参数化;对请求排队或者记录请求日志,以及支持可撤销的操作。 把接受者封装到命令对象里面,然后一起交给invoker,invoker在将来的某一时刻会回调这个命令对象,这时命令对象会给接受者发消息,执行动作。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:2:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 动态活动图 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:2:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 其他在函数式语言中,由于函数可以很方便的传来传去,就不需要命令模式这么麻烦了。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:2:4","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 解释器模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:3:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景如果一种特定类型的问题发生的频率足够高,那么可能就值得将该问题的各个实例表述为一个简单语言中的句子。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:3:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案实现一个DSL的解释器 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:3:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:3:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 其他一般情况下不需要这么复杂的方案,所以这里记的很简略。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:3:4","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 迭代器模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:4:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景聚合对象需要提供一种方法来让别人访问它的元素 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:4:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案C++标准库里对所有容器都提供了迭代器 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:4:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:4:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 中介者模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:5:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景很多对象可能以各种各样的方式连接,每个对象都知道很多其他对象,他们耦合在一起。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:5:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案用一个中介者对象,专门负责控制和协调一组对象间的交互。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:5:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:5:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 备忘录模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:6:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景有时需要捕获一个对象的状态,但是暴露其内部状态又违反封装的原则 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:6:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案做一个备忘录对象,可以存储另一个对象(originator)在某个瞬间的内部状态。 只有originator有资格初始化并访问该备忘录。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:6:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:6:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 观察者模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:7:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,要通知所有依赖于它的对象 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:7:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案一个对象Observer可以向对象Subject发出订阅请求,而subject维护了所有订阅者的集合。 当subject状态有更新时,就向所有订阅者发出update消息,而Observer要有能力处理update消息。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:7:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:7:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 状态模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:8:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景对象需要在其内部状态改变时改变它的行为 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:8:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案建模为有限状态机 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:8:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:8:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 策略模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:9:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景有一系列可相互替换的算法 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:9:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案将算法封装为策略类 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:9:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:9:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 模板方法模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:10:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景一个算法的骨架是确定的,但其中的一些步骤可以有多种实现方法 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:10:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案将算法骨架实现为模板方法,然后有差别的步骤延迟到子类中实现 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:10:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:10:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 访问者模式","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:11:0","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 场景数据是稳定的,但是要经常添加针对这些数据的操作。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:11:1","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 方案 将操作封装为visitor 客户以具体的visitor为参数向数据发送accept消息 数据处理accept消息的方法是,反过来给visitor发送visit消息,同时也把自己交给visitor 接下来,visitor根据发来的数据的类型,进行具体的处理 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:11:2","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:11:3","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 其他 添加新操作只需要增加一个对应的visitor,其中定义对各种数据类型的访问处理。 ","date":"2022-02-07","objectID":"/posts/2022/02/design-pattern-4/:11:4","tags":["软件设计"],"title":"读书笔记-设计模式-行为型模式","uri":"/posts/2022/02/design-pattern-4/"},{"categories":["读书"],"content":" 适配器模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:1:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景想使用一个已经存在的类,而它的接口不符合需求 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:1:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案 基于多重继承的 Adaptor类实现需要的接口,同时私有继承(实现继承)那个已经存在的类Adaptee。 Adaptor类在实现接口的时候,将使用私有继承来的Adaptee来实现。 基于对象组合的 Adaptor类实现需要的接口,其内部保存一个Adaptee的引用。 Adaptor类在实现接口的时候,将委托Adaptee完成相应的功能。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:1:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 基于多重继承的 基于对象组合的 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:1:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 两种方案的权衡对象适配器比较灵活,允许适配Adaptee以及它的所有子类。而类适配器则不行。 对象适配器需要额外的指针,类适配器不需要。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:1:4","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 桥接模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:2:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景要将抽象部分与它的实现部分分离,使它们都可以独立地变化 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:2:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案将抽象和实现部分分别放在独立的类层次结构中,其中一个针对接口,另一个针对实现,针对接口的类层次结构需要保存一个关于实现的对象的引用。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:2:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:2:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 其他虽然UML类图与对象适配器很相似,但是两者的目的不同,对象适配器是为了实现接口的转换,而桥接模式是为了将接口和实现分离。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:2:4","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 组合模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:3:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景处理具有整体-部分层次结构特征的对象,一些复杂的组件是由简单的组件组合而成,这些复杂的组件又是更复杂组件的组成部分。 想对所有组件进行统一处理。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:3:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案关键是让所有组件继承自同一接口。复杂组件保存有简单组件的引用。 形成的动态结构是树状的。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:3:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 类图 动态对象图 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:3:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 装饰模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:4:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景希望给某个对象而不是整个类添加一些功能。用继承方式不够灵活。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:4:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案将组件嵌入另一个对象中(装饰对象保存有原组件的引用)。装饰对象接受到请求时,在将请求发给原组件前后,可以自由执行一些额外的动作。 由于原组件和所有的装饰类都继承自同一接口,所以可以递归地嵌套多个装饰对象,从而添加任意多的功能。 形成的动态结构有点类似于链表。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:4:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:4:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 其他与组合模式相比,可以将装饰视为一个退化的、仅有一个组件的组合。然而,装饰仅给对象添加一些额外的职责,而组合的目的在于对象的聚集。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:4:4","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 外观模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:5:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景为子系统的一组接口提供一个一致的界面 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:5:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案提供一个高层接口,给客户一个一致的界面。而该接口的具体实现委托给子系统。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:5:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:5:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 享元模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:6:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景运行过程中创建了大量的对象,造成很大的存储开销。而且对象的大多数状态都可变为外部状态。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:6:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案享元模式通过共享技术实现相同或相似对象的重用。 在享元模式中可以共享的相同内容称为内部状态(Intrinsic State),而那些需要外部环境来设置的不能共享的内容称为外部状态(Extrinsic State), 由于区分了内部状态和外部状态,因此可以通过设置不同的外部状态使得相同的对象可以具有一些不同的特征,而相同的内部状态是可以共享的。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:6:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:6:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 代理模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:7:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 场景一个客户不想或者不能直接引用一个对象 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:7:1","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 方案通过引入一个新的对象(如小图片和远程代理 对象)来实现对真实对象的操作或者将新的对象作为真实对象的一个替身。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:7:2","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:7:3","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 结构型模式的讨论 适配器模式和桥接模式 适配器用于解决两个已有接口不匹配的问题。桥接模式是为了将抽象和实现两者独立演化。 组合模式和装饰模式 都基于递归组合来组织可变数目的对象,但目的不同。组合模式旨在使整体与部分统一处理,而装饰模式旨在给对象添加职责。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-3/:8:0","tags":["软件设计"],"title":"读书笔记-设计模式-结构型模式","uri":"/posts/2022/02/design-pattern-3/"},{"categories":["读书"],"content":" 简单工厂模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:1:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景创建一系列类似的产品,这些产品有差异,但属于同一类 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:1:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案 创建产品的基类,为抽象产品 一系列具体的产品继承自抽象产品 创建一个工厂类,该工厂知道所有的具体产品,可以根据传入的参数构造相应的具体产品,返回抽象产品 客户不需要知道具体产品类,只需要知道工厂类以及具体产品,就可以请求工厂为之构造具体产品 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:1:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:1:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 其他这里的工厂类也可以简化为一个普通的创建函数 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:1:4","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 工厂方法模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:2:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景也是要创建同一类但有差异的产品,每个产品的创建过程都比之前要复杂一些。 那么如果用简单工厂模式,工厂类的设计逻辑就比较复杂。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:2:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案为每一个产品都配一个对应的工厂,这个工厂就只负责这一种产品 创建一个抽象产品类和一个抽象工厂类 具体的产品类继承自抽象产品类,具体的工厂类继承自抽象工厂类 具体的产品和具体的工厂存在着一一对应关系,一个工厂只负责一种产品的构造 客户不需要知道具体的产品,但需要知道具体的工厂,给具体工厂发请求就可以得到具体的产品了 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:2:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:2:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 其他在C++中可以利用模板将产品和对应的工厂联系起来(将产品作为工厂模板的参数) ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:2:4","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 抽象工厂模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:3:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景产品不再是只有同一类了,产品也有多类,但是这些不同类的产品又需要同时对客户提供 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:3:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案一个具体工厂不再只生产一种具体产品了,而是负责生产一组产品。 对于每一类产品,都创建一个抽象产品类 对于每一个抽象产品类,都创建一系列具体产品类 创建一个抽象工厂类 创建一系列具体工厂类,每个具体工厂都负责一组产品的构造 客户不知道具体产品,只知道抽象产品类,也知道具体工厂类,给具体工厂发请求就可以得到那一组具体的产品了 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:3:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:3:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 建造者模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:4:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景一个复杂对象拥有多个组成部分,如汽车,它包括车轮、方向盘、发送机等各种部件。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:4:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案一步一步构造整个复杂对象。 创建一个抽象类builder,和若干个具体builder builder负责构造复杂对象的各个部分 创建一个具体类director,内部保存了一个builder的引用,但不知道builder具体是哪个类 director负责构造整个复杂对象,而构造的方法是给自己关联的builder发消息,让builder把各个组成部分构造出来 客户只需要知道具体的builder,把这个builder交给director,然后请求director构造复杂对象即可 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:4:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:4:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 原型模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:5:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景原型模式多用于创建复杂的或者耗时的实例,因为这种情况下,复制一个已经存在的实例使程序运行更高效 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:5:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案给对象添加一个clone方法,用于实现对自身的拷贝。 需要注意的是clone的具体实现,是深拷贝还是浅拷贝,要视具体情况而定。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:5:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:5:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 单例模式","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:6:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 场景有些类只需要唯一实例 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:6:1","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 方案一个类能返回对象一个引用(永远是同一个)和一个获得该实例的方法(必须是静态方法,通常使用getInstance这个名称); 当我们调用这个方法时,如果类持有的引用不为空就返回这个引用,如果类保持的引用为空就创建该类的实例并将实例的引用赋予该类保持的引用; 同时我们还将该类的构造函数定义为私有方法,这样其他处的代码就无法通过调用该类的构造函数来实例化该类的对象,只有通过该类提供的静态方法来得到该类的唯一实例。 多线程场景下要小心设计。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:6:2","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" UML表示 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:6:3","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 对创建型模式的讨论 抽象工厂模式,建造者模式,原型模式都是依赖于对象组合,都涉及到创建一个新的负责创建产品对象的「工厂对象」 抽象工厂模式由这个工厂对象产生多个类的对象 建造者模式由这个工厂对象使用一个相对复杂的协议,逐步创建一个复杂产品 原型模式由该工厂对象通过拷贝原型对象来创建产品对象 如何选择创建型模式 先从最简单的如工厂方法模式开始,当发现需要更大的灵活性时,再根据需要选用其他的创建型模式 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-2/:7:0","tags":["软件设计"],"title":"读书笔记-设计模式-创建型模式","uri":"/posts/2022/02/design-pattern-2/"},{"categories":["读书"],"content":" 什么是设计模式特定场景下一类问题的通用解决方案。 需要说明的是,设计模式跟所使用的编程语言是很相关的。 比如,面向对象语言中的一些行为型模式在函数式语言中就不需要,而在面向对象语言直接支持「继承」、「封装」和「多态」,如果要在过程式语言中实现,也就需要特殊的「模式」了。 所以,所谓的模式跟编程语言自身的能力息息相关。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:1:0","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 四个基本要素 模式名 问题 解决的是什么样的问题 解决方案 效果 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:1:1","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 设计模式怎样解决设计问题","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:0","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 寻找合适的对象面向对象程序由对象组成,对象包括数据和对数据进行操作的方法。对象在受到客户的请求(消息)后,执行相应的操作。 客户请求是使对象执行操作的唯一方法,操作又是改变对象内部状态的唯一方法。 面向对象设计最困难的部分是将系统分解为对象集合。 面向对象设计方法学 写出问题描述,挑出名词和动词,进而创建相应的类和操作 关注于系统的协作和职责关系 对现实世界进行建模,再将分析时发现的对象转化到设计中 各方法的优劣并无定论 设计模式如何起作用帮你确定并不明显的抽象和描述这些抽象的对象,使设计更灵活、复用性更好。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:1","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 决定对象的粒度","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:2","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 指定对象接口 操作的型构signature对象声明的每一个操作指定操作名、作为参数的对象和返回值 对象的接口interface所定义的所有操作型构的集合。描述了该对象所能接受的全部请求的集合。 类型type是用来标识特定接口的一个名字。 一个对象可以有许多类型,且不同的对象可以共享同一个类型。 当一个类型的接口包含另一个类型的接口时,我们说它是另一个类型的子类型subtype,另一个类型则称为它的超类型supertype。 子类型继承了它的超类型的接口。 接口的实现对象接口和其功能实现是分离的,两个具有相同接口的对象可以有完全不同的实现。 动态绑定客户发送请求只需要看接口,但请求具体怎么被处理,要到运行时刻才受具体对象的具体实现约束。 多态polymorphism动态绑定允许你在运行时刻彼此替换有相同接口的对象,这种可替换性叫多态。 设计模式如何起作用 通过确定接口的主要组成部分以及经接口发送的数据类型,来帮我们定义接口。 指定接口之间的关系。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:3","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 描述对象的实现 实例化由类创建一个对象,需要分配存储空间,并将操作与对象的内部数据联系起来。 类继承子类包含父类定义的所有数据和操作。子类能够改进和重新定义它们父类的操作。 抽象类为子类定义公共接口。 混入类mixin是给其他类提供可选择的接口或功能的类。与抽象类一样不能被实例化。mixin要求多继承。 类class和类型type的区别一个对象的类定义了对象是怎样实现的,同时也定义了对象的内部状态和操作的实现。 对象的类型只与它的接口有关,接口即对象能响应的请求的集合。 类继承和接口继承的区别类继承根据一个对象的实现定义了另一个对象的实现,是代码和表示的共享机制。主要为了复用。 接口继承描述了一个对象什么时候能被用来替代另一个对象。主要为了多态。 C++中,纯接口继承,接近于公有继承纯抽象类;纯实现继承或纯类继承接近于私有继承。 针对接口编程不将变量声明为某个特定的具体类的实例对象。不得已时,用创建型模式。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:4","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 运用复用机制 继承与组合实现功能复用的两种最常用技术是:类继承和对象组合,前者为白箱复用,后者为黑箱复用。 对象组合使设计更灵活,但是动态的、高度参数化的软件比静态软件更难以理解,而且还有运行低效的问题。 应该优先使用对象组合。 经验表明,设计者往往过度使用了继承这种复用技术。 委托委托是对象组合的特例。 继承和参数化类型C++ template ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:5","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 关联运行时刻和编译时刻的结构如果将编译时刻的代码结构比作静态的动植物分类,那么运行时刻结构就如活生生的生态系统。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:6","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 设计应支持变化先预测可能会发生哪些方面的变化,然后将这些变化抽象出来。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:2:7","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":" 设计模式的分类 创建型模式 单例模式、抽象工厂模式、建造者模式、工厂模式、原型模式。 结构型模式 适配器模式、桥接模式、装饰模式、组合模式、外观模式、享元模式、代理模式。 行为型模式 模版方法模式、命令模式、迭代器模式、观察者模式、中介者模式、备忘录模式、解释器模式、状态模式、策略模式、职责链模式、访问者模式。 ","date":"2022-02-06","objectID":"/posts/2022/02/design-pattern-1/:3:0","tags":["软件设计"],"title":"读书笔记-设计模式-引言","uri":"/posts/2022/02/design-pattern-1/"},{"categories":["读书"],"content":"《为什么幸运的人总幸运,倒霉的人老倒霉》读书笔记 这本小书用一个简单的故事介绍了一套做决定的方法。 故事以一个年轻人参加徒步旅行的方式展开,路上分别与不同的人交谈。这些人给年轻人引导和分享,让年轻人逐步学会这套做决定的系统方法。年轻人在生活和工作中应用这套方法后,变得更加自信、坚定而果断,遇到事情时也能做出更加明智的决定。 这套方法是怎样的呢? 首先,停止继续执行一个错误的决定。只有停下来制造一段空白,才能以更好的行动填充它。 然后开始问自己问题。分为两方面,一是向头脑提问,二是向内心提问。 向头脑提问的问题是:是不是正在满足自己真正的需要,告诉自己所有可以选择的方法,并对事情深思熟虑? 向内心提问的问题是:我作这个决定对自己是不是诚实,有没有相信自己的直觉,是不是还应该得到更好的? 关于向头脑提问,侧重于事实基础。首先要了解自己「需要」什么,尤其要区分清楚「需要(need)」和「想要(want)」的区别,如何判断是「需要」还是「想要」呢?方法是设想一个将来的场景,那时的自己会希望自己现在做这个事情吗,如果还是给出肯定的回答,那么就是「需要」,否则,就只是「想要」。 第二点是收集必要的信息,尽可能多地找出自己有哪些选择。这里的信息不止包括客观事实,也包括人们对事实的感受看法。方法包括观察和向有经验的人请教。 第三点是深思熟虑。对于每一个选择,都要推演下去,问:如果按照这个决定,可能会发生什么?然后呢? 关于向内心提问,侧重于内心感受。首先是要对自己诚实,要坦诚面对真相,不要因为真相会带来不适而欺骗自己。要问自己:我有由于不想让自己不舒服而回避真相吗? 第二点是重视直觉。如果做了一个决定,就是感到不安,那么这个决定很可能是有问题的。要问自己:如果没有恐惧,我会怎么做? 第三点是相信自己值得更好的。需要真正的相信,而不是嘴上说相信,但内心深处在抗拒。如果很难做到内心真正的相信,可以这样做,问自己:如果我相信自己应该得到更好的结果,我会怎么做?然后将自己的答案付诸行动就好了。 最后需要说明的是,要把这套方法放在触手可及的地方,比如钱包里,每当需要做决定的时候,就拿出来看看。 ","date":"2022-02-05","objectID":"/posts/2022/02/better-decision/:0:0","tags":["方法论"],"title":"如何做更好的决定","uri":"/posts/2022/02/better-decision/"},{"categories":["思维"],"content":"梁丘据谓晏子曰:「吾至死不及夫子矣!」 晏子曰:「婴闻之,为者常成,行者常至。婴非有异于人也,常为而不置,常行而不休者,故难及也。」 —— 《晏子春秋内篇·杂下》 ","date":"2022-01-26","objectID":"/posts/2022/01/do-and-persist/:0:0","tags":["方法论"],"title":"为者常成,行者常至","uri":"/posts/2022/01/do-and-persist/"},{"categories":["工具"],"content":" 排版一段代码用lstlisting环境(listing宏包) 将每一段代码用minipage环境包起来成为一个个box(注意设置每个minipage的宽度) 中间可以用\\rule命令画线,用\\hspace调整间距 若要给代码整体画个外框,可以将所有box一起放在framed环境(framed宏包)中 整体放入figure环境中,成为浮动体 示例代码: \\begin{figure}[!htb] \\lstset{language=C, numbers=left, numbersep=3pt, %frame=single, tabsize=2, xleftmargin=.05\\textwidth, %xrightmargin=.05\\textwidth, basicstyle=\\footnotesize, } \\begin{framed} \\begin{minipage}[b]{0.45\\columnwidth} \\begin{lstlisting} int callee(int x){ return x; } \\end{lstlisting} \\end{minipage} \\rule{.1pt}{36mm} \\hspace{5pt} \\begin{minipage}[b]{0.3\\columnwidth} \\begin{lstlisting} int caller() { return callee(5); } \\end{lstlisting} \\end{minipage} \\end{framed} \\caption{An example program} \\end{figure} ","date":"2022-01-21","objectID":"/posts/2022/01/latex-typeset-code-list/:0:0","tags":["问题记录","LaTex"],"title":"LaTeX如何将两段代码并排放置","uri":"/posts/2022/01/latex-typeset-code-list/"},{"categories":["思维"],"content":"如题。 是以圣人抱一以为天下式。 ","date":"2022-01-19","objectID":"/posts/2022/01/less-is-more/:0:0","tags":["方法论"],"title":"少则得,多则惑","uri":"/posts/2022/01/less-is-more/"},{"categories":["思维"],"content":" 什么是成长型思维 概念来源于心理学家卡罗尔·德韦克的经典作品《终身成长》。 主要体现在人在面对失败/挫折时的想法 固定思维的人,会自我怀疑,容易深陷于失败而裹足不前,担心即使付出努力也可能得不到成功 成长思维的人,虽然也会有一些负面情绪,但会很快调整心态,进行自我反思,尝试不同的策略去战胜种种困难和挑战 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:1:0","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 两种想法的根源何在 对自己的期待不同 固定思维期待被别人看作有天分的人 成长思维期待被别人看作肯努力的人 对失败的看法不同 固定思维把失败的行为转变成了失败的身份(我是一个失败者),更看重结果 成长思维把失败这件事当作自己改进的机会(刻意练习,有失败才能让自己进步,变得更好),更看重过程 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:2:0","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 案例 被所申请的学校拒绝后 我不想质疑您的决定。我只是想问一下,如果下次我想再申请这所学校,我该怎么改进自己的申请书。如果您能在这方面给我一些反馈和建议,我将感激不尽。 不仅要制定一个成长型思维模式计划,更要设想具体细节,设想你要如何实行它。 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:3:0","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 个体的复杂性两种思维模式并不是非此即彼的关系,人们可以在不同领域表现出不同的思维模式,很多人的成长型思维模式特质只会出现在自己感兴趣的领域。 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:4:0","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 怎样培养成长型思维","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:5:0","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 思想上 完成比完美更重要 神经可塑性 我不是一个完美的人,但我是一个坚韧宏毅的人 拥抱失败 接纳批评 任何挫折和批评都将成为我成长道路上的垫脚石 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:5:1","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["思维"],"content":" 行动上 刻意练习,用失败作为反馈,了解自己的不足 总结,反思,找到错误发生的模式,找到自己犯错的根源,争取下次不犯同种类型的一批错误 PDCA 经常说具有成长思维特点的语言 认清目标,不要为小事分心 养成一系列好习惯 ","date":"2022-01-05","objectID":"/posts/2022/01/growth-mindset/:5:2","tags":["方法论"],"title":"成长型思维","uri":"/posts/2022/01/growth-mindset/"},{"categories":["生活"],"content":" 好江风 将这轻舟催送 波翻浪涌 添几分壮志豪情 龙潭虎穴何足惧 剑戟丛中久鏖兵 非是俺藐群雄 一部春秋铭记 义不负心泰山重 忠不顾死何言轻 桃园金兰誓 弟兄山海盟 早把这七尺身躯青龙偃月 付于苍生 ","date":"2022-01-05","objectID":"/posts/2022/01/jiangshangxing/:0:0","tags":["人物"],"title":"关羽之歌","uri":"/posts/2022/01/jiangshangxing/"},{"categories":["生活"],"content":"西元新年伊始,心中有诸多感慨,却不想再抒发一遍了。仅从各方面回顾一下过去的一年,告别2021,拥抱2022。 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:0:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 健康 饮食 平时食不过饱,饮不过量,比较注意营养均衡,限制红肉类摄入。偶尔吃大餐会比较放纵。 运动 运动大概是今年我最有成就感的事情了。2月份开始跳绳减肥,大致每周2-3次,每次2000,直到9月份,减重8kg。 9月份停止跳绳,开始跑步,最初户外跑,天冷之后开始公司跑步机跑,每次4-5km。11月份,老婆给我买了跑步鞋,穿起来特别舒服,在此感谢。9月份开始腹肌撕裂者,不久后加入举铁。腹部力量明显增加,精力感觉也比之前更好。 睡眠 熬夜较严重,常常1点钟之后才睡着。早上起的倒还行,一般8点多一点。天冷之后有时赖床。睡眠偏少,精力倒还不错,大概是得益于饮食和运动吧。 打坐 前几个月还偶尔打坐,后来越来越懈怠,这两个月索性没打了。一是单纯打坐没有即时反馈,动力不足,二是自己心情较浮躁。 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:1:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 旅行 五一节去了重庆 TODO: 重庆行 12月初去了径山寺 写了一篇游记:径山寺之行 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:2:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 家庭 2月2日和老婆领了证。从此,江湖路远,与子偕行。 搬进了新家,虽然只有周末能回去 不会做饭,但也承担了一部分的家庭义务 和父母一年多没见了,因为疫情。最怕听到那句话:树欲静而风不止,子欲养而亲不待。而现实又有些无奈。后悔国庆节没回家。 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:3:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 技能 子弹笔记 记了有大半个本子,刚开始非常勤快,新鲜感过后,渐渐懒散,目前还在用的主要是习惯追踪模块。应该考虑重新用起来。 emacs 学会了神之编辑器emacs。主要用org mode,现在工作流大半都依赖emacs了,也越来越熟练了。虽然学习过程中偶有波折,但总体感觉还是很值得的。 卡片笔记写作 用org-roam,初步体验良好,但用起来还不熟练。目前主要还是按以前树状层级结构的思路去组织笔记库,应该结合卡片网状的思路,各取所长。 n1盒子折腾 淘了3个n1盒子,分别刷成了openwrt,小钢炮,和android TV,基本满足了目前家庭网络的需求。折腾过程中,学会了不少linux系统以及网络方面的知识。 英语 加入了公司背单词小分队,每天单词打卡。在知米背单词app上,把新概念3和4,雅思词汇,托福词汇,六级词汇,考研词汇,通通刷了一遍,虽然现在能记住的可能还不到1/3,但能记一点是一点,感觉现在读英文文章都比以前顺畅得多。 学习了英语兔的语音教学,纠正了自己一些错误的发音。学会了自然拼读法。 学习了英语兔的语法讲解,并结合自己以前对英语语法的思考,重新梳理了语法体系,相信会对以后的英语学习很有帮助。 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:4:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 科研 实验 大半年还是在做论文相关的实验,过程中还学习了软件工程/设计模式方面的知识,感觉还是对复杂软件系统的驾驭能力不足。 6月份误删了vps上的整个系统,代码随之无影无踪,后面花了一个月时间才勉强恢复个七七八八。反思了自己的备份习惯和备份系统。 实验数据不理想,但是,就这样吧。 论文撰写 拟好了提纲,写好了introduction,却卡在了interval analysis部分。多数时候还是有完美主义倾向,导致拖延。 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:5:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["生活"],"content":" 2022展望 完成比完美更重要 好习惯继续保持,如饮食运动 尽量不熬夜,每月熬夜不超过5次,超过12点上床算熬夜 养成记笔记的习惯 养成用思维导图思考的习惯 养成用概念图学习的习惯 坚持学英语 新概念中译英 ","date":"2022-01-01","objectID":"/posts/2022/01/summary-2021/:6:0","tags":["总结"],"title":"2021总结","uri":"/posts/2022/01/summary-2021/"},{"categories":["读书"],"content":" 什么是检视阅读检视阅读就是用浏览的方法系统性地去阅读。表面上看有点像我们平时的粗读,但其实完全不一样。关键的不同就是系统性。所谓系统性,就是说它有一套科学的流程方法,不是漫无目的,也不是随兴而至,更不是走马观花。而我们许多人,平时读书,不大注意方法,读了不少,收获不多,时间一长,连本就寥寥无几的那点收获也丢掉了。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:1:0","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 为什么要检视阅读检视阅读是一种高效的读书方法。我们平时的读书行为,主要还是为我们的现实生活服务的。不管是为了增进我们对现实世界的理解,还是为了学习解决现实问题的技巧,读书都是一个很高效的途径,特别是在这个书籍资源获取很便捷的时代。但是,如果我们没有掌握正确的方法,我们就很可能把自己淹没在这些资源中,效率很低,浪费不少时间和精力。检视阅读就是这样一种方法,帮助我们在读一本书时去伪存真,快速吸收其精华;还能帮助我们快速判断一本书的好坏,并决定是丢弃还是继续深入阅读。总之,检视阅读就是提高我们读书效率的秘诀。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:2:0","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 检视阅读怎么做","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:3:0","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 问自己问题为什么要问问题呢?其一,我们天性都是好奇的,我们的头脑对问题有一种特殊的敏感,头脑中有了问题,就会推着你去寻找答案,这会保持我们阅读的动力。其二,问题可以使我们的头脑聚焦在少量的目标上,提高思维的专注度,不至于漫无目的而效率低下。 从最通用的角度来说,对于一本书,要提出四个问题: 这本书整体在谈论什么,属于哪个类别的?这是关于这本书的主题。 这本书细部说了什么,怎么说的?这主要是要弄明白作者围绕主题说了哪些从属议题,它们之间的逻辑关系是怎样的。 这本书说得有道理吗?是全部有道理,还是部分有道理?这个决定了这本书价值到底如何。 这本书跟自己有什么关系?这样才能明白读这本书到底对自己有什么意义。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:3:1","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 带着问题去寻宝有了问题,就把自己想象成一个侦探,在找寻一本书的主题或思想的线索。 主要关注以下这几个地方: 书名 目录 序言 开头和结尾 抽取感兴趣的段落 找相关的书评 这些地方很可能藏着整本书的精华,读了它们,就能回答上一步给自己提的问题了。很多时候甚至不需要读完,读多读少以及怎么读,完全看自己的需求,总之,以能回答自己的问题,形成对书的基本轮廓为目标。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:3:2","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 做笔记不动笔墨不读书,可以将对以上四个问题的回答记录下来,就构成了这本书的读书笔记。特别是对第二个问题的回答,会帮助我们记录下这本书的基本框架。这个框架笔记,会在将来复习时帮我们快速回忆起整本书的精华内容。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:3:3","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":" 什么情况适合检视阅读检视阅读应该在初次读一本书时使用。初次读一本书时,对书的内容不了解,不知道是好是坏,用检视阅读会极大提高效率。检视阅读过程中,我们会形成对书的判断,如果不合胃口,随时可以停下来丢掉。检视阅读完成之后,如果觉得这本书价值很高,就可以深入分析精读;如果觉得一般般,那么记好必要的笔记后,不再继续读下去也无妨了,因为读这本书的目的已经达到了。 ","date":"2021-12-18","objectID":"/posts/2021/12/inspectional-reading/:4:0","tags":["方法论"],"title":"如何阅读之检视阅读","uri":"/posts/2021/12/inspectional-reading/"},{"categories":["读书"],"content":"三遍法高效读论文。 ","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:0:0","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 什么是三遍法文章读三遍。三遍层层递进,每一遍有不同的侧重,完成不同的任务,最终达到深度理解一篇文章的目的。 ","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:1:0","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 怎么做三遍法","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:2:0","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 第一遍:浏览 步骤 仔细读title/abstract/introduction 读章节标题 看一眼关于数学的部分,找出文章的理论基础 读conclusion 浏览reference,看哪些ref是自己读过的,哪些没读过 耗时5~10 min 需要回答的问题:5个C Category: What type of paper is this? A measurement paper? An analysis of an existing system? A description of a research prototype? Context: Which other papers is it related to? Which theoretical bases were used to analyze the problem? Correctness: Do the assumptions appear to be valid? Contributions: What are the paper’s main contributions? Clarity: Is the paper well written? 达到的效果if: 文章不吸引你 or 文章所讲的你已经很熟悉了 or 文章所基于的假设明显是错的 then: 丢弃之 else: 继续 ","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:2:1","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 第二遍:细读 步骤 看图表/示例 把reference中自己未读过的文献标注出来(用于补充背景知识) 耗时1 hour 达到的效果 一般来说,能理解文章的大概内容,能向别人说出文章的核心思想(the main thrust)和支撑论据。 少数情况,无法理解这篇文章,可能是由于陌生的主题,不熟悉的术语,或者作者使用的方法不熟悉。 也可能作者写得不好,或者只是你太困了。这时可以判断一下文章的价值,低价值的可以直接丢弃,高价值的,如果是缺少背景知识,就去补充背景知识,再来细读。 ","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:2:2","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 第三遍:揣摩 步骤 尝试把论文的方法重新实现一遍 跟原文方法相比较,深入理解作者的创新点,尝试找出作者的错误假设。此外,还要思考如果是自己写,自己会怎么做,并在对比中学习作者的各种技巧。还要把关于future work的想法记下来。 耗时 对于新手,4-5 hour 对于老手,1 hour 达到的效果能从记忆中重建全文的结构,并指出其优缺点。能正确指出论文的隐含假设,以及其实验或理论分析方面潜在的问题。 ","date":"2021-12-17","objectID":"/posts/2021/12/reading-a-paper/:2:3","tags":["方法论"],"title":"如何读paper","uri":"/posts/2021/12/reading-a-paper/"},{"categories":["读书"],"content":" 分析阅读的目的完整地吸取一本书的精华。 ","date":"2021-12-13","objectID":"/posts/2021/12/reading-skills-analytical/:1:0","tags":["方法论"],"title":"如何阅读之分析阅读","uri":"/posts/2021/12/reading-skills-analytical/"},{"categories":["读书"],"content":" 分析阅读的方法 第一阶段:整理内容大纲 依照书的种类与主题来分类。 使用最简短的文字说明整本书在谈些什么。 将主要部分按顺序与关联性列举出来。将全书的大纲列举出来,并将各个部分的大纲也列出来。 确定作者想要解决的问题。 第二阶段:诠释这本书的内容 找出关键字,与作者达成共识。 将一本书中最重要的句子圈出来,找出其中的主旨。 找出作者的论述,重新架构这些论述的前因后果,以明白作者的主张。 确定哪些问题已经被解决,哪些还没有被解决。 综合看前两个阶段,先是将整体分成许多部分,然后再从关键词这样的细节,一步步找出主旨与论述,再重新架构出一个整体。 第三阶段:评论一本书 除非你已经完成大纲架构,也能诠释整本书了,否则不要轻易批评。 当你不同意作者观点时,要理性的表达自己,不要无理的辩驳或争论。 尊重知识与个人观点的不同,在做出任何判断之前,都要找出理论依据。 ","date":"2021-12-13","objectID":"/posts/2021/12/reading-skills-analytical/:2:0","tags":["方法论"],"title":"如何阅读之分析阅读","uri":"/posts/2021/12/reading-skills-analytical/"},{"categories":["读书"],"content":" 分析阅读的应用 分析阅读的成本较高。 人的精力有限,不应该不分青红皂白的使用分析阅读。 分析阅读应该用于阅读对自己有高价值的书籍。 先经由检视阅读,判断书籍的价值,筛选出高价值的书籍。 ","date":"2021-12-13","objectID":"/posts/2021/12/reading-skills-analytical/:3:0","tags":["方法论"],"title":"如何阅读之分析阅读","uri":"/posts/2021/12/reading-skills-analytical/"},{"categories":["工具"],"content":" 字体类型就像图像里面的位图和矢量图一样,字体分为点阵字体和矢量字体: 点阵字体 用像素表示字体图。 很难进行缩放,特定的点阵字体只能清晰地显示在相应的字号下。 对于 12-16 px 的小号汉字来说,点阵字体往往比其它类型的字体在屏幕上有更好的显示效果。 包括来自Adobe的BDF和来自Xorg的PCF. 可以通过gzip压缩。 矢量字体 使用贝塞尔曲线、绘图指令和数学公式来描述每种字形,使得字体可以适应各种尺寸。 包括: PostScript 字体 TrueType字体(Apple 和 Microsoft 定义,ttf) OpenType字体(基于 TrueType,Microsoft 定义,otf/ttf) ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:1:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 安装字体包一般情况下用系统的包管理软件如pacman即可 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:2:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 查看字体包","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:3:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 查看所有 fc-list ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:3:1","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 查看中文 fc-list :lang=zh | cut -d: -f1 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:3:2","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 什么是serif和sans-serif从笔画风格对字体的分类。 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:4:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" serif是衬线体 衬线体起源于古罗马的石刻拉丁字母。1968年爱德华·卡蒂奇神甫在其著作《衬线的起源》一书中指出,在石刻时,先用画笔将字母轮廓标注在石头上,然后刻字人依照痕迹进行刻画形成了衬线。 风格比较正统,一般用于传统印刷。 东亚一般称为“白体”,中国大陆地区和港台的印刷界称之为 宋体 。 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:4:1","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" sans-serif是无衬线体 sans 在古希腊语言中是without的意思。 抛弃装饰衬线,只剩下主干,造型简明有力,更具现代感,起源也很晚。 风格比较轻松,适用于标题、广告。 因棱角较少,方便渲染,广泛用于电脑手机萤幕。 东亚一般称为 黑体 。 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:4:2","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" 什么是等宽字体 顾名思义,字符宽度相等的字体。英文叫monospace. 因打字机及早期的电脑画面显示等由于技术的局限,无法进行字母宽度的比例调整,因此将每个字符都制作成一样的宽度,从而形成了等宽字体。 在等宽字体中,字母“i”、“j”显得两侧余白较多,而字母“w”、“m”等的笔画显得相当拥挤。 东亚语言中,方块字基本上都作为等宽字体处理。 代码以及文字接口的程序,如代码编辑器、虚拟终端等也经常使用等宽字体,可以提高可读性。 与等宽字体相对应的是 比例字体 。 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:5:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" Reference一篇关于字体的好文章.https://sspai.com/post/71957 ","date":"2021-12-11","objectID":"/posts/2021/12/font-basics/:6:0","tags":["问题记录","字体"],"title":"字体基础知识","uri":"/posts/2021/12/font-basics/"},{"categories":["工具"],"content":" Latex排版中文的问题汇总 涉及两方面: 对中文字体的支持 对中文排版细节的处理 几个相关的宏包: - CJK宏包:提供了对中文字体的支持 - xeCJK和luatexja宏包:处理中文排版细节 - ctex 宏包和文档类:进一步封装了 CJK、xeCJK、luatexja 等宏包,使得用户在排版中文时不用再考虑排版引擎等细节。能够识别操作系统和 TEX 发行版中安装的中文字体。 - ctex 宏包:用于配合各种文档类排版中文 - ctex 文档类:对LATEX 的标准文档类进行了封装,对一些排版根据中文排版习惯做了调整,包括 ctexart/ctexrep/ctexbook/ctexbeamer。 在archlinux上,安装texlive-langchinese 即可安装ctex宏包。 注意: 1. 源文件要保存为UTF-8编码。 2. 使用 xelatex 或 lualatex 命令编译。 ","date":"2021-12-07","objectID":"/posts/2021/12/handle-chinese-in-latex/:0:0","tags":["tex"],"title":"Latex排版中文的问题汇总","uri":"/posts/2021/12/handle-chinese-in-latex/"},{"categories":["工具"],"content":" 例子 \\documentclass{ctexart} \\begin{document} 在\\LaTeX{}中排版中文。 汉字和English单词混排,通常不需要在中英文之间添加额外的空格。 当然,为了代码的可读性,加上汉字和 English 之间的空格也无妨。 汉字换行时不会引入多余的空格。 \\end{document} 用xelatex编译。 xelatex test-zh.tex 如果是markdown或org mode文件,用pandoc转。 pandoc test-zh.tex -o test-zh.pdf --pdf-engine=xelatex -V CJKmainfont=\"WenQuanYi Zen Hei\" ","date":"2021-12-07","objectID":"/posts/2021/12/handle-chinese-in-latex/:1:0","tags":["tex"],"title":"Latex排版中文的问题汇总","uri":"/posts/2021/12/handle-chinese-in-latex/"},{"categories":["工具"],"content":" refs: https://wiki.archlinux.org/title/TeX_Live_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) 一份(不太)简短的 LATEX2ε 介绍 ","date":"2021-12-07","objectID":"/posts/2021/12/handle-chinese-in-latex/:2:0","tags":["tex"],"title":"Latex排版中文的问题汇总","uri":"/posts/2021/12/handle-chinese-in-latex/"},{"categories":["工具"],"content":" 如何批量压缩照片 现在手机拍照出来的照片体积都很大,而手机厂商提供的云服务空间又有限,拍照片稍微多一点的话,空间很快就不够用了。周末去了趟径山寺玩,拍了点照片,我的小米云空间就频频告急了。 我检查了一下,发现随便拍的风景照,体积都有十几到二十兆,这么大的照片,质量也许好一些,对摄影爱好者可能有些意义,但对我这种只是偶尔拍着记录一下的人来说,意义其实不大。 我希望减小照片体积,稍微损失点质量也无妨(完全可以控制在肉眼看不出来的程度)。一来可以减少空间占用,便于备份,二来如果放在图床引用的话,对网络的压力也小。 Linux 上用 ffmpeg 就可以很容易做到这件事。步骤如下: mkdir output # output目录用来存放压缩后的照片文件 ls *.jpg | xargs -I{} ffmpeg -i {} output/{}; # 用ffmpeg默认的参数效果就已经很好了 经过亲测,原先20M的照片,转换完成后只有1.8M,原先的 1/10 都不到。至于质量,我觉得完全可以接受,至少用肉眼,我是真的看不出来,作为记录或者展示,够用了! ps: 照片文件最好还是用 jpg 格式,体积最小;我曾试了 png 和 webp,效果都不好,其中 png 采用无损压缩算法,还膨胀了好多倍,20M 转出来成了 60M。摄影图片一般色彩笔记丰富,jpg 才是最适合的格式。 ","date":"2021-12-06","objectID":"/posts/2021/12/reduce-photo-size/:0:0","tags":null,"title":"如何批量压缩照片","uri":"/posts/2021/12/reduce-photo-size/"},{"categories":["生活"],"content":" 缘起曾经对佛学感兴趣,对寺庙一直感觉亲近。十一之前,就想着找个寺庙玩玩,跟hh说了这个想法后,hh说:“十一去径山寺吧”,就埋下了径山寺之行的种子。本打算十一假期最后两天去的,可惜,hh身体不太舒服,没有成行;再后来,天气转凉,hh感冒了,久未痊愈,就把径山寺这事放下了。 直到前几天,许久未出去玩的我们重新提起,才有了昨日的径山寺之行。已经是两个月过去了,but, better late than never! ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:1:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["生活"],"content":" 上山早上八点半,窗外的阳光已洒满草地。我们各自简单收拾下,九点便出发了。径山寺所在的径山,是天目山的东北余脉,因山顶有径以通天目山而得名。位于浙江省杭州市余杭区径山镇,杭州城西北约50公里处。朝径山开了约一个小时,就到了旅游集散中心,停好车,接坐景区的中巴车上山。心情也随着接近目的地而激动了起来。 山路十八弯,我们一边随着中巴车神龙摆尾,一边感叹着司机的自信车技,还要偷空欣赏车窗外的茂林修竹,高峰深谷,约二十分钟后到了山顶——径山寺就在那里! ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:2:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["生活"],"content":" 寺庙径山寺初建于公元745年,当时唐代。至南宋时规模庞大,有僧1700余,为“江南”禅院五山十刹之一。径山寺在中国不算有名,比如我也是这两年才听说它,可是在日本地位可不低,被奉为佛教圣地、茶道祖庭。历史上日本曾派多位高僧,来径山寺求学问道,荣析禅师、圣一国师、南浦绍明都曾在此研究佛法。高僧回国时带径山茶籽,被视为日本茶道起源。现在流行的抹茶和煎茶就源自径山茶道。 径山寺门前视野开阔,可远眺群山千里。 寺门上正面书“双径归堂”,背面书“天下径山”,为径山中兴祖师大慧宗杲(gao, 三声)禅师墨迹。 门内一侧贴有禅师发愿文。佛堂里,诸佛林立,悲悯庄严,信众焚香,虔心拜首。角落处,大和尚安读楞严经,人群中,小哥哥勤讲菩萨事。说起小哥哥,我们因好奇,跟了他半路,我还向他问了几个问题,小哥哥都认真解答。 拾级而上,一路但见建筑典雅,白墙红瓦,怪石碧水,风景娟秀,据说日本京都寺院的风格也跟这里相似。不久就到了凌霄宝殿,一看时间已是十一点半,怕错过斋饭,便回头准备去填饱肚子。 ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:3:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["生活"],"content":" 斋饭打听了一下,便直奔斋堂去了。径山寺的斋堂有两处:一处是面食,另一处是米饭。我们俩经过反复对比,还是选了米饭。斋菜种类不多,我们去的那会儿有土豆、青菜、豆角,十元一份,味道清淡,身在佛门之地,自然是带着品味清淡的心情来的。 吃饱喝足,打算去径山古道走走。 ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:4:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["生活"],"content":" 古道古时人们上下山,都是从这条径山古道走。 路面铺满石头,总体比较平缓,不算难走。我们踏上古道,开始下山,一路上游人三三两两,有上山的,有下山的,欢声笑语,不绝于耳。 我们携手而行,看看山林美景,谈谈古今故事。 沿途左侧多是茶田,右侧基本都是竹林。 还见到几处枫树,枫叶红得格外显眼,为山林的色彩增添了不少层次感。 先后经过了东坡洗砚池、望江亭、钱王弹岩,约一个小时到了半山腰的一个小村庄。那里刚好有接游客下山的中巴车,于是我们坐上车就下山了。到集散中心,休息了一下,便启程回家。 ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:5:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["生活"],"content":" 结语径山寺不远,来玩其实不需要很多时间。主要是和hh好久没出来玩了,就想把琐事暂时放一放,出来散散心。丈量丈量古人走过的古道,追忆追忆古人留下的故事,着实是一件乐事! ","date":"2021-12-05","objectID":"/posts/2021/12/visit-jingshan-temple/:6:0","tags":["旅行"],"title":"径山寺之行","uri":"/posts/2021/12/visit-jingshan-temple/"},{"categories":["读书"],"content":"毛泽东早期文稿,记载了毛泽东在1912年至1920年期间所写文章以及笔记,也就是毛泽东从20岁到28岁期间文稿。昨日读之,窥得毛早期思想发展之脉络,略有所得。 ","date":"2021-12-03","objectID":"/posts/2021/12/mao-reading-of-moral-philosophy/:0:0","tags":["人物"],"title":"读《毛泽东关于“伦理学原理”的笔记》","uri":"/posts/2021/12/mao-reading-of-moral-philosophy/"},{"categories":["读书"],"content":" 毛读《伦理学原理》时的笔记","date":"2021-12-03","objectID":"/posts/2021/12/mao-reading-of-moral-philosophy/:1:0","tags":["人物"],"title":"读《毛泽东关于“伦理学原理”的笔记》","uri":"/posts/2021/12/mao-reading-of-moral-philosophy/"},{"categories":["读书"],"content":" 豆瓣网友的要点摘录如下: 主观为安宁,客观为至善;内在为安宁,外现为至善。 本此自然道德所含之真理而发挥之,以论定各种行为之得失,是则道德哲学之本职也。道德哲学,亦犹卫生科学然。在举人类自昔习惯之行为,而为之指别其损益之所在,使人人得循是以为取舍。 于是人类之行为,变其纯任自然者,而益之以思虑,由无意识之道德,而进于有意识者,斯则道德哲学之赐也。 夫具足者何耶?盖谓人类之体魄及精神,其势力皆发展至高而无所歉然者也。 今日之刑法及警察,严明平正,一洗中世酷虐之习,诚可喜也。然缘是而谓中世何以不用是制,则误矣。且今日严明平正之制之所以有效,庸讵知非中世酷虐之制所致乎? 自由思想,自由生活,本人生第一之权利,而亦第一之义务也。 意志原始之形式,即无意识之冲动也。由无意识之冲动,而现于意识中,则为有意识之冲动。吾人若增其生活之动作,而有以餍其冲动,则快感随之。若障碍其动作,而逆其冲动,则不快之感随之。 感官之欲望,即冲动而伴以动作之模象者也。欲望之前提,为智力发展之一程度与夫意志及模象之交错,而欲望之餍足与障碍,则亦有快与不快之感随之。 吾人所见各人有大同之动作者,徒观其表耳。苟求其内情,则无一不具特性。夫内情者,人之本质也。其有特性也,正其所以为具足,而不得谓之缺陷。 离群索居诚哉不堪,然社会为人而设,非个人为社会而设也(毛)。 个人有无上之价值,百般之价值依个人而存,使无个人(或个体)则无宇宙,故谓个人之价值大于宇宙之价值可也。故凡有压抑个人、违背个性者,罪莫大焉(毛)。 此缘吾人有好变化、好奇之心,人不能有俄顷不变化者(毛)。 快感为渐达至善之征候,而持快乐论者,乃即以征候为正鹄(毛)。 快乐与痛苦,有不可离之关系,苦痛为避害之向导,其理甚明,然则快乐又宁非进取之导向耶? 甲有贵显之乐,而有患得患失之苦,其比例如何?乙有境遇之苦,而有思想自由之乐,其比例又如何? 此数句可证人类以惊奇为贵。惊奇者,人类之生涯也(毛)。 且吾人关于人生及人类之邪恶,尤常欲构为普通结论,以为镇静慰藉之资。例如为妻女所苦者,常欲为女子难养之说。著述而不为世所重者,常欲为世人不辨黑白之说。是故厌世主义者,彼之良药也。彼常因其胆液质之缺点,而生恶感,则以此药疗之,虽未能去其痼疾之根本,而时有轻损苦痛之效,如麻醉药焉。 人类贵重之性质,非自然之赐,而文明之效力也。吾人平心而观察之,勇敢、诚实、清洁、节制、正义、仁爱诸德,皆为后天之性质;而恐怖、虚伪、不洁、无节、粗野、利己,则转为野蛮人类之特色焉。 鸠之能翔于空中也,以有空气之抵抗,而彼乃以为苟无空气,则其翔也更自由,此康德所以讽人,使知悟性之动,必须经验实事者也。人之意思,不可无对象之抵抗,亦然。无抵抗则无动力,无障碍则无幸福,纯粹之幸福,为纯粹之真理然,有之者其惟神乎?在人类,则享幸福者必当有障碍若损害,犹之识真理者必当有蒙昧若谬误也。 然则不平等、不自由、大战争亦当与天地终古,永不能绝,世岂有纯粹之平等自由博爱者乎?有之,其惟仙境。然则唱大同之说者,岂非谬误之理想乎(毛)? 吾尝梦想人智平等,人类皆为圣人,则一切法治均可弃去,今亦知其决无此境矣(毛)。 此却有一疑问:吾人要此历史之名作甚,彼恶人得受恶名又有何不好(毛)? 是故思留名于千载者妄也,欣羡他人之留名者亦妄也(毛)。 吾人自欲遂行具足生活也,害恶之为多为少,除得尽除不尽,吾岂知之哉(毛)。 惟土石不死,然则人类将欲营土石之生活乎(毛)? 宇宙间非仅有人生一世界,人生以外之世界,必尚有各种焉。吾人于此人生之世界已种种经验之,正应脱离此世界而到别种世界去经验。。。。虽然,吾之意不如此焉。人类者生而有好奇之心,何独于此而不然?吾人不常遇各种之奇事而好之乎?死也者,亦吾有生以来一未尝经验之奇事也,何独不之好乎?大风卷海,波澜纵横,登舟者引以为壮,况生死之大波澜何独不知引以为壮乎!(毛) 国家如此,民族亦然,人类亦然。各世纪中,各民族起各种之大革命,时时涤旧,染而新之,皆生死成毁之大变化也。宇宙之毁也亦然。宇宙之毁决不终毁也,其毁于此者必成于彼无疑也,吾人甚盼望其毁,盖毁旧宇宙而新得宇宙,岂不愈于旧宇宙耶!(毛) 或谓人在历史中负有继往开来之责者,吾不信也。吾惟发展吾之一身,使吾内而思维、外而行事,皆达正鹄。吾死之后,置吾之身于历史之中,使后人见之,皆知吾确然有以自完。后人因吾之完满如此,亦自加吾以芳名,然而非吾之所喜悦,以其属之后来,非吾躬与之现实也(毛)。* 吾人并非建功业以遗后世,此功业自有足以利后世之性质存于其中云尔。吾之不灭也,亦吾本有此不灭之性质具于吾之身中云尔(毛)。* 要之,二者原为一物,吾人各种之动作,固处处须冲动,处处系冲动之所驱,良心之明,亦处处承认之。吾人之良心固未有不以食欲性欲之事为然者也。惟在一种时候及场所,乃有谏止冲动之举,如过度之食欲,过度之性欲是也。然则良心不过加以节制而已,并非反对也。其节制亦正所以完成冲动之本职也。故良心与冲动理应一致,乃调和的而非冲突的。自后天之训练习惯,矫枉过正,乃有不循自然与冲动反对之事,致使良心之本来与冲动同原,同为真的、自然的、实在的,变而为伪的、人为的、非实在的,此则矫枉过正之咎也(毛)。* 吾谓此等义务感情,只可于无意识界求之,只可于死界求之(毛)。 盖义务感情,虽可为去恶之作用,而大人君子,决非能以义务感情实现之者,大抵由活泼之地感情之冲动而陶铸之焉。 豪杰之士发展其所得于天之本性,伸张其本性中至伟至大之力,因以成其为豪杰焉。本性以外之一切外铄之事,如制裁束缚之类,彼者以其本性中至大之动力以排除之。此种之动力,乃至坚至真之实体,为成全其人格之源,即此书所谓自然之冲动,所谓性癖也。彼但计此动力发出之适宜与否,得当与否。适宜也,得当也,则保持之,否则,变更之,以迁于适宜与得当焉。此纯出自计,决非服从外来之道德律,与夫义务感情也。泡尔生所谓大人君子非能以义务感情实现,由活泼之地感情之冲动而陶铸之,岂不然哉,岂不然哉!(毛)* 此种语言在其起源确已合于客观界之事实,乃由种种之经验而来者也。由一人而论,从幼少之时,即童而习之,似为构成于先天者。从历史观之,则纯成乎经验,而非所谓先天直觉也(毛)。 道德者,非吾人能使无定,而彼本无定,且亦无时而定者也。 或人之说,必以道德律为出于神之命令,而后能实行而不唾弃,此奴隶之心理也。服从神而不服从己,己即神也,神以外尚有所谓神乎?吾研究良心之起源而知之,此问题已得于己矣,即当举其所得于己者而服从之。一切时空内百般之事物,其应服从,价值无有过于此所得于己者之大。吾人一生之活动服从自我之活动而已,宇宙间各物之活动,各物从服自我之活动而已。吾从前固主无我论,以为只有宇宙而无我。今知其不然。盖我即宇宙也,各除去我,即无宇宙。各我集合,即成宇宙,而各我又以我而存,苟无我何有各我哉。是故,宇宙间可尊者惟我也,可畏者惟我也,可服从者惟我也。我以外无可尊,有之亦由我推之;我以外无可畏,有之亦由我推之;我以外无可服从,有之亦由我推之也(毛)。 然则兼此二者乃所以遂其生活,则仍是利己主义也,以利他而达到遂其生活之目的,不过易其手段而已。持粹然之利他主义者,其毫无根据,所不待言。持粹然之利己主义者,亦但为理论,在此多数个体杂然活动之世界中,决不能实现。虽不能实现,虽无此事实,而其意则仍在是;人类生活之本意,仍在发达其个体也。为达此目的,乃求手段之奚择?择纯然利己之手段乎?初民及人之初生实择此手段,久之障碍甚多,乃舍此纯然利己而则人己兼利之手段,于是而人各遂其生矣。是故,吾人有时兼利他之手段者,仍以达到自利之目的也。 余未尝以著述家之责任自绳。如何而为人所喜,如何而于人有益,余所不顾也。余惟精进不已,务高尚余之人格,而表彰余所见到之真若善而已矣(歌德)。 故君子小人之别,在其所见之幸福高下如何,而人格之高下随之。盖观其所见幸福之价值,而得以定其最深之意向矣。 在文化之初期,人类爱群性最强,各人皆仅为民族若都市之一份子,而并无独立之人格,否则不足以自存。故如忠义、信实、勇敢诸道德,尤为往昔英雄时代所最重也。 幸福者,非道德之应报,而即道德也,是也。人苟不以道德为鹄的,徒以求祸畏罪之故而行之,则一旦外界之幸福不如其所期,将遂不免有天道无知之怨。 盖世之可畏可疾者,固未有过于矜伐而骄奢者也。幸福者衰亡之媒,其证据如此矣。而不幸之境遇,若失败,若坎坷,乃适以训练吾人,而使得强大纯粹之效果。 彼等以为神意者,神圣也,公正也,慈悲也,吾人当以己之意志实现之于客观者,以明神意,以当默示。此诚人类之纯粹至深邃之意向矣。 于是道德与宗教之关系可知矣,二者同出一源,即热望其意志之达于美满之域者是也。惟在道德则要求之,而在宗教则实行之。 人之择何等哲学也,视其人为何等人,信然。 凡人之解释现象也,无不符合于其意向,一切生活,各欲以其所亲爱所珍重者围绕之,则亦欲得其所视为高尚之世界观围绕之,以餍其心。 质而言之,万即一,变即常。我是极高之人,又是极卑之人(毛)。 意志者,即决定最后之原因,不被规定于他原因,而亦无所谓意志之原因。 思虑、疑惑、决断,人类之特质也。人类之行为,定于决断,而决断者,思虑之果也。 惟人类是等能力发展之程度,至为不齐。其全为动物冲动所左右,而不能抑制之者,为粗暴鄙野之人;其或全无此等冲动者,则又为枯寂酷薄之人,皆非中正之道。盖人类者,位于动物之实体及理性之实体之间者也。 ","date":"2021-12-03","objectID":"/posts/2021/12/mao-reading-of-moral-philosophy/:1:1","tags":["人物"],"title":"读《毛泽东关于“伦理学原理”的笔记》","uri":"/posts/2021/12/mao-reading-of-moral-philosophy/"},{"categories":["读书"],"content":" 我的摘录以下摘录,取之以为最能表达毛氏思想者。 我为万事万念之中心,故人恒以利我为主;利他由我而起点也,利他与我有关系也。众生一大我也,宇宙一大我也,何必讳言自利耶?然大我亦有发端,终以小我为先(悟前确实如此,未知悟后亦然否?)。 由利己推而广之,利众生,利宇宙,系由小真而大真。吾儒之说亦然,“天地之道造端乎夫妇”,“先修身而后平天下”,“先亲亲而后仁民爱物”。 圣人之学为己,为实现自我也。 何谓善?在客观世界为功利,在主观世界为动机。两者皆善,方可称之为善。 且为作用,且为正鹄,则无往而不乐。 大同世界不可信。治乱迭乘,平和与战伐相寻者,自然之例也。 变化攸忽,乃人性之所喜也。 吾尝梦想人智平等,人类皆为圣人,则一切法治均可弃去,今亦知其决无此境矣。(不一定,人人皆悟,则大同成。然而人人皆悟的希望渺茫啊!) 论事不论人。 正不能胜邪,乃是正尚未能胜邪,非一定不能也。邪之存在,所以动心忍性,增益其所不能,实现正鹄之垫脚石耳。 不问收获,只问耕耘。 吾与伦理学有二主张。一曰个人主义。一切之生活动作所以成全个人,一切之道德所以成全个人,表同情于他人,为他人谋幸福,非以为人,乃以为己。吾有此种爱人之心,即须完成之,如不完成即是于具足生活有缺,即是未达正鹄。释迦墨翟皆所以达其个人之正鹄也。一曰现实主义。以时间论,止见过去未来,本不见有现在。现实非此之谓,乃指吾之一生所团结之精神、物质在宇宙中之经历,吾人务须致力于现实者。如一种行为,此客观妥当之实事,所当尽力遂行;一种思想,此主观妥当之实事,所当尽力实现。吾只对于吾主观客观之现实者负责,非吾主观客观之现实者,吾概不负责焉。既往吾不知,未来吾不知,以与吾个人之现实无关也。或谓人在历史中负有继往开来之责者,吾不信也。吾惟发展吾之一身,使吾内而思维,外而行事,皆达正鹄。吾死之后,置吾之身于历史之中,使后人见之,皆知吾确然有以自完。后人因吾之圆满如此,亦自加吾以芳名,然而非吾之所喜悦,以其属之后来,非吾躬与之现实也。历史前之事亦然。吾取历史以其足以资吾发展现实之具足生活也。或谓吾人负有生殖之责任,吾亦不信,我自欲生殖也,我具足生活中有此一片段之生活,我自欲遂行也,向谁负责任?必依此二主义,乃可谓之真自由,乃可谓之真自完。 冲动既为自然,未有不能善生存发达者。自然者,真也,实在也。 冲动与良心两者原为一物。冲动自然发出,良心加以节制而已,并非反对之。其节制亦正所以完成冲动之本职也。 无论何种之书,都是述而不作,都是经验现象之总结。 豪杰圣人乃能尽其性者也。 浩然之气,集义所生。 发显即本体,本体即发显,合无数发显而为一大本体,由一大本体而分无数发显。人类者与本体有直接关系,而为其一部分,人类之意识,亦即与本体之意识相贯通,本体或名之曰神。 己即神也。 吾人惟有对于自己之义务,未有对于他人之义务。救人畏难,所以慰安吾心,而充分发展吾人精神之能力也。 ","date":"2021-12-03","objectID":"/posts/2021/12/mao-reading-of-moral-philosophy/:1:2","tags":["人物"],"title":"读《毛泽东关于“伦理学原理”的笔记》","uri":"/posts/2021/12/mao-reading-of-moral-philosophy/"},{"categories":["读书"],"content":" 总结从毛氏笔记中,可以看出,早期毛氏受阳明心学影响极大。总体框架与心学同。其中超越心学框架者,乃所谓善之定义也。心学说主于天理则无往而不善,然而何谓天理?何谓人欲?实际操作中难以区别。毛氏则结合主观客观之说,认为功利与动机皆善方可谓之善。我则以未悟之视角,主张以大我之利为先,若不可决,则诉诸直觉。觉悟者或有另一光景,也未可知。然而吾以未悟之身,行未悟之事,义也,宜也。 ","date":"2021-12-03","objectID":"/posts/2021/12/mao-reading-of-moral-philosophy/:2:0","tags":["人物"],"title":"读《毛泽东关于“伦理学原理”的笔记》","uri":"/posts/2021/12/mao-reading-of-moral-philosophy/"},{"categories":["读书"],"content":" 商鞅徙木立信论 1912.06讲中国需要开启民智 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:1:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致湘生书 1915.06.25为学之道,先博而后约,先中而后西,先普通而后专门。 前者已矣,今日为始。 吾今日舍治科学,求分数,尚有何事?别人或谓退化,吾自谓进化也。 推崇康梁。 梁启超:先业词章,后治各科。 盖文学为百学之原,吾前言诗赋无用,实失言也。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:2:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致友人信 1915.07弟近年来所有寸进,于书本得者少,于质疑问难得者多。 夫人之生所遭不齐,惟豪杰之士知殊趋而同至,不型人以合吾之轨,亦不迁己轨以合人之型,此诚至公彻理之谈也。 该说的还是要说。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:3:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致萧子升信 1915.08言不能因愆而废,犹食不能因噎而废也。况所言者未必愆,即愆矣,亦哲人之细事。 该说的还是要说。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:4:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致萧子升信 1915.09论博学。对黎锦熙的钦佩。讲了跟黎锦熙之间的探讨。 毛:求学求什么?上山读古籍,而后下山而涉其新,可乎? 黎:不然,这样就先后倒置了。通为专之基,新为旧之基。特别是政治家、事功家,应该注重通识。知通识,则知社会。 毛:此其具体耳,其抽象则如何?下手之方则如何? 黎:于国文,不求长求异。于历史,觅其巨夫伟人,为一朝代之代表,将其前后当身之迹,一一求之至彻。于地理,地图为要,看报纸杂志应联系地理。于体操、图画、音乐、手工,得为学、养生之道;为学要有条理有秩序,养生要复其神。且有助于培养美感。 黎:《群学肆言》。为学之难有三:其一在物,其一在心,其一心物相对。在物者曰物蔽,在心者曰情瞀智絯,心物相对者曰学诐、国拘、流梏、政惑、教辟。为学之根本在缮性。缮性在学,学有三科,曰玄间著。(语文、数学、物理、化学、博物)。学,则德寓乎其中矣。 国学最要紧。其中最急切的,就是国学常识。择好书,曾氏“杂钞”其庶几焉。 曾国藩《经史百家杂钞》 姚鼐《古文辞类纂》 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:5:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致萧子升信 1915.09.25吾人立言,当以身心之修养、学问之研求为主,辅之以政事时务,不贵文而贵质,彩必遗弃,惟求其神。易言之,每为一书,必有益处,言必载物。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:6:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致黎锦熙信 1915.11.09陈述对黎式行为的疑惑,劝其早归。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:7:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致萧子升信 1916.07.25分析时事,预言中日战争,预言日美战争,奇哉! ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:8:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致黎锦熙信 1916.12.09以古之智仁勇三达德,提倡今之德智体三言。 一旦身不存,德智则随之而惰矣。 夫人之一生,所乐所事,夫曰实现。 世界之外有本体,血肉虽死,心灵不死,不在寿命之长短,而在成功之多寡。此其言固矣。 君子不立危墙之下。 弟身亦不强,近以运动之故,受益颇多。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:9:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 体育之精神 1917.04.01体育者,人类自其养生之道,使身体平均发达,而有规则次序之可言者也。 体育于吾人实占第一之位置。体强壮而后学问道德之进修勇而收效远。 故讲体育必自自动始。 体育之效,至于强筋骨,因而增知识,因而调感情,因而强意志。筋骨者,吾人之身;知识、感情、意志者,吾人之心。身心皆适,是谓俱泰。故夫体育非他,养乎吾生、乐乎吾心而已。 今之学者多不好运动,其原因盖有四焉:一则无自觉心也。一则积习难返也。一则提倡不力也。一则学者以运动力可羞也。 此事不重言谈,重在实行,苟能实行,得一道半法已足。 运动所宜注意者三:有恒一也,注全力二也,蛮拙三也。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:10:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 《一切入一》序 1917.夏学在积累。积累之道,在有条理。 贵有恒。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:11:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致黎锦熙信 1917.08.23求大本大源。人人有哲学、伦理学见解。 大同者,吾人之鹄也。 立德立功立言。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:12:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 夜学招学广告 1917.10.30","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:13:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致罗学瓒信 1918.08.11劝其从事教育 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:14:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致七八舅父母信 1918.08 1919.04.28将去北京游历。在北京大学任职员。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:15:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 《湘江评论》创刊宣言 1919.07.14","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:16:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 《大公报》非自杀 1919.11.23泡尔生:人生目的:人类之体魄及精神,其势力皆发展到至高地位,而无所歉然。即曰至善。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:17:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致陶毅信 1920.02联军。各方面都应该去打先锋的人。 新民学会。1918年4月成立。 时常交流,谈共同目的,及达到目的之方法。有意识有组织。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:18:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致周世钊信 1920.03.14国内研究与出国研究的先后问题。 求学实在没有”必要在什么地方“的理 暂时在国内研究的几种好处: ①看译本较看原本快得多,可于较短时间求到较多的知识。 ②世界文明分东西两流,东方文明在世界文明内,要占半壁的地位。然东方文明可以说就是中国文明。吾人似应先研究过吾国古今学说制度的大要,再到西洋留学才有可资比较的东西。 ③吾人如果要在现今的世界稍为尽一点力,当然“脱不开”中国这个地盘。关于这地盘内的情形,似不可不加以实地的调查,及研究。这层工夫,如果留在出洋回来的时候做,因人事及生活的关系,恐怕有些困难。不如现在做了,一来无方才所说的困难,二来又可携带些经验到西洋去,考察时可以借资比较。 先将古今中外的学说取其精华,自成体系。 团体方面:①结合同志②在很经济的可能的范围内成立为他日所必要的基础的事业。 工读互助团。 不是绝对反对留学,而是主张大留学政策。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:19:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致黎锦熙信 1920.06.07决定一年半或两年后留学俄国。学习俄语。 我对于学问,尚无专究某一种的意思,想用辐射线的方法,门门涉猎一下。颇觉常识不具,难语专攻,集拢常识,加以条贯,便容易达到深湛。 可惜我太富感情,中了慷慨的弊病,脑子不能入静,工夫难得持久,改变也很不容易改变,真是不得了的恨事呵。 文字学、言语学、和佛学,我都很想研究。 具体、鲜明、热烈。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:20:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致罗学瓒信 1920.11.26身体是一个大问题。客观环境确实有原因。主观方面的原因,就是心理上的惰性。如读书成了习惯,便一直读下去不知休息。照卫生的法则,用脑一点钟,应休息十五分钟,弟则常常接连三四点钟不休息,甚或夜以继日,并非乐此不疲,实是疲而不舍。个人方面,须养成工读并行的习惯,至少也要养成读书和游戏并行的习惯。我的生活实在太劳了,怀中(杨昌济)先生在时,曾屡劝我要节劳,要多休息,但我总不能信他的话。以后拟每两个月出游一次。 四种迷:感情论事,以偏概全,以一时概永久,以主观概客观。我自信于后三者的错误尚少,惟感情一项,颇不能免。以人废言,是我一个短处,日后务要改正。 奉向蔡做首领,组成“拒婚联盟”。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:21:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 致萧子暲信 1920.11我近觉得仅仅常识是靠不住的,深慨自己学问无专精,两年来为事所扰,学问未能用功,实深报恨。 不好利,早起,好读书,谦,此谓良习惯。 重现在有两要义,一贵我(求己、不责人),二通今(如读史必重近世,以其与我有关也) ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:22:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["读书"],"content":" 张昆弟记毛泽东的两次谈话 1917.09毛君云,西人物质文明极盛,遂为衣食住三者所拘,徒为肉欲之发达已耳。若人生仅此衣食住三者而已足,是人生太无价值。又云,吾辈必想一最容易之方法,以解经济问题,而后求遂吾人理想之世界主义。又云,人之心力与体力合行一事,事未有难成者。余甚然其言。且人心能力说,余久信仰,故余有以谭嗣同《仁学》可炼心力之说。 毛君润之云,现在国民性情,虚伪相崇,奴隶性成,思想狭隘,安得国人有大哲学革命家,大伦理革命家,如俄之托尔斯泰其人,以洗涤国民之旧思想,开发其新思想。余甚然其言。中国人沉郁固塞,陋不自知,入主出奴,普成习性。安得有俄之托尔斯泰其人者,冲决一切现象之网罗,发展其理想之世界。行之以身,著之以书,以真理为归,真理所在,毫不旁顾。前之谭嗣同,今之陈独秀,其人者,魄力颇雄大,诚非今日俗学所可比拟。 ","date":"2021-12-02","objectID":"/posts/2021/12/reading-maozedong-article/:23:0","tags":["人物"],"title":"读《毛泽东早期文稿》","uri":"/posts/2021/12/reading-maozedong-article/"},{"categories":["工具"],"content":" TeXTeX 是 Donald Knuth 编写的一套排版系统,尤其擅长排版复杂的数学公式。TeX 语言定义了一套原语,用于对纯文本进行格式控制;并且在这些原语的基础上,定义了一系列宏,增加了TeX 语言的易用性。TeX 编译器用于编译 TeX文件,初期生成的文件为dvi格式。 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:1:0","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" pdfTeX, XeTeX \u0026 LuaTeXDonald Knuth 认为 TeX 已经够用,不希望 TeX 变得太复杂,决定不再往里面添加新功能,只接受bug fix。 随着新技术的发展,以及现代化排版的需要,一些人创建了几个TeX的变体:pdfTeX, XeTeX \u0026 LuaTeX。这些变体其实是在TeX的基础上,扩展了TeX的能力,增加了新的原语和特性。虽然这些变体都继承了TeX,但这些变体之间,相互是不兼容的。 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:2:0","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" pdfTeX 提供了直接输出pdf文件的能力 对TeX的排版做了一些细节上的调整 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:2:1","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" XeTeX 处理UTF-8编码,处理多国语言 可以方便地使用OpenType字体 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:2:2","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" LuaTeX 源于pdfTeX 支持Lua脚本语言 支持UTF-8编码 可以处理OpenType字体,但处理机制和XeTeX不同 支持MetaPost画图语言 支持通过C/C++写的.dll或.so插件来添加扩展功能 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:2:3","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" LaTeX与刚讲的三个变体不同,LaTeX 并未扩展TeX的功能,而是给TeX写了一组macro,这些macro仍然是建立在TeX原语的基础之上。也就是说,LaTeX只是一批大量精心设计的macro的集合。 增加了很多对排版细节的控制,如页面布局,字体等,更加易用 可以方便地添加其他宏包,以便解决特定领域的排版问题 ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:3:0","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":["工具"],"content":" pdfLaTeX, XeLaTeX \u0026 LuaLaTeX pdfLaTeX = LaTeX macro package + pdfTeX engine XeLaTeX = LaTeX macro package + XeTeX engine LuaLaTeX = LaTeX macro package + LuaTeX engine ","date":"2021-11-24","objectID":"/posts/2021/11/tex-family/:4:0","tags":["问题记录","tex"],"title":"TeX Family","uri":"/posts/2021/11/tex-family/"},{"categories":null,"content":"要高效利用anki这个神器学习,需要知道几个基本概念: card note field card type note type deck collection ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:0:0","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" card对应一张分为正面Q和反面A的卡片。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:1:0","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" note对应一则信息。anki要做的,正是要把一则信息,转化为一张或多张卡片,方便用户记忆和学习。对应于这个转化过程的需要,故引入以下几个延伸的概念。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:2:0","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" field将一条note结构化,分成几个field。比如,最简单的分法是分为两部分:问题Q和答案A。这个结构化的过程很重要,使零散的信息变得有条理,变得井然有序,不仅能加深对信息的理解,拆解信息本身也能促进记忆。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:2:1","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" card type一条note的各个field最终要展示到card上,展示的方式由card type控制。card type实际上是一个模板,需要field的地方用对应的占位符填充。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:2:2","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" note type一条note要拆解成哪几个field,展示方式(card type)有哪几种,是由note type控制的。如果card type有多个,那么一条note最终转化出的card会有多个。一条note必须有对应的一个note type。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:2:3","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" deck简单的deck就是一系列card的集合,相当于把一堆卡片放在一起,方便做记忆计划。当然也有复杂点的deck,就是一个deck包含了另一个subdeck,构成父子关系,形成嵌套结构。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:3:0","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":null,"content":" collection以上所有东西,集合到一起就构成了collection。可以将一个collection整体打包保存和发送,这是为了方便用户备份和迁移。 厘清了以上这些基础概念,也就理解了anki这个软件的设计逻辑。而只有了解了anki整个逻辑,才能更高效地使用它,在学习上事半功倍。 ","date":"2021-10-30","objectID":"/posts/2021/10/anki-basics/:4:0","tags":["工具","anki","制卡"],"title":"anki基础-基本概念","uri":"/posts/2021/10/anki-basics/"},{"categories":["技术"],"content":" 编程语言语言有两大要素——语法和语义,语法是看得见的表面的形式,语义是真正想表达的背后的含义。各种五发八门的不同的编程语言,其表面形式可以天差地别,但其背后的语义却是相通的。只有使计算机「理解」了人类想表达的东西,才有可能准确给出人类想要的结果。当然也需要计算机拥有对应的计算能力,这正是计算理论所研究的内容,各种计算模型,如有限状态自动机,下推自动机,图灵机,确定性的,不确定性的等等,计算能力的确有差别。不过这一切的前提是你得想办法把自己的想法「告诉」计算机,这就绕不开计算机程序的语义。 ","date":"2021-04-21","objectID":"/posts/2021/04/program-semantics/:1:0","tags":["程序分析"],"title":"编程语言的形式语义","uri":"/posts/2021/04/program-semantics/"},{"categories":["技术"],"content":" 形式语义形式语义试图精确地、无歧义地描述程序的含义,并利用这些含义研究程序的性质。现实中,程序的语义通常有两种方式描述:一种是靠实现规范,如Ruby解释器有一个参考实现;另一种是写一份平实的官方规范,如C++/Java/ECMAScript。 而从更加形式化也更加数学化的角度看,描述程序可以由三种语义:操作语义、指称语义和公理语义。 ","date":"2021-04-21","objectID":"/posts/2021/04/program-semantics/:2:0","tags":["程序分析"],"title":"编程语言的形式语义","uri":"/posts/2021/04/program-semantics/"},{"categories":["技术"],"content":" 操作语义操作语义为程序在某种机器的执行定义一些规则,来捕捉编程语言的含义。这个机器通常是一种抽象的机器:为了解释这种语言所写的程序如何执行,而设计出来的一种想象的、理想化的计算机。操作语义又分为小步操作语义和大步操作语义。 小步操作语义假想一台机器,用这台机器直接按照这种语言的语法进行操作一小步ー小步地对其进行反复规约,从而对一个程序求值。这种语义相当于为程序实现了一种迭代式的解释器。 大步操作语义大步语义的思想是,定义如何从一个表达式或者语句直接得到它的结果。这必然需要把程序的执行当成一个递归的而不是迭代的过程。也就是说,为了对一个更大的表达式求值,我们要对所有比它小的子表达式求值,然后把结果结合起来得到最终答案。这种语义相当于为程序实现了一种递归式的解释器。 ","date":"2021-04-21","objectID":"/posts/2021/04/program-semantics/:2:1","tags":["程序分析"],"title":"编程语言的形式语义","uri":"/posts/2021/04/program-semantics/"},{"categories":["技术"],"content":" 指称语义用一种更低级更形式化的语言,或者至少比被描述的语言更好理解的语言,来描述新的语言。它更抽象,与操作语义更像解释器相比,它更像编译器。 ","date":"2021-04-21","objectID":"/posts/2021/04/program-semantics/:2:2","tags":["程序分析"],"title":"编程语言的形式语义","uri":"/posts/2021/04/program-semantics/"},{"categories":["技术"],"content":" 公理语义通过在语句执行前后,分别给出抽象机器状态的断言,来描述一个语句的含义:如果前置条件在语句执行前初始化为true,那么执行后的后置条件也保证为true。公理语义主要用于验证程序的正确性。 ","date":"2021-04-21","objectID":"/posts/2021/04/program-semantics/:2:3","tags":["程序分析"],"title":"编程语言的形式语义","uri":"/posts/2021/04/program-semantics/"},{"categories":["思维"],"content":"我们认识世界,离不开对事物的分析。分析能力直接影响着我们的思想深度。掌握分析事物的方法论,对于提高分析能力至关重要。 对一个事物分析的过程,可以分为观察现象和解释现象两个阶段。在这两个阶段中,用一些问题作为引导,可以使分析过程不偏大旨,事半功倍。 ","date":"2019-01-28","objectID":"/posts/2019/01/analytical-methods/:0:0","tags":["分析问题","方法论"],"title":"如何分析事物","uri":"/posts/2019/01/analytical-methods/"},{"categories":["思维"],"content":" 观察阶段 Which details seem significant? Why? What does the detail mean? What else might it mean? How do the details fit together? What do they have in common? What does this pattern of details mean? What else might this same pattern of details mean? How else could it be explained? What details don’t seem to fit? How might they be connected with other details to form a different pattern? What does this new pattern mean? How might it cause me to read the meaning of individual details differently? ","date":"2019-01-28","objectID":"/posts/2019/01/analytical-methods/:1:0","tags":["分析问题","方法论"],"title":"如何分析事物","uri":"/posts/2019/01/analytical-methods/"},{"categories":["思维"],"content":" 解释阶段So what? (持续问这一个问题,就够了) ","date":"2019-01-28","objectID":"/posts/2019/01/analytical-methods/:2:0","tags":["分析问题","方法论"],"title":"如何分析事物","uri":"/posts/2019/01/analytical-methods/"},{"categories":["思维"],"content":" 世界观三界唯心,万法唯识。 心是先验和经验的统一。能知与所知不可分离,从来相互依存。先验的部分,天命之谓性,即良知,即本体。经验的部分,经验界的一切现象,不管是自然现象,还是伦理现象,都是良知之用。良知为现象界立法。良知是理性之源(因果论是良知强加于现象界的法)。良知是德性之源。良知是人之所以为人的依据,良知是人存在的本质。良知不可能脱离现象界而存在,良知必须依托现象界才能表达自己。良知与现象界不一不二。现象界即行,既包括看得见的动作,也包括看不见的念头,从这个意义上,知行合一。良知是普遍的,是人人皆同的。良知以万物为一体。良知在表达自己时,在向现象界转化时,极容易受到现象界的干扰而偏离“中”,从而影响自己的表达,这时,天理被私欲所蔽。如果把良知与现象界的纠缠态命名为“心”,那么“心”就是本源,心即理,心即道。普遍性与个体性在“心”这里取得了统一。 纯然至善之良知,在向现象界转化时,为什么会偏离“中”?也就是说,私欲从何而来? 正是由“执著”而来。而执著,是认同一些事物为己:与外物认同,与思想认同,与情绪认同,与过往经历认同。只有去执,才能与良知合一,与生命合一,与宇宙合一。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:1:0","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["思维"],"content":" 如何“去执”?完全接受“诸行无常”(小我所认同的那些事物都是无常的);臣服并欣赏;让良知之光流入这个世界。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:1:1","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["思维"],"content":" 人生观致良知,致吾心之良知于事事物物也。天人合一。知行合一,使良知流畅地表达自己。存天理去私欲。良知为镜,磨镜去污。身是菩提树,心如明镜台;时时勤拂拭,勿使惹尘埃。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:2:0","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["思维"],"content":" 价值观万物一体。无我。无执。中和。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:3:0","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["思维"],"content":" 总结无善无恶心之体,有善有恶意之动,知善知恶是良知,为善去恶是格物。 良知自身无善无恶,却是判断善恶的准则。作为“体”的良知,在向作为“用”的现象界表达自己时,会受到现象界的物欲牵引,而偏离“中”,而有善有恶。良知必须通过现象界才能表达自己,这个表达即为“物”,工夫是现象界的事情,唯有通过“格物”方能为善去恶,恢复良知之本体,使其顺畅表达自己。 格物即审美。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:4:0","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["思维"],"content":" 补充:方法论以上已经论及方法论,但着重强调了修心的方面,对外相只说“格物”,但没说如何格。以下具体说。 所谓宇宙,往古来今谓之宙,四方上下谓之宇,就是时间和空间。 所谓空间,表现为“相”;所谓时间,表现为相与相之间的因果联系(无关乎主客观)。 从认识论的角度来说,前者为感性认识,后者为理性认识。 对当下来说,只有三个东西:对现状的了解、对规律的掌握和对目标的欲求。 人生之旅的模式永远是,利用对规律的掌握,从现状走向目标。 规律代表对过去的相的总结,现状代表现在的相,目标代表想象中的未来的相。 然而,这三个东西从来只存在于当下。时间的流逝意味着相的迁移,这一刻的相在下一刻成为过去,成为过往规律的一部分,而未来的相成为了新的这一刻的相。 假定过往规律在未来仍然适用是一个前提,否则规律对未来无价值。但活在当下意味着,随着相的迁移,必须对规律进行更新。当然现状也必须更新。 所以,人生只在三件事上努力:了解想要什么,了解现状如何,了解规律是什么。 确定目标,总结规律,了解现状;制定计划,付诸行动;……;如此反复以至于无穷。 正是润之所说:认识,实践,再认识,再实践,以至于无穷的过程。 了解现状,着重在感性认识;总结规律,着重在理性认识。 前者的关键在于客观全面。 后者则千变万化,玄之又玄,难以把握,只知道一些有利于发现规律的方法:如关注重复、对立、特例,分析和综合(把事物拆分为部分,找出最重要部分,探索部分部分之间关系、部分整体关系、整体与外部事物关系)。很像主席的矛盾分析法。 而制定计划,关键在于思考目标和现状的差距,然后从目标倒推,即,要达到目标,需要做什么,每一个步骤需要做什么。称之为“回溯法”。 付诸行动,关键在于自制力,坚决执行所制定的计划。 当然,时间在流逝,唯一可以不变的是目标,现状和规律都会改变,那么计划也会随之调整,此之谓灵活性。这也是活在当下的要义。 如果把以往规律也算为现状的一部分的话,那么就只有现状和想象中的未来这两个概念而已。 两者的差距就是唯一需要关心的事情,一切行动该围绕这点进行。 利用客观全面的观察去了解现状,利用分析综合去总结规律,利用现状、目标、规律加上回溯法去制定计划,利用坚定的内心去执行计划。 如此,可致吾心之良知于事事物物也。 ","date":"2019-01-28","objectID":"/posts/2019/01/world-views/:5:0","tags":["心学","禅宗","修行","做事方法"],"title":"三观","uri":"/posts/2019/01/world-views/"},{"categories":["生活"],"content":"法镜寺,位于西湖之西,群山之下。清乾隆时得名,曾遭战火,光绪时重建。又名下天竺寺,为杭州唯一之女众寺院。 余以二零一七年八月,自玉泉骑单车,顶骄阳,穿小径,至于山脚。于寺外遇一石,名三生石。阅三生石上文字,乃知其为东坡先生所记圆泽故事。圆泽者,古时高僧也。 购票入寺,已是午时,遂购斋饭。斋饭味道颇佳,有花生,花菜,菌菇,苞谷等。另有尼众就餐处,皆正襟危坐,待仪式毕,始就食。饭毕,余以三炷香敬神佛。后闲逛,入一房舍,桌椅整齐,案头几卷经书。本欲休息纳凉焉,奈何为人所驱,遂至客堂,讨得清茶一杯饮,且享浮生半日闲。申时,众尼做仪式,庄严诵经,其每日之必修课乎?余观之于侧。 余独于三生石处有叹焉。东坡所传圆泽僧事,究其旨,不外叹人生无常,劝人学会放下者也。盖天下事能动人心者,惟恒惟远,能动人情者,惟长惟久。万事万物皆逃不脱无常二字,念及此,人莫不戚戚然。是以道曰天地不仁,佛曰何必执着。吾不以为然。纵诸行无常又如何?人心既为天地间至神至妙之物,怀追求至善之目标,当穷其一生,尽心知性知天,矢志不渝。不求三生,只争一世。不纠结于虚无缥缈之未来,只争实实在在之今日。一万年太久,只争朝夕,此之谓也。 傍晚归,记一日所见所思,遂成此文。 ","date":"2017-08-13","objectID":"/posts/2017/08/visit-fajing-temple/:0:0","tags":["旅行"],"title":"游法镜寺记","uri":"/posts/2017/08/visit-fajing-temple/"},{"categories":["生活"],"content":"近日,心颇不安定。 世上事大多说起来容易,做起来难。修心亦是如此。 定心须先立志。所谓知止而后有定,定而后能静,静而后能安,安而后能虑,虑而后能得。立了志向,便有了方向,便不至于在纷纷扰扰中迷失。否则,便如海上一叶孤舟,随波逐流,不知所终。诸葛亮《诫子书》中说,“非淡泊无以明志,非宁静无以致远\",也是此意。 可是该立何志呢? 这是一个极难的问题。常言道,人各有志。人或以权倾朝野为志,或以腰缠万贯为志,或以青史留名为志,或想做医生救死扶伤,或想做教师桃李满天下,或想做警察惩奸除恶,或想写得锦绣文章,或想吃得天下美食,或想走遍天涯海角,又或者,只想老婆孩子热炕头。百年悲笑,无非饮食男女。虽无可厚非,但总有狭隘之感。 有没有博大一些的呢?也是有的。子曰:吾十有五而志于学,三十而立。程子曰:有求为圣人之志,然后可与共学。张子曰:为天地立心,为生民立命,为往圣继绝学,为万世开太平。相比之下,儒家理想博大豪壮而振奋人心。 似乎有两个我在对话。一个说,既然必须选择一个目标做方向,那就选最宏大的嘛,应该听圣人言,以做圣人为人生第一等事,虽千万人吾往矣。另一个说,以做圣人为志向,太笼统了吧,很难落实到行动,而且天性愚钝,到时成不了圣人,反贻笑大方了。 说白了,自己心中仍有疑惑,并不能坚定的选择做圣人为自己的志向。这也是自己心不安定的原因,也造成了在行动上毫无改善。现在是关键时期,每念及此,更添几分焦虑。 打算周末去法镜寺走走。一来期待遇到高人,解我难题,也未可知;一来即使不遇高人,能与人倾诉一番,也能稍慰我心;一来探探有无禅修课程,通过禅修静静心,即便没有,吃一餐斋饭,也是一件美事! ","date":"2017-08-03","objectID":"/posts/2017/08/journal-2017-08-03/:0:0","tags":["随笔"],"title":"随笔-2017-08-03","uri":"/posts/2017/08/journal-2017-08-03/"},{"categories":["生活"],"content":"少年时,便觉得诗词是最美的文字。 常想象自己挥笔赋诗之潇洒,只恨才不足。 近日,偶得稼轩词一二句,感其豪壮,兴趣辄増,遂一发不可收拾。 于众名家中,尤爱苏辛豪放,太祖气势。 当常诵其词,养英雄气。 ","date":"2017-08-02","objectID":"/posts/2017/08/journal-2017-08-02/:0:0","tags":["随笔"],"title":"随笔-2017-08-02","uri":"/posts/2017/08/journal-2017-08-02/"},{"categories":["思维"],"content":"心理学研究表明,多数人很难容忍问题的复杂性和模糊性,人们更想要简单直接的答案而不管问题的复杂性。比如在问到儿童的抚养问题时,心理学家会说:“这依赖于情境、父母对情境的反应、以及任何其他可能的变量”,这话足够科学严谨,但作为父母的问者对这样的回答就很没有耐心。对简单的偏好,有助于解释一些毫无营养的畅销书为何得以流行,也能解释某乎很多抖机灵的答案容易得到高赞。 大道可以至简,而具体事物之间却有着千丝万缕的联系,语言有局限,不可说,一说就错,语言永远只能说明道的某一显现。禅宗有一则公案: 僧问:指即不问,如何是月? 师曰:阿那个是汝不问底指? 又僧问:月即不问,如何是指? 师曰:月。 曰:学人问指,和尚为什么对月? 师曰:为汝问指。 可谓一语道破天机! 而且境界越高的人越明白这个道理,这反而可能被那些思维简单的人认为是傻叉。庄子说:夏虫不可语于冰,笃于时也;井蛙不可语于海,拘于虚也;曲士不可语于道,束于教也。这几个类比真的太形象! 反过来想,对于普通的交际,不要老想着说的很全面,说对方想要的答案就够了,要说对方能听懂的话。若要更进一步,事物虽然很复杂,但在众多属性中有一些属性是相对更重要的,也就是辩证法里讲的抓事物的主要矛盾,具体怎么抓主要矛盾,就是另一个更高阶的问题了。 ","date":"2017-04-16","objectID":"/posts/2017/04/language-limitation/:0:0","tags":["语言","局限性","感悟"],"title":"我为什么不说话","uri":"/posts/2017/04/language-limitation/"},{"categories":["读书"],"content":"首先需要认识到,恐惧和焦虑是人正常的情绪反应,是人进化保存在基因里的。比如当我们遇到危险时,产生恐惧情绪有助于避开危险。 但是还有一些恐惧和焦虑是不合理性的,产生原因多样复杂,可能与生活经验有关。这种不合情理的恐惧和焦虑是需要努力克服的。 对此当前最有效的治疗方法是系统脱敏疗法。其原理是建立条件反射,用身心放松取代原先的恐惧反应。这个过程需要循序渐进,逐渐减弱特定情境与恐惧反应的联系程度,知道这种联系消失,同时也就建立了新的联系(特定情境与身心放松之间的联系)。更有意思的是,这个条件反射程序不一定真的需要建立一个特定的情境,单纯的想象这种情境也可以有显著效果。因为这种不合理性的情绪本来就是通过联想产生的。 ","date":"2016-12-18","objectID":"/posts/2016/12/overcome-fear-anxiety/:0:0","tags":["心理学","恐惧","焦虑"],"title":"克服恐惧和焦虑","uri":"/posts/2016/12/overcome-fear-anxiety/"},{"categories":["读书"],"content":"一个人的行为至少部分由一种信念所决定,即相信自己的行为会产生某种后果,而这种后果是与行为相对应的。 这些都与能力和控制力有关。许多人相信自己有足够的能力,并能控制发生在他们身上的一切,至少在有些时候是这样,因为过去曾对某些情况进行过控制并取得了成功。他们相信能够通过自己的努力而达到目标。如果一个人觉得自己缺乏能力和控制力,那么剩下的就只有无助感了。 能力和控制的知觉对身心健康是非常重要的。 当一个人控制特定事件的努力遭受多次失败后,他将停止这种尝试。如果这种情形出现得太过频繁,他就会把这种控制缺失的知觉泛化到所有的情境中,甚至泛化到实际上能够控制的情况。这叫习得性无助。 ","date":"2016-12-17","objectID":"/posts/2016/12/learned-helplessness/:0:0","tags":["心理学","习得性无助"],"title":"什么是习得性无助","uri":"/posts/2016/12/learned-helplessness/"},{"categories":["读书"],"content":"读《改变心理学的40研究》,看到关于内控型和外控型人格的讨论,觉得蛮有意思,记录下来。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:0:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 什么叫内控和外控当人们把自己的行为后果归因为运气、命运或是他人力量的影响时,称为外控点的信念;与之相反,如果人们把行为后果归因于自己的行为和人格特征,则他们就具有一种内控点的信念。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:1:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 形成原因内、外控倾向形成的可能原因有三:文化差异、社会经济水平的差异以及父母教养方式的差异。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:2:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 控制点的影响控制点是一种在各种情景中一贯起作用的可界定的个体特征;而且,个体的内外控维度对行为的影响是使不同的人在面对同一情境时采取不同的行为。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:3:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 与宗教信仰的关系如果一个人具有外控倾向,但这种外部力量被认为是一种对至高无上的神灵(如上帝)的强烈信仰,那么也就不太可能陷入由外控倾向带来的一些典型问题(如无助感、抑郁、低水平的成就动机、缺少谋求改变现状的动机等)。这可以部分解释为什么一些人归于哲学,一些人归于宗教。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:4:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 控制点的可变性内外控是相对稳定的,但不是绝对。若有机会,个体能够通过学习来提高内控水平。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:5:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["读书"],"content":" 启示尽管大多时候内控水平高的人可以更好地自我调节并适应生活,但是如果一个人打算改变不可能改变的情境,那么挫折沮丧和抑郁很可能随之而来。所以最理智的策略是认清哪些能改变的、哪些不能改变,合理的设置内外控界限。 如此看来,美国神学家尼布尔的祈祷词可谓经典: 上帝,请赐予我平静,去接受我无法改变的。 赐予我勇气, 去改变我能改变的。 赐予我智慧, 分辨这两者的区别。 ","date":"2016-12-16","objectID":"/posts/2016/12/personality-control-point/:6:0","tags":["心理学","思维"],"title":"内控和外控型人格","uri":"/posts/2016/12/personality-control-point/"},{"categories":["生活"],"content":"很久没有这么正儿八经的写日志了 要想找不写的理由 总是能找出一大堆来 但归根结底还是因为自己懒 其实有时候挺想用文字记下生活的点滴 怕岁月会淡忘掉一切 但最终还是没有写 紫金港的夜迟迟不肯安静 每个人都在忙碌着自己的生活 我无权过问 也无心过问 在浙大一年半了 难得我有心情去静下来想一想自己的得失 人总是在总结中才会进步 才会成长 还记得在走进紫金港的那一刻 满心的兴奋与好奇 但马上晕头转向找不着东西南北 送妈妈回去的时候 心里多少有些失落 却很快被初入大学的兴奋掩盖 后来才知道妈在回去的车上哭了好久 然后就开始了曾经以为无比美好的大学生活 很快 这种憧憬被现实击碎 迷茫 看不清目标 痛苦 课还是那么多 孤单 曾经的好朋友都在远方 于是有一段时间我对QQ近乎迷恋 和每一个朋友联系 甚至和陌生人聊天 想藉此找到些许慰藉 却无济于事 迷茫挥之不去 直到有一天觉悟到大学还要学习 还要做很多事 把一切归于零 开始新的开始 09年还是不紧不慢的来了 春天的杭州很漂亮 一草一木都让人想入非非 在多雨的日子里 一朵朵雨伞像鲜花 最美的却是花下的人儿 同撑着伞儿携手走在细雨中该也是件浪漫的事 可我知道这浪漫不属于自己 背着忠实的小书包骑车穿梭于紫金港 开始过着一种被称为装学霸的生活 也能每天充实的回到宿舍 满足的睡着 其实现在想起来 也很佩服自己一直以来的坚持 坚持着装学霸生活 坚持认真听每一节课 坚持每天去健身房 坚持去做勤工助学 坚持好好的对待生活中的每一件事 勤工助学让我小小的体会了社会的残酷 要看人脸色 要把心里的不情愿埋在心里 要把笑容堆在脸上 又想起了爸妈 他们在外为我受了多少苦 我无法想象 游戏中最迷恋的还是仙剑 从来不会想到自己还会被游戏感动 但在仙剑里 我伤心过 难过过 也开心过 高兴过 怅然若失过 也若有所悟过 也许在只有在游戏里 才会发生最美的故事最真的爱情 大二了 很幸运的进了爱迪生班 在这里 聚集着众多的学霸和牛人 有很多人让我佩服 大家都很努力 看到这些人 我有时候甚至会感到自卑和惭愧 我以为我已经很努力了 原来我做的远远不够 一年半的大学生活已然逝去 我懂得了很多 也错过了不少机会 只是简单地相信 明天会更好 寒假过得很平淡 不知不觉已经定格在记忆里 同学都来了 见到他们时挺开心 明天就要上课了 课表上又有了许多陌生的名字 兴奋又紧张 看蜗居 看到心痛 不知结局会怎样 外面的天空还开着烟花 不知是在迎元宵节的到来 还是在送春节的远去 不早了 给自己说声晚安 ","date":"2010-02-28","objectID":"/posts/2010/02/lantern-festival-thoughts/:0:0","tags":["随笔"],"title":"元宵夜感","uri":"/posts/2010/02/lantern-festival-thoughts/"},{"categories":["思维"],"content":"想到一些事情,心情豁然! 曾羡靖节种豆南山,怡情五柳,淡然一生。然又恐过而无踪,如鸟去无影,烟散云尽,终不甘心。始思当以润之、盖茨为榜样,轰烈一生,史册有载,方不枉一世。然若此则必苦累非常,且成功几率甚小,到头一场空,人生必如此苦累乎?鱼与熊掌不可兼得,不知如何取舍也,故而苦恼。 近日慎思,闻高言妙语,始悟。 人生无须苦累若此,有最紧要者曰“幸福”,存爱己之人与己爱之人,可以无悔矣。己爱者,必不负之;爱己者,必赴汤蹈火,报之桃李。有感于《蜘蛛侠》,悟能力与责任相关之理,能力越高,责任愈大。成也心安,败也泰然,尽力则无悔。花样年华,当努力提高能力,勇担吾辈之责,为爱己者及己爱者,珍惜之,其幸福即为吾幸福,勿负之,我无憾矣! ","date":"2009-12-11","objectID":"/posts/2009/12/old-essay-mood-recording/:0:0","tags":["感悟"],"title":"明吾志","uri":"/posts/2009/12/old-essay-mood-recording/"},{"categories":null,"content":" Here \u0026 Now 万物一体,缘起性空 敬天,行善,审美 因上努力,果上随缘 谦、敬、勤、恒、舍 子来曰:“父母于子,东西南北,唯命之从。阴阳于人,不翅于父母,彼近吾死而我不听,我则悍矣,彼何罪焉!夫大块载我以形,劳我以生,佚我以老,息我以死。故善吾生者,乃所以善吾死也。今之大冶铸金,金踊跃曰‘我且必为镆鋣’,大冶必以为不祥之金。今一犯人之形,而曰‘人耳人耳’,夫造化者必以为不祥之人。今一以天地为大炉,以造化为大冶,恶乎往而不可哉!成然寐,蘧然觉。” ——《庄子.大宗师》 法于阴阳,和于术数,食饮有节,起居有常,不妄作劳,故能形与神俱,而尽终其天年,度百岁乃去。 虚邪贼风,避之有时,恬淡虚无,真气从之,精神内守,病安从来? 丈夫在世当有为,为民播下太平春 行霹雳手段,怀菩萨心肠 合抱之木,生于毫末;九层之台,起于累土;千里之行,始于足下 种子生现行,现行熏种子 烦恼,以忍辱为妙解;是非,以不辩为解脱。 游戏三昧 ","date":"0001-01-01","objectID":"/about/:0:0","tags":null,"title":"","uri":"/about/"}]