Skip to content

Instantly share code, notes, and snippets.

View phpnode's full-sized avatar

Charles Pick phpnode

View GitHub Profile
# 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
#
<?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
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
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());
@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.
/**
* 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);
}
/**
{
"Webapp":{
"properties":{
"tags":{
"index_name":"tag",
"type":"string"
},
"id":{
"type":"integer"
},
{
"_index":"main",
"_type":"Webapp",
"_id":"34",
"_version":13,
"_source":{
"id":"34",
"name":"Seriesly!",
"title":"Seriesly!",
"description":"Seriesly provides you with torrent\/streaming links for your favorite TV shows.",
{
"fields": [
"id",
"name",
"title",
"description",
"url",
"domain"
],
"query": {
{
"fields":["id","name","title","description","url","domain"],
"query": {
"custom_score": {
"query": {
"match_all":{}
},
"filter": {
"terms":{
"tags":["twitter"]