Blog

Check available RAM in Linux

folder_openCoding, Snippets
commentNo Comments
This will convert any kB lines to MB: awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t 1 awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t This version converts to gigabytes: awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t 1 awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t…
Click Me

Has word in String? – PHP

folder_openSnippets
commentNo Comments
function hasWord($word, $txt) { $patt = "/(?:^|[^a-zA-Z])" . preg_quote($word, '/') . "(?:$|[^a-zA-Z])/i"; return preg_match($patt, $txt); } $string = 'This is my own paragraph.'; echo hasWord('no', $string); 123456 function hasWord($word, $txt) {    $patt = "/(?:^|[^a-zA-Z])" . preg_quote($word, '/') . "(?:$|[^a-zA-Z])/i";    return preg_match($patt, $txt);}$string…
Click Me

Round Off Prices in woocommerce

folder_openCoding, Snippets
commentNo Comments
PHP add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 ); add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 ); add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1); add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1); function round_price_product( $price ){ // Return rounded price return round( $price ); } 123456789 add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product',…
Click Me
Menu