Skip to content

Instantly share code, notes, and snippets.

View Mechetel's full-sized avatar

Dmytro Khoma Mechetel

View GitHub Profile
@Mechetel
Mechetel / any_uploader.rb
Last active November 4, 2025 15:21
Cloudflare R2 Rails
def store_dir
if Rails.env.development? && Rails.root.join('tmp/cloud-storage-dev.txt').exist?
return "development/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
@Mechetel
Mechetel / cd.md
Last active May 16, 2024 09:39
Rails Continuous Delivery with Capistrano

SETUP Continious Delivery via capistrano-deploy

On server do next

  1. Generate SSH keys
$ ssh-keygen -t ed25519 -C "your_email@example.com"
$ export PROJECT_NAME='YOUR_PROJECT_NAME'
$ mv ~/.ssh/id_ed25519 ~/.ssh/github-actions_${PROJECT_NAME}_ed25519
$ mv ~/.ssh/id_ed25519.pub ~/.ssh/github-actions_${PROJECT_NAME}_ed25519.pub
@Mechetel
Mechetel / config.yml
Created May 26, 2023 13:25
circleci example (bad)
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.1
executors:
default:
working_directory: ~/repo
description: The official CircleCI Ruby Docker image
docker:
@Mechetel
Mechetel / .fasterer.yml
Last active October 14, 2024 14:07
production setup for any project
speedups:
rescue_vs_respond_to: true
module_eval: true
shuffle_first_vs_sample: true
for_loop_vs_each: true
each_with_index_vs_while: false
map_flatten_vs_flat_map: true
reverse_each_vs_reverse_each: true
select_first_vs_detect: true
sort_vs_sort_by: true
module SayHello
def say_hello
puts "Hello #{@name}"
end
end
class Person
include SayHello
def initialize(name)