Decorative image frame

Solito

Buring silence in SHA.

Solito

Linux CMD for daily use

check log

  1. Display whole log file content:

    1
    $ cat target.log
  2. Search key word in log file, and return lines containing keyword:

    1
    2
    3
    $ cat target.log |grep "keyword"
    or
    $ grep -i "keyword" target.log

    these two method return same result

  3. Check the most recent log (the tail lines of log file):

    1
    2
    3
    $ cat target.log |tail -n 200   # check the last 200 lines of log file
    or
    $ tail -200f target.log # show last 200 lines and continue printing new logs
    Read More...

Golang/Gin getting started

Failed to download golang toolkit

1
2
3
4
5
$ go env -w GOPROXY=https://goproxy.cn
$ go get -v golang.org/x/tools/gopls
go: downloading golang.org/x/tools/gopls v0.7.1
go: downloading golang.org/x/tools v0.1.5
go: downloading golang.org/x/tools v0.1.6-0.20....

cannot initialize 1 variables with 2

1
input, _ := strconv.ParseInt(scanner.Text(), 10, 64)

here the strconv will return a set of two values, one for result and one for error exception, so we add the _ to catch the exception msg

Read More...

Python concepts

classmethod & staticmethod

https://www.cnblogs.com/baxianhua/p/10845620.html

Python不支持多个的參数重载构造函数,用classmethod修饰符的方式,定义出来的函数就能够在类对象实例化之前调用这些函数,就相当于多个构造函数,解决多个构造函数的代码写在类外面的问题

类最基本的作用是实例化出一个对象,但是有的时候再实例化之前,就需要先和类做一定的交互(init方法里需要调用类里的方法,或init之前需要调用类方法),这种交互可能会影响实际实例化的过程,所以必须放在调用构造函数之前。大概也可能是因为这个原因出现了classmethod

对于一个普通的类,我们要使用其中的函数的话,需要对类进行实例化,而一个类中,某个函数前面加上了staticmethod或者classmethod的话,那么这个函数就可以不通过实例化直接调用,可以通过类名进行调用的

类方法的第一个参数(cls)指代的就是类本身。类方法会用这个类来创建并返回最终的实例。使用类方法的另一个好处就是在继承的时候,保证了子类使用可选构造函数构造出来的类是子类的实例而不是父类的实例

staticmethod就是全局可调的静态方法

yield

https://blog.csdn.net/mieleizhi0522/article/details/82142856
yield = return & generator

Read More...

Python development & problems

venv setup, activate & exit

  1. setup:
    1
    $ python3 -m venv
  2. activate:
    1
    2
    $ . venv/Scripts/activate        # windows
    $ source venv/bin/activate # linux & Mac OS
  3. exit:
    1
    $ deactivate
    ref: https://blog.csdn.net/weixin_30292745/article/details/101445788?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_v2~rank_aggregation-3-101445788.pc_agg_rank_aggregation&utm_term=python+%E5%85%B3%E9%97%ADvenv&spm=1000.2123.3001.4430
Read More...

Frontend Interview

This article is created for recording problems encountered in my interview.

什么是IIFE(立即调用函数表达式)

它是立即调用函数表达式(Immediately-Invoked Function Expression),简称 IIFE。函数被创建后立即被执行:

1
2
3
4
(function IIFE(){
console.log( "Hello!" );
})();
// "Hello!"

在避免污染全局命名空间时经常使用这种模式,因为 IIFE(与任何其他正常函数一样)内部的所有变量在其作用域之外都是不可见的。

ref: https://www.jianshu.com/p/d4d2eb4be216

Read More...

React Learning

This is a recording of my study on React framework

super(props) | super() | no super

  • super():
    If constructor is used, there is a must to add super(), it is for initializing this, and can bind events to this.
  • super(props):
    If you want to use this.props in a constructor, also need to add super(props).
    (No matter there is a constructor, this.props can work in render(), this is auto-implemented by React)
  • no super:
    If there is no constructor, super is not mandatory, cuz React will add a empty constructor as default.
Read More...