Hi, Ubuntu does not carry chkconfig any more .. besides the standard update-rc.d apache2 defaults or update-rc.d apache2 remove There is a cool tool called : sysv-rc-conf. This tool can be installed using : sudo apt-get install sysv-rc-conf On its own the command opens a cool ncurses interface like this : …
Reboot required Ubuntu
To find out what triggered this use : more /var/run/reboot-required.pkgs nJoy π
converting webm to mp3s ffmpeg
for FILE in *.webm; do echo -e “Processing file ‘\e[32m$FILE\e[0m'”; ffmpeg -i “${FILE}” -vn -ab 128k -ar 44100 -y “${FILE%.webm}.mp3”; done; nJoy π
Snapshot backup using cp -al and rsync
This script requires genuine cp -al capable gnu and rsync commands together with a hardlink capable FS + OS. #!/bin/bash [ $# -ne 2 ] && echo “Incorrect usage : $0 <source path> <target path>” && exit 128 ; SOURCEFOLDER=$1 TARGETFOLDER=$2 SF_LEN=${#SOURCEFOLDER}-1 TF_LEN=${#TARGETFOLDER}-1 #echo “Last character in source folder is ${SOURCEFOLDER:SF_LEN}” if […
Wait for jobs in the background and measure time taken
SECONDS=0;sleep 5 & sleep 6 & sleep 3 & sleep 7 & wait ; elapsedseconds=$SECONDS ; echo $elapsedseconds nJoy π
Simple page to redirect to https from index.html
<html> <head> <title> Redirecting…</title></head> <script language=”JavaScript”> function redirectHttpToHttps() { var httpURL= window.location.hostname + window.location.pathname + window.location.search; var httpsURL= “https://” + httpURL; window.location = httpsURL; } redirectHttpToHttps(); </script> <body> </body> </html> nJoy π
List all mount binds
findmnt | grep “\[” nJoy π
Installing node on old version of Ubuntu 10.04
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | 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 π
Saving a mount in /etc/fstab for availability after reboot
UUID=de9a1ccd-a2dd-44f1-8be8-0123456abcdef /data ext4 defaults,nofail 0 or /dev/xvdf /data ext4 defaults,nofail 0 π nJoy
Saving a million documents in Mongo using Nodejs and mongodb module
/** * Created by davidsaliba on 13/03/2017. */ var MongoClient = require('mongodb').MongoClient , format = require('util').format; var url = 'mongodb://localhost:27017/test'; var async = require ('async'); var entry = { data : "skdlfjsdf", array : [ {id:"arr_obj1"} , {id:"arr_obj2"} ] }; var entries = []; var total_entries = 1000000 for (var j = 0 ; j…