Skip to content

Instantly share code, notes, and snippets.

@zenglian
zenglian / clean_code.md
Created February 12, 2019 09:35 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@zenglian
zenglian / layout-en.md
Last active August 30, 2018 05:45
Optimize Keyboard Layout for Developers

Optimize Keyboard Layout for Developers

Design

For most people, " is much more frequently used than '.
For most developers,Esc is much more frequently used than Caps Lock.
For programmers of Java/JavaScript/C/C++/C# etc, {/} is more frequently used than [/].

So it's not bad to swap them.

Configuration

@zenglian
zenglian / layout.md
Last active February 18, 2021 14:10
程序员的键盘布局优化方案与配置

程序员的键盘布局优化

问题

据粗略统计:

  • 对于绝大部分人,"的使用频率大于'
  • 对于开发人员,Esc键的使用频率大于Caps Lock键。
  • 对于Java系/JavaScript系/C系/C#/Go等程序员,{/}的使用频率要明显大于[/]

解决方案

交换以上键3组按键。

@zenglian
zenglian / cisco-anyconnect-auto-login.md
Last active July 9, 2024 15:20
auto login with cisco anyconnect (password saved, silent mode)

Cisco AnyConnect: auto login in silent mode

This gist is for Linux. For windows is the same thing.

Connect

create a file .login_info as below:

connect your.server.url    
usernanme 
@zenglian
zenglian / log4j-socket-server-separate-files.md
Last active August 19, 2018 09:48
log4j socket server: save log events from different clients to separate files

log4j socket server: save log events from each client to a separate file

Issue

An application can run on multiple hosts and if we want to collect the logs from all clients we can use log4j's socket appender.

Log4j has implemented SimpleSocketServer which calls SocketNode which collects all events from all clients to a single log file so it's difficult to identify them.

Goal

Out goal is to collect events from each client to a separate log file with file name xxx-{client}.log where {client} is the client address.