[Algorithm] Cooling

Cooling is removal of heat, usually resulting in a lower temperature and/or phase change. Newton’s law of cooling Newton’s law of cooling states that the rate of heat loss of a body is directly proportional to the difference in the temperatures between the body and its surroundings as long as... Continue reading...

[Algorithm] Hausdorff Distance

Introduction Hausdorff Distance is a measure of the degree of mismatch between two sets of points that takes into account the order of the points in the sets. It is defined as the maximum of the distances from a point in one set to the closest point in the other... Continue reading...

[Thought]左方右圆

在金庸的小说《神雕侠侣》中,老顽童周伯通有一项绝技:左右互搏。他的左手和右手可以同时打出两招不同的招式,方便自己和自己对打。这项绝技可以解决一个非常大的敌人——寂寞。 平时的工作中难以避免的会有一些日常性的杂务,没有任何难度,也对个人不太有提升,但是却需要花费大量的时间。这些杂务往往会让人感到烦躁,因为它们占用了大量的时间,但是却没有什么价值。 大米小菜我去弄,是大材小用啊,难事大事我去办,是囊中取物! ——《欢颜》 Hacker应该都有这种傲慢之气,认为自己天妒英才,不应该做一些琐碎的事情,应该把时间花在更有价值的事情上。 如果能够把这些杂务快速处理完,Get Things Done! 那么就可以节省大量的时间,也可以节约时间、精力去做一些更有价值的事情。 所有接触过并发编程的应该都很容易想到并发、并行,如果可以把这些事务并行化,同时进行多项事务的处理,是不是可以事半而功倍呢? 理想是丰满的,现实是骨感的。并发控制是在程序设计中也是一项比较复杂的工作,设计不合理并不一定可以提升多少性能,但整体的可维护性却会大大降低。并且并发控制涉及到上下文切换的问题,如果并发控制的粒度过小,反而会因为上下文切换的开销而降低性能。 经过仔细的思考,我发现通过提升并行度来提升日常向的事务的处理效率是南辕北辙。提升并发是在摩尔定律失效之后才成为必选项的,但日常琐事的处理效率远没有达到物理极限,所以提升处理速度才是正途。 琐事之所以是琐事,就是因为他们的琐碎,不成体系,所以就算并行化之后也依旧是琐事。真正能够解决这类问题的是自动化。 处理琐事的最高境界不是高效处理,而是不处理,至少不能让人来处理。不治而治,才符合程序员懒惰的优良气质。 所以我认为不仅不应该研究并行化处理琐事的技术,而是应该踏踏实实的仔细做好琐事,并且在做的同时仔细思考、分析、梳理,让处理琐事的思路和方法更加系统化,并且逐步提升其自动化程度。通过多做、好好做,实现少做、快速做,最终达到不做,至少不常做的目的。 左方右圆,术也;傲慢懒惰,道也。 Continue reading...

[Tool] Docker Hello World

Docker Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package. And because containers... Continue reading...

[Tool] fish Cheat Sheet(Updating...)

Introduction What How set environment variable set -x VARNAME value Erase environment variable set -e VARNAME Alias alias name 'command' Add Path fish_add_path "/path/to/your/bin/" For Loop for i in (seq 1 10); echo $i; end Math math "12345679 * 9" Conditional if [ -e a.out ]; ./a.out; end Comparesion if... Continue reading...

[Language] Rewrite Core Method with C++

Introduction Sometimes we need to rewrite core method with C++ to improve performance. For example, hive UDF. We can use JNI to call C++ method in Java. Here is a simple example. The Java Part First We need to create a Java class and declare a native method. The native... Continue reading...

[Language] REGEX Column Specification

A SELECT statement can take regex-based column specification in Hive releases prior to 0.13.0, or in 0.13.0 and later releases if the configuration property hive.support.quoted.identifiers is set to none. We use Java regex syntax. Try http://www.fileformat.info/tool/regex.htm for testing purposes. The following query selects all columns except ds and hr. SELECT... Continue reading...

[Tool] VSCode

VSCode is a great editor. It’s free, fast, and extensible. You can use it to edit almost any kind of files. It’s a great tool for developers. Keymaps Function Keymap Open file ⌘ + P Create new file ⌘ + N Save file ⌘ + S Close file ⌘ +... Continue reading...

[Algorithm] Lock

Introduction A lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. A lock is designed to enforce a mutual exclusion concurrency control policy. Lock Types Optimistic/Pessimistic locking Optimistic locking is a strategy where the lock is... Continue reading...

[Architecture] Clean Architecture

Introduction The Clean Architecture is a set of practices to create a software architecture that is simple, understandable, flexible, testable, and maintainable. The Clean Architecture The Clean Architecture is a layered architecture. The layers are: Entities Use Cases Interface Adapters Frameworks and Drivers Boundaries In my opinion, the Clean Architecture... Continue reading...