This file contains 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
{ | |
foo=1 | |
bar=2 | |
baz=3 | |
} | |
{ | |
foo=0 | |
} | |
{ | |
} |
This file contains 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 | |
$path = rtrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); | |
// If that doesn't correspond to an existing path, assume a route... | |
$path = realpath(__DIR__ . $path) ?: __DIR__ . '/index.php'; | |
extract(pathinfo_safe($path)); // $dirname, $basename, $extension, and $filename | |
if ( !$extension ) extract(pathinfo_safe($path .= '/index.php')); |
This file contains 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 | |
class Model | |
{ | |
static $hooks = [ ]; | |
/** | |
* Add initialization hook $init to (FIFO) queue, which will be bound to the | |
* instance of the object at initialization. | |
* |
This file contains 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 | |
/** | |
* A "functional" test is typically one that runs the full application through it's | |
* paces: constructing a request, triggering a route, generating a response, and | |
* testing the fully rendered output. This abstract class provides some assertions | |
* appropriate for testing requests and responses and abstract methods for actually | |
* fetching requests and responses and routing the application. The developer should | |
* extend this class for his or her specific framework or application. | |
*/ |
This file contains 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
angular.module('myModule', [ ], function($rootScope){ // equivalent to .config(function($rootScope){ . . . }) | |
$rootScope._ = _; // Make `_` available in Angular Expressions | |
}).controller('MyController', function(Something){ | |
var saveSomething = this.saveSomething = Something.save(); | |
$scope.$watch('something', _.debounce(saveSomething, 500)); | |
$scope.something = 'some value'; | |
}) | |
; // END myModule |
This file contains 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
var assert = require('assert'); | |
function test(actual, expected, success){ | |
success = success || 'pass!'; | |
assert.equal(actual, expected); | |
console.log(success); | |
} |
This file contains 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
/** | |
* Conway's Game of Life: http://en.wikipedia.org/wiki/Conway's_Game_of_Life | |
* | |
*/ |
This file contains 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
var assert = require('assert'); | |
function test(actual, expected, success){ | |
success = success || 'pass!'; | |
assert(actual === expected) || console.log(success); | |
} | |
/** | |
* Check Writing |
This file contains 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
var assert = require('assert'); | |
/** | |
* @param Array actual | |
* @param Array expected | |
* @param String message optional | |
* @return Boolean | |
*/ | |
assert.deepEqual = function(actual, expected, message){ | |
/* Then a miracle occurs... */ |
This file contains 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
/** --- TEST CODE --- **/ | |
var expect = chai.expect; | |
/** | |
* Next multiple of 3 or 5 | |
* n = 0: 3 | |
* n = 3: 5 | |
* n = 5: 6 | |
* n = 6: 9 | |
* n = 9: 10 |
OlderNewer