- Don't copy files into current document root
- Let existing requests finish on old code
- New requests start on new code
- Avoid clearing your opcode cache
- Minimal impact on production traffic
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 | |
class Roman_converter | |
{ | |
public $numerals = array( | |
'I' => 1, | |
'II' => 2, | |
'V' => 5, | |
'X' => 10, | |
'L' => 50, |
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 | |
/** | |
* Imagine a hallway (from the Matrix) with 50 doors on each side. | |
* Take a walk down the hallway and back up, opening every door. | |
* On a second pass, close all the even numbered doors. | |
* The third pass, each third door, close it if it's open and open if it's closed. | |
* Repeat. | |
* What is the state of the doors after 100 passes? | |
*/ |
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 | |
/** | |
* Given a decimal number like 1, 3 7, 13, 57, 42, convert to its Roman Numeral | |
* equivalent. For example, "46" is "XLVI", "973" is "CMLXXIII", "1984" is | |
* "MCMLXXXIV". | |
*/ | |
function toRoman($decimal){ | |
$romanNumerals = array( | |
"1"=>"I", | |
"2"=>"II", |
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
{ | |
foo=1 | |
bar=2 | |
baz=3 | |
} | |
{ | |
foo=0 | |
} | |
{ | |
} |
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 | |
$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 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 | |
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 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 | |
/** | |
* 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 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
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 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
var assert = require('assert'); | |
function test(actual, expected, success){ | |
success = success || 'pass!'; | |
assert.equal(actual, expected); | |
console.log(success); | |
} |