Skip to content

Instantly share code, notes, and snippets.

View jonathan-bird's full-sized avatar

Jonathan Bird jonathan-bird

View GitHub Profile
@jonathan-bird
jonathan-bird / script.rb
Last active November 12, 2018 00:34
X for $X Shopify Script Editor
X_FOR_X_DISCOUNT_ENABLED = false
X_FOR_X_RULES_ARR = [
{
TAG_NAME: 'tagname_something',
PRODUCT_COUNT: 3,
PRICE: 9900,
MESSAGE: '2 for $30 collection'
}
]
@jonathan-bird
jonathan-bird / reddit-ranking.php
Created January 3, 2017 00:26
Reddit Ranking Algorithm (2012)
<?php
/**
* Ranking Library
* contains alogrithms for story ranking
* Basically a PHP Implementation of reddits algorithms
*
* @author Lucas Nolte <lnolte@i.biz>
* @since 0.1
* @package Polska Wiadomosc
* @subpackage Libraries
@jonathan-bird
jonathan-bird / imgix.php
Last active October 31, 2016 00:19
Imgix API Image Purge with Guzzle 5
<?php
use Guzzle\Http\Client;
use Guzzle\Http\Exception\ClientErrorResponseException;
private function purgeImgixCache($imageUrl)
{
$client = new Client();
try {
$request = $client->post('https://api.imgix.com/v2/image/purger',
@jonathan-bird
jonathan-bird / gist:7886342
Created December 10, 2013 06:07
Change div background at a certain scroll point
$(function() {
var fixadent = $(".logo-nav"); //the div you want
h = $(window).height(); //calculate height of window or whatever element you want it to scroll past
$(window).scroll(function() {
if($(this).scrollTop() > h ) {
$(fixadent).css('background', '#5fc1d8');
}
else {
$(fixadent).css('background', '#222');
@jonathan-bird
jonathan-bird / front.php
Last active December 21, 2015 11:58
Wordpress: Use custom post type on home page
<?php
query_posts('post_type=featured-work');
if ( have_posts() ) : while ( have_posts() ) : the_post();
global $wpdb;
$metatable = $wpdb->prefix."postmeta";
$post_id = $post->ID;
$deschome = $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM $metatable where post_id=%d AND meta_key='wpcf-featured-work-description-home'",$post_id));?>
<div class="work-home">
<div class="work-view">
<div class="work-img"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div>
@jonathan-bird
jonathan-bird / gist:6275309
Created August 19, 2013 23:14
Wordpress: Featured Work Page - Custom Post Type with custom field for description
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
global $wpdb;
$metatable = $wpdb->prefix."postmeta";
$post_id = $post->ID;
$deschome = $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM $metatable where post_id=%d AND meta_key='wpcf-featured-work-description-home'",$post_id));
?>
<div class="container">
<div class="work-home">
@jonathan-bird
jonathan-bird / blog.php
Created August 19, 2013 23:12
Wordpress: Blog Page - Simple Title & Description
<?php
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>
<div class="container">
<article id="content">
<?php