Go Language for Loop Examples

Go provides several ways to perform looping, including the for loop. Here are some examples of using the for loop in Go: Classic for loop: for i := 0; i < 10; i++ { fmt.Println(i) } This loop will start from 0, continue until i is less than 10, and increment i by 1 on … Read more

WordPress Add Shortcodes To Excerpts

By default, WordPress does not allow shortcodes to be executed in excerpts. To enable shortcodes in WordPress excerpts, you need to add the following code to your theme’s functions.php file: add_filter(‘the_excerpt’, ‘do_shortcode’); This code adds a filter to the the_excerpt function, which runs the do_shortcode function on the excerpt before it is displayed. The do_shortcode … Read more

4 Linux Commands To View Page Faults Statistics

Here are four Linux commands to view page fault statistics: vmstat – This is a versatile command that provides information on system resource utilization, including page faults. The vmstat command reports the number of page faults in the “faults” column. vmstat procs ———–memory———- —swap– —–io—- -system– ——cpu—– r b swpd free buff cache si so … Read more

Lighttpd: Set Cache-Control: public, max-age Headers For Caching Purpose

To set Cache-Control: public, max-age headers for caching purposes in Lighttpd, you need to modify the configuration file. The default configuration file is usually located at /etc/lighttpd/lighttpd.conf. To set the Cache-Control headers, add the following to your Lighttpd configuration file: $HTTP[“url”] =~ “\.(gif|jpg|jpeg|png|css|js)$” { # set cache-control headers for static files add_header “Cache-Control” “public, max-age=31536000, … Read more

Linux / Unix Rsync Copy Hidden Dot Files and Directories Only

To copy only hidden dot files and directories using rsync, use the –include option with a pattern to match hidden files, and the –exclude option with a pattern to exclude all other files: rsync -av –include=’.*/’ –exclude=’*’ source_directory/ destination Here’s what each option does: -a (or –archive) is equivalent to -rlptgoD and preserves almost everything … Read more