Skip to content

Instantly share code, notes, and snippets.

View chuckadams's full-sized avatar

Chuck Adams chuckadams

View GitHub Profile
@chuckadams
chuckadams / ProcessManager.php
Created November 30, 2024 21:56
Simple parallel process manager for symfony/process
<?php
declare(strict_types=1);
namespace App\Services;
// Based on https://github.com/BluePsyduck/symfony-process-manager/tree/master
use App\Services\Interfaces\ProcessManagerInterface;
use Closure;
@chuckadams
chuckadams / JsonLogger.php
Created November 30, 2024 21:54
Simple PSR-3 JSON Logger
<?php
declare(strict_types=1);
namespace App\Services;
use DateTime;
use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;
use RuntimeException;
@chuckadams
chuckadams / named_bind.sh
Created September 27, 2024 00:12
docker named bind mount
docker volume create --driver local -o o=bind -o type=none -o device="$YOUR_DIRECTORY" $VOLUME_NAME
@chuckadams
chuckadams / module_demo.php-ish
Last active July 5, 2024 17:50
Thoughts on a PHP module system
////////////////
module My\Stuff\MyModule; // implies “namespace My\Stuff\MyModule”
export class Foo { }
export function foo() { }
function bar() { } // not exported
export string $message = “your ad here”;
@chuckadams
chuckadams / hyperkey.ahk
Created August 19, 2023 04:53
hyper key for autohotkey
#NoEnv ; recommended for performance and compatibility with future
autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input
@chuckadams
chuckadams / .inputrc
Created August 19, 2023 02:14
minimal sane .inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@chuckadams
chuckadams / gist:16ab2b111f68025b5e6894dbea4bcde5
Created January 1, 2023 20:41
docker-compose with caddyfile
version: '3.4'
services:
caddy:
image: caddy:2
restart: "unless-stopped"
ports:
- "80:80"
- "443:443"
volumes:
- .docker/caddy/Caddyfile:/etc/caddy/Caddyfile
@chuckadams
chuckadams / tricks.ts
Last active September 13, 2020 17:52
Stupid Typescript tricks
//// Exact types
type Exact<TExpected, TActual extends TExpected> = TExpected extends TActual ? TExpected: never;
type Foo = { x: number };
function acceptT<T extends Foo>(input: Exact<Foo, T>) {}
//// JSON Schema Type
type JSONSchema<T> = T extends number
? {
@chuckadams
chuckadams / singleton.ts
Created May 21, 2020 17:44
dependent types in typescript
type Maybe<a> = { val: a, tag = "some" } | { tag: "none" }
function isSome<A, Ma: Maybe<a>>(m: Ma): Ma["val"] is A {
return m.tag == "some";
}
#!/bin/sh
if [ -z $1 ]; then
stamp=$(mktemp /tmp/stamp.XXXXXXXX)
trap 'rm $stamp' EXIT
emacs $HOME/bin
find $HOME/bin/ -type f -cnewer $stamp | xargs -r chmod +x
exit 0
fi