View MemberOfMacro.php
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\Database\Query\Builder; | |
$memberOf = function ($value, string $column, string $path = '$', $boolean = 'and') { | |
return $this->whereRaw( | |
sprintf( | |
'? MEMBER OF(JSON_EXTRACT(%s, "%s"))', | |
$this->getGrammar()->wrap($column), | |
$path | |
), |
View fixchars.sh
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
#!/usr/bin/env bash | |
# @see: https://superuser.com/questions/617517/remove-all-illegal-characters-from-all-filenames-in-a-given-folder | |
# The 's/[\:?\\]//g' regular expression removes ?, : and \ characters. | |
# Dry Run: | |
find "/path/to/files" -type f -exec rename -n 's/[\:?\\]//g' {} \; | |
# Execute: | |
find "/path/to/files" -type f -exec rename 's/[\:?\\]//g' {} \; |
View docker-images-save-and-load.sh
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
#!/usr/bin/env bash | |
function save-docker-images() { | |
DEST="${1:-.}" | |
mkdir -p "$DEST" | |
echo "Saving Docker Images:" | |
for IMAGE in $(docker images --format "{{.Repository}}"); do | |
docker save "$IMAGE" > "$DEST/$(echo "$IMAGE" | sed -E 's~:|/~_~g').tar" |
View delete-tweets.yml
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
name: Delete Tweets | |
on: | |
workflow_dispatch: | |
schedule: | |
# Once every month | |
# @see: https://crontab.guru/#0_0_1_*_*_* | |
- cron: "0 0 1 * *" | |
jobs: | |
delete: | |
runs-on: ubuntu-latest |
View Dockerfile
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.0-fpm | |
# Copy Composer: | |
COPY --from=composer /usr/bin/composer /usr/bin/composer | |
# Install PHP extensions: | |
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | |
RUN chmod +x /usr/local/bin/install-php-extensions && \ | |
install-php-extensions zip |
View Dockerfile
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-alpine | |
# @see: @see: https://stackoverflow.com/a/65969295 | |
RUN apk --no-cache add binutils curl \ | |
&& GLIBC_VER=$(curl -s https://api.github.com/repos/sgerrand/alpine-pkg-glibc/releases/latest | grep tag_name | cut -d : -f 2 | tr -d \",' ') \ | |
&& curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \ | |
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \ | |
&& curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \ | |
&& apk add --no-cache \ | |
glibc-${GLIBC_VER}.apk \ |
View mysql-wait.sh
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
#!/usr/bin/env bash | |
# Load dot environment file: | |
export $(cat .env | xargs) | |
# Wait for MySQL service to start (this could be on the host or in a Docker container): | |
until mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e '\q'; do | |
>&2 echo "MySQL container is unavailable - sleeping" | |
sleep 1 | |
done |
View Toggle Armoury Crate.bat
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
SET /P state=Start (1) or Stop (0) Armoury Crate? | |
@ECHO OFF | |
IF %state% == 1 (ECHO "Starting Armoury Crate..." & NET START ArmouryCrateControlInterface & NET START ArmouryCrateService) ELSE (ECHO "Stopping Armoury Crate..." & NET STOP ArmouryCrateControlInterface & NET STOP ArmouryCrateService) | |
ECHO "Done." | |
PAUSE |
View alpinejs-checkboxes.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="http://unpkg.com/alpinejs" defer></script> | |
</head> | |
<body> | |
<!-- | |
We have to use $refs because x-bind:checked updates the HTML not the prop. | |
@see: https://github.com/alpinejs/alpine/issues/520 |
View random-files.sh
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
# Generate Random Files | |
# @see: https://support.google.com/elastifile-support/answer/9899027?hl=en | |
# Usage: ./random-files.sh -d /path/to/ouput -s 10 -m 20 - l 5 | |
# Large: <2GB | |
# Medium: <200MB, <8MB each | |
# Small: <1MB | |
DEST="$PWD" | |
SMALL=0 | |
MEDIUM=0 |