Skip to content

Instantly share code, notes, and snippets.

View wiretype.config.jsonc
{
// You can extend the same config file typescript uses to avoid drift
"extends": "./base.json",
// Accepts globs. Works just like TypeScript
"include": [
"src/wiretypes/**"
],
"exclude": [
"src/wiretypes/*.test.ts"
],
@matt-allan
matt-allan / README.md
Created Jul 31, 2020
Compound sorting Laravel collections
View README.md

This is an example of sorting a Laravel collection by > 1 attribute with different sort directions. Unlike some of the other solutions mentioned in this thread it works with any type PHP can normally sort and doesn't require hashing.

That works because of how PHP's comparison functions work:

Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value

The <=> operator is PHP's combined comparison operator, or 'spaceship' operator. It makes writing custom sort functions very easy.

If you need to do a compound sort but every attribute is being sorted in the same direction, you can use sortBy/sortByDesc instead of writing your own sort function.

@matt-allan
matt-allan / index.html
Last active Sep 8, 2021
Electron Fiddle Gist
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Context Bridge Example</title>
<link rel="stylesheet" type="text/css" href="./styles.css">
</head>
<body>
<main class="app">
<button onclick="window.app.setFullscreen(true)">Enter fullscreen</button>
View keybase.md

Keybase proof

I hereby claim:

  • I am matt-allan on github.
  • I am mattya (https://keybase.io/mattya) on keybase.
  • I have a public key ASCD9RfpRxzyrRfF79o7vA-ANxS6WBJTb785HRo1NsZnIwo

To claim this, I am signing this object:

@matt-allan
matt-allan / Caddyfile
Last active Mar 26, 2019
PHP Httpoxy example
View Caddyfile
localhost:8080
fastcgi / 127.0.0.1:9000 php {
env HTTP_AUTH_PASSWORD secret123
}
rewrite {
regexp .*
ext /
to /index.php?{query}
@matt-allan
matt-allan / Caddyfile
Created Mar 22, 2019
Caddyfile for PHP bug 77782
View Caddyfile
localhost:8080
fastcgi / 127.0.0.1:9000 php {
env FOO bar
}
rewrite {
regexp .*
ext /
to /index.php?{query}
View Caddyfile
0.0.0.0
root ./
gzip
fastcgi / 127.0.0.1:9000 php {
env FOO bar
}
rewrite {
regexp .*
ext /
to /index.php?{query}
View openapi.yaml
openapi: 3.0.0
info:
version: 1.0.0
title: Matt's Bicycle Shop API
servers:
- url: http://api.matts-bikes.dev/v1
paths:
/work-orders:
post:
summary: Create a work order
View di-service-provider.php
<?php
abstract class ServiceProvider implements DefinitionSource
{
/**
* @return array
*/
abstract protected function definitions(): array;
/**
View composer-script-compl.sh
_composer_scripts() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local scripts=$(composer run-script -l --no-ansi 2> /dev/null | awk '/^ +[a-z]+/ { print $1 }')
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur}) )
return 0
}
complete -F _composer_scripts composer