Skip to content

Instantly share code, notes, and snippets.

@shankie-codes
shankie-codes / gist:ce3db93355c2310d289e
Created October 6, 2015 15:29
rsub SSH config entry
RemoteForward 52698 127.0.0.1:52698
@shankie-codes
shankie-codes / gist:ec03354802c0b4aea9b2
Last active August 29, 2015 14:16
Query Parameters - extend String prototype
// Get the query params from a string
String.prototype.getQueryParameters = function(){
return this.replace(/^.*(\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this;}.bind({}))[0];
};
@shankie-codes
shankie-codes / gist:621e1e5d756ceb9e0ff4
Created March 10, 2015 10:20
jQuery Query Parameters plugin
// jQuery Query Parameters plugin from https://css-tricks.com/snippets/jquery/get-query-params-object/
jQuery.extend({
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
});
<?php
/**
* Plugin Name: Get The Image
* Plugin URI: http://themehybrid.com/plugins/get-the-image
* Description: This is a highly intuitive script that can grab an image by custom field, featured image, post attachment, or extracting it from the post's content.
* Version: 1.0.1
* Author: Justin Tadlock
* Author URI: http://justintadlock.com
*/
@shankie-codes
shankie-codes / gist:e74b9c9157b65d93f6d1
Last active August 29, 2015 14:16
Galleria ACF Repeater
<?php
/*
* Snippet to add a media gallery to post types/templates of your choosing.
* PHP include me.
* If using Proper Bear, drop me in _/inc/php and I'll work dandy
*/
// Define an array of post types, templates etc to attach this repeater to.
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
jQuery(function ($) {
//grab the entire query string
var query = document.location.search.replace('?', '');
//extract each field/value pair
query = query.split('&');
//run through each pair
for (var i = 0; i < query.length; i++) {