Skip to content

Instantly share code, notes, and snippets.

View pjmelling's full-sized avatar

Peter Melling pjmelling

View GitHub Profile

How to deploy a Rails 7.1 app with Postgres and Kamal on a single server

I think you have looked at the tutorial from Mr. Heinemeier Hansson at least once or twice and have a similar setup.

rails new kamal_pg --css tailwind --skip-test --database=postgresql

cd kamal_pg
@robzolkos
robzolkos / Dockerfile
Last active March 2, 2024 20:59
Kamal / SQLite3 issue
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# Set production environment

OpenBSD logo     Rails logo     Falcon logo


Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software (NGiNX & Apache (httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker etc.)

OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest config

@mabenson00
mabenson00 / cheatsheet.rb
Last active May 3, 2024 22:40
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
source "https://rubygems.org"
ruby File.read(".ruby-version").strip
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "activeadmin"
gem "activeadmin_json_editor"
gem "ahoy_email"
gem "ahoy_matey"
@pedrocarmona
pedrocarmona / something_lookup.rb
Created March 16, 2021 19:45
Polymorphic lookup - collection
class SomethingLookup < ApplicationRecord
self.table_name = 'something_lookups'
belongs_to :something, polymorphic: true
def self.load_schema!
# rubocop:disable Naming/MemoizedInstanceVariableName
@columns_hash ||= {}
# rubocop:enable Naming/MemoizedInstanceVariableName
end
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 6, 2024 07:25
set -e, -u, -o, -x pipefail explanation
@dommmel
dommmel / blob_authenticatable.rb
Last active July 12, 2023 01:01
Devise authentication for Rails' ActiveStorage
# Rails controller concern to enable Devise authentication for ActiveStorage.
# Put it in +app/controllers/concerns/blob_authenticatable.rb+ and include it when overriding
# +ActiveStorage::BlobsController+ and +ActiveStorage::RepresentationsController+.
#
# Optional configuration:
#
# Set the model that includes devise's database_authenticatable.
# Defaults to Devise.default_scope which defaults to the first
# devise role declared in your routes (usually :user)
#
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active March 1, 2024 14:39
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql