11/01/2018

tldr

tldr is a small tool to help you cannot always remember the arguments to many commands as like me. TL;DR originates for "Too long; Didn't Read" in Internal Slang, where it is used to indicate that a long text has been skipped...

We like simplified man pages focused on practical example like below:

➜  ~ tldr lsof
Local data is older than two weeks, use --update to update it.


lsof

Lists open files and the corresponding processes.
Note: Root privileges (or sudo) is required to list files opened by others.

- Find the processes that have a given file open:
    lsof path/to/file

- Find the process that opened a local internet port:
    lsof -i :port

- Only output the process ID (PID):
    lsof -t path/to/file

- List files opened by the given user:
    lsof -u username

- List files opened by the given command or process:
    lsof -c process_or_command_name

- List files opened by a specific process, given its PID:
    lsof -p PID

- List open files in a directory:
    lsof +D path/to/directory

keep it simple, stupid.

tldr in alfred

Really enjoy this plugin in alfred.

https://github.com/cs1707/tldr-alfred

tldr github

https://github.com/tldr-pages/tldr

10/27/2018

sift

I like sift tool which is best than most other grep tools, to search the huge log and code base.

sift also is easy customizations to default ignore case as below.

An example config file: ~/.sift.conf

{
      "BinarySkip": true,
      "Git": true,
      "GroupByFile": true,
      "IgnoreCase": true
  }

Performance report

https://sift-tool.org/performance

Usage

https://sift-tool.org/samples

9/14/2018

Using curl to test port connectivity

It's often necessary to troubleshoot port connectivity as common env, but not found telnet.

curl -v telnet://target ip address:desired port number

curl -v telnet://dragon1:22
* Rebuilt URL to: telnet://dragon1:22/
* Trying 192.168.3.31...
* TCP_NODELAY set
* Connected to dragon1 (192.168.3.31) port 22 (#0)
SSH-2.0-Sun_SSH_1.1.4

4/10/2018

Generate Cron Expression in SOP

Sometimes, the cron expression is difficult to generate while you want to resolve urgent things. Let us SOP to generate cron expression.

Here are two links to easily generate cron expression.

  1. http://www.cronmaker.com/
  2. Cron Expression Generator & Explainer - Quartz

1/23/2018

Building Software

Based on Kent Beck describes three activities in building software:

  1. First make it work. (make business or money first)
  2. Then make it right. (refactor code ...you and others can understand it as needs change)
  3. Then make it fast. (refactor code for "needed" performance, don't do this first)

12/26/2017

My Development Principals in Java World

Here are my development principals in java world. 

  • Simple and Small objects
  • Immutable object
  • Interface, it’s a contract that our object must obey in order to communicate with other objects.
  • Don’t use static object and method
  • Don’t use null anywhere
  • Multiple contractor to reuse your code-fee
  • Always chain exception
  • Aspect-oriented programming for special handling
  • A unit test is a part of class.
  • ...continue...

9/18/2014

Switch JDK verson on Mac

When you installed many of jdk versions, there are two ways to switch the jdk.

  • Using Java Preferences application, but Apple decided to remove it.
  • Using java_home in console

After a lot of googing a found simple way solution, I’d like to share.

Edit your profile /.bash_profile or /.zshrc

alias java_ls='/usr/libexec/java_home -V 2>&1 | grep -E "\d.\d.\d[,_]" | cut -d , -f 1 | colrm 1 4 | grep -v Home'

function java_use() {
export JAVA_HOME=$(/usr/libexec/java_home -v $1)
export PATH=$JAVA_HOME/bin:$PATH
java -version
}

Execute java_ls

1.8.0_11
1.7.0_45
1.6.0_65-b14-462
1.6.0_65-b14-462

Execute java_use 1.8

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)