Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
@zeshanshani
zeshanshani / convertURLToLinks.js
Created October 7, 2016 04:54
Check if a string contains any URLs and wrap them all into HTML <a> tags.
@zeshanshani
zeshanshani / nav-menu-exporter-importer.php
Created September 1, 2016 09:04 — forked from hissy/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@zeshanshani
zeshanshani / runFunctionMultipleTimes.js
Created August 24, 2016 04:54
Run a function multiple times until the element is found on the page
function runUACLCLoop() {
setTimeout(function() {
// Check if something is found on the page.
if ( jQuery('.class_name').is(':visible') ) { // change it to another condition
// Run the same function again to create the loop.
runUACLCLoop();
// If nothing is found, then run the else statement.
@zeshanshani
zeshanshani / fetchGoogleNewsItems.js
Created August 18, 2016 05:54
Fetch Google News items of the specified term and display them in an element.
/**
* Converts XML to JSON
* Source: https://davidwalsh.name/convert-xml-json
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
@zeshanshani
zeshanshani / scrollToNextSection.css
Last active July 4, 2016 08:36
Click on the arrow to scroll to the next section to the banner.
/* Additional Styling */
#bottom-arrow {
position: absolute;
width: 52px; /* Width of arrow image */
height: 32px; /* Height of arrow image */
left: 50%;
margin-left: -26px; /* Horizontally centered, should be half of the 'width' */
background: url(path/to/arrow/file.png) no-repeat center center;
z-index: 10;
text-indent: -9999px; /* To visually hide the text inside the button */
@zeshanshani
zeshanshani / fullScreenBannerWithOffset.js
Last active July 4, 2016 08:35
Full Screen Banner with Offset. Default offset is header only.
/**
* Full Screen Banner with Offset Value
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*/
jQuery(document).ready(function($) {
// To run on homepage only. Remove/update if required on other pages.
if ($('body').hasClass('home')) {
@zeshanshani
zeshanshani / fullHeightSection.js
Last active April 17, 2019 23:17
This JavaScript function will expand the sections to the 100% of browser window height.
/**
* Full Height Sections
* This function will expand the sections to the 100% of browser window height.
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*
* Replace '#banner' with your targeted element's selector.
*/
if (window.devicePixelRatio > 1) {
/* highDPI display */
}
if (window.devicePixelRatio >= 2) {
/* retina display */
}
@zeshanshani
zeshanshani / gist:05dc77bf977a74dec9104fc72501b03d
Created May 17, 2016 07:29 — forked from betweenbrain/gist:5405671
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@zeshanshani
zeshanshani / extendedAnimations.css
Last active June 10, 2016 13:39
Extended Animations - Utilizes animate.css. Provides data attributes to add animations in any element on the page. Triggers animations on scroll. Updated: trigger all animations in one section at once.
/**
* Extended Sections Animations
* By: Zeshan Ahmed
* URI: http://www.zeshanahmed.com/
*
* Extended animations trigger on scroll. Uses animate.css.
*/
.not-animated {
opacity: 0;