git diff
git diff --cached
git diff HEAD^..HEAD
/** | |
* Retrieve object from Chrome's Local StorageArea | |
* @param {string} key | |
*/ | |
const getObjectFromLocalStorage = async function(key) { | |
return new Promise((resolve, reject) => { | |
try { | |
chrome.storage.local.get(key, function(value) { | |
resolve(value[key]); | |
}); |
<?php | |
/* | |
Plugin Name: R Debug | |
Description: Set of dump helpers for debug. | |
Author: Andrey "Rarst" Savchenko | |
Author URI: https://www.rarst.net/ | |
License: MIT | |
*/ |
<?php | |
/** | |
* Borrowed from https://stackoverflow.com/a/38407568/1994640 | |
* | |
* Fixed fatal errors and unwanted creation of empty arrays | |
*/ | |
$filePath = 'hello.zip'; | |
$za = new ZipArchive(); | |
if ($za->open($filePath) !== true) { // check for the zip archive |
git clone https://github.com/krakjoe/pcov.git | |
cd pcov | |
/usr/local/bin/phpize | |
./configure | |
export INCLUDE_PATH=/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+3/bin/darwin/include | |
make CPPFLAGS="-I${INCLUDE_PATH}/php -I${INCLUDE_PATH}/php/main -I${INCLUDE_PATH}/php/TSRM -I${INCLUDE_PATH}/php/Zend -I${INCLUDE_PATH}/php/ext -I${INCLUDE_PATH}/php/ext/date/lib" | |
sudo make install | |
sudo cp $(php-config --extension-dir)/pcov.so /usr/local/php/extensions |
# If you are debugging a code in editors like Visual Studio Code (VSCode) or Sublime | |
# Text and if you see that breakpoints are getting triggered due to WordPress Ajax | |
# requests, then XDEBUG Remote Debugging can be disabled for Ajax Requests by | |
# adding code below in .htaccess file. | |
<If "%{REQUEST_URI} =~ /admin-ajax/"> | |
php_value xdebug.remote_enable 0 | |
</If> |
// Add / Update a key-value pair in the URL query parameters | |
function updateUrlParameter(uri, key, value) { | |
// remove the hash part before operating on the uri | |
var i = uri.indexOf('#'); | |
var hash = i === -1 ? '' : uri.substr(i); | |
uri = i === -1 ? uri : uri.substr(0, i); | |
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"); | |
var separator = uri.indexOf('?') !== -1 ? "&" : "?"; | |
if (uri.match(re)) { |
function wp_timezone_object_from_gmt_offset() { | |
$min = 60 * get_option('gmt_offset'); | |
$sign = $min < 0 ? "-" : "+"; | |
$absmin = abs($min); | |
$tz = sprintf("%s%02d%02d", $sign, $absmin/60, $absmin%60); | |
return new DateTimeZone( $tz ); | |
} |
<?php | |
/** | |
* Modifies html tag attributes in the html string | |
* | |
* Remember, this will autofix the passed html. So if invalid html string is sent (e.g. `a` tag w/o end), | |
* then the o/p returned by function will be valid html string. | |
* | |
* Examples: | |
* 1. modifyHtmlTagAttrsInString( |
git add . | |
git stash | |
git pull --rebase | |
git stash pop | |
git status | |
git commit | |
git push |