Skip to content

Instantly share code, notes, and snippets.

View philbirnie's full-sized avatar

Phil Birnie philbirnie

View GitHub Profile
@philbirnie
philbirnie / git-deploy.php
Created March 21, 2017 18:35
Webook deployment script
<?php
/** @var string Secret Key $secret */
$secret = '';
/** @var bool $debugging */
$debugging = false;
$webDirectory = '/var/www/html/';
@philbirnie
philbirnie / css-height-transition.md
Last active March 14, 2017 14:07
CSS Height Transition Options/Ideas

CSS Height Transitions

Option 1: Max Height

This is when you set max-height on an element and then transition that property rather than height. This is simple but has obvious downsides:

  • If min-height is much larger than auto, there will be a delay, plus you put a max-height on your element.
  • The transition is relative to the element height. (e.g. 1000px min height, but 600px element means that the transition will be 0.6s.
@philbirnie
philbirnie / throttle.js
Created June 5, 2016 15:27
Throttling Function, based heavily on Underscore's but updated for ES6.
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `{leading: false}`. To disable execution on the trailing edge, ditto.
const throttle = function(func, wait, options) {
let timeout, context, args, result;
let previous = 0;
@philbirnie
philbirnie / debounce.js
Created June 5, 2016 15:25
Debounce function; based heavily on underscore's but updated for ES6
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
const debounce = function(func, wait, immediate) {
let timeout;
return function(...args) {
@philbirnie
philbirnie / js-testing.md
Last active June 2, 2016 17:29
JS Testing Setup

JS Testing Setup

Testem.json Setup

Start with a testem.json file that includes sinon for stubbing, etc as well as any files that would be utilized in testing.

{
  "framework": "mocha+chai",

"launch_in_dev": ["Chrome", "phantomjs"],

@philbirnie
philbirnie / ConflictExample.php
Created November 11, 2015 02:23
PHP Book insteadof and as.
<?php
/**
* If two traits share the same method and are both included in a class, we have a problem. Rare, but possible
* Here's how to get around it.
*
* Reference: PHP Objects, Patterns and Practice, ed 4. pp 49
**/
trait TaxTools {
function calculateTax($price) {
@philbirnie
philbirnie / PriceUtilities.php
Last active November 11, 2015 02:31
PHP Book - The Trait
<?php
/**
*
* Traits
*
* 1. PHP does not allow for multiple inheritance
* 2. A class can implement many interfaces, but interfaces only provide a template.
* 3. Traits allow us to share implementation across class hierarchies.
*
@philbirnie
philbirnie / ShopProduct.php
Last active August 29, 2015 14:27
PHP Book - The Class
<?php
/* A class is used to create an object - an object is defined by a class */
class ShopProduct {
/** Properties **/
public $title = 'Default Product';
public $producer_last = 'Last Name';
@philbirnie
philbirnie / externalChecker.js
Last active September 20, 2016 03:11
External Link Prompter
(function() {
/**
* Wrapper Element
* @type {Element}
*/
const wrapperElement = document.querySelector('body');
/**
* Root Domain
@philbirnie
philbirnie / custom_post_demo.php
Last active August 29, 2015 14:07
Custom Post Boilerplate
<?php
/*
Plugin Name: BBB - Videos
Plugin Uri: URI
Description: Custom Field Type Video
Author: Phil Birnie
Version 0.9
Author Uri: http://mindstreaminteractive.com
*/