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 / mapOrder.js
Created May 2, 2019 21:30 — forked from ecarter/mapOrder.js
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];
@zeshanshani
zeshanshani / troubleshooting.md
Created October 20, 2018 11:22 — forked from adamwathan/troubleshooting.md
Troubleshooting Valet on macOS Sierra

Troubleshooting Valet on Sierra

Common Problems

Problem: I just see "It works!"

Apache is running on port 80 and interfering with Valet.

  1. Stop Apache: sudo /usr/sbin/apachectl stop
  2. Restart Valet: valet restart
#!/bin/bash
USER="root"
PASSWORD=""
FILES="/Users/tenold/Backups/MySQL/*"
for f in $FILES
do
echo "Processing $f file..."
@zeshanshani
zeshanshani / dump.sh
Created February 12, 2018 20:39 — forked from andsens/dump.sh
Backup all MySQL databases into separate files
#!/bin/sh
## backup each mysql db into a different file, rather than one big file
## as with --all-databases. This will make restores easier.
## To backup a single database simply add the db name as a parameter (or multiple dbs)
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is
## Create the user and directories
# mkdir -p /var/backups/mysql/databases
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup
## Remember to make the script executable, and unreadable by others
@zeshanshani
zeshanshani / primary_category.php
Created September 19, 2017 09:46 — forked from jawinn/primary_category.php
Display Primary Category (Yoast's WordPress SEO)
<?php
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_category();
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
@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 / 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 / customizer-controls-40.php
Last active March 5, 2016 08:00 — forked from devinsays/customizer-controls-40
WordPress 4.0 Customizer Controls
<?php
function prefix_customizer_register( $wp_customize ) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Example Panel', 'textdomain' ),
'description' => __( 'Description of what this panel does.', 'textdomain' ),
@zeshanshani
zeshanshani / acf-wrapper-functions.php
Created November 4, 2015 22:19 — forked from raideus/acf-wrapper-functions.php
Wrapper functions for Advanced Custom Fields
<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()