Skip to content

Instantly share code, notes, and snippets.

View robskidmore's full-sized avatar

Rob Skidmore robskidmore

View GitHub Profile
@robskidmore
robskidmore / array-diff.js
Created September 30, 2017 18:07
A quick diff array function for debugging in the console.
Array.prototype.diff = function (a) {
return this.filter(function (i) {
return a.indexOf(i) === -1;
});
};
function isRestUrl() {
$bIsRest = false;
if ( function_exists( 'rest_url' ) && !empty( $_SERVER[ 'REQUEST_URI' ] ) ) {
$sRestUrlBase = get_rest_url( get_current_blog_id(), '/' );
$sRestPath = trim( parse_url( $sRestUrlBase, PHP_URL_PATH ), '/' );
$sRequestPath = trim( $_SERVER[ 'REQUEST_URI' ], '/' );
$bIsRest = ( strpos( $sRequestPath, $sRestPath ) === 0 );
}
return $bIsRest;
}
class MeasureRender extends React.Component {
constructor() {
super();
this.mounted = false;
}
render() {
const { name } = this.props;
if (this.mounted) {
window.performance.mark(`${name}UpdateStart`);