Skip to content

Instantly share code, notes, and snippets.

Avatar

Philip Iezzi onlime

View GitHub Profile
@onlime
onlime / EventServiceProvider.php
Last active Dec 3, 2021
Log emails as *.eml in Laravel Mailer
View EventServiceProvider.php
<?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 / accounts.list
Last active Sep 23, 2021
imapsync script to migrate multiple IMAP accounts in a row
View accounts.list
# <SRCUSER> <SRCPW> <DSTUSER> <DSTPW>
@onlime
onlime / action.d_apache-get-dos.conf
Created Sep 9, 2021
Using a Fail2ban jail to mitigate against simple DoS attacks against Apache
View action.d_apache-get-dos.conf
# 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 Aug 30, 2021
Configure ESLint and Prettier for Vue/Nuxt.js project in VS Code
View .eslintrc.js
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
},
@onlime
onlime / .env
Created Aug 30, 2021
Algolia Vue InstantSearch component in Nuxt/content
View .env
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 Aug 21, 2021
Small Ansible playbook to install latest-stable Composer
View install-composer.yml
- 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 / .gitlab-ci.yml
Last active Aug 18, 2021
Simple SSH/rsync based continuous deployment of a Nuxt.js static frontend project with GitLab CI/CD
View .gitlab-ci.yml
image: node:current
variables:
# In case you did not set up $SSH_KNOWN_HOSTS variable:
# SSH_OPTS: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
SSH_OPTS: ''
BASE_DIR: public_html/blog
KEEP: 5
default:
@onlime
onlime / mysql-recursive-dump.py
Created Aug 17, 2021
Recursively fetch dependent rows with mysqldump
View mysql-recursive-dump.py
#!/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;
@onlime
onlime / build-encryption-key.sh
Created Aug 17, 2021
Secure External Backup with ZFS Native Encryption
View build-encryption-key.sh
#!/bin/bash
#
# This script usually is called on the first login and asks for a password
# to build the LUKS + ZFS encryption keys which then are stored only in volatile
# memory /mnt/ramfs (ramfs).
# This script is added to your /root/.profile in order you won't forget to
# build the encryption key each time you reboot the server.
#
# We are using ramfs instead of tmpfs as there is no swapping support in
# ramfs which is good in a security perspective.
@onlime
onlime / zfs-destroy-snapshots.py
Created Aug 6, 2021
Helper script to remove old ZFS snapshots
View zfs-destroy-snapshots.py
#!/usr/bin/env python3
"""
Helper script to remove old ZFS snapshots
Copyright (c) Onlime GmbH, https://www.onlime.ch
"""
import argparse
from re import compile
from datetime import datetime, timedelta
from subprocess import check_output
import sys