Skip to content

Instantly share code, notes, and snippets.

@ajdinmore
ajdinmore / full-cache-clear.sh
Last active February 28, 2024 18:21
Clear all Symfony cache pools
#!/bin/bash
bin/console cache:pool:list | head -n -2 | tail -n +4 | xargs bin/console cache:pool:clear
@ajdinmore
ajdinmore / docker-compose.yaml
Created September 19, 2023 15:39
Docker Compose/Stack Placeholder Template Examples
#file: noinspection SpellCheckingInspection
# https://docs.docker.com/engine/reference/commandline/service_create/#create-services-using-templates
# https://docs.docker.com/config/containers/logging/awslogs/#tag
# https://docs.docker.com/config/containers/logging/log_tags/
# https://forums.docker.com/t/example-usage-of-docker-swarm-template-placeholders/73859
services:
service:
image: busybox
command: env
hostname: '{{.Task.Name}}-{{.Node.Hostname}}'
export GPG_TTY=$(tty)
export DOCKER_BUILDKIT=1
@ajdinmore
ajdinmore / apps-install.sh
Last active August 30, 2023 14:29
Laptop apps install script (work in progress)
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
xdg-open ~/Downloads &> /dev/null &
xdg-open 'https://www.gitkraken.com/download/linux-deb' &> /dev/null &
xdg-open 'https://www.jetbrains.com/toolbox-app/download/download-thanks.html?platform=linux' &> /dev/null &
xdg-open 'https://slack.com/intl/en-gb/downloads/linux' &> /dev/null &
<?php
declare(strict_types=1);
/**
* Plugin Name: WooCommerce Import Fix 2022-10-05
* Description: Fixes importing variable product drafts.
*/
add_filter('woocommerce_product_importer_formatting_callbacks', function (array $callbacks, \WC_Product_Importer $importer) {
$key = array_search('published', $importer->get_mapped_keys());
if (false !== $key && isset($callbacks[$key])){
@ajdinmore
ajdinmore / docker-compose.yaml
Last active August 24, 2022 17:02
Quick-start PHP project Docker setup
version: '3.8'
services:
php:
image: ajdinmore/php:8.1-dev
hostname: php
tty: true
volumes:
- ./:/app
- ${COMPOSER_HOME:-~/.composer}:/composer
environment:
@ajdinmore
ajdinmore / DevController.php
Last active September 15, 2022 19:25
Symfony Dev Controller Template
<?php /** @noinspection PhpMultipleClassesDeclarationsInOneFile */
declare(strict_types=1);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
cd "$(dirname "$(readlink -f "$0")")" || (echo "Failed to change directory." && exit 1)
@ajdinmore
ajdinmore / .bash_aliases
Last active February 15, 2024 01:24
Bash Aliases
#/bin/bash
function kt {
(&>/dev/null kate "$@" & exit)
}
function dolp {
(&>/dev/null dolphin "${@:-.}" & exit)
}
@ajdinmore
ajdinmore / wp_cron_multisite.sh
Created February 25, 2019 16:20
WordPress Multisite Cron Shell Script
#!/bin/bash
WP_PATH="/srv/example/public_html"
for SITE_URL in $(wp site list --field=url --archived=0 --deleted=0 --path="$WP_PATH")
do
echo -e "\n$SITE_URL"
wp cron event run --due-now --path="$WP_PATH" --url="$SITE_URL"
done