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 root@1.2.3.4
adduser deploy
adduser deploy sudo
exit
ssh-copy-id root@1.2.3.4
ssh-copy-id deploy@1.2.3.4
@lazaronixon
lazaronixon / dropzone_controller.js
Last active June 19, 2024 19:43
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
@ayamomiji
ayamomiji / list.html
Last active June 14, 2024 06:08
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>