Install pigz (Parallel Implementation of GZip)

pigz, which stands for Parallel Implementation of GZip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz is approx 10x faster then regular GZip. For Ubuntu 16.04 or

Install latest version of RAR in Linux

Run as root. wget tar -xf rarlinux-x64-5.8.0.tar.gz cd rar chmod +x rar unrar mv rar unrar /usr/local/bin mv rarfiles.lst /etc wget -O rarreg.key mv default.sfx rarreg.key /usr/local/lib cd .. rm -r rar rm rarlinux-x64-5.8.0.tar.gz bash  

Install Speedtest

export INSTALL_KEY=379CE192D401AB61 export DEB_DISTRO=$(lsb_release -sc) apt-key adv –keyserver –recv-keys $INSTALL_KEY echo “deb ${DEB_DISTRO} main” | tee /etc/apt/sources.list.d/speedtest.list apt update && apt install gnupg1 apt-transport-https dirmngr speedtest ln -s /usr/bin/speedtest /usr/local/bin/spd

Better exec()

/** * Run command and get output and exit code. * See * See */ function run_command($command) { $output = []; exec($command, $output, $exitcode); // Trim, Remove empty and Reset keys. $output = array_values(array_filter(array_map(‘trim’, $output), function($string) { return

Read STDOUT and STDERR in non blocking way on proc_open

<?php // The command to run. $command = ‘ping’; $descriptors = [ 0 => [‘pipe’, ‘r’], // STDIN 1 => [‘pipe’, ‘w’], // STDOUT 2 => [‘pipe’, ‘w’], // STDERR ]; $process = proc_open($command, $descriptors, $pipes); if (is_resource($process)) {

Manage WSL like a boss with LxRunOffline

Download LxRunOffline from Github and add it to the PATH so it can be accessible from anywhere. Download Ubuntu form the links below, then extract the .zip file. # Ubuntu 16.04 # Ubuntu 18.04 To install Ubuntu 16.04

Reset IPMI password

Worked for me on Ubuntu 16.04 ipmitool user list ipmitool user set password <user id from list> <new password>

Real time flushing in PHP on Nginx

Works perfectly on RunCloud’s Native Nginx Stack. @ini_set(‘zlib.output_compression’, 0); @ini_set(‘output_buffering’, ‘Off’); @ini_set(‘implicit_flush’, true); @ob_implicit_flush(1); @ob_end_clean(); header(‘Content-Encoding: none’); header(‘X-Accel-Buffering: no’);

Remove image sizes in WordPress

/** * Function to Remove image size. * @param [string] $size */ function remove_image_size_by_size($size) { $dimension = explode(‘x’, $size); global $_wp_additional_image_sizes; foreach ($_wp_additional_image_sizes as $key => $single) { if ($single[‘width’] == $dimension[0] && $single[‘height’] == $dimension[1]) { remove_image_size($key); break; }

Change default PHP CLI configuration on RunCloud

Runcloud allows you to change the PHP Settings for each application from their Web Panel. But if you’re like me who heavily uses the PHP-CLI then changing config from Web Panel won’t help you. The PHP configs from their Web

Handful WP-CLI Tricks

Delete posts based on search # Spaces needs replace with + (plus sign) # Eg: hello+world wp post delete $(wp post list –post_type=’post’ –s=’keyword+here’ –format=ids) –force

Fix CMD output when using shell_exec() from PHP

/** * Fix weird output encoding. */ function run_command($command) { $string = shell_exec($command); $string = mb_convert_encoding($string, ‘UTF-8’, ‘UTF-16LE’); return $string; } Source:

Linux touch command for Windows

Create touch.cmd with the following content and it to ENV Path. @echo off setlocal enableextensions disabledelayedexpansion (for %%a in (%*) do if exist “%%~a” ( pushd “%%~dpa” && ( copy /b “%%~nxa”+,, & popd ) ) else ( type nul