Skip to content

Instantly share code, notes, and snippets.

Avatar

SanjeevMohindra

View GitHub Profile
@SanjeevMohindra
SanjeevMohindra / function.php
Last active May 27, 2018
Add Google Adsense Ads to AMP Pages
View function.php
<?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
Convert shortcode to AMP compatible Shortcode
View function.php
<?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
Display Your Logo rather than blog name on the AMP Pages
View function.php
<?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 Jun 4, 2018
Footer.php file for AMP pages template for WordPress site
View footer.php
@SanjeevMohindra
SanjeevMohindra / function.php
Last active Oct 17, 2017
Change Comment Form in Genesis 2.0
View function.php
<?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 Oct 4, 2017
Replace existing shortcakes with a new shortcode
View functions.php
<?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 Oct 2, 2017
Remove ShortCode from WordPress while keep displaying the content
View functions.php
<?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 Sep 27, 2017
Remove ShortCode Plugin From WordPress
View function.php
<?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 Jan 31, 2018
A basic customisation to add social icons in Genesis Author Box
View Genesis Author Box Customisation
/**
* 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);
View Binary Search in Java
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;
You can’t perform that action at this time.