Skip to content

Instantly share code, notes, and snippets.

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++) {
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, " "));
}
@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.
<?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: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];
}
});
@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:ce3db93355c2310d289e
Created October 6, 2015 15:29
rsub SSH config entry
RemoteForward 52698 127.0.0.1:52698
@shankie-codes
shankie-codes / gist:5176630e61ee0b98ba43
Last active October 6, 2015 15:33
rsub: add helper script to server
wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate; chmod +x /usr/local/bin/rsub
@shankie-codes
shankie-codes / gist:20bbe5c2e2c1efabc3e4
Created October 6, 2015 15:42
rsync over SSH with zip
rsync -vzre ssh --delete $sourcedir $destdir
@shankie-codes
shankie-codes / twitter-oauth.js
Last active March 31, 2016 10:55 — forked from santosh79/twitter-oauth.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('util');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = process.env['TWITTER_CONSUMER_KEY'];
var _twitterConsumerSecret = process.env['TWITTER_CONSUMER_SECRET'];
console.log("_twitterConsumerKey: %s and _twitterConsumerSecret %s", _twitterConsumerKey, _twitterConsumerSecret);