Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
@ringmaster
ringmaster / gist:1405324
Created November 29, 2011 16:05
PHP 5.4 Factory trait
trait Factory {
public function create() {
$class = get_called_class();
$args = func_get_args();
$r_class = new \ReflectionClass($class);
return $r_class->newInstanceArgs( $args );
}
}
@ringmaster
ringmaster / gist:1481722
Created December 15, 2011 16:27 — forked from chrismeller/gist:1339633
Github Packager
<?php
class Github_Packager {
private static $api_endpoint = 'http://github.com/api/v2/json/';
private static $temp_path = './temp/';
public static function list_branches ( $addon_name, $with_commits = false ) {
$url = self::$api_endpoint . 'repos/show/habari-extras/' . $addon_name . '/branches';
@ringmaster
ringmaster / style.css
Created February 6, 2012 22:31
Wazi Compiled CSS
@import url(http://fonts.googleapis.com/css?family=Quattrocento);
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block;}
audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}
audio:not([controls]){display:none;}
[hidden]{display:none;}
html{font-size:100%;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}
body{margin:0;}
body,button,input,select,textarea{font-family:sans-serif;}
a:focus{outline:thin dotted;}
a:hover,a:active{outline:0;}
@ringmaster
ringmaster / gist:1777673
Created February 9, 2012 05:46
Get all items from a test
db.tests.remove({slug: "foo"})
db.tests.insert({slug: "foo", forms: [ {slug: "section 1", clusters: [
{slug: "cluster 1", items: [1,2,3]},
{slug: "cluster 2", items: [4,5,6]}
]}]});
var map = function() {
this.forms.forEach(function(form){
form.clusters.forEach(function(cluster){
@ringmaster
ringmaster / gist:1901070
Created February 24, 2012 13:53
jQuery browser version detection
var userAgent = navigator.userAgent.toLowerCase();
jQuery.browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie|me|on)[\/: ]([\d.]+)/ ) || [])[1],
chrome: /chrome/.test( userAgent ),
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
webkit: /webkit/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
@ringmaster
ringmaster / gist:1902017
Created February 24, 2012 16:58
Habari pluggable sample
<?xml version="1.0"?>
<pluggable type="theme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///d:/Owen/Documents/PluggableSchema.xsd">
<name>resurrection</name>
<license url="http://apache.org">ASL 2.0</license>
<!-- one or more authors -->
<author url="http://asymptomatic.net">Owen Winkler</author>
<author url="http://sagrising.cockrumpublishing.com/">Rick Cockrum</author>
<copyright>Copyright 2009</copyright>
@ringmaster
ringmaster / BaseObject.php
Last active October 1, 2015 05:58
Fluid PHP Create
<?php
// Explained (somewhat) at http://redalt.com/fluid-php-baseobject-class
trait FluentCreate
{
public static function create()
{
$class = get_called_class();
$args = func_get_args();
$r_class = new \ReflectionClass($class);
@ringmaster
ringmaster / dabblet.css
Created March 9, 2012 15:29
Table overflow
/**
* Table overflow
*/
#tbl {
width: 300px;
table-layout: fixed;
}
#tbl td {
@ringmaster
ringmaster / proposal.plugin.php
Created April 10, 2012 01:15
All-in-one data-bound post type
<?php
class ProposalPlugin extends Plugin
{
public function action_plugin_activation( $plugin_file )
{
Post::add_new_type( 'proposal' );
}
public function action_plugin_deactivation( $plugin_file )
@ringmaster
ringmaster / index.php
Created April 10, 2012 16:04
index.php on beacon.habariproject.org
<?php
$out = date('r') . "\n";
$out .= var_export($_GET,true) . "\n";
$out .= var_export($_POST,true) . "\n";
file_put_contents(dirname(__FILE__) . '/update.log', $out);
header('Content-type: application/xml');