Skip to content

Instantly share code, notes, and snippets.

@gwoo
gwoo / gist:4141670
Created November 24, 2012 22:34
filter for Media::encode arrays.
Media::applyFilter('encode', function($self, $params, $chain) {
foreach ($params['data'] as $key => $value) {
if ($value instanceof \lithium\data\Collection) {
$params['data'][$key] = array_values($value->to('array'));
}
}
return $chain->next($self, $params, $chain);
});
@mehlah
mehlah / queries_logger.php
Created November 10, 2012 10:40
Li3 database queries logger
<?php
use lithium\analysis\Logger;
use lithium\data\Connections;
use lithium\core\Environment;
use lithium\action\Dispatcher;
/**
* This filter intercepts the `run()` method of the `Dispatcher`
@awshout
awshout / foundation4-topbar-menu.php
Last active September 5, 2024 01:34
WordPress Menu & Walker for ZURB's Foundation 4 Top Bar
<?php
add_theme_support('menus');
/**
* Register Menus
* http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
'top-bar-r' => 'Right Top Bar'
@domenic
domenic / promises.md
Last active April 1, 2025 01:54
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@cgutierrez
cgutierrez / action.php
Created October 10, 2012 02:42
Lithium Global CSRF Protection
use lithium\action\Dispatcher;
use lithium\storage\Session;
use lithium\security\validation\RequestToken;
use lithium\action\Response;
Dispatcher::applyFilter('run', function($self, $params, $chain) {
$request = $params['request'];
$excludes = array('get', 'head', 'options');
@rmarscher
rmarscher / MongoLogger.php
Created October 8, 2012 05:24
MongoDB logging in Lithium PHP
<?php
namespace li3_common\analysis;
use lithium\action\Request;
use lithium\console\Request as ConsoleRequest;
use lithium\core\Environment;
use lithium\data\Connections;
use lithium\util\String;
use MongoDate;
@gwoo
gwoo / LearningAngular.txt
Last active March 15, 2016 20:26
Learning Angular
## Angular modules
http://ngmodules.org/
http://angular-ui.github.com/
http://angular-ui.github.com/bootstrap/
## Angular resources
John Lindquist Videos:
http://egghead.io
@d1rk
d1rk / Base.php
Created September 20, 2012 10:58 — forked from nateabele/Base.php
MongoDB-based model accessors (relationships) in Lithium
<?php
namespace my_app\models;
use MongoId;
use lithium\data\collection\DocumentArray;
use lithium\data\collection\DocumentSet;
use lithium\data\entity\Document;
use lithium\util\Inflector;
use lithium\core\Libraries;
@nateabele
nateabele / Base.php
Created September 19, 2012 21:53
MongoDB-based model accessors (relationships) in Lithium
<?php
namespace my_app\models;
use MongoId;
use lithium\data\collection\DocumentArray;
use lithium\data\collection\DocumentSet;
use lithium\data\entity\Document;
use lithium\util\Inflector;
use lithium\core\Libraries;
@igorw
igorw / FooController.php
Created September 5, 2012 22:13
Silex convention-based controllers
<?php
// src/Foobar/Controller/FooController.php
namespace Foobar\Controller;
class FooController
{
public function helloAction($request)
{