Skip to content

Instantly share code, notes, and snippets.

@markguinn
markguinn / auth_FacebookApi.php
Created December 21, 2015 11:18
How we're handling OAuth+REST
<?php
/**
* @author Mark Guinn <mark@adaircreative.com>
* @date 12.18.2015
* @package simple-giving
* @subpackage auth
*/
class FacebookApi extends Object implements ISocialApi
{
/** @var string */
<?php
/**
* Simple extension of the default Requirements_Backend that
* allows you to specify exactly where css and js is placed
* via html comments:
*
* <!-- INSERT CSS HERE -->
* <!-- INSERT JS HERE -->
*
* If either is not present, it will fall back to the default rules.
/**
* @param array $data
* @return SS_HTTPResponse
*/
protected function returnJson(array $data) {
$response = $this->getController()->getResponse();
$response->addHeader('Content-type', 'application/json');
$response->setBody(json_encode($data));
return $response;
}
@markguinn
markguinn / designer.html
Last active August 29, 2015 14:17
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@markguinn
markguinn / CreateViewForClass.php
Last active January 5, 2017 15:44
Create MySQL view for multi-table Silverstripe DataObject
<?php
/**
* Creates a Flat table view for a given class
* @author Mark Guinn <mark@adaircreative.com>
* @date 06.13.2014
*/
class CreateViewForClass extends BuildTask
{
protected $title = 'DEV: Flat View for Class';
protected $description = 'Use class=XXXX to create a flat view of all the tables that make up a given class';
@markguinn
markguinn / gist:7502041
Last active December 28, 2015 12:39
Very unscientific benchmark of PHP 5.4 traits against Silverstripe Extensions at mixed-in function calls. Results on my late 2011 MBP: Traits are between 10 and 40 times faster.
<?php
/**
Results on my Macbook:
Native function (no Object, no traits): 0.12234592
Native function (no Object, traits): 0.13018894
Native function (traits): 0.15913486
Native function (extension): 0.12871218
Mixin function (traits): 0.12146902
Mixin function (extension): 4.077214
Random functions (traits): 0.46887112
@markguinn
markguinn / gist:6249009
Created August 16, 2013 11:01
Bookmarklet to reveal error trace in Silverstripe CMS admin. Click this and you can scroll up.
javascript:(function(){ document.body.style.overflow='scroll'; })();