Skip to content

Instantly share code, notes, and snippets.

K Adam White kadamwhite

View GitHub Profile
View necessary-emoji.txt
:cuttlefish:
:hotdog:
:shark:
@kadamwhite
kadamwhite / p5-instantiation.md
Last active Aug 29, 2015
Options for instantiating P5
View p5-instantiation.md

P5 Instance Creation Options

Automatic Instantiation

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

function draw() {
@kadamwhite
kadamwhite / Gruntfile.js
Created Mar 14, 2014
Grunt task to error out if files are missing
View Gruntfile.js
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 / mmadness.logo
Created Mar 17, 2014
iterative code to make a March Madness-style bracket, runnable at http://www.calormen.com/jslogo/
View mmadness.logo
View 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 / barcodes.js
Created Apr 10, 2014
Bar Code generator
View barcodes.js
$('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 / types-into-taxes.diff
Created May 28, 2014
Proposed solution for embedding custom types into taxonomies
View types-into-taxes.diff
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 Aug 29, 2015
Proposed solution for embedding custom types into taxonomies
View types-into-taxes.diff
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 / 505-bad-gateway.diff
Created May 28, 2014
If I try to call $this->get_post_type inside a filter function, I get a 502 bad gateway error.
View 505-bad-gateway.diff
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 / private-query-vars.js
Created Jun 24, 2014
Query vars for WP-API, trying to understand how everything works
View private-query-vars.js
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
You can’t perform that action at this time.