Skip to content

Instantly share code, notes, and snippets.

@matt-allan
matt-allan / index.html
Last active Jan 6, 2022
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 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.

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}
@matt-allan
matt-allan / croutonGamepadFix.md
Last active Nov 3, 2017
setup dragonrise controllers with crouton
View croutonGamepadFix.md

To make dragonrise n64 and snes controllers work with my crouton xfce4/ubuntu chroot, I had to recompile the kernel with support for the hid_dr module. These are the steps to get the controllers working. Almost all steps are taken from the sources listed below. All commands are entered in the chroot's terminal, not the chronos shell.

sudo apt-get install git-core make kernel-package
cd ~
git clone https://chromium.googlesource.com/chromiumos/third_party/kernel -b chromeos-3.8
cd kernel
nano chromeos/config/base.config

type ctrl-w, type 'error_on_warning' and press enter to find the line you need to edit.

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;
/**