Skip to content

Instantly share code, notes, and snippets.

View CamdenSegal's full-sized avatar

Camden Segal CamdenSegal

View GitHub Profile
@CamdenSegal
CamdenSegal / custom-endpoints.php
Created October 11, 2014 03:38
WP_JSON_CustomPostType Endpoint Generation
class MAP_API_DemoItemType extends WP_JSON_CustomPostType {
protected $base = '/map/demo';
protected $type = 'demo';
public function register_routes( $routes ) {
$routes = parent::register_routes( $routes );
return $routes;
}
}
@CamdenSegal
CamdenSegal / gist:f4cdcdb2b27a4f7f897b
Created October 11, 2014 03:33
json_prepare_post example
function map_prepare_post_add_score( $_post, $post, $context ) {
$_post['score'] = map_get_post_score( $post['ID'] );
return $_post;
}
add_filter( 'json_prepare_post', 'map_prepare_post_add_score', 10, 3 );
@CamdenSegal
CamdenSegal / jquery.findcache.js
Created August 15, 2014 13:48
jQuery selector cache plugin
jQuery.fn.findC = function( selector, reset ) {
var cache = this.data('jcache') || {};
if ( reset || undefined === cache[ selector ] ) {
cache[ selector ] = this.find( selector );
}
this.data( 'jcache', cache );
return cache[ selector ];
};
@CamdenSegal
CamdenSegal / Xdebug.sublime-settings
Last active June 15, 2017 11:09
SublimeText VVV Xdebug settings
{
"path_mapping": {
"/srv/www": "/full-path-to-your-vvv-installation/www"
}
}
@CamdenSegal
CamdenSegal / pre-commit
Last active September 26, 2016 14:42
Run phpunit pre-commit stop commit if failed.
#!/usr/bin/php
<?php
echo PHP_EOL;
echo 'Starting unit tests' . PHP_EOL;
exec( 'phpunit', $test_output, $returnCode );
if ( 0 !== $returnCode ) {
echo implode( PHP_EOL, $test_output );
echo PHP_EOL;
@CamdenSegal
CamdenSegal / Parallax.cs
Last active December 31, 2015 02:09
Unity 4.3 Parallax script
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Parallax : MonoBehaviour {
// Scale of movement 0 being stationary 1 being sticking to the camera.
public Vector2 parallaxScale = new Vector2( 0.5f, 0.2f );