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 | |
$expected = ["name", "email", "comments"]; | |
$required = ["name", "comments"]; | |
foreach ($_POST as $key => $value) { | |
if (!is_array($value)) { | |
$value = trim($value); | |
} |
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 module = function(exports) { | |
Object.defineProperty(exports, '__esModule', { value: true }); | |
/** | |
* Copyright (c) 2013-present, Facebook, Inc. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE file in the root directory of this source tree. | |
* | |
*/ |
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
<div id="tweet-box-home-timeline" contenteditable="true"> | |
What's happening? | |
</div> |
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
#!/usr/bin/env bash | |
function is_browser { | |
local path=$1 | |
local basename=$(basename $path) | |
if [[ $basename = "chromium-browser" ]]; then | |
return 1 | |
fi |
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 | |
function marshal(array $rows) { | |
foreach ($rows as $row) { | |
assert(is_object($row)); | |
assert(property_exists($row, "id")); | |
assert(property_exists($row, "type")); | |
$row->relatives = array_filter($rows, function ($next) use ($row) { | |
$key = "{$row->type}_id"; |
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 | |
function is_iterable($value) { | |
return is_array($value) || $value instanceof Traversable; | |
} | |
function flatMap(/* iterable */ $iterable, callable $callable) { | |
foreach ($iterable as $value) { | |
if (is_iterable($value)) { | |
foreach (flatMap($value, $callable) as $next) { |
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
class Lexer { | |
get patterns() { | |
return { | |
"whitespace": "\\s+", | |
"type": "int", | |
"assign": "=", | |
"identity": "[a-z]+", | |
"value": "[0-9]+" | |
}; | |
} |
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
let tokens = [ | |
["type", "int"], | |
["whitespace", " "], | |
["identity", "minutes"], | |
["whitespace", " "], | |
["assign", "="], | |
["whitespace", " "], | |
["value", "90"] | |
]; |
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
composer require yay/yay:dev-master | |
vendor/bin/yay range.yay.php > range.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 | |
private function newConnectionString(array $config) | |
{ | |
switch ($config->get("driver")) { | |
case "mysql": { | |
return sprintf( | |
"mysql:host=%s;port=%s;dbname=%s;unix_socket=%s;charset=%s", | |
$config->get("host"), | |
$config->get("port"), |