Skip to content

Instantly share code, notes, and snippets.

View johnReeve's full-sized avatar

John Reeve johnReeve

View GitHub Profile
@johnReeve
johnReeve / addElements.js
Created December 4, 2012 17:36
A bit of javascript to add arbitrary elements to a list (in this case of input elements for an array)
<script>
(function($) {
$(document).ready(function (){
// here we can add <li><button class="addNewSiblingField">Add New</button></li>, and it will auto setup a list to add and remove arbitrary elements
$('.addNewSiblingField').closest('ul').addClass('addNewSiblingsList');
$('.addNewSiblingField').parent().siblings().append('<button class="removeSiblingField">Remove</button>');
$('.addNewSiblingsList').on('click', '.addNewSiblingField', function(e){
@johnReeve
johnReeve / content.php
Created November 26, 2013 04:02
Function to generate a random class name for a post body (kinda stupid obvious, I suppose)
<article <?php post_class('clearfix ' . oneMenu_randomColor() ); ?>></article>
@johnReeve
johnReeve / animation.js
Created December 3, 2013 14:26
Example of a really basic javascript animation that triggers when the user rolls past an element. See the $(window).bind('scroll' ...statements for the actual triggers.
var dial_hasBeenTriggered = false,
bar_hasBeenTriggered = false;
function increase_dial(element, value, originalValue) {
if( !originalValue ) {
originalValue = element.data('target-value').toString();
}
var currentVal = value || 0;
element.val(currentVal).trigger('change');
@johnReeve
johnReeve / custom.php
Created December 4, 2013 18:08
How I do my WordPRess site specific configuration fields
<?php
/* setup custom general settings */
function ts_theme_settings () {
register_setting( 'general', 'homepage_slider_wide' );
add_settings_field(
'homepage_slider_wide',
'Homepage Slider (Wide)',
'homepage_slider_wide_callback',
@johnReeve
johnReeve / gist:8395518
Last active January 3, 2016 02:29
My 2-joystick serial controller
/*
2-stick Serial Controller w/ xBee funcionality
*/
#include <SoftwareSerial.h>
#define echoToSerialOut true
#define rxPin 2
@johnReeve
johnReeve / gist:9244010
Last active August 29, 2015 13:56
Sample Bootstrap Collapse
<a data-toggle="collapse" href="#theExtraBioInformation">
Read more
</a>
<div id="theExtraBioInformation" class="panel-collapse collapse">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
$('.gallery').on('mouseenter', 'li', function (){
$(this).removeClass('greyedout');
});
$('.gallery').on('mouseout', 'li', function (){
$(this).removeClass('greyedout');
});
@johnReeve
johnReeve / .gitignore
Created July 31, 2015 17:41
WPE root git ignore
.idea/
.gitattributes
.htaccess
/index.php
/wp-content/index.php
/wp-content/themes/index.php
last-mod
license.txt
readme.html
<?php
/**
* Here is some functionality specific to the contact page.
*
*/
class Prep_Contact_Page {
<?php
// this sample is in MU-plugins. It's just a sample
// pattern about how you can use a namespaced class to
// decrease how much is injected into the global name space
namespace Materiell;
class Google_AMP_Mods {