Skip to content

Instantly share code, notes, and snippets.

View Radiergummi's full-sized avatar

Moritz Friedrich Radiergummi

View GitHub Profile
@Radiergummi
Radiergummi / routes.d.ts
Last active October 30, 2024 15:40
Laravel Route replacement in Frontend code at build-time
import { type RouteParameters, type Routes } from '$api/routes.js';
/**
* Resolve a route without parameters
*
* Takes the name of a route as defined in the Laravel application and returns
* the URI of the endpoint.
*
* @param name Route name
*/
import type { Client, Database } from '$lib/server/database';
import type { Insertable, Selectable } from 'kysely';
const table = 'authentication.challenge' as const;
export async function resolveCurrentChallenge(
client: Client,
identifier: string
) {
const { challenge, expires_at } = await client

Keybase proof

I hereby claim:

  • I am Radiergummi on github.
  • I am radiergummi (https://keybase.io/radiergummi) on keybase.
  • I have a public key whose fingerprint is E221 7CF8 EE59 2CB0 9F03 A1C8 B315 6A31 942E 83A6

To claim this, I am signing this object:

@Radiergummi
Radiergummi / ArtisanServeFormatter.php
Last active November 7, 2023 07:22
Formatter for Laravel's artisan serve command that will preserve log output
<?php
declare(strict_types=1);
namespace App\Support;
use DateTime;
use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LineFormatter;
use Monolog\LogRecord;
@Radiergummi
Radiergummi / README.md
Last active July 17, 2023 07:40
Docker Swarm Deployment

This is the deployment runner script we use in our BitBucket pipelines. It does the following things, in this order:

  1. Sign in to Docker Hub
    So we can download images and propagate authentication to Swarm nodes. This connects to the connection in DOCKER_HOST (defaulting to the Docker socket), so you can also run this within a deployment container - see below for more.
  2. Expand secrets and configs
    To configure services, we can use configs and secrets to let the swarm engine mount those values securely
@Radiergummi
Radiergummi / partition.ts
Created April 19, 2023 07:53
A type-preserving TypeScript helper to partition arrays.
/**
* Partition an array into two arrays based on a predicate.
*
* @param array
* @param isValid
*/
export function partition<T, V>( array: ( T | V )[], isValid: ( x: T | V ) => x is T ): [ T[], V[] ] {
return array.reduce( ( [ pass, fail ], elem ) => {
return isValid( elem ) ? [ [ ...pass, elem ], fail ] : [ pass, [ ...fail, elem ] ];
}, [ [] as T[], [] as V[] ] );
@Radiergummi
Radiergummi / deployment.sh
Last active March 18, 2024 19:54
RabbitMQ configuration
#!/usr/bin/env sh
export DOCKER_HOST=unix:///var/run/docker.sock
docker_hosts=$(docker node ls --format '{{.Hostname}}')
# Retrieve the list of hosts from the Docker node (needs to run
# within the Swarm).
# We use this list to configure RabbitMQ statically: On every node
# in the cluster, a RabbitMQ instance is running. They are
# configured to use the Swarm node hostname as their hostname; so
This file has been truncated, but you can view the full file.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Stripe.Account": {
"description": "The Account object.",
"properties": {
"business_profile": {
"$ref": "#/definitions/Stripe.Account.BusinessProfile",
"description": "Business information about the account."
},
/**
* Validates a value that isn't falsy.
*
* @param field
* @param message
*/
export function required(
field?: string,
message?: string | Message<string>,
): Validator {
@Radiergummi
Radiergummi / App.vue
Last active May 2, 2023 09:51
A Vue directive to react to something being dragged on the browser window. Port of this Stack Overflow answer: https://stackoverflow.com/a/55392885/2532203
<template>
<div v-dragging="{ enter, leave }">
</div>
</template>
<script>
import './dragging.ts';
export default {
methods: {