Skip to content

Instantly share code, notes, and snippets.

@AliOsm
AliOsm / .env
Last active April 17, 2024 17:18
Deploy Rails, GoodJob, PostgreSQL, Redis, Memcached, Meilisearch, and ChromaDB on the same server using Kamal.
KAMAL_REGISTRY_PASSWORD=dckr_pat_xXXxx_x0xXxXx-xX-XXX0xX0x-x
RAILS_MASTER_KEY=00x00xxx000xxx000000xx0x000x0x00
POSTGRES_PASSWORD=xXxxx0xXXx0
MEILI_MASTER_KEY=xXxxx0xXXx0
BLAZER_DATABASE_URL=postgres://service:{POSTGRES_PASSWORD}@service-name-postgres:5432/service_production
@argami
argami / Caddyfile
Last active February 18, 2024 21:23
Execute HTTPS Local development in 1 Step
https:// {
log
tls internal {
on_demand
}
reverse_proxy :3000
}
@amirrajan
amirrajan / demo.md
Last active October 30, 2022 22:22
DragonRuby Game Toolkit - Tech Demo Source Code
the-keeper-iteration-2.mp4
@kddnewton
kddnewton / json.rb
Last active October 6, 2023 09:25
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@natematykiewicz
natematykiewicz / unroutable_routes.rake
Last active June 9, 2022 19:47
Find routes that will raise a routing error when requested
desc 'Find routes that will raise a routing error when requested'
task unroutable_routes: :environment do
# A lot of this code was taken from how `rake routes` works
# https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/routes/routes_command.rb
require 'action_dispatch/routing/inspector'
unroutables = Rails.application.routes.routes.
map { |r| ActionDispatch::Routing::RouteWrapper.new(r) }.
reject { |r| r.internal? || r.engine? || r.path.starts_with?('/rails/') || !r.controller }.
@yahonda
yahonda / ruby31onrails.md
Last active June 25, 2024 20:26
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.
@searls
searls / 001_functions_and_views.sql
Created December 29, 2020 13:32
KameSame's December 2020 search overhaul
-- This all starts with some functions and a *materialized* postgres view that unnests several
-- arrays of strings of definitions into flattened rows that are easier to search. Fun fact:
-- you can even create indexes on materialized views' columns! They'll refresh whenever the view
-- is refreshed (which in my case is every time that we pull new dictionary data from WaniKani or JMDICT
-- This function will take an array of strings and convert all the double-width alphanumeric characters
-- and normalize them as half-width. That way a search query can be massaged from "OK" to "ok" easily
CREATE OR REPLACE FUNCTION array_hankakufy_romaji(character varying[])
RETURNS character varying[]
AS
@existentialmutt
existentialmutt / Ruby.sublime-syntax
Last active February 19, 2022 21:49
Enhancing Sublime Ruby syntax highlighting with ERB and HAML embedded in heredocs
%YAML 1.2
---
name: Ruby (Custom)
# TODO: unresolved issues
#
# text:
# "p << end
# print me!
# end"
# symptoms:
@manoj-choudhari-git
manoj-choudhari-git / WSL_Install.ps1
Last active April 21, 2024 15:44
PowerShell script to install WSL 2
# STEP 1: Enable Virtual Machine Platform feature
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# STEP 2: Enable WSL feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# STEP 3: Restart Win 10 Machine
# STEP 4: To set the WSL default version to 2.
# Any distribution installed after this, would run on WSL 2