Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
<?php
$expected = ["name", "email", "comments"];
$required = ["name", "comments"];
foreach ($_POST as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
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.
*
*/
@assertchris
assertchris / index.html
Created December 15, 2017 17:05
XVmWBV
<div id="tweet-box-home-timeline" contenteditable="true">
What's happening?
</div>
#!/usr/bin/env bash
function is_browser {
local path=$1
local basename=$(basename $path)
if [[ $basename = "chromium-browser" ]]; then
return 1
fi
<?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";
<?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) {
class Lexer {
get patterns() {
return {
"whitespace": "\\s+",
"type": "int",
"assign": "=",
"identity": "[a-z]+",
"value": "[0-9]+"
};
}
let tokens = [
["type", "int"],
["whitespace", " "],
["identity", "minutes"],
["whitespace", " "],
["assign", "="],
["whitespace", " "],
["value", "90"]
];
composer require yay/yay:dev-master
vendor/bin/yay range.yay.php > range.php
<?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"),