Skip to content

Instantly share code, notes, and snippets.

View joshdavenport's full-sized avatar
🦉
Hooting and Howling

Josh Davenport-Smith joshdavenport

🦉
Hooting and Howling
View GitHub Profile
@joshdavenport
joshdavenport / gist:957257
Created May 5, 2011 15:32 — forked from paulirish/README.md
imagesLoaded() jquery plugin
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!
// callback function is passed the last image to load
// as an argument, and the collection as `this`
@joshdavenport
joshdavenport / reloadWithQueryStringVars.js
Created April 21, 2012 09:55
Reload the current page with specified query string variables
function reloadWithQueryStringVars (queryStringVars) {
var existingQueryVars = location.search ? location.search.substring(1).split("&") : [],
currentUrl = location.search ? location.href.replace(location.search,"") : location.href,
newQueryVars = {},
newUrl = currentUrl + "?";
if(existingQueryVars.length > 0) {
for (var i = 0; i < existingQueryVars.length; i++) {
var pair = existingQueryVars[i].split("=");
newQueryVars[pair[0]] = pair[1];
}
@joshdavenport
joshdavenport / custom-metabox-fields-pages-functions.php
Last active December 14, 2015 20:09
Example of how to use the Custom Metaboxes and Fields framework for WordPress with pages, hiding the WYSIWYG for pages with managed templates. Better examples of the types of fields are shown here: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress/blob/master/example-functions.php
<?php
/**
* Remove wysiwyg for pages that have theme managed templates
*/
add_action('admin_init', 'fafpp_remove_editor_init');
function fafpp_remove_editor_init() {
if(isset($_GET['post'])) {
$post_id = $_GET['post'];
@joshdavenport
joshdavenport / liquid_showoptions.html
Last active December 21, 2015 00:48
Liquid code for Shopify templates to allow displaying of option variants. Useful if you want to show a list of sizes for a product on a collection page or a list of colours. Can use for any option type, just change the option_handle check.
{% comment %}
Show all sizes for a product in liquid
{% endcomment %}
{% for option in product.options %}
{% assign option_handle = option | handle %}
{% assign option_index = forloop.index0 %}
{% if option_handle == 'size' %}
{% assign values = '' %}
<ul class="{{ option_handle }}-options">
{% for variant in product.variants %}
@joshdavenport
joshdavenport / get-mage-config-path-from-selection.js
Last active August 29, 2015 13:58
Find Magento configuration path of selected field in WebKit
(function() {
/**
* Super simple to use, inspect the field (input, select, whatever) with developer tools and run this code from a
* bookmarklet, pasted into console or even as a snippet. You'll be prompted with the field where you can copy it
* for whatever you may need it for :)
*/
function getMageConfigPathFromInput(inputElement) {
var splitFieldName = inputElement.attributes['name'].value.replace('groups','').replace(/\[/g,'').split(']');
return /section\/(.*?)\//g.exec(window.location.href)[1] + '/' + splitFieldName[0] + '/' + splitFieldName[2];
}

Keybase proof

I hereby claim:

  • I am joshdavenport on github.
  • I am joshdavenport (https://keybase.io/joshdavenport) on keybase.
  • I have a public key whose fingerprint is 2D49 23A5 62CA 7C03 53CF 943F 3A9E 02A6 CED7 1D27

To claim this, I am signing this object:

@joshdavenport
joshdavenport / a-gallery.md
Created January 13, 2018 12:04
Basic reusable jekyll gallery utilising variable
// Name: Open Notion URL in Notion App
import "@johnlindquist/kit"
const url = await arg('What is the Notion URL?');
if (!url.includes('notion.so')) {
throw new Error('Not a Notion URL');
}
// Name: NTS Live
// Description: Stream NTS Live Channel 1 or 2
// Author: Vogelino, extended by Josh Davenport-Smith
// Twitter: @soyvogelino
// Shortcut:
import "@johnlindquist/kit";
const PLAYER_HEIGHT = 76;
const PLAYER_WIDTH = 205;
// Name: NTS Live
// Description: Stream NTS Live Channel 1 or 2
// Author: Vogelino, extended by Josh Davenport-Smith
// Twitter: @soyvogelino, @jdprts
import "@johnlindquist/kit";
const PLAYER_HEIGHT = 76;
const PLAYER_WIDTH = 205;