Skip to content

Instantly share code, notes, and snippets.

View onlime's full-sized avatar

Philip Iezzi (Pipo) onlime

View GitHub Profile
@onlime
onlime / HandleInertiaRequests.php
Created April 3, 2023 22:11
Vue3-Toastify in a Laravel/Inertia/Vue project
<?php
namespace App\Http\Middleware;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware
{
public function share(Request $request)
{
@onlime
onlime / HandleInertiaRequests.php
Last active April 4, 2023 20:21
Vue3-toastify in Laravel/Inertia.js/Vue/Tailwind
<?php
namespace App\Http\Middleware;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware
{
public function share(Request $request)
{
@onlime
onlime / mysql-kill-sleeping.sh
Created January 6, 2023 10:26
MySQL process killer for long running Sleep processes
#!/bin/bash
# Number of seconds a query is allowed to execute before it is killed. (default: 3h)
MAX_EXEC_TIME=${1:-10800}
MYSQL_USER=your-mysql-user
mysql -sNB -e "SHOW FULL PROCESSLIST" \
| sed 's/\t/ /g' \
| sed 's/ \+/ /g' \
| while read process_id user host db command_type time state info time_ms rows_sent rows_examined; do
@onlime
onlime / .eslintrc.js
Last active May 7, 2024 08:54
ESLint/Prettier config for Vue 3 in VS Code
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'prettier'
@onlime
onlime / EventServiceProvider.php
Last active February 4, 2022 15:06
Log emails as *.eml in Laravel Mailer
<?php
namespace App\Providers;
use App\Listeners\LogSentMessage;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Mail\Events\MessageSent;
class EventServiceProvider extends ServiceProvider
{
@onlime
onlime / action.d_apache-get-dos.conf
Created September 9, 2021 13:52
Using a Fail2ban jail to mitigate against simple DoS attacks against Apache
# Fail2Ban filter to scan Apache access.log for DoS attacks
[INCLUDES]
before = common.conf
[Definition]
# Option: failregex
# Notes.: regex to match GET requests in the logfile resulting in one of the
# following status codes: 401, 403, 404, 503.
# The host must be matched by a group named "host". The tag "<HOST>"
@onlime
onlime / .eslintrc.js
Created August 30, 2021 21:37
Configure ESLint and Prettier for Vue/Nuxt.js project in VS Code
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
},
@onlime
onlime / .env
Created August 30, 2021 21:33
Algolia Vue InstantSearch component in Nuxt/content
ALGOLIA_INDEX=dev_articles
ALGOLIA_APP_ID=ABCDE12345
#ALGOLIA_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ALGOLIA_SEARCH_ONLY_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ALGOLIA_HITS_PER_PAGE=5
ALGOLIA_QUERY_BUFFER_TIME=300
@onlime
onlime / install-composer.yml
Created August 21, 2021 23:24
Small Ansible playbook to install latest-stable Composer
- hosts: webservers
tasks:
# Install Composer the lightweight way (without using installer)
# https://getcomposer.org/download
- name: Composer | Install Composer latest-stable
get_url:
url: https://getcomposer.org/download/latest-stable/composer.phar
checksum: 'sha256:https://getcomposer.org/download/latest-stable/composer.phar.sha256sum'
dest: /usr/local/bin/composer.phar
@onlime
onlime / mysql-recursive-dump.py
Created August 17, 2021 10:26
Recursively fetch dependent rows with mysqldump
#!/usr/bin/env python3
#
# Copyright (c) 2021 Philip Iezzi, Onlime GmbH - https://www.onlime.ch
#
import argparse
import subprocess
header = """SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;