Skip to content

Instantly share code, notes, and snippets.

Christopher Pitt assertchris

Block or report user

Report or block assertchris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View validate.php
<?php
$expected = ["name", "email", "comments"];
$required = ["name", "comments"];
foreach ($_POST as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
View react-pixi-fibre.js
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.
*
*/
View index.html
<div id="tweet-box-home-timeline" contenteditable="true">
What's happening?
</div>
View focus-switch.sh
#!/usr/bin/env bash
function is_browser {
local path=$1
local basename=$(basename $path)
if [[ $basename = "chromium-browser" ]]; then
return 1
fi
View marshal.php
<?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";
View flatMap.php
<?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) {
View gist:9bc8fa85d694be22004e
class Lexer {
get patterns() {
return {
"whitespace": "\\s+",
"type": "int",
"assign": "=",
"identity": "[a-z]+",
"value": "[0-9]+"
};
}
View gist:4e700ee6f55931677bbd
let tokens = [
["type", "int"],
["whitespace", " "],
["identity", "minutes"],
["whitespace", " "],
["assign", "="],
["whitespace", " "],
["value", "90"]
];
View compile.sh
composer require yay/yay:dev-master
vendor/bin/yay range.yay.php > range.php
View connector.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"),
You can’t perform that action at this time.