This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SimpleRand as part of C implementation | |
| // Usage: | |
| // s = new SimpleRand(seed); | |
| // v = s.rand(5, 10); | |
| function SimpleRand(randState) { | |
| var u; | |
| function next() { | |
| if (randState === u) { | |
| randState = 54819; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on idea of http://millermedeiros.github.com/js-signals/ | |
| function Signal(context, remember) { | |
| this._bindings = []; | |
| this._sorted = true; | |
| this._erased = false; | |
| this._remember = !!remember; | |
| this._params = null; | |
| this._propagate = false; | |
| this._context = context || this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Binds a method to its owner, optionally adding more arguments | |
| function bindMethod(_this, method) { | |
| method = _this[method]; | |
| if (arguments.length <= 2) { | |
| return method.bind(_this); | |
| } | |
| var args = Array.prototype.slice.call(arguments, 2); | |
| return args.unshift(_this), method.bind.apply(method, args); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function extend(object) { | |
| if (arguments.length > 1) { | |
| for (var i = 1; i < arguments.length; ++i) { | |
| for (j in arguments[i]) { | |
| object[j] = arguments[i][j]; | |
| } | |
| } | |
| } | |
| return object; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Event() { | |
| } | |
| extend(Event.prototype, { | |
| propagationStopped: false, | |
| stopPropagation: function() { | |
| this.propagationStopped = true; | |
| return this; | |
| }, | |
| isPropagationStopped: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Makes fn inherit from parent class | |
| // Allows "super" calls ONLY in the constructor via Class.parent(this, param1, param2, ...) | |
| // Also allows to extend the prototype giving more arguments | |
| function inherit(parent, fn) { | |
| fn || (fn = function() { }); | |
| fn.prototype = Object.create(parent.prototype); | |
| for (var i = 2; i < arguments.length; ++i) { | |
| extend(fn.prototype, arguments[i]); | |
| } | |
| fn.prototype.constructor = fn; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $observableUniverse = new Location('Universo observable'); | |
| $virgoSuperCluster = new Location('Supercúmulo de Virgo', $observableUniverse); | |
| $localGroup = new Location('Grupo Local', $virgoSuperCluster); | |
| $milkyWay = new Location('Via Lactea', $localGroup); | |
| $orionArm = new Location('Brazo de Orión', $milkyWay); | |
| $solarSystem = new Location('Sistema Solar', $orionArm); | |
| $earth = new Location('La Tierra', $solarSystem); | |
| $europe = new Location('Europa', $earth); | |
| $spain = new Location('España', $europe); | |
| $catalonia = new Location('Catalunya', $spain); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $geocode = new \Google\Maps\Geocode\GeocodeService(); | |
| $cachePath = $this->container->getParameter('kernel.root_dir') . '/../cache'; | |
| $cache = new \Doctrine\Common\Cache\FilesystemCache($cachePath); | |
| $cacheAdapter = new \Guzzle\Cache\DoctrineCacheAdapter($cache); | |
| $cachePlugin = new \Guzzle\Plugin\Cache\CachePlugin($cacheAdapter); | |
| $geocode->getClient()->addSubscriber($cachePlugin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Download composer as explained in http://getcomposer.org/download | |
| > curl -s https://getcomposer.org/installer | php | |
| # Create a new Symfony2 project | |
| > composer.phar create-project symfony/framework-standard-edition directory |