Skip to content

Instantly share code, notes, and snippets.

Mark Dain ancarda

Block or report user

Report or block ancarda

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 no-errors.php
<?php
// catch everything
set_error_handler(function (int $errno, string $errstr, string $errfile = 'unknown', int $errline = 0, array $errcontext = []) {
echo("<p>$errfile:$errline</p>\n");
echo("<p>[#$errno] $errstr</p>\n");
print_r($errcontext);
exit(1);
});
View tests.php
<?php
public function providerPsr7Implementations(): array
{
$guzzle = \GuzzleHttp\Psr7\stream_for(static::TEST_STRING);
return [
[StringStream::class, new StringStream(static::TEST_STRING)],
[get_class($guzzle), $guzzle],
[\Nyholm\Psr7\Stream::class, \Nyholm\Psr7\Stream::create(static::TEST_STRING)],
View automatically-start-tmux.sh
# Start tmux if it's not already running
if [ -z $TMUX ]
then
# Try to attach to an existing session if possible.
tmux attach
# If `tmux attach` returns 1, tmux isn't running. Start it
if [ $? -eq 1 ]
then
tmux
View rfc.md

PHP RFC: Remove mktime

Introduction

This RFC proposes we remove the mktime function.

mktime has existed since PHP 4, and is mostly a shim around the POSIX mktime function. Since it's introduction in PHP, better constructions have emerged like the DateTime object.

The behavior of mktime is confusing and unintuitive. In particular, the behavior of nulls:

@ancarda
ancarda / bandersnatch.dot
Last active Dec 29, 2018
WIP Flowchart for Netflix Bandersnatch (***SPOILERS***). Note that not all decisions are made available automatically. Sometimes you need to re-play a few times, or need to explore alternate options.
View bandersnatch.dot
# Netflix Bandersnatch choices.
#
# WARNING: Major spoilers (duh!).
#
# Paste into http://webgraphviz.com/ and hit "Generate Graph" to see.
#
digraph G {
Bandersnatch [shape=box];
"Breakfast?" [shape=diamond];
Bandersnatch -> "Breakfast?";
@ancarda
ancarda / rust-v-haskell.md
Last active Dec 5, 2018
Maybe, Option, ADT
View rust-v-haskell.md

Rust vs. Haskell

Algebraic Data Types

Built In Type: Maybe

enum Option<T> {
    Some(T),
    None,
@ancarda
ancarda / serious-document.xml
Created Dec 2, 2018
I saw some MathML for the first time and got so angry that each **character** has it's own XML, eg. `where` would be written `<mi>w</mi><mi>h</mi><mi>e</mi><mi>n</mi>`. As a lover of XML, I believe this abuse must end. Here is where that kind of thinking leads to.
View serious-document.xml
<?xml version="1.0" charset="UTF-8"?>
<SeriousDocument sb:xmlns="https://seriousbusiness.com/xmlschemas/2001/PortableXMLDocumentFormat" Identifier="{5DAB3EB7-A21E-4F1D-8F14-1C7AFA2249AA}" DocumentNamespace="com.SeriousBusiness.PortableXMLDocumentFormats.SeriousDocumentExampleFiles.HelloWorldVersionv2.65-FINAL-SignedOff-2019">
<sb:PrimaryDocumentMetadata>
<sb:DocumentModificationLogs>
<sb:DocumentModificationLogEntry Identifier="{D6581BC3-296B-4D4B-8647-CB41C08A333D}">
<sb:DocumentModificaitonAuthor Identifier="{33238F05-41C7-4B9A-B56D-6006C6F79EA7}">
<sb:DocumentModificaitonAuthorGivenName>
<sb:DocumentAuthorNameSegmentCandidates>
<sb:DocumentAuthorNameSegmentCandidate Language="en-GB" IsPreferredTextWherePossible="YES" Description="Given Name at Birth" NameFromBirth="YES" NameInRelevantLegalJurisdiction="YES">Mark</sb:DocumentAuthorNameSegmentCandidate>
</sb:DocumentAuthorNameSegmentCandidates>
View divide-by-zero.hs
main = do
print $ 0 / 0 -- NaN
print $ 0 / 1 -- 0.0
print $ 1 / 0 -- Infinity
View starter-pack.sh
# Essential terminal programs
apt install -y sudo curl wget vim git sudo htop screenfetch tree nmap dos2unix pgcli xclip
# Essential GUI programs
apt install -y vim-gtk3 vlc terminator
# i3
apt install -y i3 i3blocks
# Programming Languages
View gist:b3eb8270a67d1064525e4980e9e35072
build-cores = 4
build-max-jobs = 4
binary-caches = https://cache.nixos.org/ https://nixcache.reflex-frp.org
binary-cache-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI=
You can’t perform that action at this time.