Skip to content

Instantly share code, notes, and snippets.

@SanjeevMohindra
SanjeevMohindra / function.php
Last active June 25, 2023 15:18
Add Google Adsense Ads to AMP Pages
<?php
// Do not copy the above php tag in your function.php
/**
* Add Google Adsense Ad on top of the post content
*
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/configure-enable-amp-wordpress/
@SanjeevMohindra
SanjeevMohindra / function.php
Created May 27, 2018 07:47
Convert shortcode to AMP compatible Shortcode
<?php
// Do not copy the above php tag in your function.php
/**
* Change shortcodes to AMP compatible Shortcodes
*
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/configure-enable-amp-wordpress/
@SanjeevMohindra
SanjeevMohindra / function.php
Last active May 27, 2018 07:38
Display Your Logo rather than blog name on the AMP Pages
<?php
// Do not copy the above php tag in your function.php
/**
* Change blog name to a blog logo on the AMP Page Header
*
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/configure-enable-amp-wordpress/
@SanjeevMohindra
SanjeevMohindra / footer.php
Last active June 4, 2018 16:32
Footer.php file for AMP pages template for WordPress site
@SanjeevMohindra
SanjeevMohindra / function.php
Last active October 17, 2017 08:42
Change Comment Form in Genesis 2.0
<?php
// Do not copy the above php tag in your function.php
/**
* Change Comment Form
*
* This function will modify the comment form in genesis 2.0
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
@SanjeevMohindra
SanjeevMohindra / functions.php
Last active October 4, 2017 11:37
Replace existing shortcakes with a new shortcode
<?php
/**
* Remove ShortCode Plugin
*
* This function will remove the shortcode from getting diplayed while keep displaying the content.
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/wordpress-remove-shortcode-plugin/
@SanjeevMohindra
SanjeevMohindra / functions.php
Last active October 2, 2017 08:14
Remove ShortCode from WordPress while keep displaying the content
<?php
/**
* Remove ShortCode Plugin
*
* This function will remove the shortcode from getting diplayed while keep displaying the content.
* Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/wordpress-remove-shortcode-plugin/
@SanjeevMohindra
SanjeevMohindra / function.php
Created September 27, 2017 17:16
Remove ShortCode Plugin From WordPress
<?php
/**
* Remove ShortCode Plugin
*
* This function will remove the shortcode from getting diplayed. Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/wordpress-remove-shortcode-plugin/
*/
@SanjeevMohindra
SanjeevMohindra / Genesis Author Box Customisation
Last active January 31, 2018 12:50
A basic customisation to add social icons in Genesis Author Box
/**
* Author Box With Social Icons
*
* This function will add social icons to author box in genesis. Add this to your function.php
*
* @author MetaBlogue
* @license GPL-2.0+
* @link https://metablogue.com/genesis-add-social-media-icons-author-box/
*/
add_filter( 'genesis_author_box','custom_author_box', 10, 6);
public static int binarySearch(final int[] inputSortedData, final int searchElement) {
int minLeft = 0;
int maxRight = inputSortedData.length - 1;
while ( minLeft <= maxRight ) {
final int middleElement = (minLeft + maxRight) / 2;
if (searchElement == inputSortedData[middleElement]) { return middleElement + 1; }
if (searchElement < inputSortedData[middleElement]) { maxRight = middleElement - 1; }
if (searchElement > inputSortedData[middleElement]) { minLeft = middleElement + 1; }
}
return -1;