Skip to content

Instantly share code, notes, and snippets.

View kadamwhite's full-sized avatar

K Adam White kadamwhite

View GitHub Profile
:cuttlefish:
:hotdog:
:shark:
@kadamwhite
kadamwhite / p5-instantiation.md
Last active August 29, 2015 13:56
Options for instantiating P5

P5 Instance Creation Options

Automatic Instantiation

function setup() {
	rect( 0, 0, 100, 100 );
}

function draw() {
@kadamwhite
kadamwhite / Gruntfile.js
Created March 14, 2014 19:31
Grunt task to error out if files are missing
var _ = require('lodash');
module.exports = function(grunt) {
grunt.registerMultiTask('check', 'Check for the existence of files', function() {
var filesMissing = false;
// Flatten the nested source arrays -- I used _.flatten, there are other methods
_.flatten( this.data ).forEach(function( filepath ) {
if ( ! grunt.file.exists(filepath) ) {
@kadamwhite
kadamwhite / prng.js
Created March 17, 2014 20:52 — forked from Protonk/prng.js
// Linear Congruential Generator
// Variant of a Lehman Generator
var lcg = (function() {
// Set to values from http://en.wikipedia.org/wiki/Numerical_Recipes
// m is basically chosen to be large (as it is the max period)
// and for its relationships to a and c
var m = 4294967296,
// a - 1 should be divisible by m's prime factors
a = 1664525,
// c and m should be co-prime
@kadamwhite
kadamwhite / mmadness.logo
Created March 17, 2014 23:29
iterative code to make a March Madness-style bracket, runnable at http://www.calormen.com/jslogo/
@kadamwhite
kadamwhite / barcodes.js
Created April 10, 2014 15:23
Bar Code generator
$('body').append('<div class="container"></div>');
_.times(10, function() {
_.times(100, function(){
var $div = $('<div/>');
$div.addClass('line');
var rand = Math.random();
if (rand < 0.33) {
$div.addClass('left');
} else if (rand > .67) {
@kadamwhite
kadamwhite / 505-bad-gateway.diff
Created May 28, 2014 18:09
If I try to call $this->get_post_type inside a filter function, I get a 502 bad gateway error.
diff --git a/lib/class-wp-json-posts.php b/lib/class-wp-json-posts.php
index 941c796..599e8af 100644
--- a/lib/class-wp-json-posts.php
+++ b/lib/class-wp-json-posts.php
@@ -1090,6 +1090,23 @@ class WP_JSON_Posts {
}
/**
+ * Embed post type data into taxonomy data
+ *
@kadamwhite
kadamwhite / types-into-taxes.diff
Created May 28, 2014 19:13
Proposed solution for embedding custom types into taxonomies
diff --git a/lib/class-wp-json-posts.php b/lib/class-wp-json-posts.php
index 941c796..a06ed0f 100644
--- a/lib/class-wp-json-posts.php
+++ b/lib/class-wp-json-posts.php
@@ -519,9 +519,10 @@ class WP_JSON_Posts {
*
* @param string|object $type Type name, or type object (internal use)
* @param boolean $_in_collection Is this in a collection? (internal use)
+ * @param boolean $_in_taxonomy Is this request being added to a taxonomy record? (internal use)
* @return array Post type data
@kadamwhite
kadamwhite / types-into-taxes.diff
Last active August 29, 2015 14:01
Proposed solution for embedding custom types into taxonomies
diff --git a/lib/class-wp-json-posts.php b/lib/class-wp-json-posts.php
index 941c796..a06ed0f 100644
--- a/lib/class-wp-json-posts.php
+++ b/lib/class-wp-json-posts.php
@@ -519,9 +519,10 @@ class WP_JSON_Posts {
*
* @param string|object $type Type name, or type object (internal use)
* @param boolean $_in_collection Is this in a collection? (internal use)
+ * @param boolean $_in_taxonomy Is this request being added to a taxonomy record? (internal use)
* @return array Post type data
@kadamwhite
kadamwhite / private-query-vars.js
Created June 24, 2014 00:22
Query vars for WP-API, trying to understand how everything works
module.exports = [
'offset', // (int) - number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround). The 'offset' parameter is ignored when 'posts_per_page'=>-1 (show all posts) is used.
'posts_per_archive_page', // (int) - number of posts to show per page - on archive pages only. Over-rides posts_per_page and showposts on pages where is_archive() or is_search() would be true.
// 'showposts', // <replaced by posts_per_page>
'nopaging', // (boolean) - show all posts or use pagination. Default value is 'false', use paging.
'post_type', // (string / array) - use post types. Retrieves posts by Post Types, default value is 'post'.
'post_status', // (string / array) - use post status. Retrieves posts by Post Status. Default value is 'publish', but if the user is logged in, 'private' is added.
'category__in', // (array) - use ca