Cheatsheets
https://www.lukeko.com/cheatsheetsPost concise notes that can be used for quick reference here!
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 ...
Self Publish on Amazon
Sign in at https://kdp.amazon.com/en_US/ Choose eBook or Paperback (see subtopics below)
Forward root to www on Google Domains
Go to "DNS" > "Synthetic records" Select subdomain forward option in the dropdown menu Enter @ for the subdomain. This represents the naked or root domain. Enter the subdomain URL which is the URL ...
Compute instances
“Google Cloud today announced the launch of its new E2 family of compute instances” https://techcrunch.com/2019/12/11/google-cloud-gets-a-new-family-of-cheaper-general-purpose-compute-instances/
Encrypt your HD on a Mac
Open Disk Utility Click on "Encrypt" Choose APFS encrypted
Revert Git to a previous commit
Working on your own and just want it to work? To revert to a previous commit, ignoring any changes: ruby git reset --hard HEAD To revert to a commit that's older than the most recent commit: ```r...
Use Git to quickly manage documents on a Mac
/Users/Sosie/Documents/deeds ruby git init git add . git commit -m "init" Work on the docs, make changes and then ruby git commit -a -m "edit summary" If you add a document ruby git add . git com...
Reach IKEA with online order problem
888-888-4532 -> 3 -> 2 -> 3 (missing item) -> 2 (online purchase) Finally got a hold of a rep and she claims that this would reach them sooner 888-888-4532 > 3 > 2 > 4
Setup family sharing
iOS -> settings -> iCloud -> Manage Storage -> Change Storage Plan
Create expiring S3 URLs
Email secure links that expire after a chosen time With Ruby: https://stackoverflow.com/questions/26690490/s3-link-expire-with-aws-sdk With Python: https://medium.com/runascloud/creating-a-secure-u...