Skip to content

Instantly share code, notes, and snippets.

View onlime's full-sized avatar

Philip Iezzi (Pipo) onlime

View GitHub Profile
@onlime
onlime / fixpreferences.sh
Created April 22, 2014 14:28
fix user preferences in Roundcube webmail
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/fixpreferences.sh |
| |
| Copyright (c) 2014 Onlime Webhosting (http://www.onlime.ch) |
| Licensed under the GNU General Public License version 3. |
| |
| PURPOSE: |
@onlime
onlime / libxl.rb
Last active August 29, 2015 14:05
Homebrew php56-excel (using libxl)
require 'formula'
class Libxl < Formula
homepage 'http://www.libxl.com/'
url 'ftp://xlware.com/libxl-mac-3.6.0.tar.gz'
sha1 '52da78f73e4a8e727c8c73c99435f4136e3774c2'
def install
lib.install 'lib/libxl.dylib'
include.install Dir["include_c/*.h"]
@onlime
onlime / build-encryption-key.sh
Created August 17, 2021 10:22
Secure External Backup with ZFS Native Encryption
#!/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 / 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;
@onlime
onlime / .gitlab-ci.yml
Last active August 18, 2021 16:02
Simple SSH/rsync based continuous deployment of a Nuxt.js static frontend project with GitLab CI/CD
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 / .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 / 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 / zfs-destroy-snapshots.py
Created August 6, 2021 11:27
Helper script to remove old ZFS snapshots
#!/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
@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 / 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)
{