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
[ | |
{ | |
"match": "You fight like a Dairy Farmer!", | |
"description": "swordfighting for might pirates", | |
"listener": "hear", | |
"response": "How appropriate! You fight like a cow!" | |
}, | |
{ | |
"match": "This is the END for you, you gutter crawling cur!", | |
"description": "swordfighting for might pirates", |
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
extern crate rand; | |
extern crate docopt; | |
extern crate rustc_serialize; | |
use rand::{OsRng, Rng}; | |
use docopt::Docopt; | |
static USAGE: &'static str = " | |
Usage: rpgen [options] | |
rpgen --help |
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 | |
$baseDir = $argv[1]; | |
if (false === is_dir($argv[1])) { | |
die ("$baseDir is not a directory"); | |
} | |
// get all files with an extension | |
$allFiles = array_filter( | |
array_map('pathinfo', glob("$baseDir/*")), |
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 DataCollection implements \IteratorAggregate | |
{ | |
private $data; | |
public function __construct($data) | |
{ | |
$this->data = $data; | |
} |
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
### Keybase proof | |
I hereby claim: | |
* I am gooh on github. | |
* I am gooh (https://keybase.io/gooh) on keybase. | |
* I have a public key whose fingerprint is 729C 589F B492 0AE6 C22C 08F3 73BC 4368 C9EB 252E | |
To claim this, I am signing this 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
function getLinesInRandomOrder($filePath) | |
{ | |
$file = new SplFileObject($filePath); | |
$file->setFlags(SplFileObject::DROP_NEW_LINE | SplFileObject::SKIP_EMPTY); | |
$file->seek(PHP_INT_MAX); | |
$linesToTry = range(0, $file->key()); | |
shuffle($linesToTry); | |
foreach ($linesToTry as $line) { | |
$file->seek($line); | |
yield $file->current(); |
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 | |
function lint($code) | |
{ | |
$code = strpos($code, '<?php') === 0 ? $code : "<?php $code"; | |
$filename = tempnam(sys_get_temp_dir(), 'lnt'); | |
file_put_contents($filename, $code); | |
exec(PHP_BINARY . " -l $filename", $errors); | |
unlink($filename); |
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 | |
for ($i = 1; $i <= 100; $i++) { | |
echo | |
$i % 3 === 0 ? 'Fizz' : '', | |
$i % 5 === 0 ? 'Buzz' : '', | |
$i % 3 && $i % 5 ? $i : '', | |
PHP_EOL; | |
}; |
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 | |
trait AttributeReader | |
{ | |
/** | |
* Interceptor for non-accessible properties | |
* | |
* @param string $property | |
* @returns mixed | |
*/ | |
public function __get($property) |
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 | |
$functions = get_defined_functions(); | |
foreach($functions['internal'] as $function) { | |
$GLOBALS[$function] = function() use ($function) { | |
return call_user_func_array( | |
$function, | |
func_get_args() | |
); | |
}; |
NewerOlder