According to React official doc, most of useEffect don’t require any cleanup, but in some cases, we should cleanup useEffect hook to avoid memory leaking and some other errors like

The useEffect cleanup is built in a way that if we return a function within the method, this function will execute when the component gets disassociated. In simple terms, is used to clean up the effect we produced last time.

The simplest example of useEffect with cleaup is as following

A detailed explanation about when you should use useEffect with cleanup

When does cleanup function run?

How to fetch data with React Hooks?

Create a new Next.js project

npx create-next-app my-project

Tailwindcss installation and configuration

npm install tailwindcss@latest postcss@latest autoprefixer@latestnpx tailwindcss init -p

then change the option in

module.exports = {
// purge: [], annotate this line
mode: 'jit', // add `mode` option
purge: ['./pages/**/*.js', './components/**/*.js'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}

Import Tailwind in your own CSS

delete in local folder , add configure with following new contents.

/* ./styles/global.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

Attention: Since you’ve deleted , you should also delete the line in folder (also other code related to )

Now open terminal and run command and that’s all done

yarn run dev

This article will help you set you Raspberry Pi as a Shadowsocks client(rather than a gateway or a router in your house) to access websites blocked by GFW.

  1. You should have a overseas server with shadowsocks server already installed and configured
  2. Install Shadowsocks with Python
sudo pip3 install shadowsocks

3…

After enabling two-factor authentication for your github account, the lagacy password authentication is invalid with the following error, so your need to use token to enable a new auth way.

remote: Invalid username or password.
fatal: Authentication failed for '...'
  1. Generate a new token for your account( to replace your…

Installation

pip3 install virtualenvpip3 install virtualenvwrapper

Configuration

vim ~/.bashrc

Specify the Python path , virtualenvwrapper storage directory .

# virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.7
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Basic usage

# create a new virtualenvmkvirtualenv test --python=python3# activate a virtualenvwork on VIRTUALENV_NAME# deactivate virtualenvdeactivate# list all virtualenvslsvirtualenv# remove virtualenvrmvirtualenv VIRTUALENV_NAME

Reference

https://segmentfault.com/a/1190000014935970

apt install software-properties-commonadd-apt-repository ppa:deadsnakes/ppaapt updateapt install python3.7

Install pip only for Python3.7

If another version Python3 also exists in the system, to solve the conflict, it’s neccessary to install only one version pip for a specific version Python3.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython3.7 get-pip.py
  1. Change promot info(color, path)

Terminal promot info was determined by parameter PS1, check it

echo $PS1

terminal returns info like

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]

\u is current username, \h is the name of host, \w is current path.

change PS1 in ~/.bashrc

# change the info to greeenPS1="\[\e[01;32m\]\u@\h: \W\$\[\e[00m\] "

then activate the PS1 setting permanently.

export PS1source ~/.bashrc

2. Change login promot info

If you want to show message after just input ssh command(before login successfully), modify /etc/issue.net, add the content you like. Do not add message which may leak sensitive info of your server as all anonymous user can see it.

To show message after you login successfully, you should modify file /etc/motd, it’s a safe way for authenticated user.

Then reload the SSH service

service ssh reload

That’s all done.

Typical format of resolv.conf generated by resolvconf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver ...

The resolveconf setting file is /etc/resolvconf/resolv.conf.d/head

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

If you edit the resolv.conf manually, it will be overwritten automatically after restarting network. So to change the resolv.conf permanently, you should change the /etc/resolvconf/resolv.conf.d/head file.

Add a line at the end of the head file like

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 1.1.1.1

Then reload the resolv.conf and restart the network.

resolvconf -u/etc/init.d/networking restart

项月亮

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store