Coding Frenzy

Chang the swap behavior of linux

The default swappiness is 60. It can be 0-100, with the bigger value more pages will be swapped to harddisk from memory. If you want to use more physical memory and less swap, decrease the number. echo 40 > /proc/sys/vm/swappiness

Share

What you may not know about linux sed

1. Separator can be any symbol. This also works: echo ‘/etc/python3/dummy’ | sed ‘s|/etc/python3/|/etc/python2/|’ output: /etc/python2/dummy In this example above I used | to replace the normally used separator /

Share

Two ways to write literal strings containing line breaks to a file

1. Use printf printf "line 1 line2 line 3 containing a variable: ${PWD} line 4 contains a quote mark ‘ and \" ">temp.txt   cat temp.txt Notice double quote ” needs to be escaped. 2. Use Here Doc: cat > temp.txt <<EOF line 1 line2 line 3 containing a variable: ${PWD} line 4 contains a [...]

Share

How to run chrome from command line

YOu need first add the chrome.exe directory to windows environment. [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Program Files (x86)\Google\Chrome\Application", "User")

Share

Script works under command line but not in crontab?

Add the following lines to crontab and then it will work: SHELL=/bin/bash PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Share