Cheatsheets
https://www.lukeko.com/cheatsheetsPost concise notes that can be used for quick reference here!
Use different credit cards for different Heroku apps
https://help.heroku.com/T8Q2N4SV/how-do-i-manage-billing-multiple-clients-with-separate-apps
Sidekiq
bash require 'sidekiq/api' https://stackoverflow.com/questions/12683222/are-there-console-commands-to-look-at-whats-in-the-queue-and-to-clear-the-queue ```yml :verbose: false :concurrency: 15 :max...
Create a random password in Rails
ruby SecureRandom.alphanumeric
Run a Rails server on https and localhost
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt then rails s -b 'ssl://localhost:3000?key=localhost.key&cert=localhost.crt' This will give y...
Add Stripe to a Rails app
https://courses.gorails.com/payments-with-rails-master-class https://rubygems.org/gems/stripe
Modeling double entry accounting in a relational database
https://stackoverflow.com/questions/59432964/relational-data-model-for-double-entry-accounting https://medium.com/@RobertKhou/double-entry-accounting-in-a-relational-database-2b7838a5d7f8 https://c...
Pass persisted params in a Rails form
If the params you want to persist are state and order ruby <% request.params.slice('state', 'order').each do |key, value| %> <%= hidden_field_tag key, value %> <% end %>
Find a process and kill it in terminal
% ps aux | grep ruby lukeko 29806 0.0 0.0 4277500 696 s000 S+ 6:49PM 0:00.00 <process you don't want> % kill -9 29806
Actiontext
Go to https://guides.rubyonrails.org/actiontextoverview.html Only extra things left to do is @import "trix/dist/trix";
Override update_counters from counter_cache: true
```ruby class Post < ApplicationRecord belongsto :author, countercache: true end class Author < ApplicationRecord has_many :posts def self.updatecounters(id, counters) Author.find(id).dos...
Remove folder and all files inside it in Terminal
using rm can be very dangerous if you're not careful -- get in the habit of using mv instead do this mv .git ~/.Trash instead of rm -rf .git the first command is safer on many levels
Serialized Hash in Rails form
review of what a hash is ```ruby schedule = {mon: true, tue: false, wed: true} schedule[:mon] => true schedule[:tue] => false schedule[:wed] => true schedule[:thu] => nil schedule.class => Hash ```...
Find and kill a process
% ps aux | grep puma 52480 0.0 0.0 4268176 508 s000 R+ 10:10AM 0:00.00 grep puma 52050 0.0 0.8 4517160 142512 s000 T 9:52AM 0:27.34 puma 4.3.5 (tcp://localhost:3000) [crazya...
Use PostgreSQL's interval type as ActiveRecord::Duration
I couldn't bring myself to use an integer as a db column with the amazing interval available. Unfortunately Rails just sees it as a string, but here's how you can get it to work ruby class CreateAv...
Create Amazon IAM user
Step 1: https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-startedcreate-admin-group.html Step 2: https://console.aws.amazon.com/iam/home?#/securitycredentials
SendGrid on Heroku
Not sure why everything I looked online makes it look complicated but this worked. And you don't even need to add the SendGrid gem. /config/environments/production.rb ruby config.action_mailer.de...
Installing Bootstrap in Rails 6
% yarn add bootstrap jquery popper.js app/config/webpack/environment.js ```javascript const { environment } = require('@rails/webpacker') const webpack = require('webpack') environment.plugins.ap...
Run Heroku Rails apps in production mode locally
Procfile web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development} .env RACK_ENV=production PORT=3000 .gitigore .env % rails assets:precompile % heroku local
Manage Ruby versions with rbenv
update rbenv ``` $ brew upgrade rbenv ruby-build list all available versions: $ rbenv install -l install a Ruby version: $ rbenv install 2.7.1 ``` set default/global version of ruby ~/.rbenv % ls ...