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/to/migrations/directory/Version20121011141021.php | |
*/ | |
namespace ExampleMigrations; | |
use Doctrine\DBAL\Migrations\AbstractMigration; | |
use Doctrine\DBAL\Schema\Schema; | |
class Version20121011141021 extends AbstractMigration |
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 | |
// Silex Style Controllers | |
class App extends \Slim\Slim | |
{ | |
public function mount($controller) | |
{ | |
if (! is_object($controller)) { | |
throw new \InvalidArgumentException('Controller must be an object.'); | |
} |
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 | |
// http://content.codersdojo.org/code-kata-catalogue/fizz-buzz/ | |
foreach (range(1, 100) as $i) { | |
$x = ''; | |
$x .= ($i % 3 === 0 ? 'Fizz' : ''); | |
$x .= ($i % 5 === 0 ? 'Buzz' : ''); | |
echo $i . ' ' . (empty($x) ? $i : $x) . "\n"; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Image from Webcam</title> | |
<style type="text/css"> | |
video { display: block; margin: 0 auto; border: 10px solid #ccc; } | |
.button { margin: 10px auto; padding: 10px; background: #ccc; color: white; text-align: center; width: 200px; cursor: pointer; } | |
#container, |
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 OpenStruct extends ArrayObject | |
{ | |
public function __construct($input = array()) | |
{ | |
parent::__construct($input, static::ARRAY_AS_PROPS); | |
} | |
public function offsetSet($key, $value) | |
{ |
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
#!/usr/bin/env php | |
<?php | |
if (php_sapi_name() !== 'cli') { | |
exit(1); | |
} | |
function input() { | |
return fgets(STDIN); | |
} |
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 | |
/** | |
* Checklist Field Type. | |
* | |
* File: PERCH_PATH/addons/fieldtypes/checklist/checklist.class.php | |
* Usage: <perch:content id="features" type="checklist" label="Features" options="Feature 1, Feature 2, Feature 3" /> | |
* @author Jamie York | |
**/ | |
class PerchFieldType_checklist extends PerchAPI_FieldType | |
{ |
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
#!/bin/bash | |
# Usage: ./hgupdate.sh /path/to/repositories | |
# Trap Ctrl + C command and exit the script. | |
trap 'exit 1' 2 | |
# Strip trailing slashes from argument and test it's a directory. | |
TARGET=${1%/} | |
if [[ ! -d $TARGET ]]; then | |
echo "Please pass in a directory path." |
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
#!/usr/bin/env php | |
<?php | |
// Left associative ternary. | |
// Output: T | |
echo (true ? 'True' : false ? 'T' : 'F') . "\n"; | |
// This is essentially the same as above. | |
// Output: T | |
echo ((true ? 'True' : false) ? 'T' : 'F') . "\n"; |
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
// Usage: casperjs screenshot.js http://www.bbc.co.uk bbc.png | |
// https://gist.github.com/2310901 | |
var casper = require('casper').create({ | |
viewportSize: { width: 1024, height: 768 } | |
}); | |
var utils = require('utils'); | |
if (casper.cli.args.length < 2) { |