Using ngrok with React based websites

The problem : When we have a react.js based site (hosted on port 8000) and ngrok it for development purposes we get Invalid Host Header The fix is to override the header on reflection: ngrok http 8000 -host-header=”localhost:8000″   That’s it 😉 nJoy

Clear Linux Cache

1. Clear PageCache only. # sync; echo 1 > /proc/sys/vm/drop_caches 2. Clear dentries and inodes. # sync; echo 2 > /proc/sys/vm/drop_caches 3. Clear PageCache, dentries and inodes. # sync; echo 3 > /proc/sys/vm/drop_caches nJoy 😉

Ubuntu Clean old kernel images

Be VERY CAREFUL with this.   sudo dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get -y purge 😉 nJoy

PM2 set logs to compress and expire

Referring to the github pm2 install pm2-logrotate@2.6.0 pm2 set pm2-logrotate:compress true pm2 set pm2-logrotate:max_size 10M pm2 set pm2-logrotate:retain 7 pm2 conf { “pm2-logrotate”: { “max_size”: “10M”, “retain”: “7”, “compress”: “true”, “dateFormat”: “YYYY-MM-DD_HH-mm-ss”, “workerInterval”: “30”, “rotateInterval”: “0 0 * * *”, “rotateModule”: true }, “module-db”: { “pm2-logrotate”: { “uid”: null, “gid”: null } }…

Show all cronjobs for all users

This is a simple script to get all cronjbs for all users on a system for someone in $(cut -f1 -d: /etc/passwd); do echo $someone; crontab -u $someone -l ; done nJoy 😉  

Dummy node script to respond 200 (or anything) to a call for testing purposes

This is as bare a node App as you can make but it comes in handy when you want a . dummy server just to return 200s and or a JSON object at super fast speeds on small systems:   var express = require(‘express’); var app = express(); app.get(‘*’, function(req, res) { res.sendStatus(200); }); app.listen(‘3000’);…

Installing node on old version of Ubuntu 10.04

curl -o- | bash logoff and log on nvm ls-remote nvm install v7.9.0 npm -v node -v Caveat :   Lots of node stuff fails to compile and run on such an old version of linux be warned… Thats it you now have node and npm installed. nJoy 😉

send video from local device to a slave computer with ffmpeg

setup service listener on viewer machine : while : ; do ffplay -i tcp://192.168.xx.xx:1234?listen ; done send video to it : ffmpeg -re -i /dev/video1 -vcodec mpeg2video -f alsa -i hw:2,0 -ac 2 -s 1920×1080 -r 25 -strict -2 -f mpegts tcp://192.168.xx.xx:1234 where 192.168.xx.xx is the IP of the viewer where the ffplay is running….

starting a machine in Docker with ports

docker run -p 800:80 -p 2222:22 -p  4443:443  -it 68715929d32a  /bin/bash If ports do not work check : sysctl net.ipv4.ip_forward if  you get: net.ipv4.ip_forward = 0 then issue : sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1if you get the error :   docker: Error response from daemon: driver failed programming external connectivity on endpoint amazing_williams (44e256a6039741b20e4124800702d9794d69fb6be9da71ba25059de4dd527121):…