Skip to content

Instantly share code, notes, and snippets.

@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)
#
@shad1w
shad1w / rails_subdir_deploy.md
Last active April 22, 2024 23:12
Deploying a rails application in a subdirectory

Making a Rails application deployable in a subdirectory

USE THIS GUIDE AT YOUR OWN RISK! I AM NOT RESPONSIBLE FOR ANYTHING YOU DO BY FOLLOWING THIS GUIDE! IF ANY DAMAGE IS DONE BY FOLLOWING THE INSTRUCTIONS HERE, IT IS ENTIRELY YOUR RESPONSIBILITY AND I MAY NOT BE HELD LIABLE FOR IT!

Using this guide, you can make it possible to put your Ruby on Rails application behind a reverse proxy in a subdirectory.
This guide was written for Rails 5.

Prerequisites

Using this method, the environment variable RAILS_RELATIVE_URL_ROOT should not be set.

@imZack
imZack / zram.sh
Last active December 30, 2020 15:39 — forked from voyeg3r/zram.sh
How enable zram module on kernel (debian lik distro)?
#!/bin/bash
### BEGIN INIT INFO
# Provides: zram
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM)
# Description: Adapted from systemd scripts at https://github.com/mystilleef/FedoraZram
### END INIT INFO
@blacktm
blacktm / install_ruby_rpi.sh
Last active February 28, 2024 23:24
A Bash script to install Ruby on the Raspberry Pi
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Set the Ruby version you want to install