Buy Me a Coffee

[Git] How to rebase the pushed branch

Learning the knowledage with a real case is always perferred. I met a case today that I need to use git rebase --interactive to solve the issue. The story is that my colleague created a branch for doing some research one year ago. Let’s say the branch name is feat/performance-research. As the branch is mainly for research purpose, it was not merged to the master branch at that time. However, some changes and results were quite valuable. ...

[Axios] How to extract header data in Axios response interceptor

Let me give an example first. Frontend sends an API request, and server will reject it and add a reason of the rejection into the response header. In this scenario, Frontend wants to extract the reason from the header in the response interceptor and then navigate to different page depending on the reason. The code is very straightforward like below. 1export function errorInterceptor(error: AxiosResponse) { 2 if (error.status === 401) { 3 const reason = error.headers['reason']; 4 if (reason === 'bar') { 5 window.location.href = '/#!/foo'; 6 } 7 } 8 return Promise.reject(error); 9} 10 11axios.interceptors.response.use( 12 (response: AxiosResponse) => response, 13 errorInterceptor 14); Unfortunately, the above code will behave unexpectedly. As the highlight code error.headers['reason'] will be undefined. ...

[Linux] Error: ENOSPC: System limit ...

I can do general frontend work, but I’m not specialized in front end. Today when I run up the front-end project, I met the following issue. Error: Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached... The reason is that there is restriction of opening files by one process in Linux. The default number of opening file might be too limited especially when you run with webpack. The solution is to increase the limitation. You can change as below. ...

[Ubuntu] How to mount the external hard drive permanently

I will introduce this topic with a real example. The scenario is that I have two external NTFS hard drives. I want them to behave like the partition on Windows, like D drive, E drive something. However, every time when the Ubuntu is rebooted, those two hard drives are mounted to the path /media/<username>/<label name> and they are read-only. I wrote a temporary solution for the above issue, but it stil requires to execute the command every time when PC boots. This post will give a one-go solution. ...

[Ubuntu] External hard drive is read-only

Yesterday I installed Ubuntu on my PC, but I met an issue about the external drive is always the read-only. As the hard drive was the destination of my internal minio server, so I have make it writable too. Error: mkdir: cannot create directory ‘abc’: No such file or directory When I ran the df -T, it shows like /dev/sdb2 fuseblk 3907000316 278934580 3628065736 8% /media/username/InternalBackup I labelled the hard drive name as InternalBackup in the Windows OS before. ...

[microk8s] Troubleshooting Microk8s Installation on macOS

Error: Your Command Line Tools are too outdated By following the instruction from the official website Alternative install methods: macOS, I got an error while running brew install ubuntu/microk8s/microk8s as shown below As the prompt suggested, I installed the latest Xcode from the AppStore. (It took quite long to be honest). But it still showed the same error after updating the Xcode to the 13.2.1 The trick is that we should run the following commands: ...

[Git] How to work with remote repository (with example)

When we manage and maintain a public github repository, it is common to see a case that a fixed branch from outside contributor’s is staled. The reasons can be The github repository owner/maintainer and contributor did not actively process the issue in time. The contirbutor only commited the changes in his branch but didn’t make a pull request, and after a period, he is not reachable. Other reasons… Overall, it is not easy to maintain a public github repository, especially the one with lots of stars. This post will show a way to solve the above issue with a git feature. ...

[Git] How to ignore the commited file

In Git, we can ignore to track of a file or folder by adding their paths into the file .gitignore. However, sometimes we could mistakenly commit and push file and folders that are not needed to be tracked by Git. In such case, .gitignore will be not working. The issue can be solved by the below steps: Add the file path into .gitignore file. Remove the commited file from the git cache by git rm --cached bar/foo.log Commit the changes by git commit -m "xxx" After executing the above steps, you can see the file bar/foo.log is still there but will be not tracked by Git. ...

[macOS] How to set environment variable on macOS

It is very common for developers to set Environment Variable while doing some development work or configuring the development environment. There are two kinds of Environment Variable: temporary and permanent. This post will show how to set both on macOS 1. Temporary environment variable We can simply execute the below command in the Terminal export [env_key]=[env_value] For example, to set DEBUG_MODE to true before running the development project. export DEBUG_MODE=true 2. Permanent environment variable Go to the user working directory to locate the file .bash_profile. Normally we can use vi ~/.bash_profile. Add the below command to the bottom of the file export [env_key]=[env_value] Save the changes with :wq in vim Refresh the cache of .bash_profile with source ~/.bash_profile After setting the environment variable, we can type echo ${env_key} to validate if it is successfully set. ...

[Inkscape] How to smooth svg file with Inkscape

Again, Inkscape is a free and open-source vector graphics editor. Open Inkscape Right click and choose Trace Bitmap, just simply click OK After trace bitmap, the original svg file is still in the background, we need to resize the front processed svg in order to showing out the original svg file. And delete it Done In this example, the svg image has full black color surround it. We should make some space for it so that it can look better. Set image size 22px, document size 24px, starting point is (1,1)

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !