DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator


Warning: Missing argument 1 for shapeshifter_archive_page_title(), called in /var/www/dallascao.com/en/wp-content/themes/shapeshifter/category.php on line 10 and defined in /var/www/dallascao.com/en/wp-content/themes/shapeshifter/includes/functions-do-actions.php on line 142

Category: Coding Frenzy

Learn Java: print an asterisk tower

Learn Java: print an asterisk tower
/** Print a asterisk tower. Learn Java practice OUTPUT * *** ***** ******* ********* *********** ************* *************** ***************** ******************* @author Yifan Chao */ public class Ast { /** app entry point */ public static void main(String[] args) { for (int counter1 = 1; counter1Read More

Solve “too many open files” error on ubuntu/debian

Solve “too many open files” error on ubuntu/debian
Use cat /proc/sys/fs/file-nr to check open file numbers vs max numbers. printf " fs.file-max = 655350" >> /etc/sysctl.conf sysctl -p /etc/sysctl.conf printf " * soft nofile 655350 * hard nofile 655350" >> /etc/security/limits.conf printf " session required pam_limits.so" >> /etc/pam.d/su printf " session required pam_limits.so" >> /etc/pam.d/common-session printf " ulimit -n 655350" >> /root/.bashrc printf […]Read More

Chang the swap behavior of linux

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/swappinessRead More

What you may not know about linux sed

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 /Read More

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

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 temp.txtRead More