Skip to content

Instantly share code, notes, and snippets.

View Deanout's full-sized avatar
💭
Should be sleeping.

Dean DeHart Deanout

💭
Should be sleeping.
View GitHub Profile
@armahillo
armahillo / i18n.rake
Created July 5, 2022 05:30
Rails task that identifies text that should be extracted to localization files
# I wrote this up one evening while auditing an app for localization. It can almost certainly be optimized, but it works!
namespace :i18n do
# This method is doing most of the heavy lifting. It accepts a full filename with path and returns
# a hash of arrays, where each key is one of the different groupings
def scan_file_for_literals file_with_path
file = File.read(file_with_path)
# First off, omit any straight ruby code that isn't emitted, since it won't need to be localized
file.gsub! /^<%[^=].*%>/m, ''
@Deanout
Deanout / Production Deployment Commands Ubuntu 18.04
Created March 31, 2020 14:37
Deploy to production with nginx, passenger, capistrano, rails 6
These commands are meant to be followed in conjunction with:
https://www.youtube.com/watch?v=xpYpaRUFzTI
https://gorails.com/deploy/ubuntu/18.04
ssh [email protected]
adduser deploy
adduser deploy sudo
exit
ssh-copy-id [email protected]
ssh-copy-id [email protected]
@lazaronixon
lazaronixon / _form.html.erb
Last active June 6, 2025 19:24
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
@ayamomiji
ayamomiji / list.html
Last active March 11, 2025 21:14
Stimulus example: smart scroll
<div data-controller="smart-scroll"
data-action="smart-scroll:added->smart-scroll#handleAdded
resize->smart-scroll#handleAdded
scroll->smart-scroll#handleScroll">
<div data-controller="smart-scroll-item">
aya: an an
</div>
<div data-controller="smart-scroll-item">
hatate: ni hao
</div>