Skip to content

Instantly share code, notes, and snippets.

@ohnotnow
ohnotnow / CountsDatabaseQueries.php
Created January 3, 2022 15:15
Little Laravel testing trait to help monitor DB queries
<?php
namespace Tests;
trait CountsDatabaseQueries
{
protected $recordedDatabaseQueries = [];
protected function countDatabaseQueries()
{
@ohnotnow
ohnotnow / getvideolength.sh
Created October 15, 2021 17:16
Get the length of a video (in minutes) using ffprobe
#!/bin/bash
T=`ffprobe -i "$1" -v quiet -show_entries format=duration -hide_banner | grep duration | cut -f2 -d'='` && echo "${T}/60" | bc
@ohnotnow
ohnotnow / diff_configs.sh
Last active January 28, 2021 15:54
diff your current laravel project configs with the laravel/laravel repo
#!/bin/bash
#set -e
if [ $# != 1 ];
then
echo 'Please supply a laravel version to check'
exit 1
fi
@ohnotnow
ohnotnow / RenameRoutes.php
Created October 5, 2020 15:41
Artisan command to convert laravel routes to the version 8 syntax
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class ReformatRoutes extends Command
{
protected $signature = 'route:reformat-l8 {--file=web} {--dry-run}';
@ohnotnow
ohnotnow / example.yml
Created August 6, 2020 16:34
Create a minio bucket in docker compose formet
createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add myminio http://minio:9000 AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY;
/usr/bin/mc rm -r --force myminio/somebucketname;
/usr/bin/mc mb myminio/somebucketname;
/usr/bin/mc policy download myminio/somebucketname;
@ohnotnow
ohnotnow / traefik-manual-ssl.yml
Created February 8, 2020 17:42
Traefik v2 with manual SSL certs
version: "3.7"
services:
traefik:
image: traefik:v2.1.3
restart: always
container_name: traefik
ports:
- target: 80
published: 80
@ohnotnow
ohnotnow / Dockerfile
Created January 24, 2020 16:04
Arg/Env
FROM whatever
ARG GIT_URL
ENV GIT_URL=${GIT_URL}
RUN git clone "${GIT_URL}"
# docker build --build-arg GIT_URL=https://.... -t myimage .
@ohnotnow
ohnotnow / traefik.yml
Created December 5, 2019 14:14
Test traefik v2 docker swarm stack file
version: "3.3"
services:
################################################
#### Traefik Proxy Setup #####
###############################################
traefik:
image: traefik:v2.0
restart: always
container_name: traefik
@ohnotnow
ohnotnow / wp.yml
Created December 5, 2019 14:09
test wordpress traefik 2 stack
version: "3.3"
services:
wordpress: # <== we aren't going to open :80 here because traefik is going to serve this on entrypoint 'web'
## :80 is already exposed from within the container ##
image: wordpress
restart: always
container_name: wp
environment:
@ohnotnow
ohnotnow / example.yml
Created October 17, 2019 16:02
Traefik labels for v1.7
labels:
- "traefik.backend=${TRAEFIK_BACKEND}"
- "traefik.docker.network=proxy"
- "traefik.frontend.rule=Host:${TRAEFIK_HOSTNAME}"
- "traefik.enable=true"
- "traefik.port=80"
- "traefik.default.protocol=http"