This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
class EnsureAppUrl | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class OpenEventEmitter<T> implements EventEmitter<T> { | |
private readonly handlers: { [eventName in keyof T]?: ((value: T[eventName]) => void)[] } | |
constructor() { | |
this.handlers = {} | |
} | |
getClosedEmitter(): EventEmitter<T> { | |
return this | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Inertia } from '@inertiajs/inertia' | |
import { onBeforeMount, onBeforeUnmount } from 'vue' | |
/** | |
* @param {() => boolean} shouldBlockUnload | |
* @param {string} message | |
* @returns void | |
*/ | |
export function useBeforeUnload( | |
shouldBlockUnload, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Idea stolen from https://stackoverflow.com/questions/610839/how-can-i-programmatically-create-a-new-cron-job#13355743 | |
addCronjob() { | |
user=$(whoami) | |
(crontab -u "$user" -l 2>/dev/null || echo '' ; echo "$1") \ | |
| sort - \ | |
| uniq - \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM composer:2 | |
FROM php:8-cli | |
COPY --from=composer /usr/bin/composer /usr/bin/composer | |
VOLUME /app | |
WORKDIR /app | |
RUN apt update && apt install -y \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8-cli | |
VOLUME /app | |
WORKDIR /app | |
RUN apt update && apt install -y \ | |
tini \ | |
libonig-dev \ | |
&& rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Http\Response; | |
use Illuminate\Support\Facades\Storage; | |
use Symfony\Component\HttpFoundation\StreamedResponse; | |
/** | |
* Similar to Storage::download, but serves the file as a stream. | |
* | |
* Stolen and adapted from stackoverflow.com/questions/44965777/laravel-5-file-downloads-stream-or-download |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function readCsv(string $filepath, string $separator = ';'): array | |
{ | |
$csv = file_get_contents($filepath); | |
$lines = explode("\n", $csv); | |
$head = str_getcsv(array_shift($lines), $separator); | |
$data = []; | |
$lineNumber = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Ensures that text is readable on any background. | |
Stolen from https://stackoverflow.com/questions/23968961/css-how-can-i-make-a-font-readable-over-any-color#43135326 | |
*/ | |
@mixin readable-shadow($size, $color: white) { | |
text-shadow: | |
#{0.01 * $size}em 0 $color, | |
0 #{0.01 * $size}em $color, | |
#{-0.01 * $size}em 0 $color, | |
0 #{-0.01 * $size}em $color, |
NewerOlder