Convert Large numbers to binary in Excel

=DEC2BIN(MOD(QUOTIENT($A$1,16^7),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^6),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^5),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^4),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^3),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^2),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^1),16),4)&" "&DEC2BIN(MOD(QUOTIENT($A$1,16^0),16),4)

The above code will convert large numbers up to 32 bit.

nJoy 😉

SYSTEMD – controls

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:

systemctl start SERVICE – Use it to start a service. Does not persist after reboot

systemctl stop SERVICE – Use it to stop a service. Does not persist after reboot

systemctl restart SERVICE – Use it to restart a service

systemctl reload SERVICE – If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.

systemctl status SERVICE – Shows the status of a service. Tells whether a service is currently running.

systemctl enable SERVICE – Turns the service on, on the next reboot or on the next start event. It persists after reboot.

systemctl disable SERVICE – Turns the service off on the next reboot or on the next stop event. It persists after reboot.

systemctl is-enabled SERVICE – Check if a service is currently configured to start or not on the next reboot.

systemctl is-active SERVICE – Check if a service is currently active.

systemctl show SERVICE – Show all the information about the service.

sudo systemctl mask SERVICE – Completely disable a service by linking it to /dev/null; you cannot start the service manually or enable the service.

sudo systemctl unmask SERVICE – Removes the link to /dev/null and restores the ability to enable and or manually start the service.

Just copied notes. 😉 nJoy

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 README.md https://github.com/pm2-hive/pm2-logrotate


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
}
}
}

nJoy 😉

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');

console.log('Magic happens on port 3000');

exports = module.exports = app;


Before running the js file run 
npm install express 

to deploy express..

Thats it !

nJoy 😉