Thursday, August 29, 2024

Start new tab with the current directory in windows WSL

Use the following alias:

alias nt='wt.exe -w 0 wsl'

It means starting a new  terminal (tab) in the same window (-w 0) , and run a command wsl with it.

Thursday, June 27, 2024

Node.js certificate issues

When you encountered certificate issues when using node.js, there are some workaround that can be tried:

1) Add custom CA certs

    $ export NODE_EXTRA_CA_CERTS=[your CA certificate file path]

2) Disable certificate checking

    NODE_TLS_REJECT_UNAUTHORIZED


Keep current log file when using logrotate

When using logrotate in Linux, you might encounter a situation where your log file gone when the log rotated. One of the flag that you may need to notice is the copytruncate flag. It did not remove the current log file, instead it copy the log file and then truncate it:

File name: /etc/logrotate.d/your-application

 /var/log/your-application/output.log {
    copytruncate
    rotate 5
    daily 
    compress
    delaycompress
    notifempty
    missingok
}


Thursday, May 23, 2024

Quasar failed to proxy pass via https

When failed to proxy pass with https in Quasar framework, it is very likely that the target-host HTTPS are configured incorrectly.  As a workaround, you can modify the quasar.conf.js with secure:false as following:

        "/context/path1/": {
          target: "https://target-host/path1/",
          secure: false,
          changeOrigin: true,
          pathRewrite: {
            "^/context/path1/": "",
          },
        },


Thursday, May 9, 2024

Limit CPU and Memory usage in Linux Slack

The Linux Slack consumes a lot of CPU and memory in Linux environment. To limit its resource usages, you can apply a quote via the snap command:

sudo snap set-quota slacklimit --memory=2GB --cpu=20% slack

Thursday, March 28, 2024

Sync multiple git repo at once

Use the following command in Linux will do the job:

 ls -d RepoNames* | xargs -I{} git -C {} pull

Tuesday, December 12, 2023

ffmpeg to convert MPEG4 to Animated GIF

In short, use the following command to do the conversion:

ffmpeg -i source_file.m4v -filter_complex "[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse" output_trimmed_enhanced.gif


Reference: https://www.bannerbear.com/blog/how-to-make-a-gif-from-a-video-using-ffmpeg/



Wednesday, December 6, 2023

Using Conda behind firewall

 To use conda behind firewall, in Windows:

1) Edit the .condarc

channels:
- defaults
proxy_servers:
  http: <proxy_host>:8080
  https: <proxy_host>:8080
ssl_verify: False

NOTE: Beware doing something like this:
http: http://proxyhost:8080
https: http://proxyhost:8080

Don't add "http://" above, it's wrong!


2) Using pip (need to trust the hosts)

pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pandas

Some other better methods exist, the above is just one of the options that works.

Wednesday, August 16, 2023

Bind port 80 for normal user in Linux

To bind port 80 for normal user in Linux, use 'authbind'

Steps:

1. sudo apt get authbind

2. sudo touch /etc/authbind/byport/80

3. sudo chown user:user /etc/authbind/byport/80

4. chmod 500 /etc/authbind/byport/80

5. authbind --deep <command to run> (e.g. quasar dev)

Wednesday, June 28, 2023

Favourite LS_COLORS

Just wanna have my script files (Python script, Shell script) shows color in ls:

LS_COLORS=$LS_COLORS:'*.py=0;94:*.sh=0;94' ; export LS_COLORS 

CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...