Skip to content

Instantly share code, notes, and snippets.

View fractaledmind's full-sized avatar

Stephen Margheim fractaledmind

View GitHub Profile
module ArrayColumns
extend ActiveSupport::Concern
class_methods do
def array_columns_sanitize_list(values = [])
return [] if values.nil?
values.select(&:present?).map(&:to_s).uniq.sort
end
def array_columns(*column_names)
@fractaledmind
fractaledmind / install_sqlite.sh
Created September 10, 2023 09:04
A script to install and compile a custom SQLite installation
#!/usr/bin/env sh
cd ../vendor
mkdir -p sqlite/bin sqlite/lib sqlite/include
# ============================================================================================================
# Compile and install sqlite3 (for performance turning and build customizations)
# SEE: https://www.sqlite.org/compile.html
# NOTE: The sqlite3 Ruby gem will not work with the following compile time flags
# * -DSQLITE_OMIT_DEPRECATED
@fractaledmind
fractaledmind / compile_sqlite.sh
Last active September 8, 2023 13:18
Shell script to install and compile project-local SQLite
#!/usr/bin/env sh
cd ../vendor
mkdir -p sqlite/bin
mkdir -p sqlite/lib
mkdir -p sqlite/include
# ============================================================================================================
# Compile and install sqlite3 (for performance turning and build customizations)
# SEE: https://www.sqlite.org/compile.html
@fractaledmind
fractaledmind / index.css
Created September 7, 2023 12:23
Minimal requirements for linked headings in a BridgetownRB site
[aria-hidden="true"] {
visibility: hidden;
}
.anchor {
text-decoration: none;
}
h2:hover .anchor,
h3:hover .anchor,
@fractaledmind
fractaledmind / active_record_sqlite3adapter.rb
Last active October 22, 2024 17:51
A Rails initializer to enhance the SQLite adapter to allow for pragmas to be configured in the /config/database.yml file
module RailsExt
module SQLite3Adapter
# Perform any necessary initialization upon the newly-established
# @raw_connection -- this is the place to modify the adapter's
# connection settings, run queries to configure any application-global
# "session" variables, etc.
#
# Implementations may assume this method will only be called while
# holding @lock (or from #initialize).
#
@fractaledmind
fractaledmind / sqlite-where-iif-test.rb
Created August 4, 2023 13:44
A reproducible bug script demonstrating that WHERE IIF doesn't behave as expected.
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "sqlite3"
@fractaledmind
fractaledmind / litearray.rb
Created August 4, 2023 13:30
An executable Ruby script sandbox demonstrating how to implement "tag columns" for a SQLite database.
# frozen_string_literal: true
# require "bundler/inline"
#
# gemfile(true) do
# source "https://rubygems.org"
#
# git_source(:github) { |repo| "https://github.com/#{repo}.git" }
#
# gem "rails"
@fractaledmind
fractaledmind / litekiq.rb
Last active August 9, 2023 08:27
An executable Ruby script sandbox to explore the concept of a SQLite-backed, process-embedded job backend
# frozen_string_literal: true
# require "bundler/inline"
#
# gemfile(true) do
# source "https://rubygems.org"
#
# git_source(:github) { |repo| "https://github.com/#{repo}.git" }
#
# gem "sqlite3"
# /lib/rails_ext/generated_attribute.rb
# Here, we patch the GeneratedAttribute class to add `richer_text` as a field type, which behaves much the same as the `rich_text` type.
# We will patch the Model generator as well to tweak the ActiveRecord model generated when this type is used
require 'rails/generators/generated_attribute'
module Rails
module Generators
class GeneratedAttribute
import { Controller } from "@hotwired/stimulus"
// use with Rails' `time_Tag` helper like so:
// <%= time_tag campaign.starts_at, campaign.starts_at.to_formatted_s(:short), data: { controller: "localized-time", localized_time_type_value: "datetime-short" } %>
export default class extends Controller {
static targets = [ ]
static values = {
type: String,
style: { type: String, default: 'medium' },
locale: { type: String, default: 'default' },