Skip to content

Instantly share code, notes, and snippets.

//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@agborkowski
agborkowski / bst.js
Created December 5, 2012 11:39 — forked from trevmex/bst.js
A simple binary search tree in JavaScript
/*
* File: bst.js
*
* A pure JavaScript implementation of a binary search tree.
*
*/
/*
* Class: BST
*
# skipp it if you wont change mirror of repository
curl https://raw.github.com/gist/1588091/8b7b7a203074231f3dc75bdee48b3017078fb621/CentOS-Base.repo -o /etc/yum.repos.d/CentOS-Base.repo
curl https://raw.github.com/gist/1588091/2e5ab750cd0603dd7210ea7a999d15f9aadae711/epel.repo -o /etc/yum.repos.d/epel.repo
<?php
/*
cakephp 1.2 database configuration for different environments
@author AgBorkowski
@link http://blog.aeonmedia.eu/2013/02/good-way-to-change-in-easy-way-application-environment
*/
class DATABASE_CONFIG {
public $default = array();
@agborkowski
agborkowski / gist:5619553
Last active December 17, 2015 13:49
lithium #li3 model validator configs #user-exist #user-active #is-unique
public $validates = [
'email_id' => [
[
'notEmpty',
'email',
'required' => true,
'message' => 'Enter a valid email',
'last' => true
],
// [
@agborkowski
agborkowski / routes.php
Last active December 19, 2015 21:18
#li3 #rest #media #router #angular #js #ngResource #lithiumphp
<?php
//route.php
/**
* Lithium REST routes
* Support:
* - Angular, NgResource, $http
* - ExtJs (Media.php should be included)
*
* @author AgBorkowski <[email protected]> http://blog.aeonmedia.eu
* @see http://book.cakephp.org/view/1239/The-Simple-Setup
<?php
//config/bootstrap/cache.php
use lithium\storage\Cache;
Cache::config(array(
'local' => array(
'adapter' => 'Apc'
),
<?php
// somewhere in config/bootstrap
Dispatcher::config(array('rules' => array(
'admin' => array(
'action' => 'admin_{:action}'
)
)));
// app/classes/PostsController.php
<?php
class Base extends lithium\data\Model {
public function save($entity, $data = null, array $options = array()) {
if ($data) {
$entity->set($data);
}
if (!$entity->exists()) {
$entity->created = new MongoDate();
@agborkowski
agborkowski / logger.php
Last active December 20, 2015 05:49
#li3 #lithium #php logging sql queries
<?php
if (!Environment::is('production')) {
// Attach to the `Connections` adapters after dispatch.
Filters::apply('\lithium\action\Dispatcher', '_callable', function($self, $params, $chain) {
/**
* Loop over all defined `Connections` adapters and tack in our
* filter on the `_execute` method.
*/
foreach (Connections::get() as $connection) {