/images/art2.png

My Zsh setting

Zsh & Bash

Since MacOs 10.15(Catalina). The default shell switch from bash to zsh. It is hard to say which one is better however Zsh has been used more widely than bash especially from Linux user.

Zsh

The Z shell (also known as zsh) is a Unix shell that is built on top of bash (the default shell for macOS (Before MacOs Catalina)) with additional features. It’s recommended to use zsh over bash. It’s also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.

Erlang overview

Basic

Documentation: https://erlang.org/doc/search/

Functional language

Erlang is a functional language. Code need compile and running line by line.

Every line need finish by a .. like: A = 1..

Module

Every erlang file will consider as a module. You console will compile all module you want.

You have to add -module(<filename>). into first line. Module should be same with filename without suffix.

In erl console, run c(<filename>). to compile it. Run a function is like: <moduleName>: <functionName>(...<argument>)

Z-shell overview

Reference

Very useful blog:

http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/#username-and-hostname

http://zsh.sourceforge.net/Intro/intro_12.html#SEC12

Variable

nameusage
%mHostname
%nUsername
%dDirectory from /
%~Directory from ~
%ttime (12)
%Ttime (24)

%d and %~ can add a number to specify how many previous path will show. Like %1~

Guide to zsh

Here is the link to A User’s Guide to the Z-Shell

single quotes & double quotes

RPROMPT="$(command)"  # this will run command, then set RPROMPT to the result
RPROMPT='$(command)'  # this will set RPROMPT to run command each time it is printed

Date

man Date

What is "this" in javascript

Author: Dmitri Pavlutin

Reference: https://dmitripavlutin.com/gentle-explanation-of-this-in-javascript/

Concept

  • Invocation of a function is executing the code that makes the body of a function, or simply calling the function. For example parseInt function invocation is parseInt('15').
  • Context of an invocation is the value of this within function body. For example the invocation of map.set('key', 'value') has the context map.
  • Scope of a function is the set of variables, objects, functions accessible within a function body.

Invocations

  • function invocation: alert(‘Hello World!’)
  • method invocation: console.log(‘Hello World!’)
  • constructor invocation: new RegExp(’\d')
  • indirect invocation: alert.call(undefined, ‘Hello World!’)

this in different invocations

this is base on the context of calling this function

How to have a dynamic class name

In same case, you may want to have a different style depend on your state or a variable. Now we can have two ways to achieve that.

classNames

This is a javascript for conditionally joining classNames.

Here is: Github

Basically, you can combine any number of classNames.

const classNames = require('classNames');
classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }); // => 'foo bar baz quux'

ES6 template literals

You can just use template literals.