How to send a POST request in Go? For example, send a POST of content like ‘id=8’ to a URL like https://example.com/api. In Go, the http package provides many common functions for GET/POST. Related to POST requests, the package provides 2 APIs: Post Post issues a POST to the specified URL. func (c *Client) Post(url,
Read more
Tag: Tutorial
How to change the maximum uploading size for PHP with Apache on Linux?
Posted onHow to change the maximum uploading size for PHP with Apache on Linux? PHP has parameters to control the maximum uploading size. Here, we use Ubuntu 18.04 LTS default version as an example. First, open the php.ini configuration file using your favorite editor /etc/php/7.2/apache2/php.ini Then, find the following parts ; Maximum size of POST data
Read more
How to detect whether a file is being written by any other process in Linux?
Posted onHow to detect whether a file is being written by any other process in Linux? Before a program open a file to processes it, it wants to ensure no other processes are writing to it. Here, we are sure after the files are written and closed, they will not be written any more. Hence, one-time
Read more
How to make CentOS Linux to load a module automatically at boot time?
Posted onHow to make CentOS Linux to load a module, say ixgbe, automatically at boot time? I am using CentOS 7. You can create a text file <some name>.conf in the /etc/modules-load.d/ and list the modules to be loaded there, one per line. The systemd-modules-load.service daemon will read these files and load the modules. Check more
Read more
How to count the number of reads in each chromosome in a bam file?
Posted onHow to count the number of reads in each chromosome in a bam file? The bam file is already sorted by the chromosome names. If the bam file is indexed, you may quickly get these info from the index: samtools idxstats in.bam | awk ‘{print $1″ “$3}’ If the bam file is not indexed, you
Read more
How to write a SQL to replace strings in a column in a MySQL database table?
Posted onHow to replace strings in a column in a MySQL database table? For example, I would like to replace http://www.systutorials.com with https://www.systutorials.com in a content column of a table post. You may use a SQL statement as follows. update post set content = replace(content, ‘http://www.systutorials.com’, ‘https://www.systutorials.com’) where content like ‘%http://www.systutorials.com%’
How to use encfs on Windows 10?
Posted onI am happy using encfs on Linux. But how to use encfs on Windows 10? I would suggest EncFS MP. It support Encfs on Windows. Features of EncFSMP: Mounts EncFS folders on Windows and OS X Can create, edit, export and change the password of EncFS folders Is 100% compatible with EncFS 1.7.4 on Linux
Read more
How to use encfs in Android?
Posted onIs encfs available in an Android phone? You may try Encdroid a piece of free software released under the GNU General Public License. It is an Android application. It can access EncFS volumes on cloud storage or internal/USB storage devices. Google Play Store Link: https://play.google.com/store/apps/details?id=org.mrpdaemon.android.encdroid&hl=en Source code: https://github.com/mrpdaemon/encdroid
Killing Running Bash Script Process Itself and All Child Processes In Linux
Posted onIn Linux, how to kill a process and all its child processes? For example, a Bash script A starts B, B starts C and C calls rsync. I would like to kill A and all its child processes all together. How to do this? There are possibly many answers to this question. One of the
Read more
How to estimate the memory usage of HDFS NameNode for a HDFS cluster?
Posted onHDFS stores the metadata of files and blocks in the memory of the NameNode. How to estimate the memory usage of HDFS NameNode for a HDFS cluster? Each file and each block has around 150 bytes of metadata on NameNode. So you may do the calculation based on this. For examples, assume block size is
Read more
How to split a gzip file to several small ones on Linux?
Posted onI have a very large (e.g. 100GB) .gz file and would like to split it into smaller files like 8GB/each for storage/copying. How to split a gzip file to several small ones on Linux? You may use the tool split to split a file by sizes. An example to split a large.tgz to at most
Read more
How to embed a Map image from Google Map in a website?
Posted onGoogle Map has APIs. But the requirement is that the Map image should be static and uploaded to the website only. No request or dependency on Google’s website should be needed so that the website can run without Internet. Is it possible or allowed (like a screenshot of the Google Map)? If not, any suggestions
Read more
How to get the mtime of a file on Linux?
Posted onHow to get the mtime of a file on Linux from the file’s path? You can use stat to get the file status including the mtime: %y time of last modification, human-readable %Y time of last modification, seconds since Epoch As an example, $ stat -c %y ./file 2017-06-26 13:33:06.764042064 +0800 $ stat -c %Y
Read more
How to find the hostname of an IP using /etc/hosts if it has the mapping on Linux?
Posted onCommon DNS queries like ping will first get the IP of a hostname if it exists in /etc/hosts. How to find the hostname of an IP using /etc/hosts if it has the mapping on Linux? Multiple tools on Linux can do the “reverse” checking using /etc/hosts file. For example, if we have a line 192.0.2.1
Read more
How to force systemd to refresh or reloaded a changed fstab on Linux?
Posted onOn Linux, how to force systemd to refresh or reloaded a changed /etc/fstab file? To force systemd to reload the changed /etc/fstab file content, run $ sudo systemctl daemon-reload To, further, make systemd auto remount any new entries, do $ sudo systemctl restart remote-fs.target local-fs.target
How to check last boot’s systemd journal log in CentOS 7 Linux?
Posted onThe command to check last boot’s journal log shows nothing on CentOS 7: # journalctl -b -1 Failed to look up boot -1: No such boot ID in journal Is the log stored and where it is? The reason this happens on CentOS 7 is that CentOS 7 by default does not enable the persistent
Read more
How to compare date in SQL?
Posted onHow to compare date in SQL? For example, the ‘users’ table has a column ‘loggin’ which is the date and time. How to find out the ‘users’ whose ‘loggin’ date is later than Jan 10, 2017? In SQL, dates can be compared using ‘’, ‘=‘. For the example described, the SQL statement could be: SELECT
Read more
How to show N entries in result of a select SQL query to MySQL?
Posted onHow to show only N entries in the result of a select SQL query to MySQL? The select SQL query is: select * from qa_users; To limit the N entries (say N = 10), we can use the limit clause as follows. SELECT * FROM qa_users LIMIT 10; Note that it is for MySQL. For
Read more
How to print a line to STDERR and STDOUT in C++?
Posted onIn C++, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely? And similarly, how to print the line to STDERR? In C++, you may print the string and then ‘n’ or std::endl to STDOUT by operating on the std::cout stream: std::cout << your_string << std::endl;
Read more
How to print a line to STDERR and STDOUT in OCaml?
Posted onIn OCaml, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely? And similarly, how to print the line to STDERR? In OCaml, you may print a string with the end line character to STDOUT using the function in the Pervasives module: val print_endline : string
Read more