Skip to content

Instantly share code, notes, and snippets.

View phpnode's full-sized avatar

Charles Pick phpnode

View GitHub Profile
/**
* Runs before the action
* @param CAction $action The action to be run
* @return boolean Whether to run the action or not
*/
public function beforeAction($action) {
Yii::beginProfile("Run Action");
return parent::beforeAction($action);
}
/**
@phpnode
phpnode / gist:1312008
Created October 25, 2011 09:24
Yii based event system with no dependencies
<?php
class Eventable {
/**
* The events attached to this class
* @var Event[]
*/
protected $_events = array();
/**
* Determines whether an event is defined.
<?php
class ActiveRecord {
public static function generateCacheKey($field, $id = null)
{
return get_class(static::model()).($id !== null ? ':'.$id : '').':'.$field;
}
public function getCacheKey($field)
{
return self::generateCacheKey($field,$this->getPrimaryKey());
function d(b){e=function(c){return c.replace(/"/,'\\"')};g=function(c){var b=[];for(i=0;i<c.length;i++)b.push(d(c[i]));return b};h=function(b){var f=[];for(a in b)f.push('"'+e(a)+'": '+d(b[a]));return"{"+f.join(",")+"}"};r=Object.prototype.toString.call(b).split(" ").pop().charAt(0);return"S"==r?'"'+e(b)+'"':"N"==r?b:"A"==r?"["+g(b).join(",")+"]":h(b)}
<?php
/**
* Provides a wrapper for the CKEditor wysiwyg html editor
* @author Charles Pick
* @package packages.ckeditor
*/
class ACKEditorWidget extends CInputWidget {
/**
* The options for the editor
* @var array
# Promise to load a file from the file system
# Requirements:
# it "should load aliased files correctly", (done) ->
# app.load("@lib/Invoke.coffee")
# .then (contents) ->
# contents.should.contain "this unique text that you are reading right now"
# done()
# .otherwise (err) ->
# throw err
#
# Set up our requirements
request = require "request"
chai = require "chai"
chai.should()
# The API provides several methods for interacting with users.
describe "API user", ->
# Get a list of records. The set of returned attributes for list may be different from view.
describe "list", ->
from pygments.formatter import Formatter
import json
class Formatter(Formatter):
name = 'JSON'
aliases = ['json']
filenames = []
def format(self, tokensource, outfile):
arr = []
class AutoWhat
constructor: ->
console.log "constructing"
foo: => console.log this
window["whatever"] = ->
AutoWhat::constructor.apply this, arguments
for attr, val of AutoWhat::
window["whatever"]::[attr] = val
b = new whatever
<article about="/spin/latest/">
<partial template="article-header">
<h1>What's been spinning on the radio?</h1>
</partial>
<partial template="signup-link" />
<p>
<span property="stats.total"></span>
<if condition="stats.total == 1">Recent spin.</if>
<else>Recent spins.</else>
Click for full playlist.