Skip to content

Instantly share code, notes, and snippets.

View gabriel-curtino's full-sized avatar

Gabriel gabriel-curtino

View GitHub Profile
@gabriel-curtino
gabriel-curtino / action_mailbox_relay.md
Last active November 4, 2024 14:10
Exim4 relay for Action Mailbox

1. Relay script

This bash script replaces the Rails task action_mailbox:ingress:exim then your rails app doesn't need to be running in the same location than the email server.

$ nano /usr/local/bin/action_mailbox_relay.sh

URL and INGRESS_PASSWORD are hardcoded as defaults but these can be removed if prefer work with ENV vars.

#!/bin/bash
@gabriel-curtino
gabriel-curtino / sqlite_full_text_search.rb
Created September 7, 2024 13:57
Rails SQLite Full Text Search (per table, at db level)
## SqliteFullTextSearch Concern
#
# The `SqliteFullTextSearch` concern provides a set of methods and triggers to enable full-text search capabilities for ActiveRecord models using SQLite's FTS5 extension.
#
# ### Key Features
# - **Full-Text Search Scope**: Adds a `search` scope to the model for performing full-text searches.
# - **Index Creation and Management**: Automatically creates and manages FTS5 tables and triggers for the model.
# - **Attribute Configuration**: Allows specifying attributes to include in the full-text search index.
# - **Trigger Management**: Sets up triggers to keep the search index up-to-date with model changes.
#
@gabriel-curtino
gabriel-curtino / index.rb
Last active December 19, 2024 17:48
Rails SQLite Global Index
# models/index.rb
# == Index Model
#
# The `Index` model manages full-text search indexes using SQLite's FTS5 (Full-Text Search) extension.
# It provides methods for adding, removing, and searching indexed items, as well as managing the underlying database schema.
#
# ### Key Features
# - **Adding Items**: Adds items to the index, ensuring any existing entries are first removed.
# - **Removing Items**: Removes items from the index based on their ID and class type.