Skip to content

Instantly share code, notes, and snippets.

View LEstradioto's full-sized avatar

Luan Estradioto LEstradioto

View GitHub Profile
@LEstradioto
LEstradioto / kill_server_pid_if_exists.rb
Created April 16, 2025 01:17
Terminate Rails server before starting over
# config/initializers/kill_server_pid_if_exists.rb
#
# Terminate the server process if it's running
# Since its a dev env, no big deal
if Rails.env.development? && !defined?(Rails::Console) && !defined?(Rake)
pid_file = Rails.root.join("tmp/pids/server.pid")
if pid_file.exist?
pid = pid_file.read.to_i
@LEstradioto
LEstradioto / Rails on WSL Network Access.md
Last active April 25, 2025 15:32
Rails on WSL Network Access

Rails on WSL Network Access

A concise guide for making your Rails/Puma server in WSL accessible from external devices.

1. Configure Rails/Puma

Edit config/puma.rb and add:

# Bind the server to all network interfaces to allow external access
@LEstradioto
LEstradioto / password_protected_checker.rb
Created October 15, 2024 01:40
check doc docx msword and pdf for password protected on ruby (minimal dependencies)
require "image_processing/mini_magick"
require "zip"
require "ole/storage"
# Basically, we return true if the file is password protected
# We do this by trying to open the file and catching any errors
# Note: if PDF check get too slow, we can replace mini_magick with a faster library like libvips
module PasswordProtectedChecker
class FileChecker
@LEstradioto
LEstradioto / Dockerfile
Created July 3, 2024 19:54
Docker Rails 7, Sidekiq, Two Redis Instances (cache and sidekiq) to Coolify
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# ENVs are external .env
@LEstradioto
LEstradioto / Readme.md
Last active May 28, 2024 02:22
devise + acts_as_tenant + subdomain scope

Minimal setup for devise + acts_as_tenant + subdomain scope