git diff
git diff --cached
git diff HEAD^..HEAD
<?php | |
/* | |
Plugin Name: R Debug | |
Description: Set of dump helpers for debug. | |
Author: Andrey "Rarst" Savchenko | |
Author URI: https://www.rarst.net/ | |
License: MIT | |
*/ |
// 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( |
#!/bin/bash | |
echo "==================================" | |
echo "Installing Dependencies" | |
echo "==================================" | |
sudo apt-get update | |
sudo apt-get install \ | |
git \ | |
build-essential \ |
if (window.Element && !Element.prototype.closest) { | |
Element.prototype.closest = | |
function(s) { | |
var matches = (this.document || this.ownerDocument).querySelectorAll(s), | |
i, | |
el = this; | |
do { | |
i = matches.length; | |
while (--i >= 0 && matches.item(i) !== el) {}; | |
} while ((i < 0) && (el = el.parentElement)); |
function sortObjectByKeys(obj) { | |
var keys = Object.keys(obj).sort(function keyOrder(k1, k2) { | |
if (k1 < k2) return -1; | |
else if (k1 > k2) return +1; | |
else return 0; | |
}); | |
var i, after = {}; | |
for (i = 0; i < keys.length; i++) { |
/** | |
* 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]); | |
}); |
/** | |
* Format Array to make useful in SQL Queries | |
* | |
* @param array $array Array to be escaped. | |
* @return string | |
*/ | |
function escape_array( $array = array() ) { | |
global $wpdb; | |
$escaped = array(); | |
foreach ( $array as $k => $v ) { |